Jump to content
Search Community

Animation doesn't stop outside of ScrollTrigger area

kabocreative test
Moderator Tag

Go to solution Solved by mvaneijgen,

Recommended Posts

Hi!

 

I've got a repeating animation working beautifully, but I only want it to play when inside the ScrollTrigger boundaries.

 

Currently it doesn't start until it enters the ScrollTrigger start boundary, but then it all goes wrong and doesn't stop when scrolling out of the boundary.

 

I'm pretty sure the issue lies somewhere in the fact the animation is set to repeat, but I've no idea how to resolve that.

 

As always any help is veeeeeery much appreciated :)

See the Pen Baqjzqv by kabocreative (@kabocreative) on CodePen

Link to comment
Share on other sites

  • Solution

I would create a timeline of that repeating animation and set it to paused: true and then use the callbacks of the ScrollTrigger to .play() or .pause() the timeline when you want to. Check the ScrollTrigger docs for more info. Hope it helps and happy tweening! 

 

callback system including onEnter, onLeave, onEnterBack, onLeaveBack, onToggle, onUpdate, onScrubComplete, and onRefresh.

 

See the Pen gOBPLmM?editors=0011 by mvaneijgen (@mvaneijgen) on CodePen

 

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