Skip to content

Commit

Permalink
fix up into window return commit
Browse files Browse the repository at this point in the history
  • Loading branch information
beefchimi committed Apr 14, 2024
1 parent 290f34c commit e55f506
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/hooks/useElementRect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,12 @@ export function useElementRect(round = false) {
[round],
);

const {scrollX, scrollY, visibleWidth, visibleHeight} = useWindowScroll({
const {
scrollX,
scrollY,
visibleWidth: windowWidth,
visibleHeight: windowHeight,
} = useWindowScroll({
updateStrategy: 'aggressive',
});

Expand All @@ -65,7 +70,7 @@ export function useElementRect(round = false) {

useIsoEffect(() => {
updateRect(ref.current);
}, [updateRect, scrollX, scrollY, visibleWidth, visibleHeight]);
}, [updateRect, scrollX, scrollY, windowWidth, windowHeight]);

return {
ref,
Expand All @@ -74,9 +79,7 @@ export function useElementRect(round = false) {
...rect,
// Returning some of our `window` values as they could
// be useful to consumers.
scrollX,
scrollY,
visibleWidth,
visibleHeight,
windowWidth,
windowHeight,
};
}

0 comments on commit e55f506

Please sign in to comment.