react-hook-animate-number
TypeScript icon, indicating that this package has built-in type declarations

1.0.6 • Public • Published

react-hook-animate-number

Horizontal scroll component for javascript

NPM JavaScript Style Guide

A simple number animation using React hooks.

Try out the DEMO HERE

Install

npm install --save react-hook-animate-number

Usage

//
// \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 number Returns the current number
  • isAnimating boolean Is the number currently being animated
  • isGoingUp boolean Is 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"

Todo

  • Add more tests

License

MIT © desduvauchelle

Package Sidebar

Install

npm i react-hook-animate-number

Weekly Downloads

77

Version

1.0.6

License

MIT

Unpacked Size

33.8 kB

Total Files

12

Last publish

Collaborators

  • desduvauchelle