Skip to content

Commit d4b44db

Browse files
committed
Update Vertical Swipe Support
update swipeMethod props for Horizontal or Vertical Swip
1 parent 858e0d1 commit d4b44db

File tree

8 files changed

+442
-192
lines changed

8 files changed

+442
-192
lines changed

Diff for: README.md

+84-41
Original file line numberDiff line numberDiff line change
@@ -240,51 +240,94 @@ deactivedViewStyleHandler={({ location, action, isNestedRoute }) => {
240240

241241
```
242242

243-
### transition up like Scaling
243+
### Vertical Swipe and Navigation
244244

245-
![Scaling Transiction Up Animation](https://raw.githubusercontent.com/Taymindis/react-router-native-animate-stack/master/demo/scale_and_moveup.gif)
245+
![Scaling Transiction Up Animation](https://raw.githubusercontent.com/Taymindis/react-router-native-animate-stack/master/demo/vertical_swipe.gif)
246246

247247
```jsx
248-
activedViewStyleHandler={({ location, action, isNestedRoute }) => {
249-
return {
250-
paddingLeft: 30,
251-
transform: [
252-
{
253-
translateY: enterAnimKit.interpolate({
254-
inputRange: [0, 1],
255-
outputRange: [height, 0],
256-
}),
257-
},
258-
{
259-
scale: enterAnimKit.interpolate({
260-
inputRange: [0, 0.5, 1],
261-
outputRange: [1, 0.2, 1],
262-
}),
263-
},
264-
],
265-
};
266-
}}
267-
deactivedViewStyleHandler={({ location, action, isNestedRoute }) => {
268-
return {
269-
paddingLeft: 30,
270-
transform: [
271-
{
272-
translateY: exitAnimKit.interpolate({
273-
inputRange: [0, 1],
274-
outputRange: [0, -height],
275-
}),
276-
},
277-
{
278-
scale: exitAnimKit.interpolate({
279-
inputRange: [0, 0.5, 1],
280-
outputRange: [1, 0.2, 1],
281-
}),
282-
},
283-
],
284-
};
285-
}}
286248

287-
```
249+
<NativeRouter>
250+
<View style={styles.container}>
251+
<View style={{ flex: 9, height: '100%' }}>
252+
<AnimatedStack
253+
swipeMethod={SwipeMethod.SWIPE_VERTICAL}
254+
onMountAnimate={() => {
255+
Animated.timing(enterAnimKit, {
256+
toValue: 1,
257+
duration: 100,
258+
}).start();
259+
}}
260+
onTransitionAnimate={({ location, action, isNestedRoute }) => {
261+
if (isNestedRoute) return;
262+
// Enter and exit or one only
263+
enterAnimKit.setValue(0);
264+
exitAnimKit.setValue(0);
265+
266+
Animated.timing(enterAnimKit, {
267+
toValue: 1,
268+
duration: 500,
269+
delay: 200,
270+
}).start();
271+
272+
Animated.timing(exitAnimKit, {
273+
toValue: 1,
274+
duration: 500,
275+
}).start();
276+
}}
277+
activedViewStyleHandler={({ location, action, isNestedRoute }) => {
278+
return {
279+
paddingLeft: 40,
280+
transform: [
281+
{
282+
translateY: enterAnimKit.interpolate({
283+
inputRange: [0, 1],
284+
outputRange: [height, 0],
285+
}),
286+
},
287+
{
288+
scale: enterAnimKit.interpolate({
289+
inputRange: [0, 0.5, 1],
290+
outputRange: [1, 0.2, 1],
291+
}),
292+
},
293+
],
294+
};
295+
}}
296+
deactivedViewStyleHandler={({ location, action, isNestedRoute }) => {
297+
return {
298+
transform: [
299+
{
300+
translateY: exitAnimKit.interpolate({
301+
inputRange: [0, 1],
302+
outputRange: [0, -height],
303+
}),
304+
},
305+
{
306+
scale: exitAnimKit.interpolate({
307+
inputRange: [0, 0.5, 1],
308+
outputRange: [1, 0.2, 1],
309+
}),
310+
},
311+
],
312+
};
313+
}}
314+
>
315+
<Route exact path="/">
316+
<Home />
317+
</Route>
318+
<Route path="/about">
319+
<About />
320+
</Route>
321+
<Route path="/topics" component={Topics} />
322+
</AnimatedStack>
323+
</View>
324+
<View style={{ flex: 1 }}>
325+
<Navigator />
326+
</View>
327+
</View>
328+
</NativeRouter>
329+
330+
```
288331

289332

290333
## Reason of created this

Diff for: demo/scale_and_moveup.gif

-173 KB
Binary file not shown.

Diff for: demo/vertical_swipe.gif

713 KB
Loading

Diff for: example/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"react-native": "https://github.com/expo/react-native/archive/sdk-36.0.0.tar.gz",
1818
"react-native-web": "~0.11.7",
1919
"react-router-native": "^5.1.2",
20-
"react-router-native-animate-stack": "^1.2.5"
20+
"react-router-native-animate-stack": "^1.2.6"
2121
},
2222
"devDependencies": {
2323
"@babel/core": "^7.0.0",

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-router-native-animate-stack",
3-
"version": "1.2.5",
3+
"version": "1.2.6",
44
"description": "custom animatable stack design from react router native",
55
"author": "Taymindis",
66
"license": "MIT",

0 commit comments

Comments
 (0)