Hey. I started to use gsap animation few weeks ago and create some functions, but i dont know, how i could round values to prevent float values during animations.
My code is working, but is very bad code, i think
function prettify(num) {
let n = num.toString();
return n.replace(/(\d{1,3}(?=(?:\d\d\d)+(?!\d)))/g, "$1" + ' ');
}
// transform digits like 99000 in digits 99 000 (adding spaces)
const total_total = Math.round(((((type * ppl * days * hours) * ak) * tax) + total_cord) / 10) * 10;
// my value
TweenLite.to(total_result, 0.5, {innerHTML: prettify(total_total), roundProps: 'innerHTML', ease: SteppedEase.config(10), onComplete: function(){
$('#total_result').val(total_total)}})
}
// my animation
So, to round my values i need now:
1. round value in 10 like (/ 10) * 10)
2. i need to add Stteped ease with config 10
3. i need to add roundProps.
Please help me
How i can do it easily to prevent float digits during animation.
Thank you.