Skip to content

Commit

Permalink
fix(): improve size handling on different zoom levels
Browse files Browse the repository at this point in the history
Fixes #423

More information about the issue here:
https://bugs.chromium.org/p/chromium/issues/detail?id=608142
  • Loading branch information
petyosi committed Aug 6, 2021
1 parent e64d207 commit 392b9c8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/sizeSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,11 @@ export function hasGroups(sizes: SizeState) {

type OptionalNumber = number | undefined

const SIZE_MAP = {
offsetHeight: 'height',
offsetWidth: 'width',
} as const

/** Calculates the height of `el`, which will be the `Item` element in the DOM. */
export type SizeFunction = (el: HTMLElement, field: 'offsetHeight' | 'offsetWidth') => number

Expand All @@ -240,7 +245,7 @@ export const sizeSystem = u.system(
const groupIndices = u.statefulStream([] as number[])
const fixedItemSize = u.statefulStream<OptionalNumber>(undefined)
const defaultItemSize = u.statefulStream<OptionalNumber>(undefined)
const itemSize = u.statefulStream<SizeFunction>((el, field) => el[field])
const itemSize = u.statefulStream<SizeFunction>((el, field) => el.getBoundingClientRect()[SIZE_MAP[field]])
const data = u.statefulStream<Data>(undefined)
const initial = initialSizeState()

Expand Down

0 comments on commit 392b9c8

Please sign in to comment.