axelra-ag / react-native-animateable-text

🆎 A fork of React Native's <Text/> component that supports Animated Values!
https://www.npmjs.com/package/react-native-animateable-text
MIT License
360 stars 27 forks source link

How to prevent floating points during animation? #13

Closed waltermvp closed 3 years ago

waltermvp commented 3 years ago

I am animating a text value from "00" to "100". I have applied a duration and it works. However, the animation shows decimal points which I would like to omit. How would I omit the decimal points during the animation?

waltermvp commented 3 years ago

I have tried with numbers as well and the result is the same

waltermvp commented 3 years ago

@axelra-ag?

JonnyBurger commented 3 years ago

If you have a number, you can omit the decimal points after the comma and convert it to a string by using .toFixed(0).

Example:

const hi = 100.123
const rounded = hi.toFixed(0) // "100"