Closed pryley closed 4 years ago
I highly recommend against animating the trigger element. Your triggerElement
should not be your animated element. Make them be 2 different elements.
I recommend setting up a scrollTrigger element that it's soul purpose is to trigger the event, and not animate at all.
Follow this comment to find my recommendation: https://github.com/jonkwheeler/ScrollScene/issues/5#issuecomment-576702673
It's very easy to setup something like
<div className="data-reveal">
<div className="scroll-trigger" />
<div className="element-to-reveal" />
</div>
Just to hammer this home, never animate the trigger <--- this causes jumping.
I'm a bit slammed with work right now, but when I get time I'll update the README more to explain. I had to deal with this jumpiness years ago on scrollmagic. Once I changed the way in which I setup my triggers, I never had an issue again.
Thanks for the tip about the trigger.
While this solves the jitter, it does not solve the use case where I only want the animation to run when the trigger scrolls in and out of view from the bottom of the window, but not from the top of the window.
This is why a short-circuit callback option (with the observer entry as an available parameter) would be useful.
Ah I see. Yeah I'll consider adding this in the future. Nice shout. In the meantime you should use ScrollScene
to achieve that.
I have elements that reveal-in along the Y axis on scroll:
I cannot use this transition however with the ScrollObserver. It works great when scrolling the page up the Y axis, but scrolling down will cause jitters as when the bottom of the element reaches the top of the window the animation starts to move the element down again, essentially fighting against the direction of the scrolling.
The fix would be fairly simple:
Unfortunately, there is no option to short-circuit the observer callback so this cannot be done.