Skip to content
This repository was archived by the owner on Feb 25, 2020. It is now read-only.

Commit dbdd352

Browse files
committed
refactor: migrate to animated
1 parent 318400b commit dbdd352

File tree

14 files changed

+391
-564
lines changed

14 files changed

+391
-564
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- v1-dependencies-example-
2323
- run: |
2424
yarn install --frozen-lockfile --cwd example
25-
yarn install --frozen-lockfile
25+
yarn install --frozen-lockfile --ignore-scripts
2626
yarn sync
2727
- save_cache:
2828
key: v1-dependencies-{{ checksum "yarn.lock" }}

example/.eslintrc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
'expo-asset',
99
'react-navigation-stack',
1010
'react-native-gesture-handler',
11-
'react-native-reanimated',
1211
'react-native-vector-icons',
1312
],
1413
},

example/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"react-native-gesture-handler": "~1.5.0",
2121
"react-native-maps": "0.26.1",
2222
"react-native-paper": "^2.15.2",
23-
"react-native-reanimated": "~1.4.0",
23+
"react-native-reanimated": "^1.4.0",
2424
"react-native-safe-area-context": "0.6.0",
2525
"react-native-unimodules": "^0.7.0-rc.1",
2626
"react-native-web": "^0.11.4",

example/src/DragLimitedToModal.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
import React from 'react';
22
import { View, Text, StyleSheet, Dimensions } from 'react-native';
3-
import Animated from 'react-native-reanimated';
43
import { NavigationStackScreenComponent } from 'react-navigation-stack';
54

65
const HEIGHT = Dimensions.get('screen').height;
76

8-
const { interpolate } = Animated;
9-
107
const DragLimitedToModal: NavigationStackScreenComponent = () => (
118
<View style={styles.modal}>
129
<Text style={styles.text}>Adjusts to the size of text</Text>
@@ -18,7 +15,7 @@ DragLimitedToModal.navigationOptions = {
1815
gestureDirection: 'vertical',
1916
gestureResponseDistance: { vertical: HEIGHT },
2017
cardStyleInterpolator: ({ current }) => {
21-
const translateY = interpolate(current.progress, {
18+
const translateY = current.progress.interpolate({
2219
inputRange: [0, 1],
2320
outputRange: [HEIGHT, 0],
2421
});

example/src/ModalStack.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ import {
1313
NavigationStackScreenProps,
1414
StackCardStyleInterpolator,
1515
} from 'react-navigation-stack';
16-
import Animated from 'react-native-reanimated';
17-
18-
const { interpolate } = Animated;
1916

2017
const gestureResponseDistance = {
2118
vertical: Dimensions.get('window').height,
@@ -25,7 +22,7 @@ const forVerticalInvertedIOS: StackCardStyleInterpolator = ({
2522
current: { progress },
2623
layouts: { screen },
2724
}) => {
28-
const translateY = interpolate(progress, {
25+
const translateY = progress.interpolate({
2926
inputRange: [0, 1],
3027
outputRange: [-screen.height, 0],
3128
});

example/src/StackAnimationConsumerStack.tsx

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import * as React from 'react';
2-
import { Button, View } from 'react-native';
3-
import Animated from 'react-native-reanimated';
2+
import { Animated, Button, View } from 'react-native';
43
import {
54
createStackNavigator,
65
NavigationStackScreenProps,
@@ -27,12 +26,12 @@ const ListScreen = (props: NavigationStackScreenProps) => (
2726
const AnotherScreen = () => (
2827
<StackCardAnimationContext.Consumer>
2928
{value => {
30-
const fontSize = value
31-
? Animated.interpolate(value.current.progress, {
29+
const scale = value
30+
? value.current.progress.interpolate({
3231
inputRange: [0, 1],
33-
outputRange: [8, 32],
32+
outputRange: [0.25, 1],
3433
})
35-
: 32;
34+
: 1;
3635

3736
return (
3837
<View
@@ -44,7 +43,11 @@ const AnotherScreen = () => (
4443
}}
4544
>
4645
<Animated.Text
47-
style={{ fontSize, opacity: value ? value.current.progress : 1 }}
46+
style={{
47+
fontSize: 32,
48+
opacity: value ? value.current.progress : 1,
49+
transform: [{ scale }],
50+
}}
4851
>
4952
Animates on progress
5053
</Animated.Text>
@@ -69,7 +72,7 @@ const YetAnotherScreen = () => (
6972
style={{
7073
fontSize: 24,
7174
opacity: value
72-
? Animated.interpolate(value.swiping, {
75+
? value.swiping.interpolate({
7376
inputRange: [0, 1],
7477
outputRange: [1, 0],
7578
})
@@ -86,7 +89,7 @@ const YetAnotherScreen = () => (
8689
style={{
8790
fontSize: 24,
8891
opacity: value
89-
? Animated.interpolate(value.closing, {
92+
? value.closing.interpolate({
9093
inputRange: [0, 1],
9194
outputRange: [1, 0],
9295
})

example/src/TransparentStack.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import {
44
createStackNavigator,
55
NavigationStackScreenComponent,
66
} from 'react-navigation-stack';
7-
import Animated from 'react-native-reanimated';
87

98
const ListScreen: NavigationStackScreenComponent = function(props) {
109
return (
@@ -75,7 +74,7 @@ export default createStackNavigator(
7574
cardStyle: { backgroundColor: 'transparent' },
7675
gestureEnabled: false,
7776
cardStyleInterpolator: ({ current: { progress } }) => {
78-
const opacity = Animated.interpolate(progress, {
77+
const opacity = progress.interpolate({
7978
inputRange: [0, 0.5, 0.9, 1],
8079
outputRange: [0, 0.25, 0.7, 1],
8180
});

example/yarn.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9985,7 +9985,7 @@ react-native-paper@^2.15.2:
99859985
react-lifecycles-compat "^3.0.4"
99869986
react-native-safe-area-view "^0.12.0"
99879987

9988-
react-native-reanimated@~1.4.0:
9988+
react-native-reanimated@^1.4.0:
99899989
version "1.4.0"
99909990
resolved "https://registry.yarnpkg.com/react-native-reanimated/-/react-native-reanimated-1.4.0.tgz#7f1acbf9be08492d834f512700570978052be2f9"
99919991
integrity sha512-tO7nSNNP+iRLVbkcSS5GXyDBb7tSI02+XuRL3/S39EAr35rnvUy2JfeLUQG+fWSObJjnMVhasUDEUwlENk8IXw==

jest-setup.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,3 @@ jest.mock('react-native-gesture-handler', () => ({
3333
END: 5,
3434
},
3535
}));
36-
37-
jest.mock('react-native-reanimated', () =>
38-
require('react-native-reanimated/mock')
39-
);

package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"prerelease": "yarn sync",
2020
"release": "release-it",
2121
"example": "yarn --cwd example",
22-
"bootstrap": "yarn example && yarn && yarn sync",
22+
"bootstrap": "yarn example && yarn --ignore-scripts && yarn sync",
2323
"sync": "bash scripts/sync-stack.sh",
2424
"patch": "diff -ruN node_modules/@react-navigation/stack/src src/vendor > scripts/stack.patch; printf ''"
2525
},
@@ -50,7 +50,7 @@
5050
"@expo/vector-icons": "^10.0.6",
5151
"@react-native-community/bob": "^0.7.0",
5252
"@react-native-community/masked-view": "^0.1.5",
53-
"@react-navigation/stack": "^5.0.0-alpha.45",
53+
"@react-navigation/stack": "^5.0.0-alpha.48",
5454
"@release-it/conventional-changelog": "^1.1.0",
5555
"@types/color": "^3.0.0",
5656
"@types/jest": "^24.0.23",
@@ -68,7 +68,6 @@
6868
"react-dom": "~16.9.0",
6969
"react-native": "~0.61.4",
7070
"react-native-gesture-handler": "^1.5.2",
71-
"react-native-reanimated": "^1.4.0",
7271
"react-native-safe-area-context": "^0.6.1",
7372
"react-native-screens": "^1.0.0-alpha.23",
7473
"react-navigation": "^4.0.10",
@@ -82,7 +81,6 @@
8281
"react": "*",
8382
"react-native": "*",
8483
"react-native-gesture-handler": "^1.0.0",
85-
"react-native-reanimated": "^1.3.0-alpha",
8684
"react-native-safe-area-context": "^0.3.3",
8785
"react-native-screens": "^1.0.0 || ^1.0.0-alpha || ^2.0.0-alpha",
8886
"react-navigation": "^4.0.7"

0 commit comments

Comments
 (0)