@@ -115,6 +115,14 @@ $.event.special.tap = {
115
115
116
116
// also handles swipeleft, swiperight
117
117
$ . event . special . swipe = {
118
+ scrollSupressionThreshold : 10 , // More than this horizontal displacement, and we will suppress scrolling.
119
+
120
+ durationThreshold : 1000 , // More time than this, and it isn't a swipe.
121
+
122
+ horizontalDistanceThreshold : 30 , // Swipe horizontal displacement must be more than this.
123
+
124
+ verticalDistanceThreshold : 75 , // Swipe vertical displacement must be less than this.
125
+
118
126
setup : function ( ) {
119
127
var thisObject = this ,
120
128
$this = $ ( thisObject ) ;
@@ -144,7 +152,7 @@ $.event.special.swipe = {
144
152
} ;
145
153
146
154
// prevent scrolling
147
- if ( Math . abs ( start . coords [ 0 ] - stop . coords [ 0 ] ) > 10 ) {
155
+ if ( Math . abs ( start . coords [ 0 ] - stop . coords [ 0 ] ) > $ . event . special . swipe . scrollSupressionThreshold ) {
148
156
event . preventDefault ( ) ;
149
157
}
150
158
}
@@ -154,9 +162,9 @@ $.event.special.swipe = {
154
162
$this . unbind ( touchMoveEvent , moveHandler ) ;
155
163
156
164
if ( start && stop ) {
157
- if ( stop . time - start . time < 1000 &&
158
- Math . abs ( start . coords [ 0 ] - stop . coords [ 0 ] ) > 30 &&
159
- Math . abs ( start . coords [ 1 ] - stop . coords [ 1 ] ) < 75 ) {
165
+ if ( stop . time - start . time < $ . event . special . swipe . durationThreshold &&
166
+ Math . abs ( start . coords [ 0 ] - stop . coords [ 0 ] ) > $ . event . special . swipe . horizontalDistanceThreshold &&
167
+ Math . abs ( start . coords [ 1 ] - stop . coords [ 1 ] ) < $ . event . special . swipe . verticalDistanceThreshold ) {
160
168
161
169
start . origin . trigger ( "swipe" )
162
170
. trigger ( start . coords [ 0 ] > stop . coords [ 0 ] ? "swipeleft" : "swiperight" ) ;
0 commit comments