Skip to content

Commit

Permalink
fix(transition): Do not create styles for hidden elements
Browse files Browse the repository at this point in the history
This was a terrible performance bug since hidden elements would
update their positioning onScroll.
  • Loading branch information
mlaursen committed Jan 30, 2022
1 parent a38abfb commit 6eff8a8
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/transition/src/useFixedPositioning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ export function useFixedPositioning<
});

setStyle(style);
setActive(!!element);
setActive(!!element && !element.hidden);

// Only changing the initialX and initialY should cause the useEffect below
// to trigger, which is why everything else is set in a ref.
Expand Down Expand Up @@ -274,8 +274,10 @@ export function useFixedPositioning<
});

useEffect(() => {
updateStyle();
}, [updateStyle]);
if (!ref.current || !ref.current.hidden) {
updateStyle();
}
}, [ref, updateStyle]);

const callbacks: Required<FixedPositioningTransitionCallbacks> = {
onEnter(appearing) {
Expand Down

0 comments on commit 6eff8a8

Please sign in to comment.