-
Notifications
You must be signed in to change notification settings - Fork 513
/
Copy pathIconDrawer.js
90 lines (85 loc) · 2.81 KB
/
IconDrawer.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
import React, { Component } from 'react';
import { StyleSheet, View, Animated } from 'react-native';
import Interactable from 'react-native-interactable';
export default class IconDrawer extends Component {
constructor(props) {
super(props);
this._deltaX = new Animated.Value(0);
}
render() {
return (
<View style={styles.container}>
<View style={{backgroundColor: 'red'}}>
<View style={{position: 'absolute', right: 0, height: 75, flexDirection: 'row', alignItems: 'center'}}>
<Animated.View style={
[styles.button, {
opacity: this._deltaX.interpolate({
inputRange: [-230, -230, -180, -180],
outputRange: [1, 1, 0, 0]
}),
transform: [{
scale: this._deltaX.interpolate({
inputRange: [-230, -230, -180, -180],
outputRange: [1, 1, 0.8, 0.8]
})
}]
}
]} />
<Animated.View style={
[styles.button, {
opacity: this._deltaX.interpolate({
inputRange: [-165, -165, -115, -115],
outputRange: [1, 1, 0, 0]
}),
transform: [{
scale: this._deltaX.interpolate({
inputRange: [-165, -165, -115, -115],
outputRange: [1, 1, 0.8, 0.8]
})
}]
}
]} />
<Animated.View style={
[styles.button, {
opacity: this._deltaX.interpolate({
inputRange: [-100, -100, -50, -50],
outputRange: [1, 1, 0, 0]
}),
transform: [{
scale: this._deltaX.interpolate({
inputRange: [-100, -100, -50, -50],
outputRange: [1, 1, 0.8, 0.8]
})
}]
}
]} />
</View>
<Interactable.View
horizontalOnly={true}
snapTo={[{x: 0, id: 'closed'}, {x: -230, id: 'open'}]}
onSnap={this.onDrawerSnap}
animatedValueX={this._deltaX}>
<View style={{left: 0, right: 0, height: 75, backgroundColor: '#e0e0e0'}} />
</Interactable.View>
</View>
</View>
);
}
onDrawerSnap(event) {
const snapPointId = event.nativeEvent.id;
console.log(`drawer state is ${snapPointId}`);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
backgroundColor: 'white',
},
button: {
width: 40,
height: 40,
marginRight: 25,
backgroundColor: 'blue'
}
});