-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathbox.js
69 lines (60 loc) · 1.72 KB
/
box.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
import React from 'react'
import { Button, View } from 'react-native'
import Behavior from '../src/behavior'
class Box extends React.PureComponent {
state = {
currentState: 0,
}
goTo = (nextState) => {
this.setState({ currentState: nextState })
}
render() {
const { currentState } = this.state
return (
<View style={styles.container}>
<View style={styles.behaviorContainer}>
<Behavior
config={{ type: 'timing', duration: 250 }}
currentState={currentState}
state={[
{},
{ opacity: 0.5 },
{ rotate: '45deg' },
{ scale: 1.5 },
{ translateX: -50 },
{ translateY: -50 },
]}
style={styles.behavior}
/>
</View>
<View style={styles.stepsContainer}>
<Button color="#0f9d58" title="original" onPress={() => this.goTo(0)} />
<Button color="#0f9d58" title="opacity" onPress={() => this.goTo(1)} />
<Button color="#0f9d58" title="rotate" onPress={() => this.goTo(2)} />
<Button color="#0f9d58" title="scale" onPress={() => this.goTo(3)} />
<Button color="#0f9d58" title="translateX" onPress={() => this.goTo(4)} />
<Button color="#0f9d58" title="translateY" onPress={() => this.goTo(5)} />
</View>
</View>
)
}
}
const styles = {
container: { flex: 1 },
behaviorContainer: {
alignItems: 'center',
flex: 1,
justifyContent: 'center',
},
behavior: {
backgroundColor: '#0f9d58',
height: 100,
width: 100,
},
stepsContainer: {
flexDirection: 'row',
flexWrap: 'wrap',
justifyContent: 'space-between',
},
}
export default Box