Jump to content
Search Community

once callback

JinSan test
Moderator Tag

Go to solution Solved by OSUblake,

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

Hi and welcome to the GreenSock forums,

 
You can remove an eventCallback like this:
 
var tl = new TimelineLite({onComplete:done});
tl.to(".box", 3, {rotation:360})


function done() {
  alert("this onComplete will fire only once, press the restart button");
  TweenLite.set("#restart", {visibility:"visible"});
  tl.eventCallback("onComplete", null);
}


document.getElementById("restart").onclick = function() {
  tl.restart();
}
 
If you need something different, please provide a demo (you can just fork mine) that illustrates the issue.
Thanks!
  • Like 3
Link to comment
Share on other sites

Hi Carl,
 
I doesn't mean the event callback. I want to add and remove 'delayedCall' callback.
 
Here is a code snippet.

var tween = TweenLite.delayedCall(0, someFunc);
this.timeline.add(tween, position); 

I already know that I can remove it with timeline.kill(), but I should save the tween to remove it. I just want add once callback. I mean the callback is exactly called just once. What is the best way to implement the once called callback?

Link to comment
Share on other sites

 

Hi and welcome to the GreenSock forums,

 
You can remove an eventCallback like this:
 
var tl = new TimelineLite({onComplete:done});
tl.to(".box", 3, {rotation:360})


function done() {
  alert("this onComplete will fire only once, press the restart button");
  TweenLite.set("#restart", {visibility:"visible"});
  tl.eventCallback("onComplete", null);
}


document.getElementById("restart").onclick = function() {
  tl.restart();
}

See the Pen AXzrEN?editors=0010 by GreenSock (@GreenSock) on CodePen

 
If you need something different, please provide a demo (you can just fork mine) that illustrates the issue.
Thanks!

 

Thank you for sharing this. 

Link to comment
Share on other sites

Any other help for my last question?

 

Please notice my last comment.

 

 

 

I just want add once callback. I mean the callback is exactly called just once. What is the best way to implement the once called callback?
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...