@@ -115,6 +115,14 @@ $.event.special.tap = {
115115
116116// also handles swipeleft, swiperight
117117$ . 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+
118126 setup : function ( ) {
119127 var thisObject = this ,
120128 $this = $ ( thisObject ) ;
@@ -144,7 +152,7 @@ $.event.special.swipe = {
144152 } ;
145153
146154 // 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 ) {
148156 event . preventDefault ( ) ;
149157 }
150158 }
@@ -154,9 +162,9 @@ $.event.special.swipe = {
154162 $this . unbind ( touchMoveEvent , moveHandler ) ;
155163
156164 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 ) {
160168
161169 start . origin . trigger ( "swipe" )
162170 . trigger ( start . coords [ 0 ] > stop . coords [ 0 ] ? "swipeleft" : "swiperight" ) ;
0 commit comments