How to stop Tweenmax animation while animating

Pioter picture Pioter · Aug 18, 2014 · Viewed 12.8k times · Source

I have tried to stop animation before complete the animation in TweenMax. Initially div top is '0px'. I am animating it to top '90px' in 3 seconds. If I click on button I want stop it. How to get it?

    TweenMax.to("div", 3, {
        top: '90px',
    }); 
    <div id="stop">stop</div>

Answer

karan3112 picture karan3112 · Aug 18, 2014

You can use kill() to remove the tween.

JS: To remove a tween.

 var tween = TweenMax.to('div', 3, { top: '90px' }); 
 //then later...
 tween.kill();

Source