1.0.18 • Published 7 months ago

@crossfox/react-animated-number v1.0.18

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
7 months ago

React animated number by CrossFox

npm version Blazing Fast gzip size NPM downloads license

A lightweight, blazing-fast React component that's easy to use and works with React 16.8 and higher.

  • 📦 <1kb mini library
  • 🌟 Easy to use
  • ⚡ High performance
  • 🔗 No dependency

Demo:

View demo here

Install

npm install @crossfox/react-animated-number
yarn add @crossfox/react-animated-number

Author

Props

NameTypeDefault ValueDescriptionVersion
valuenumber0Current value, triggers animation on change1.00
roundnumber0Number of decimal places1.00
durationnumber1000Animation duration(ms)1.00
classNamestring0You can add custom classes1.00
showArrowbooleanfalseDisplay an arrow to the left of the number indicating growth or decline1.00
reserveMinusSpacebooleanfalseAdds a space for the minus sign1.00
reservenumber0Reserves space for the number1.00
alignstring"left"Reservation direction. Available only as 'left', in other cases 'right'1.00
prefixstring""Adds text to be placed before the number. For example, '$100'1.00
suffixstring""Adds text to be placed after the number. For example, '1000 UAH'1.00
ratestring60Number of updates per second1.00
tagNamestringdivTag to be created for the number.1.00
onFinishfunctionfunction(oldValue, value, $el)Event triggers after the animation is complete. Returns the old number, current number, and the element node.1.00

ClassName status

ClassNameDescription
is-progressAdded during the animation
is-incrementNotifies that the number has increased
is-decrementNotifies that the number has decreased

Example

import React, { useState } from 'react';
import AnimatedNumber from '@crossfox/react-animated-number';

const App = () => {
	const [value, setValue] = useState(0)
	const onClickRandom = () => setValue(Math.random() * 10000 >> 0)
	return (<>
		<button onClick={onClickRandom}>Random value</button>
		<AnimatedNumber value={value}/>
	</>)
}
1.0.18

7 months ago

1.0.17

7 months ago

1.0.16

7 months ago

1.0.15

7 months ago

1.0.14

8 months ago

1.0.13

8 months ago

1.0.12

8 months ago

1.0.11

8 months ago

1.0.10

8 months ago

1.0.9

8 months ago

1.0.8

8 months ago

1.0.6

8 months ago

1.0.5

8 months ago

1.0.4

8 months ago

1.0.3

8 months ago

1.0.2

8 months ago

1.0.1

8 months ago

1.0.0

8 months ago