Jump to content
GreenSock

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

Killing problem.

Recommended Posts

Hi, I have big problem with killing ;)

The problem:

1. I have 5 functions fired one by one with "onComplete".

2. I need to kill any tweens from this functions in any time, and it works properly when I kill any of these functions for the first time.

3. It doesn't work properly when I fired these functions and try too kill one again.

4. It does look like "the killing machine" remember position of myElement when the first "kill" was fired and move in a blink myElement to this position, then of course kill the tween.

 

Should I clear something or maybe something else?

 

Best Regards

Link to comment
Share on other sites

Hi and welcome to the GreenSock forums.

 

Yeah it's a bit unclear what you're trying to do.

 

The first thing that comes to my mind is that perhaps you could try to clear any initialization data the Tween instance could have, for that you can use invalidate():

 

http://greensock.com/docs/#/HTML5/GSAP/TweenLite/invalidate/

 

Using that method you can kill the instance, then invalidate it and finally restart it or create it again.

var t = TweenLite.to(elem, 1, {vars, onComplete:myFunc});

function myFunc(){

  // some code here

}

// then kill and invalidate the tween
// keep in mind that most GSAP methods return the same instance
// like that you can chain them
t.kill().invalidate();

Another option is to set the time or progress of the tween to 0 before killing it, that will force the initial render state of the element:

var t = TweenLite.to(elem, 1, {vars, onComplete: myFunc});

function myFunc(){

  // code here

}

// then kill the instance
// using time
t.pause(0).kill();

// using seek
t.seek(0).kill();

// using progress
t.progress(0).kill();

FInally, please take a look at this thread to learn how to create a reduced sample using codepen, that usually reduces support time dramatically, since it allows us to see the real issue and tinkering with whatever code you're using:

 

  • Like 2
Link to comment
Share on other sites

Thanks for your answer Rodrigo.

I will use the codepen in the future, sorry for confusion ;)

 

Probably I missed the point with my animation, 'cos I mixed timeline with not-timeline animation.

Now everything is ok, as always with GSAP!

You guys are the best :)

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