Closed MotaZor94 closed 7 months ago
Ya, unfortunately this wasn't built to support sticky elements. Because those elements stop scrolling at certain points the cached values can change depending on when they are updated. Window focus is one event that updates the cached values. The shift is due to the new position when becoming stuck.
You may be able to work around it by using a targetElement
, which would reference an element that is not sticky. Or you can use predefined startScroll
| endScroll
values instead. Could be tricky depending on your design needs, but this would avoid the sticky issue.
I'll update the docs to clarify this lack of support for sticky.
We're encountering a problem in our Next.js application where the position of animations within a sticky container becomes misaligned whenever the browser tab is changed.
This happens only on the elements within a sticky container, the rest is working fine!
Please have a look at the Loom recording below:
https://www.loom.com/share/d7dbc26b0a794a2eb7be6fa79f202444?sid=4ee4d574-f174-4e8a-bf3a-bbcd6b9dc364
Basic example:
We have a root layout defined:
and the parallax provider:
We are running Next 14 with App router and react 18.2.0