-
Notifications
You must be signed in to change notification settings - Fork 158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stop the effect at a given position #212
Comments
It would help to know the exact effect that you're trying to achieve, then I could show you how it might be done with this library, or advise to use something else instead. |
Thank you for the quick answer :) The green block should stop at the end of the purple |
It should start in the middle (my example) and end at the bottom of purple |
This is a good example https://react-scroll-parallax-examples.vercel.app/ |
I'm just guessing here ;-) Updated the CodeSandbox: They stop animating when the target is out of view and they are aligned because of their ending CSS position is aligned and no transform styles are used at the end of the effect Beyond that it's up to you to provide the correct styling to make it fit your specific needs. |
That works, thanks! :)) A better API for this would be // before translateY changes the original position
// I think `window.addEventListener('load', ...)` is required here
const start = window.pageYOffset + element.getBoundingClientRect().top
...
startScroll: (start - offset)
endScroll: (start - offset) + duration |
You can already decide when the animation begins with
targetElement
&rootMargin
, but not when it should end.The option
startScroll, endScroll
isn't friendly with responsiveness.The progress could be paused when reaching a certain point and then resumed when scrolling up.
or
endScroll
could indicate the progress e.g.0.55
Is there a hack way that I could do right now?
Related #133
The text was updated successfully, but these errors were encountered: