Jump to content
Search Community

Floating point precision of gsap.to()

m4chei test
Moderator Tag

Go to solution Solved by akapowl,

Recommended Posts

I tried implementing state-transitions with Vue.js 3 and gsap, like in the example of the Vue.js 3 documentation: https://v3.vuejs.org/guide/transitions-state.html#organizing-transitions-into-components
This example rounds to fullNumbers. 

In my little project, I don't want the numbers to be rounded, but gsap.to() seems to round to a floating point precision of 4 (e.g. 0.00049 is rounded to 0.0005). 
Is there a way, I can increase the precision of gsap.to() so that my small numbers are not always rounded to 0?

gsap.to is used like this: 

tween(newValue, oldValue) {
    gsap.to(this.$data, { 
       duration: 0.5, 
       tweeningValue: newValue,
       ease: 'sine'
    });
}



Thanks!

See the Pen oNBvZMj by lmachegger (@lmachegger) on CodePen

Link to comment
Share on other sites

Hi @akapowl

 

This did indeed get me a step further, I updated my codepen to use this plugin. 
Sadly I don't really understand whats happening in this plugin. Is there a way I can set the number of decimals to a specific value (in my case I would need 8)? 

Ideally it would be great, if the animation would consider the number of decimals of the target value. But I could work with a solution where I can specify the number of decimals to a fixed value, since in my case I always need 8 decimals

Thanks
 

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