@@ -32,6 +32,7 @@ export default class Slide extends React.Component{
32
32
33
33
constructor ( props , context ) {
34
34
super ( props , context ) ;
35
+ this . dragging = false ;
35
36
}
36
37
37
38
componentWillMount ( ) {
@@ -49,10 +50,6 @@ export default class Slide extends React.Component{
49
50
componentWillReceiveProps ( newProps ) {
50
51
let newState = this . _getStateFromProps ( newProps ) ;
51
52
this . setState ( newState ) ;
52
- }
53
-
54
- componentDidMount ( ) {
55
- //this.state.autoPlay && this._autoPlay();
56
53
React . Children . count ( this . state . children ) && this . state . autoPlay && this . _autoPlay ( ) ;
57
54
}
58
55
@@ -61,24 +58,9 @@ export default class Slide extends React.Component{
61
58
}
62
59
63
60
_getStateFromProps ( props ) {
64
- let height = props . height ;
65
- let autoPlay = props . autoPlay ;
66
- let loop = props . loop ;
67
- let showPagination = props . showPagination ;
68
- let paginationStyle = props . paginationStyle ;
69
- let paginationWrapStyle = props . paginationWrapStyle ;
70
- let activePaginationStyle = props . activePaginationStyle ;
71
- let children = props . children ;
72
61
return {
73
- height,
74
- autoPlay,
75
- loop,
76
- showPagination,
77
- paginationStyle,
78
- paginationWrapStyle,
79
- activePaginationStyle,
80
- children
81
- }
62
+ ...props
63
+ } ;
82
64
}
83
65
84
66
_createPagination ( ) {
@@ -110,6 +92,7 @@ export default class Slide extends React.Component{
110
92
111
93
_autoPlay ( ) {
112
94
var interval = this . state . autoPlay ;
95
+ clearTimeout ( this . timer ) ;
113
96
this . timer = setTimeout ( ( ) => {
114
97
if ( Platform . OS === 'ios' ) {
115
98
this . setState ( {
@@ -195,6 +178,10 @@ export default class Slide extends React.Component{
195
178
}
196
179
}
197
180
181
+ isDragging ( ) {
182
+ return this . dragging ;
183
+ }
184
+
198
185
render ( ) {
199
186
//first come may have no child, such as async get child
200
187
if ( ! React . Children . count ( this . state . children ) ) { //this.state.children.length?
@@ -250,22 +237,28 @@ export default class Slide extends React.Component{
250
237
ref = { scrollView => this . scrollView = scrollView }
251
238
style = { styles . scrollView }
252
239
initialPage = { 0 }
240
+ onPageScrollStateChanged = { status => {
241
+ //idle means not dragging
242
+ if ( status === 'idle' ) {
243
+ this . dragging = false ;
244
+ }
245
+ else if ( status === 'dragging' ) {
246
+ this . dragging = true ;
247
+ }
248
+ else {
249
+ this . dragging = false ;
250
+ }
251
+ } }
253
252
onPageScroll = { e => {
254
253
//this will trigger all the time when the view is sliding, but stops at e.nativeEvent.offset=0
255
254
let { offset, position} = e . nativeEvent ;
256
255
if ( offset === 0 ) {
257
256
this . _moveEnd ( position ) ;
258
257
}
259
- } }
260
- //user action
261
- onPageSelected = { e => {
262
-
263
258
} } >
264
259
{ this . _getChildren ( ) }
265
260
</ ViewPagerAndroid > ) ;
266
- // React.Children.map(this.props.children, child=>{
267
- // console.log(child);
268
- // });
261
+
269
262
return (
270
263
< View style = { [ styles . container , {
271
264
height : this . state . height
0 commit comments