react-animated-number

React component for animating numbers

  • 所有者: ameyms/react-animated-number
  • 平台:
  • 许可证: MIT License
  • 分类:
  • 主题:
  • 喜欢:
    0
      比较:

Github星跟踪图

react-animated-number

npm version
devDependency Status

React component for animating numbers

Install

react-animated-number is available via npm and can be used with browserify or webpack.

npm install --save react-animated-number

Usage

import AnimatedNumber from 'react-animated-number';
...
...

class Demo extends Component {

    ...

    render () {
        <AnimatedNumber component="text" value={bigValue}
            style={{
                transition: '0.8s ease-out',
                fontSize: 48,
                transitionProperty:
                    'background-color, color, opacity'
            }}
            frameStyle={perc => (
                perc === 100 ? {} : {backgroundColor: '#ffeb3b'}
            )}
            duration={300}
            formatValue={n => prettyBytes(n)}/>
    }
}

API

value: number

required
Numeric value to which to tween to


initialValue: number

default: 0
Initial numeric value for the tween start


component: any

default: "span"
This is similar to the react transition API. By default, renders text inside a <span>. You can pass in any valid ReactElement. Use "text" for rendering into SVG.


formatValue: ?(n: number) => string

A callback function that accepts a number and returns a formatted string


duration: ?number

default: 300
Total duration of animation in milliseconds


frameStyle: ?(perc: number) => Object, void,

A callback function that accepts the percentage of completion of current animation and returns the style object to applied to the current frame


stepPrecision: ?number

The number of decimal places to render for intermediate values.
If set to 0, rounds off the intermediate values using Math.round

Demo

A demo can be found here.
Source code for the demo can be found here.

License

react-animated-number is licensed under MIT license.

主要指标

概览
名称与所有者ameyms/react-animated-number
主编程语言JavaScript
编程语言JavaScript (语言数: 2)
平台
许可证MIT License
所有者活动
创建于2016-03-24 16:05:36
推送于2025-01-28 09:54:13
最后一次提交2018-01-02 10:56:55
发布数9
最新版本名称v0.4.4 (发布于 )
第一版名称v0.1.0 (发布于 )
用户参与
星数167
关注者数4
派生数28
提交数30
已启用问题?
问题数18
打开的问题数8
拉请求数5
打开的拉请求数2
关闭的拉请求数1
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?