Repository navigation
Expand file tree
/
Copy pathSettingSection.js
More file actions
60 lines (57 loc) · 1.68 KB
/
Copy pathSettingSection.js
File metadata and controls
60 lines (57 loc) · 1.68 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
import React, { Component } from 'react'
import { Text, TouchableOpacity, Animated, Easing } from 'react-native'
import styles from './styles'
export default class SettingSection extends Component {
props: {
data: Array,
onPress: () => {},
mapSetting: any,
}
constructor(props) {
super(props)
this.state = {
imgRotate: new Animated.Value(0),
}
}
onPress = section => {
Animated.timing(this.state.imgRotate, {
toValue: !this.props.data.visible ? 0 : -0.5,
duration: 200,
easing: Easing.out(Easing.quad), // 一个用于定义曲线的渐变函数
delay: 0, // 在一段时间之后开始动画(单位是毫秒),默认为0。
}).start()
this.props.onPress && this.props.onPress(section)
}
render() {
const image = require('../../assets/mapEdit/icon_spread.png')
return (
<TouchableOpacity
activeOpacity={1}
style={styles.section}
onPress={() => {
this.onPress(this.props.data)
}}
>
<Animated.Image
source={image}
style={[
styles.selection,
{
transform: [
// scale, scaleX, scaleY, translateX, translateY, rotate, rotateX, rotateY, rotateZ
{
rotate: this.state.imgRotate.interpolate({
// 旋转,使用插值函数做值映射
inputRange: [-1, 1],
outputRange: ['-180deg', '180deg'],
}),
},
],
},
]}
/>
<Text style={styles.sectionsTitle}>{this.props.data.title}</Text>
</TouchableOpacity>
)
}
}