简体   繁体   中英

TweenMax instance handling

Do TweenMax instances need to be cleared/unset/killed manually or is it done automatically? Here's the following code I'm using to add effect to a piece of text on screen:

TweenMax.to($('#score'), 0.25, { fontSize: '56px', onComplete: myFunction });

function myFunction(){
    TweenMax.to($('#score'), 0.125, { fontSize: '28px' });
}

This piece of code runs a lot and I'm afraid over time some garbage would pile up.

You could try and use the kill() method:

Also you can store your reference to the tween in a variable:

Check out this Example

var myTween = TweenMax.to($('#score'), 0.25, { fontSize: '56px', onComplete: myFunction });

function myFunction(){
   myTween.kill();
   myTween = TweenMax.to($('#score'), 0.125, { fontSize: '28px' });
}

For more info checkout the GreenSock TweenMax Docs .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM