Skip to content

Commit

Permalink
fix(): revert RAF for useSize
Browse files Browse the repository at this point in the history
Fixes #269
Opens #254

A workaround is present here:
DevExpress/testcafe#4857 (comment)
  • Loading branch information
petyosi committed Jan 24, 2021
1 parent 22d8498 commit 5475a10
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/hooks/useSize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,19 @@ export function useSizeWithElRef(callback: (e: HTMLElement) => void, enabled: bo
const ref = useRef<CallbackRefParam>(null)
const observer = new ResizeObserver(entries => {
const element = entries[0].target as HTMLElement
// Revert the RAF below - it causes a blink in the upward scrolling fix
// See e2e/chat example
// Avoid Resize loop limit exceeded error
// https://github.com/edunad/react-virtuoso/commit/581d4558f2994adea375291b76fe59605556c08f
requestAnimationFrame(() => {
// if display: none, the element won't have an offsetParent
// measuring it at this mode is not going to work
// https://stackoverflow.com/a/21696585/1009797
if (element.offsetParent !== null) {
callback(element)
}
})
// requestAnimationFrame(() => {
//
// if display: none, the element won't have an offsetParent
// measuring it at this mode is not going to work
// https://stackoverflow.com/a/21696585/1009797
if (element.offsetParent !== null) {
callback(element)
}
// })
})

const callbackRef = (elRef: CallbackRefParam) => {
Expand Down

0 comments on commit 5475a10

Please sign in to comment.