react-component / tween-one

Animate One React Element
https://tween-one.vercel.app/
MIT License
380 stars 30 forks source link

数值变化动画出错 #36

Closed infeng closed 6 years ago

infeng commented 6 years ago

在官网的示例中随机输入一个数字会出现以下错误

index.js:335 Uncaught RangeError: Invalid array length
    at setRatio (index.js:335)
    at index.js:335
    at Array.forEach (<anonymous>)
    at c.f.setRatio (index.js:335)
    at index.js:335
    at Array.forEach (<anonymous>)
    at g.b.setRatio (index.js:335)
    at index.js:335
    at Array.forEach (<anonymous>)
    at g.b.render (index.js:335)
jljsj33 commented 6 years ago

看到了,,浮点精度错误,,,谢谢/。。。

jljsj33 commented 6 years ago

2.0.9

infeng commented 6 years ago

https://github.com/react-component/tween-one/blob/master/src/plugin/ChildrenPlugin.jsx#L47

decimal = decimal.length > 2 ? decimal.substring(0, 2) : decimal;

这里的 2 应该是 floatLength 才对

jljsj33 commented 6 years ago

~只取前两个啊,,~

jljsj33 commented 6 years ago

没事,,那个 toFixed 修了

jljsj33 commented 6 years ago

搞忘了,,乱了。。。哈哈,,谢谢

infeng commented 6 years ago

:smile: