react-native-navigator-animation
Custom page switch animation.
Install
npm install react-native-navigator-animation --save
Use
import AnimationInit from "react-native-navigator-animation";
let buildStyleInterpolator = require('buildStyleInterpolator');
let NavAnimate = AnimationInit(buildStyleInterpolator);
<Navigator
initialRoute={Routes}
configureScene={(route)=>{
// here
return NavAnimate.AnimationScaleInRightDown;
}}
renderScene={(route,navigator)=>{
let Component = route.component;
return <Component {...route.params} RootNavigator={navigator} />
}}/>
Document
Animation has been defined:
AnimationScaleInRight
AnimationScaleInRightDown
AnimationScaleInRightUp
AnimationRotateInLeft
SwitchMain
(switch tab no animation)
Custom animation API:
CustomAnimation("actionIn","actionOut",[gesture Object],[base Object])
Optional value of the first parameter:
{UpLeftIn,UpLeftOut},
{UpRightIn,UpRightOut},
{DownLeftIn,DownLeftOut},
{DownRightIn,DownRightOut},
{RightIn,RightOut},
{LeftIn,LeftOut},
{RotateRightIn,RotateLeftOut},
{RotateRightinUp,RotateLeftoutUp},
{RotateiInY,RotateOutY},
{RotateInX,RotateOutX},
{CenterScaleIn,CenterScaleOut}
You can use it like this:
CustomAnimation("UpLeftIn","UpLeftOut");
CustomAnimation("UpRightIn","UpLeftOut");
The third parameter is gesture
:
{
pop:{
...BaseLeftToRightGesture,
direction:"left-to-right",
fullDistance:Width
},
jumpForward:null,
jumpBack:null,
jumpTo:null
}
The four parameter is base
:
{
springFriction: 26,
springTension: 200,
defaultTransitionVelocity: 1.5,
}
The BaseLeftToRightGesture
Default value:
const BaseLeftToRightGesture = {
isDetachable: false,
gestureDetectMovement: 2,
notMoving: 0.3,
directionRatio: 0.66,
snapVelocity: 2,
edgeHitWidth: 30,
stillCompletionRatio: 3 / 5,
fullDistance: Width,
direction: 'left-to-right',
};
You can use like this:
import AnimationInit from "react-native-navigator-animation";
let buildStyleInterpolator = require('buildStyleInterpolator');
let NavAnimate = AnimationInit(buildStyleInterpolator);
NavAnimate.CustomAnimation("rightin","leftout",{
...BaseLeftToRightGesture,
jumpTo:{
}
},{
springFriction: 50,
springTension: 600,
})
Example
- step 1
git clone https://github.com/zhouyuexie/react-native-navigator-animation.git
- step 2
cd ./react-native-navigator-animation/example
- step 3
npm install
- step 4
react-native run-ios
UpdateLog
- 1.2.0:
CustomAnimation
accept four parameters, the fourth argument is an object that contains the control animation parameters