Jump to content


MotionPathPlugin — Reset path onRepeat

Moderator Tag

Recommended Posts



I have an element (a pony) that moves along a random path, flips and returns. I would like to recalculate that path each time the pony returns. I tried to work with vars.motionPath.path, but the new path isn't applied to the tween ... (see my comments in the code)

I there another way to update the path on the fly?


Thanks so much, 


See the Pen eYMBLqz by rob83 (@rob83) on CodePen

Link to comment
Share on other sites

Hey there!


I'd probably do something like this?


See the Pen RwMoEbp?editors=0010 by GreenSock (@GreenSock) on CodePen

You'll have to add a bit of conditional logic to flip the pony and change direction, but creating a new tween each time rather than trying to update the original tween is probably a better (easier) route.


Alternatively - maybe the modifiers plugin could help? I haven't messed about with it much but modifying existing properties is what it's for!




Link to comment
Share on other sites

Thanks, Cassie! 


I'll have a look at the ModifiersPlugin, but I guess I'll just go with the solution of creating a new tween each time. 


  • Like 1
Link to comment
Share on other sites

Cassie's approach is solid. If you really need to reuse the same tween instance(s), you could invalidate() to force them to re-parse the vars on the next render. Just beware that if the parent timeline's playhead is passed the tween's end, it'll of course call the onComplete again on the very next tick after invalidating, thus you'd need to add some logic to skip things in that scenario. Here's a fork illustrating what I mean: 


See the Pen QWmdLVE?editors=0010 by GreenSock (@GreenSock) on CodePen

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