1.0.6 • Published 3 years ago
react-hook-animate-number v1.0.6
react-hook-animate-number
Horizontal scroll component for javascript
A simple number animation using React hooks.
Try out the DEMO HERE
Install
npm install --save react-hook-animate-numberUsage
//
// \FUNCTIONAL COMPONENT
//
import React from 'react'
import useAnimateNumber from 'react-hook-animate-number'
const Example = () => {
const animatedNumber = useAnimateNumber({ number: 1203 })
return <>{animatedNumber.number}</>
}Returns
{
number: 3, // Number
isAnimating: true, // Boolean
isGoingUp: true // boolean
}- number
numberReturns the current number - isAnimating
booleanIs the number currently being animated - isGoingUp
booleanIs the number currently going up or down
Attributes
| Attribute | Default | Type | Description |
|---|---|---|---|
| number | 0 | number | The number to display |
| durationInMs | 4000 | number | The duration of the animation |
| decimalPlaces | 0 | number | The number of decimal places |
| easingFunctionName | "easeOutExpo" | string | The animation easing function name, options are: "easeInOutCubic" | "easeOutCirc" | "easeOutQuint" | "easeOutExpo" |
Todo
- Add more tests
License
MIT © desduvauchelle