0.2.0 • Published 2 years ago

react-native-reanimated-numbers v0.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

react-native-reanimated-numbers

react native library shows animation when numbers change, powered by reanimated

Important

限制了最小 react-native 版本 和 reanimated 版本

"react-native-reanimated": "3.6.0"

"react-native": "0.72.5"

reanimated 的安装,请参考官方文档

demo_gif

Installation

npm install react-native-reanimated-numbers


yarn add react-native-reanimated-numbers

Usage

import AnimatedNumber from 'react-native-reanimated-numbers';

// ...

const [animateToNumber, setAnimateToNumber] = React.useState(18888);

<AnimatedNumber
  animateToNumber={animateToNumber}
  fontStyle={{
    fontSize: 30,
  }}
  onAnimationFinished={() => {
    Alert.alert('Animation finished');
  }}
/>;

<Button
  title="Animate"
  onPress={() => setAnimateToNumber(Math.floor(Math.random() * 10000))}
/>;

Props

Prop NameTypeDefault ValueDescription
animateToNumbernumber需要动画效果到达的数值。
fontStyleStylePropundefined文本样式属性,可以是任何 Text 组件有效的 StyleProp。
animationDurationnumber1300动画持续时间(毫秒)。
easingEasingFunction | EasingFunctionFactoryEasing.elastic(1.2)控制动画节奏的缓动函数。
onReady() => voidundefined组件准备完毕时的回调函数。
emptyTextstring | numberundefined当没有内容时显示的文本或数值。
onAnimationFinished() => voidundefined动画完成后的回调函数。

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Made with create-react-native-library