Một mục tập trung thiết kế trong kho dữ liệu GitHub của TopGit: oblador/react-native-animatable, 9.9k sao, nhóm UI / UX, JavaScript. Standard set of easy to use animations and declarative transitions for React Native
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
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:
import * as Animatable from 'react-native-animatable';
MyCustomComponent = Animatable.createAnimatableComponent(MyCustomComponent);
Declarative Usage
Animations
<Animatable.Text animation="zoomInUp">Zoom me up, Scotty</Animatable.Text>
Looping
To make looping animations simply set the iterationCount to infinite. Most animations except the attention seekers work best when setting direction to alternate.
<Animatable.Text animation="slideInDown" iterationCount={5} direction="alternate">Up and down you go</Animatable.Text>
<Animatable.Text animation="pulse" easing="ease-out" iterationCount="infinite" style={{ textAlign: 'center' }}>❤️</Animatable.Text>
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.
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 successfully or cancelled. Function is called with an endState argument, refer to endState.finished to see if the animation completed or not.
None
onTransitionBegin
A function that is called when the transition of a style has been started. The function is called with a property argument to differentiate between styles.
None
onTransitionEnd
A function that is called when the transition of a style has been completed successfully or cancelled. The function is called with a property argument to differentiate between styles.
None
useNativeDriver
Whether to use native or JavaScript animation driver. Native driver can help with performance but cannot handle all types of styling.
false
isInteraction
Whether or not this animation creates an "interaction handle" on the InteractionManager.
false if iterationCount is less than or equal to one
Imperative Usage
Animations
All animations are exposed as functions on Animatable elements, they take an optional duration argument. They return a promise that is resolved when animation completes successfully or is cancelled.
Animations can be referred to by a global name or a definition object.
Animation Definition Schema
An animation definition is a plain object that contains an optional easing property, an optional style property for static non-animated styles (useful for perspective, backfaceVisibility, zIndex etc) and a list of keyframes. The keyframes are refered to by a number between 0 to 1 or from and to. Inspect the source in the definitions folder to see more in depth examples.
<Animatable.Text animation={zoomOut} >Zoom me out</Animatable.Text>
To make your animations globally available by referring to them by a name, you can register them with initializeRegistryWithDefinitions. This function can also be used to replace built in animations in case you want to tweak some value.
The talk A Novel Approach to Declarative Animations in React Native from React Europe 2017 about this library and animations/transitions in general is available on YouTube.
MakeItRain example
See Examples/MakeItRain folder for the example project from the talk.
AnimatableExplorer example
See Examples/AnimatableExplorer folder for an example project demoing animations available out of the box and more.
oblador/react-native-animatable thuộc nhóm UI / UX trên TopGit, cùng 3 topic GitHub. Trang Trending và Topics liệt kê các repo cùng số sao và cùng ngôn ngữ để so sánh.
Đọc thêm về oblador/react-native-animatable ở đâu?
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/oblador/react-native-animatable là nguồn chính thức.
oblador/react-native-animatable có phải mã nguồn mở không?
Có — oblador/react-native-animatable phát hành theo license MIT, nghĩa là mã nguồn mở để đọc, fork và (tùy license) tái sử dụng. Mã: github.com/oblador/react-native-animatable.
oblador/react-native-animatable có website riêng không?
TopGit chưa ghi nhận URL trang chủ cho oblador/react-native-animatable. Phần README ở tab phía trên thường có link demo, hoặc xem mô tả GitHub của repo.
oblador/react-native-animatable dùng license gì?
oblador/react-native-animatable phát hành theo license MIT. Nên mở file LICENSE trên GitHub để xác nhận — license metadata đôi khi lệch với thực tế dự án.
oblador/react-native-animatable là gì?
oblador/react-native-animatable (oblador/react-native-animatable) là dự án JavaScript trên GitHub. Theo mô tả gốc: Standard set of easy to use animations and declarative transitions for React Native
Vì sao oblador/react-native-animatable được xếp vào nhóm UI / UX?
TopGit xếp oblador/react-native-animatable vào nhóm UI / UX dựa trên GitHub topics và mô tả của repo (gắn thẻ: "animation", "react-native", "transition"). Việc phân loại dựa trên metadata thật của repo, không phải đoán theo cảm tính biên tập.
Đọc đầy đủ README ở tab phía trên.
Chưa chắc react-native-animatable có hợp với bạn?
Để ChatGPT, Claude hoặc Perplexity tìm hiểu giúp — bấm bên dưới và xem AI nói gì về react-native-animatable.