Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Super easy way to animate numbers with React

License

NotificationsYou must be signed in to change notification settings

Leocardoso94/animated-number-react

Repository files navigation

npmBuild Status

A simple animated number for React, usinganime.

Live demohere

Usage

$ npm install animated-number-react# OR$ yarn add animated-number-react
importAnimatedNumberfrom"animated-number-react";exportdefaultclassAppextendsComponent{state={value:150,};handleChange=({target:{ value}})=>{this.setState({ value});};formatValue=(value)=>value.toFixed(2);render(){return(<div><inputtype="number"onChange={this.handleChange}value={this.state.value}/><AnimatedNumbervalue={this.state.value}formatValue={this.formatValue}/></div>);}}

View demo hereEdit animated-number-react

Props

Followingprops are used while initialization

Note : Onlyvalue is a required prop. Others are optional

Prop NameTypeDescriptionDefault Value
value(required)[ Number, String]number that will be animated
duration(optional)Numberthe duration of animation1000
delay(optional)Numberthe delay of animation0
className(optional)Stringan className to add to the spannull
easing(optional)Stringyou can found all valid valueshere'linear'

Callbacks props

Execute a function at the beginning, during or when an animation or timeline is completed.

NamesTypesArgumentsInfo
formatValueFunctionvalueNumberA function that will manipulate the animated value
updateFunctionanimationObjectCalled at time = 0
runFunctionanimationObjectCalled after delay is finished
beginFunctionanimationObjectCalled after animation delay is over
completeFunctionanimationObjectCalled only after all the loops are completed

Format Value

formatValue() is used to format the animatedValue.

Update

update() is called on every frame while the instance is playing.

Begin

begin() is called once after the delay is finished.

Check if the animation has begun withmyAnimation.began, returntrue orfalse.

Run

run() is called every frame after the delay is finished.

Complete

complete() is called once after the animation is finished.

About

Super easy way to animate numbers with React

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors5


[8]ページ先頭

©2009-2025 Movatter.jp