@@ -18,6 +18,10 @@ function getTouchProps (touch) {
18
18
var Mixin = {
19
19
propTypes : {
20
20
moveThreshold : PropTypes . number , // pixels to move before cancelling tap
21
+ moveXThreshold : PropTypes . number , // pixels on the x axis to move before cancelling tap (overrides moveThreshold)
22
+ moveYThreshold : PropTypes . number , // pixels on the y axis to move before cancelling tap (overrides moveThreshold)
23
+ allowReactivation : PropTypes . bool , // after moving outside of the moveThreshold will you allow
24
+ // reactivation by moving back within the moveThreshold?
21
25
activeDelay : PropTypes . number , // ms to wait before adding the `-active` class
22
26
pressDelay : PropTypes . number , // ms to wait before detecting a press
23
27
pressMoveThreshold : PropTypes . number , // pixels to move before cancelling press
@@ -40,6 +44,7 @@ var Mixin = {
40
44
getDefaultProps : function ( ) {
41
45
return {
42
46
activeDelay : 0 ,
47
+ allowReactivation : true ,
43
48
moveThreshold : 100 ,
44
49
pressDelay : 1000 ,
45
50
pressMoveThreshold : 5
@@ -65,6 +70,14 @@ var Mixin = {
65
70
this . clearActiveTimeout ( ) ;
66
71
} ,
67
72
73
+ componentWillUpdate : function ( nextProps , nextState ) {
74
+ if ( this . state . isActive && ! nextState . isActive ) {
75
+ this . props . onDeactivate && this . props . onDeactivate ( ) ;
76
+ } else if ( ! this . state . isActive && nextState . isActive ) {
77
+ this . props . onReactivate && this . props . onReactivate ( ) ;
78
+ }
79
+ } ,
80
+
68
81
processEvent : function ( event ) {
69
82
if ( this . props . preventDefault ) event . preventDefault ( ) ;
70
83
if ( this . props . stopPropagation ) event . stopPropagation ( ) ;
@@ -193,11 +206,16 @@ var Mixin = {
193
206
if ( movement . x > this . props . pressMoveThreshold || movement . y > this . props . pressMoveThreshold ) {
194
207
this . cancelPressDetection ( ) ;
195
208
}
196
- if ( movement . x > this . props . moveThreshold || movement . y > this . props . moveThreshold ) {
209
+ if ( movement . x > ( this . props . moveXThreshold || this . props . moveThreshold ) ||
210
+ movement . y > ( this . props . moveYThreshold || this . props . moveThreshold ) ) {
197
211
if ( this . state . isActive ) {
198
- this . setState ( {
199
- isActive : false
200
- } ) ;
212
+ if ( this . props . allowReactivation ) {
213
+ this . setState ( {
214
+ isActive : false
215
+ } ) ;
216
+ } else {
217
+ return this . endTouch ( event ) ;
218
+ }
201
219
} else if ( this . _activeTimeout ) {
202
220
this . clearActiveTimeout ( ) ;
203
221
}
@@ -219,7 +237,9 @@ var Mixin = {
219
237
this . processEvent ( event ) ;
220
238
var afterEndTouch ;
221
239
var movement = this . calculateMovement ( this . _lastTouch ) ;
222
- if ( movement . x <= this . props . moveThreshold && movement . y <= this . props . moveThreshold && this . props . onTap ) {
240
+ if ( movement . x <= ( this . props . moveXThreshold || this . props . moveThreshold ) &&
241
+ movement . y <= ( this . props . moveYThreshold || this . props . moveThreshold ) &&
242
+ this . props . onTap ) {
223
243
event . preventDefault ( ) ;
224
244
afterEndTouch = ( ) => {
225
245
var finalParentScrollPos = this . _scrollParents . map ( node => node . scrollTop + node . scrollLeft ) ;
0 commit comments