-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
49 lines (45 loc) · 1 KB
/
App.js
File metadata and controls
49 lines (45 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import Animated, {
useSharedValue,
withTiming,
useAnimatedStyle,
Easing,
} from "react-native-reanimated";
import { View, Button } from "react-native";
import { StrictMode } from "react";
export default function AnimatedStyleUpdateExample(props) {
const randomWidth = useSharedValue(10);
const config = {
duration: 500,
easing: Easing.bezier(0.5, 0.01, 0, 1),
};
const style = useAnimatedStyle(() => {
return {
width: withTiming(randomWidth.value, config),
};
});
return (
<View
style={{
flex: 1,
alignItems: "center",
justifyContent: "center",
flexDirection: "column",
}}
>
<StrictMode>
<Animated.View
style={[
{ width: 100, height: 80, backgroundColor: "black", margin: 30 },
style,
]}
/>
</StrictMode>
<Button
title="toggle"
onPress={() => {
randomWidth.value = Math.random() * 350;
}}
/>
</View>
);
}