Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
RichC

.kill() is not working

Recommended Posts

I have this tween that repeats infinitely:

 

var sparkleblink = TweenMax.staggerTo(".confetti", .5, {ease:Linear.easeNone, opacity:.2, repeat:-1}, .01);

 

but I want to stop this animation after a certain point. I have a TimelineLite() which calls a function after the last animation:

 

var tothebox = new TimelineLite();
	tothebox.to(".scrollnotif", .1, {opacity:0})

		// ** other animations here** //
          
		.to(".scrollnotif", .1, {opacity:1, onComplete:killthis});

 

Then I have that function that's being called onComplete: 

 

function killthis(){
	sparkleblink.kill();
}

 

Not sure if I'm missing something or what. Advance thanks for whoever is going to help! 

Link to comment
Share on other sites

TweenMax.staggerTo() returns an ARRAY of tweens, but it looks like you're treating it as if it's a timeline or a tween. In other words, you're calling kill() on an array. 

 

You could either loop through that array and kill() each tween, or you could just use a TimelineLite staggerTo() instead so that all those tweens are embedded in a timeline which can be killed, like:

var sparkleblink = new TimelineLite();
sparkleblink.staggerTo(".confetti", .5, {ease:Linear.easeNone, opacity:.2, repeat:-1}, .01);
... 
//then later...
sparkleblink.kill();

 

Does that help?

  • Like 2
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.
×