Jump to content
Search Community

GSAP 3.0.1 Arithmetic error

hugo_rune test
Moderator Tag

Recommended Posts

I've been trying to animate a number increment from 0 to 250,000

Interestingly, GSAP 3.0.1, once it gets above 214,000 (ish) it changes the number to a negative and counts down..

When using TweenMax (latest) the code functions as expected.

Here is a codepen of how it should work (using https://cdnjs.cloudflare.com/ajax/libs/gsap/latest/TweenMax.min.js)

See the Pen pooXMNQ by hugoartemisrune (@hugoartemisrune) on CodePen



And here is the identical code that doesn't work (https://cdnjs.cloudflare.com/ajax/libs/gsap/3.0.1/gsap.min.js)



Can anyone shed any light on this matter? I'm mid port to gsap 3 and wasn't quite expecting this behavior :)

Thanks, 

Hugo

for reference, the code in both examples is
 

var Cont={val:0} , NewVal = 250000 ;

TweenLite.to(Cont,1,{val:NewVal,roundProps:"val",onUpdate:function(){
  document.getElementById("counter").innerHTML=Cont.val
}});

 

See the Pen MWWMNJL by hugoartemisrune (@hugoartemisrune) on CodePen

Link to comment
Share on other sites

30 minutes ago, TiagoFonseca said:

This works fine:
 


const tl = new gsap.TimelineLite()

tl.to("foo", { x: 100})


 

 

I see. You are already using it as a namespace. Most people would do it like this.

 

import { TimelineLite } from '../vendor/gsap-latest-beta.min.js';

const tl = new TimelineLite();

 

But you don't need to use TimelineLite/Max. They are just aliases for gsap.timeline()

import { gsap } from '../vendor/gsap-latest-beta.min.js';

// Same as new TimelineLite/Max
const tl = gsap.timeline();

// Same as TweenLite/Max
gsap.to()

 

  • Like 1
Link to comment
Share on other sites

  • 1 month later...
On 1/16/2020 at 4:18 PM, ZachSaucier said:

The bug fix for this has already been released in GSAP 3.0.5. But GSAP 3.1.0 is planned to be released early next week.

Thank you a lot) I thought I've checked v.3.0.5 but it was still 3.0.1 because it was inserted from another lib... So, 3.0.5 works great

  • Like 1
Link to comment
Share on other sites

  • 4 months later...
On 11/27/2019 at 7:00 AM, OSUblake said:

I think it's because @GreenSock is doing some bit shifting in the rounding, so it's unsigned.

 


~~2147483647 // => 2147483647
~~2147483648 // => -2147483648

 

 

Fixed in latest.

https://s3-us-west-2.amazonaws.com/s.cdpn.io/16327/gsap-latest-beta.min.js

 

See the Pen 0004f0c5cdd27f206af7b7cb47427c50 by osublake (@osublake) on CodePen

 

 

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