Skip to content

Commit 0e28274

Browse files
author
Henning Hall
committed
add reanimated1
1 parent 03a9c16 commit 0e28274

File tree

5 files changed

+48
-9
lines changed

5 files changed

+48
-9
lines changed

.prettierrc.js

+1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ module.exports = {
33
jsxBracketSameLine: true,
44
singleQuote: true,
55
trailingComma: 'all',
6+
semi: false,
67
};

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"react-native": "0.62.2",
1515
"react-native-gesture-handler": "^1.6.1",
1616
"react-native-reanimated": "^2.0.0-alpha.1",
17+
"react-native-reanimated-1": "npm:react-native-reanimated@^1.9.0",
1718
"react-native-vector-icons": "^6.6.0"
1819
},
1920
"devDependencies": {

src/HeavyLoad.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react'
22
import {View} from 'react-native'
33

4-
const componentsToRender = 3000
4+
const componentsToRender = 5000
55

66
export const HeavyLoad = () => {
77
return (

src/libs/Reanimated1.js

+38-8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,40 @@
1-
import React from 'react'
2-
import {Text} from '../Text'
1+
import React, {useRef, useState} from 'react';
2+
import {Transition, Transitioning} from 'react-native-reanimated';
3+
import {Card} from '../Card';
4+
import {CardContainer} from '../CardContainer';
5+
import {
6+
animationDuration,
7+
collapsedHeight,
8+
expandedHeight,
9+
initialHeight,
10+
} from '../constants';
11+
12+
const transition = (
13+
<Transition.Change interpolation="easeInOut" durationMs={animationDuration} />
14+
);
15+
16+
export const Reanimated1 = ({heavyLoad}) => {
17+
const ref = useRef();
18+
let [height, setHeight] = useState(initialHeight);
19+
20+
const onPress = () => {
21+
ref.current.animateNextTransition();
22+
setHeight(height === expandedHeight ? collapsedHeight : expandedHeight);
23+
};
324

4-
export const Reanimated1 = () => {
525
return (
6-
<Text style={{margin: 20, textAlign: 'center'}}>
7-
Checkout branch "reanimated1"
8-
</Text>
9-
)
10-
}
26+
<Transitioning.View ref={ref} transition={transition}>
27+
<CardContainer>
28+
<Card />
29+
</CardContainer>
30+
31+
<CardContainer style={{height}} onPress={onPress}>
32+
<Card expandable heavyLoad={heavyLoad} />
33+
</CardContainer>
34+
35+
<CardContainer>
36+
<Card />
37+
</CardContainer>
38+
</Transitioning.View>
39+
);
40+
};

yarn.lock

+7
Original file line numberDiff line numberDiff line change
@@ -5527,6 +5527,13 @@ react-native-gesture-handler@^1.6.1:
55275527
invariant "^2.2.4"
55285528
prop-types "^15.7.2"
55295529

5530+
"react-native-reanimated-1@npm:react-native-reanimated@^1.9.0":
5531+
version "1.9.0"
5532+
resolved "https://registry.yarnpkg.com/react-native-reanimated/-/react-native-reanimated-1.9.0.tgz#38676c99dd585504fdc7331efb45e5f48ec7339a"
5533+
integrity sha512-Aj+spgIHRiVv7ezGADxnSH1EoKrQRD2+XaSiGY0MiB/pvRNNrZPSJ+3NVpvLwWf9lZMOP7dwqqyJIzoZgBDt8w==
5534+
dependencies:
5535+
fbjs "^1.0.0"
5536+
55305537
react-native-reanimated@^2.0.0-alpha.1:
55315538
version "2.0.0-alpha.1"
55325539
resolved "https://registry.yarnpkg.com/react-native-reanimated/-/react-native-reanimated-2.0.0-alpha.1.tgz#d8d451aeb8e31b59e36664749a2c00c736c981e9"

0 commit comments

Comments
 (0)