Repository navigation
Expand file tree
/
Copy pathSMTitle.js
More file actions
executable file
·84 lines (73 loc) · 2.61 KB
/
Copy pathSMTitle.js
File metadata and controls
executable file
·84 lines (73 loc) · 2.61 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*********************************************************************************
Copyright © SuperMap. All rights reserved.
Author: Zihao Wang
E-mail: pridehao@gmail.com
Description:标题控件(搜索控件子控件)。
**********************************************************************************/
'use strict';
var ReactNative =require('react-native');
var React = require('react');
var {
PanResponder,
StyleSheet,
Text,
View,
} = ReactNative;
var SMTitle = React.createClass({
_panResponder: {},
componentWillMount: function() {
this._panResponder = PanResponder.create({
onStartShouldSetPanResponder: this._handleStartShouldSetPanResponder,
onMoveShouldSetPanResponder: this._handleMoveShouldSetPanResponder,
onPanResponderGrant: this._handlePanResponderGrant,
onPanResponderMove: this._handlePanResponderMove,
onPanResponderRelease: this._handlePanResponderEnd,
onPanResponderTerminate: this._handlePanResponderEnd,
});
},
render: function() {
return (
<View style={styles.container} {...this._panResponder.panHandlers}>
<Text style={styles.text}>
{this.props.title}
</Text>
</View>
);
},
_handleStartShouldSetPanResponder: function(e: Object, gestureState: Object): boolean {
return true;
},
_handleMoveShouldSetPanResponder: function(e: Object, gestureState: Object): boolean {
return true;
},
_handlePanResponderGrant: function(e: Object, gestureState: Object) {
console.log('press');
},
_handlePanResponderMove: function(e: Object, gestureState: Object) {
if(gestureState.dy<-0.5){
console.log('手势上滑');
}else if(gestureState.dy>0.5){
console.log('手势下滑');
}
// this._circleStyles.style.left = this._previousLeft + gestureState.dx;
// this._circleStyles.style.top = this._previousTop + gestureState.dy;
// this._updateNativeStyles();
},
_handlePanResponderEnd: function(e: Object, gestureState: Object) {
console.log('end');
},
});
var styles = StyleSheet.create({
container: {
margin: 10,
height: 50,
padding: 0,
backgroundColor: '#F7F7F7',
},
text: {
fontSize: 19,
fontWeight: '500',
textAlign:'center',
},
});
module.exports = SMTitle;