-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInteractable.js
More file actions
63 lines (59 loc) · 1.7 KB
/
Interactable.js
File metadata and controls
63 lines (59 loc) · 1.7 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
import React, { Component } from 'react';
import { StyleSheet, View, TouchableOpacity, Text } from 'react-native';
import Interactable from 'react-native-interactable';
export default class ChangePosition extends Component {
constructor(props) {
super(props);
this.state = {
};
}
render() {
const snapPoints = [
{x: -140, y: -250},
{x: 140, y: -250},
{x: -140, y: -120},
{x: 140, y: -120},
{x: -140, y: 0},
{x: 140, y: 0},
{x: -140, y: 120},
{x: 140, y: 120},
{x: -140, y: 250},
{x: 140, y: 250}
];
const blueDestination = snapPoints[3];
return (
<View style={styles.container}>
<Interactable.View
style={{zIndex: 2}}
ref='blue'
snapPoints={snapPoints}
initialPosition={{x:10, y: 370}}
>
<View style={{width: 70, height: 70, backgroundColor: '#3182C8', borderRadius: 35}} />
</Interactable.View>
<View style={{
position: 'absolute',
top: 90,
left: 50,
zIndex: 1,
}}>
<TouchableOpacity
onPress={() => {
this.refs['blue'].changePosition(blueDestination)
}}
>
<Text style={{color: '#3182C8', borderColor: '#3182C8', borderWidth: 1, padding: 6, borderRadius: 15, alignSelf: 'center'}}>{"ChangePosition to " + JSON.stringify(blueDestination)}</Text>
</TouchableOpacity>
</View>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: 'white',
}
});