-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp1.js
More file actions
89 lines (85 loc) · 1.79 KB
/
App1.js
File metadata and controls
89 lines (85 loc) · 1.79 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
* @flow
*/
import React, { Fragment } from "react";
import {
SafeAreaView,
StyleSheet,
ScrollView,
View,
Text,
StatusBar,
Animated
} from "react-native";
import { PanGestureHandler, State } from "react-native-gesture-handler";
export default class App extends React.Component {
constructor() {
super();
this.translateX = new Animated.Value(0);
this.onGestureEvent = Animated.event(
[
{
nativeEvent: {
translationX: this.translateX
}
}
],
{ useNativeDriver: true }
);
this.onHandlerStateChange = event => {
if (event.nativeEvent.oldState == State.ACTIVE) {
Animated.timing(this.translateX, {
toValue: 0,
duration: 1000,
useNativeDriver: true
}).start();
}
};
}
componentDidMount() {
setInterval(() => {
for (let index = 0; index < 5000; index++) {
console.log("hello", index);
}
}, 1000);
}
render() {
return (
<View style={styles.container}>
<PanGestureHandler
onGestureEvent={this.onGestureEvent}
onHandlerStateChange={this.onHandlerStateChange}
>
<Animated.View
style={[
styles.box,
{
transform: [
{
translateX: this.translateX
}
]
}
]}
></Animated.View>
</PanGestureHandler>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: "center",
alignItems: "center"
},
box: {
height: 100,
width: 100,
backgroundColor: "red"
}
});