Skip to content

Commit 6eff8a8

Browse files
committed
fix(transition): Do not create styles for hidden elements
This was a terrible performance bug since hidden elements would update their positioning onScroll.
1 parent a38abfb commit 6eff8a8

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

packages/transition/src/useFixedPositioning.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ export function useFixedPositioning<
242242
});
243243

244244
setStyle(style);
245-
setActive(!!element);
245+
setActive(!!element && !element.hidden);
246246

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

276276
useEffect(() => {
277-
updateStyle();
278-
}, [updateStyle]);
277+
if (!ref.current || !ref.current.hidden) {
278+
updateStyle();
279+
}
280+
}, [ref, updateStyle]);
279281

280282
const callbacks: Required<FixedPositioningTransitionCallbacks> = {
281283
onEnter(appearing) {

0 commit comments

Comments
 (0)