Jump to content
Search Community

Destroying and Reinitializing Timeline

j.burleigh1 test
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

Hey Guys, 

 

I'm a bit of a GreenSock noob and I'm hacking away at something which I think I have almost working. I have a series of SVGs running down the page, used to create one responsive, interlinked path which follows the content down. 

 

I have an 'orb' which is supposed to follow the user down the path as the user scrolls. As I'm using multiple SVGs combined to create what looks like a single path, I am having to detach the orb from one SVG and append it into the next one as it reaches the end of each path.

 

It's mostly working, but I'm struggling with the killing / reinitialization of the orb as it transitions from one SVG to the next. Using killAll seems to almost work, but the animation 'jitters', I presume as I'm calling KillAll on scroll it is constantly being killed / reinitialized. 

 

Hopefully the codepen example will help, would really appreciate someone more experienced to take a look and shed some light on where I'm going wrong!

 

Thanks,

See the Pen JvQaoV by team (@team) on CodePen

Link to comment
Share on other sites

Hm, I don't have time to rewrite all the code and troubleshoot at the moment, but I'll offer a few things:

  1. There's no need for killAll(), especially in every scroll event.
  2. It looks like you're re-creating your entire tween on every single scroll event (extremely inefficient). I'd add some conditional logic that only recreates the tween when absolutely necessary.
  3. Is there a particular reason you don't want to just chain all 3 bezier animations together and then adjust the progress value of that one timeline? I didn't quite understand why you felt the need to be juggling between them, killing/recreating so often, etc. Seems cleaner to just create them all once, drop 'em into a TimelineLite and scrub the progress value accordingly. But maybe I'm missing something. 
  4. If your goal is to drop all the animations from a timeline, you can use timeline.clear() instead of the brute-force, global TweenMax.killAll(). 

I hope that at least nudges you in the right direction :)

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