Jump to content
Search Community

ScrollTo autoKill trigger toggle?

B_wu test
Moderator Tag

Recommended Posts

Hello,
I'm running into an issue with scrollTo. Codepen attached has an example where some animation happens, then the scroll begins. There is a replay button and the scroll text gets set back to the top, but on replay the text no longer scrolls. Is there a way to reset the autoKilll feature eachtime the replay button is clicked? I basically need the text to be able to scroll each time the replay button is pressed but setting it back to y:0 seems to trigger the autoKill. Any help is appreciated, thanks!

See the Pen OJEaVZP by b_wu (@b_wu) on CodePen

Link to comment
Share on other sites

Hi @B_wu and welcome to the GreenSock forums!

 

The issue here is that the auto kill feature of the ScrollTo instance, removes the instance from the timeline, so is no longer there, that's why is not scrolling again.

 

What you have to do is check if the particular instance is defined in the timeline. If it is, that means the ScrollTo instance still exists so there is no problem. If the instance doesn't exists means that you have to add it again to the timeline and restart it.

 

Something like this:

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

 

Hopefully this is enough to get you started.

 

Let us know if you have more questions.

 

Happy Tweening!

  • 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...