Jump to content


Start animation from beginning

Moderator Tag

Recommended Posts

Hey everybody,
i need quick help with an issue on my scroll trigger animation.

i have a simple scroll triggered animation but when i scroll to a certain point and refresh the page the animation stays where it was the moment i refreshed. But i want it to jump back to the beginning when refreshing. Is there a simple solution?

PS: I now added the codepen im not sure what exactly i should have added but thats everything i have so i hope you can help me...

See the Pen XWxRWgM by hannaaaahp (@hannaaaahp) on CodePen

Edited by hannah_hey
I added the codepen hope it works now
Link to comment
Share on other sites

It's pretty tough to troubleshoot without a minimal demo - the issue could be caused by CSS, markup, a third party library, your browser, an external script that's totally unrelated to GSAP, etc. Would you please provide a very simple CodePen or CodeSandbox that demonstrates the issue? 


Please don't include your whole project. Just some colored <div> elements and the GSAP code is best (avoid frameworks if possible). See if you can recreate the issue with as few dependancies as possible. If not, incrementally add code bit by bit until it breaks. Usually people solve their own issues during this process! If not, then at least we have a reduced test case which greatly increases your chances of getting a relevant answer.


Here's a starter CodePen that loads all the plugins. Just click "fork" at the bottom right and make your minimal demo

See the Pen aYYOdN by GreenSock (@GreenSock) on CodePen


If you're using something like React/Next/Vue/Nuxt or some other framework, you may find StackBlitz easier to use. We have a series of collections with different templates for you to get started on these different frameworks: React/Next/Vue/Nuxt.


Once we see an isolated demo, we'll do our best to jump in and help with your GSAP-specific questions. 

Link to comment
Share on other sites

I added the codepen now i hope anybody can help me solve this problem...(:

Link to comment
Share on other sites

Hm, it looks like your CodePen is linking to files/images that you have locally, so the paths don't work and we can't see anything in that CodePen, so it's hard to diagnose. It looks like you've got scrub enabled on your ScrollTrigger which means the playhead of the animation will be tied directly to the scrollbar position. So it makes sense that if you're scrolled down on the page and refresh, when the page stays at that scroll position the animation would jump there too. If you don't want scrub, you can disable that and use toggleActions instead. See the ScrollTrigger docs for details. 


I'd also strongly recommend updating to the latest version of GSAP/ScrollTrigger. It looks like you're using pretty old files there. 3.11.5 is the latest right now. 


If you still need help, please provide a CodePen that clearly illustrates the issue and we'd be happy to take a peek. 

Link to comment
Share on other sites

well thank you already but the video didn't really help...

i learned some new things in the video but the toggleActions won't work as i am having a pinned website so the scroll trigger never goes out the frame (at least i guess thats the reason).
I'd like to provide a Codepen but i dont know how to embed pictures in the Codepen...

See the Pen LYgLzBG by hannaaaahp (@hannaaaahp) on CodePen

Anyways im adding the link here if thats also enough
I'm also a little lost in finding a way to provide the demo just like the one in the beginning😅
I hope you can still help me if not it would be nice if you could help me out a little🙃

Link to comment
Share on other sites

There's really no need to use images - just use colored <div> elements instead to illustrate your issue. 

Link to comment
Share on other sites



Maybe you're looking for scroll restoration, which can be done with ScrollTrigger's clearScrollMemory method:



Also remember that you can use images from unsplash in codepen as shown in this example from another thread you created:

See the Pen QWZvbQz by GreenSock (@GreenSock) on CodePen


In order for us to test a situation that happens when the page is refreshed, the codepen editor is not a good example. Be sure to include the link to the codepen editor and the debug version as well, since that runs directly on the page without any iframes.


Hopefully this helps.

Happy Tweening!

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.