-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
118 lines (112 loc) · 2.88 KB
/
App.js
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
import React from 'react';
import {
ScrollView,
StyleSheet,
Text,
TouchableOpacity,
View,
} from 'react-native';
export default class App extends React.Component {
state = {
top: 0,
left: 0,
};
square = [];
onSquarePress = index => () => {
this.square[index].measureInWindow((left, top) => {
this.setState({ top, left });
});
};
render() {
let { top, left } = this.state;
return (
<View>
<View style={[styles.square, { top, left }]} />
<ScrollView style={styles.outer}>
<View style={styles.content}>
<Text>1</Text>
<View>
<TouchableOpacity
onPress={this.onSquarePress(0)}
style={{ marginVertical: 10 }}
>
<Text>come here square</Text>
</TouchableOpacity>
</View>
<View ref={c => (this.square[0] = c)} style={styles.comeSquare} />
</View>
<View style={styles.content}>
<Text>2</Text>
<View>
<TouchableOpacity
onPress={this.onSquarePress(1)}
style={{ marginVertical: 10 }}
>
<Text>come here square</Text>
</TouchableOpacity>
</View>
<View ref={c => (this.square[1] = c)} style={styles.comeSquare} />
</View>
<ScrollView style={styles.inner}>
<View style={styles.content}>
<Text>3</Text>
<View>
<TouchableOpacity
onPress={this.onSquarePress(2)}
style={{ marginVertical: 10 }}
>
<Text>come here square</Text>
</TouchableOpacity>
</View>
<View ref={c => (this.square[2] = c)} style={styles.comeSquare} />
</View>
<View style={styles.content}>
<Text>4</Text>
<View>
<TouchableOpacity
onPress={this.onSquarePress(3)}
style={{ marginVertical: 10 }}
>
<Text>come here square</Text>
</TouchableOpacity>
</View>
<View ref={c => (this.square[3] = c)} style={styles.comeSquare} />
</View>
</ScrollView>
</ScrollView>
</View>
);
}
}
let styles = StyleSheet.create({
outer: {
borderWidth: 1,
borderColor: 'lightblue',
padding: 20,
},
content: {
height: 500,
borderWidth: 2,
borderColor: 'pink',
margin: 20,
padding: 20,
},
inner: {
height: 500,
borderWidth: 1,
borderColor: 'purple',
},
comeSquare: {
height: 50,
width: 50,
backgroundColor: 'pink',
},
square: {
backgroundColor: 'steelblue',
position: 'fixed',
height: 50,
width: 50,
padding: 20,
zIndex: 99999,
},
});