Jump to content
Search Community

Possible bug with easeParams

Tom B. @ Wix test
Moderator Tag

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

I'm trying to use 'easeParams' when passing 'ease' as a string.

It seems that when an ease is passed as a string 'easeParams' is never read - 

in TweenMax.js line 6196:

if (!ease) {
	this._ease = TweenLite.defaultEase;
} else if (ease instanceof Ease) {
	this._ease = (v.easeParams instanceof Array) ? ease.config.apply(ease, v.easeParams) : ease;
} else {
	this._ease = (typeof(ease) === "function") ? new Ease(ease, v.easeParams) : _easeMap[ease] || TweenLite.defaultEase;
}

When ease is a string we get to the last 'else', and then to '_easeMap[ease]' without applying easeParams like in the 2 previous ifs. 

 

if I add 

if (typeof ease === 'string'){
	ease = _easeMap[ease];
}

Just before the previous code, everything works.

Edited by Tom B.
Link to comment
Share on other sites

This is great!

BUT it doesn't work:

 

line 6220:

this._ease = ease.config.apply(ease, v.easeParams);

fails because you set this._ease and not change the original ease var.

 

Should be -

this._ease = this._ease.config.apply(this._ease, v.easeParams);

Or, change it the original passed ease var here  -

ease = (!ease) ? TweenLite.defaultEase : (ease instanceof Ease) ? ease : (typeof(ease) === "function") ? new Ease(ease, v.easeParams) : _easeMap[ease] || TweenLite.defaultEase;

btw, I would have used if(){}else{} and not one liner ternary statements just because it is hard to read and debug (and js minifiers optimise it anyway ).

Link to comment
Share on other sites

Ha ha. Silly me - serves me right for rushing the patch to you. I have attached a better version that uses "ease" instead of this._ease to make minification better/tighter. 

 

As for the if/else stuff, yes, minifiers may make that tighter, but they don't necessarily optimize the logic/order itself so in this case I opted to write it out in a tighter fashion from the get-go. 

 

Does this one work well for you? Sorry about the earlier one.

GSAP_1.12.2_preview5.zip

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