1.0.2 • Published 4 years ago

@sevenschan/react-count-to v1.0.2

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

React-countTo

It's a react component that will count to a target number at a specified duration

react license npm npm minified gzip

Inspire by Vue-countTo.

React-countTo is a easy component for counting to a target number at a specified duration.

Try the demo

How to use?

npm install @sevenschan/react-count-to

Example

import { ReactCountTo } from '@sevenschan/react-count-to'

<ReactCountTo className={'demo_1'} ref={'counter'} startVal={1990} endVal={2020} duration={1000}/>

Options

PropertyDescriptiontypedefault
startValthe value you want to begin atNumber0
endValthe value you want to arrive atNumber2020
durationduration in millisecondNumber3000
autoplaywhen mounted autoplayBooleantrue
decimalsthe number of decimal places to showNumber0
separatorthe separatorString,
prefixthe prefixString''
suffixthe suffixString''
prefixClassNamethe prefix's classString''
prefixStylethe prefix's styleString''
suffixClassNamethe suffix's styleString''
suffixStylethe suffix's styleString''
useEasingis use easing functionBooleantrue
easingFnthe easing functionFunction

notes: when autoplay:true , it will auto start when startVal or endVal change

Functions

Function NameDescription
startstart the countTo
pausepause the countTo
resumeresume to countTo
stopstop the countTo
resetreset the countTo

Events

Event NameDescription
onDonewhen animation is done will callback