Jump to content
Search Community

Suggestion: change addCallback arguments order

Jan Cássio test
Moderator Tag

Go to solution Solved by GreenSock,

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

Hello guys,

 

I would like to suggest this simple change in TimeLineMax.addCallback signature:

 

Current

TimeLineMax.addCallback(callback, position, [args], scope)

Suggestion

TimeLineMax.addCallback(callback, position, scope, [args])

I know there is a reason to this current signature, but there is some situations where you don't want to set arguments, so the usage can be more simple and clean like this

// Example
var tmx = new TimelineMax;

tmx.add(twm1)

// current
// tmx.addCallback(onTMXComplete, tmx.totalDuration(), null, this)

// suggestion
tmx.addCallback(onTMXComplete, tmx.totalDuration(), this)

Look the last argument can be ignored.

 

Of course, this same sequence, can be used for any method that needs to set scope as argument (callback, scope, args).

 

Sorry if I made a suggestion in a wrong place.

 

Thanks,

 

UPDATE: I forgot to add position argument.

  • Like 1
Link to comment
Share on other sites

  • Solution

We always appreciate getting suggestions, Jan. Thanks. There are two difficulties here:

  1. We see a lot more situations where people don't want (or need) to define a scope. It's far more common to want to define parameters, thus switching the order would be pretty frustrating for those users. 
  2. Changing the order would instantly break legacy code. So if we released an update with the parameters reversed, we'd likely get a bunch of emails from people reporting problems and getting frustrated because their apps broke.

That being said, please keep sending us feedback and suggestions. Some of the best features and improvements have come from users. 

 

Happy tweening!

  • Like 2
Link to comment
Share on other sites

Yeah makes total sense, there is a solid legacy code behind gsap (I know because I'm a heavy greensock user since Flash and I follow this project for a long time).

I personally like to register scope always, so for me is a good stuff, but this is personal and may not be good for everyone.

 

Thanks for the feedback Jack.

 

Cheers,

Jan

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