greensock / GSAP

GSAP (GreenSock Animation Platform), a JavaScript animation library for the modern web
https://gsap.com
19.83k stars 1.72k forks source link

Element becomes untweenable after tween scale to NaN #453

Closed dondiegote closed 3 years ago

dondiegote commented 3 years ago

Hello gsap team.

I found a problem with gsap 3.x. When you try tween an element scale to NaN, gsap silently fails and the element becomes untweenable.

Steps to reproduce:


var num = 0/0;
TweenMax.to(".rec", 1, {scale:num});

TweenMax.to(".rec", 1, {scale:.1});    // don´t work
TweenMax.to(".rec", 1, {x:200});    // don´t work

num = 2;
TweenMax.to(".rec", 1, {scale:num});    // don´t work, element is untweenable

Expected behaviour:

Thanks for this great library, have a nice day.

jackdoyle commented 3 years ago

Thanks for pointing that out, @dondiegote. I definitely wouldn't recommend setting thing to invalid values, but I can add some logic to the next release that senses that condition and works around it (defaulting to 0). You can preview the next release (minified) here: https://assets.codepen.io/16327/gsap-latest-beta.min.js

Better?

dondiegote commented 3 years ago

I agree Jack, definitely not a good idea tween nothing to NaN. I used to apply some transforms with gsap.set (lazy me), and in my actual proyect one previous operation returned me NaN sometimes. I spent some time checking why it didn't apply tweens after that, so i'm pretty sure this little change can helps other users to save time.

I checked the last version, works perfectly.

Thx again, you guys do a great job with gsap.

Have a nice day Diego