Jump to content
Search Community

ScrollTrigger - not reversing tween on reload

josh-warner test
Moderator Tag

Recommended Posts

Hi team,

 

I have an animation which tweens in from the top of the screen on scroll using ScrollTrigger. The issue I have found is if I scroll part way down the page, and refresh the screen, the page loads after the trigger and so the animation is already in its completed state (which it should be) but when I scroll back up to the top of the page past the trigger it doesn't reverse the animation and the element is stuck in its completed state rather than be reverted to where it started from.

 

Couldn't replicate the issue on codepen since you can't refresh the page part way down but this is how I have setup the animation: 

See the Pen JjGOJZo by josh-kiwi (@josh-kiwi) on CodePen

 

If you were to reload the page half way down, the pink box would be visible, but after scrolling to the top it would not hide itself.

 

Thanks!

See the Pen by (@) on CodePen

Link to comment
Share on other sites

Hey Jack, thanks for the quick reply. Okay that helped me look elsewhere, I have just worked out it was an issue within React not ScrollTrigger. 

 

I was using React hooks and needed to update the hook to not run on every render rather only on mount.

 

Thanks again

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...