oblador /react-native-animatable

Standard set of easy to use animations and declarative transitions for React Native

★ 9,924⑂ 687👁 109⑃ 109● 306▤ 24
JavaScriptMITCreated 2015-10-18
下载:1.4.01.4.0 ↓1.4.02023-10-26
+0
日增长
9,924
stars
687
forks
109
watchers
109
prs
306
issues
24
releases

README

react-native-animatable
Declarative transitions and animations for React Native

  

 Installation

$ npm install react-native-animatable --save

 Usage

To animate things you must use the createAnimatableComponent composer similar to the Animated.createAnimatedComponent. The common components View, Text and Image are precomposed and exposed under the Animatable namespace. If you have your own component that you wish to animate, simply wrap it with a Animatable.View or compose it with:

js
import  as Animatable from 'react-native-animatable';
MyCustomComponent = Animatable.createAnimatableComponent(MyCustomComponent);


 Declarative Usage

 Animations

html
Zoom me up, Scotty


 Looping

To make looping animations simply set the iterationCount to infinite. Most animations except the attention seekers work best when setting direction to alternate. 

html
Up and down you go
❤️


!Animatable looping demo

 Generic transitions

You can create your own simple transitions of a style property of your own choosing. The following example will increase the font size by 5 for every tap – all animated, all declarative! If you don't supply a duration property, a spring animation will be used. 

Note: If you are using colors, please use rgba() syntax.

Note: Transitions require StyleSheet.flatten available in React Native 0.15 or later. If you are running on anything lower, please polyfill as described under imperative usage.


html
 this.setState({fontSize: (this.state.fontSize || 10) + 5 })}
  Size me up, Scotty



 Properties
Note: Other properties will be passed down to underlying component.

| Prop | Description | Default |
|---|---|---|
|animation|Name of the animation, see below for available animations. |None|
|duration|For how long the animation will run (milliseconds). |1000|
|delay|Optionally delay animation (milliseconds). |0|
|direction|Direction of animation, especially useful for repeating animations. Valid values: normal, reverse, alternate, alternate-reverse. |normal|
|easing|Timing function for the animation. Valid values: custom function or linear, ease, ease-in, ease-out, ease-in-out, ease-in-cubic, ease-out-cubic, ease-in-out-cubic, ease-in-circ, ease-out-circ, ease-in-out-circ, ease-in-expo, ease-out-expo, ease-in-out-expo, ease-in-quad, ease-out-quad, ease-in-out-quad, ease-in-quart, ease-out-quart, ease-in-out-quart, ease-in-quint, ease-out-quint, ease-in-out-quint, ease-in-sine, ease-out-sine, ease-in-out-sine, ease-in-back, ease-out-back, ease-in-out-back. |ease|
|iterationCount|How many times to run the animation, use infinite for looped animations. |1|
|iterationDelay|For how long to pause between animation iterations (milliseconds). |0|
|transition|What style property to transition, for example opacity, rotate or fontSize. Use array for multiple properties.  |None|
|onAnimationBegin|A function that is called when the animation has been started. |None|
|onAnimationEnd|A function that is called when the animation has been completed s

Top issues

Latest release

1.4.0 v1.4.0 2023-10-26
What's Changed
 Make it possible to override isInteraction by @joel-bitar in https://github.com/oblador/react-native-animatable/pull/291
 fix: typing by @DeanVanNiekerk in https://github.com/oblador/react-native-animatable/pull/301
 Drop usage of deprecated React TypeScript types by @eps1lon in https://github.com/oblador/react-native-animatable/pull/400
 Disable iterationDelay delay on the beginning of animation by @HishamMubarak in https://github.com/oblador/react-native-animatable/pull/324

 New Contributors
 @joel-bitar made their first contribution in https://github.com/oblador/reac

Snapshot: 2026-11-16T09:23:14Z · Data license Apache-2.0 · JSON