File tree Expand file tree Collapse file tree 1 file changed +17
-13
lines changed Expand file tree Collapse file tree 1 file changed +17
-13
lines changed Original file line number Diff line number Diff line change 1
1
/**
2
2
* @author 剧中人
3
3
* @github https://github.com/bh-lay/toucher
4
- * @modified 2015-6-5 09:37
4
+ * @modified 2015-6-23 00:25
5
5
*
6
6
*/
7
7
201
201
clearTimeout ( touchDelay ) ;
202
202
}
203
203
204
+
205
+ //断定此次事件为轻击事件
206
+ function isSingleTap ( ) {
207
+ actionOver ( ) ;
208
+ EMIT . call ( this_touch , 'singleTap' , eventMark ) ;
209
+ }
204
210
//触屏开始
205
211
function touchStart ( e ) {
206
212
//缓存事件
207
213
eventMark = e ;
208
-
209
214
x1 = e . touches [ 0 ] . pageX ;
210
215
y1 = e . touches [ 0 ] . pageY ;
211
216
x2 = 0 ;
229
234
return
230
235
}
231
236
var now = new Date ( ) ;
232
- if ( now - lastTouchTime > 260 ) {
233
- touchDelay = setTimeout ( function ( ) {
234
- //断定此次事件为轻击事件
235
- actionOver ( ) ;
236
- EMIT . call ( this_touch , 'singleTap' , eventMark ) ;
237
- } , 250 ) ;
237
+ //若未监听doubleTap,直接响应
238
+ if ( ! this_touch . _events . doubleTap || this_touch . _events . doubleTap . length == 0 ) {
239
+ isSingleTap ( ) ;
240
+ } else if ( now - lastTouchTime > 200 ) {
241
+ //延迟响应
242
+ touchDelay = setTimeout ( isSingleTap , 190 ) ;
238
243
} else {
239
244
clearTimeout ( touchDelay ) ;
240
245
actionOver ( e ) ;
259
264
if ( ! isActive ) {
260
265
return
261
266
}
262
- x2 = e . touches [ 0 ] . pageX
263
- y2 = e . touches [ 0 ] . pageY
267
+ x2 = e . touches [ 0 ] . pageX
268
+ y2 = e . touches [ 0 ] . pageY
264
269
if ( Math . abs ( x1 - x2 ) > 2 || Math . abs ( y1 - y2 ) > 2 ) {
265
270
//断定此次事件为移动手势
266
271
var direction = swipeDirection ( x1 , x2 , y1 , y2 ) ;
267
272
EMIT . call ( this_touch , 'swipe' + direction , e ) ;
268
273
} else {
269
274
//断定此次事件为轻击事件
270
- actionOver ( e ) ;
271
- EMIT . call ( this_touch , 'singleTap' , e ) ;
275
+ isSingleTap ( ) ;
272
276
}
273
277
actionOver ( e ) ;
274
278
}
320
324
return function ( dom ) {
321
325
return new touch ( dom ) ;
322
326
} ;
323
- } ) ;
327
+ } ) ;
You can’t perform that action at this time.
0 commit comments