GithubHelp home page GithubHelp logo

xiaofuchuan / react-animated-number Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ameyms/react-animated-number

0.0 2.0 0.0 471 KB

React component for animating numbers

License: MIT License

JavaScript 93.01% HTML 6.99%

react-animated-number's Introduction

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.

react-animated-number's People

Contributors

ameyms avatar nanexcool avatar a-axton avatar phiresky avatar

Watchers

James Cloos avatar thin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.