Jump to content
Search Community

What's the gsap 3 equivalent to v2's addCallback()?

Friebel test
Moderator Tag

Recommended Posts

Upgrading projects from v2 to v3 I'm not at a point where gsap doesn't recognise .addCallback() in version 3's timeline object. I can't find anything on that in the migration guide (shouldn't this be in there?)

 

I've tried replacing all 'addCallback()'s to 'call()', which looks the same according to the v3 docs, but that doesn't seem to be the same, as than I suddenly get maximum stack reached errors (so is obviously not being called at the right time / in endless loops).

[edit 25-2] The maximum stack errors written about here are from an issue in gsap 3 on timeline.tweenTo(). I've created another thread about this issue here:

 

What is the 'official' direct equivalent in version 3 to addCallback()? 

Link to comment
Share on other sites

Alright, addCallback is removed from the API according to the releasenotes and it looks like '.add(function())' is what I'm after. So far this seems to do the job.

 

@GreenSock Shouldn't the removal of addCallback() be in the Migration document too? I might be mistaken, but when I search the document on addCallback I  can't find it there which could confuse more people like me.

  • Like 1
Link to comment
Share on other sites

1 hour ago, Friebel said:

Shouldn't the removal of addCallback() be in the Migration document too? I might be mistaken, but when I search the document on addCallback I  can't find it there which could confuse more people like me.

We didn't include every API change in the migration guide because then it'd just look like the release notes :) We wanted to keep the migration guide restricted to the most common changes to convert things from GSAP 2 to GSAP 3. The removal of .addCallback() on timelines didn't make the cut because we don't see many people using it. 

 

As said at the bottom of the migration guide, for the nitty-gritty details we recommend that people go to the release notes :) 

Link to comment
Share on other sites

7 hours ago, Friebel said:

I've tried replacing all 'addCallback()'s to 'call()', which looks the same according to the v3 docs, but that doesn't seem to be the same, as than I suddenly get maximum stack reached errors (so is obviously not being called at the right time / in endless loops).

 

Seems fine here.

See the Pen a1a6bce288886ade93cc89c50f687960 by osublake (@osublake) on CodePen

 

  • Like 1
Link to comment
Share on other sites

18 hours ago, ZachSaucier said:

We wanted to keep the migration guide restricted to the most common changes to convert things from GSAP 2 to GSAP 3.

So how do you know which methods people use? I for instance use addCallback() a lot. Also I think a migration document doesn't have to include everything that has changed (like the release notes), but IMHO should contain everything that could break existing code, so we know what to migrate. That's why we create migration docs right?

 

 I understand you'd like people to move from v2 to v3 and make that transition as small as possible and don't want to scare people so they don't make the transition, but if the transition in the end contains all kinds of extra things we need to migrate next to the migration document (as how it is now) - we have to figure out ourselves -, than it's way more work than expected and that's causing confusion and all these questions on the forum. I understand you made this choice, so I understand this is not a discussion and after a lot of searching I found most of the stuff out now, so for me it's not really an issue anymore, but I just want you to know I respectfully have to disagree and really do think all breaking changes need to be in a migration document. That would have helped me a lot to make the choice to migrate now or on a later stage to gsap 3, or better: be confident enough because of the migration doc that a transition would be easy to make with the information in that document. 

Link to comment
Share on other sites

14 minutes ago, Friebel said:

So how do you know which methods people use?

 

Mostly from looking at other people's code. Unlike gotoAndPlay, I knew .addCallback() existed, but I really can't remember seeing anybody use it. I always tell people to use .add(). I never saw a really good reason to use .call() either because you can just bind parameters to a function.

 

I think the migration guide is just meant to be a high level overview of the major changes. At the bottom of the page, it does say to check out the release notes for more details.

 

Maybe change the name from release notes to "In Depth Migration Guide"? But I don't do the documentation around here.

  • Like 2
Link to comment
Share on other sites

5 hours ago, Friebel said:

be confident enough because of the migration doc that a transition would be easy to make with the information in that document

We are confident that our migration doc would make a transition to GSAP 3 be easy for the vast majority of users moving from GSAP 2 to 3 :) But thanks for sharing your views! We really appreciate the feedback and will definitely keep that in mind moving forward. Thanks for all of your help and making posts so that if someone else has the same issues they'll be able to find your posts.

  • Like 1
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...