Jump to content
Search Community

timeline.call() version 3 vs 2

e11 test
Moderator Tag

Recommended Posts

The "this" was dropped in 3.0
.call( callback:Function, params:Array, position:* ) : self
vs
.call( callback:Function, params:Array, scope:*, position:* ) : *

 

scope: *

(default = null) — The scope in which the callback should be called (basically, what “this” refers to in the function). NOTE: this parameter only exists in the JavaScript and AS2 versions.

How do I port this code to GSAP3?


Here are the contents of a class method

timelineMax
.add([tmTitleSet, tmMetricSet, tmFooterSet])
.add([tmTitle])
.add([tmMetric, tmFooter])
.play()
.call(this.animationDone, null, this, "+=1");
Link to comment
Share on other sites

Don't know why that was dropped.

 

Just use bind. You can even include params.

 

 

gsap.timeline()
  .add(this.animationDone.bind(this), "+=1");

// with params
gsap.timeline()
  .add(this.animationDone.bind(this, "foo", "bar"), "+=1");

 

From the code you posted, it looks like you could also do this.

gsap.timeline({
  onComplete: this.animationDone,
  callbackScope: this
})
.add([tmTitleSet, tmMetricSet, tmFooterSet])
.add([tmTitle])
.add([tmMetric, tmFooter])
.set({}, {}, "+=1");

 

And I'm guessing that the play() call in there is unnecessary. Animations don't start playing until the next cycle.

 

  • 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.
×
×
  • Create New...