From d0bcdc085470325d6484837c11a1ecf3a63e59d9 Mon Sep 17 00:00:00 2001 From: Eugene Zhlobo Date: Wed, 21 Jan 2015 15:38:35 +0300 Subject: [PATCH] Check touch events first than pointer events --- dist/tap.js | 4 +--- dist/tap.min.js | 2 +- src/tap.js | 4 +--- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/dist/tap.js b/dist/tap.js index 1a459a2..1b5e59a 100644 --- a/dist/tap.js +++ b/dist/tap.js @@ -108,9 +108,7 @@ }; init = function() { - var i = eventMatrix.length; - - while ( i-- ) { + for ( var i = 0, l = eventMatrix.length; i < l; i++ ) { if ( eventMatrix[ i ].test ) { deviceEvents = eventMatrix[ i ].events; diff --git a/dist/tap.min.js b/dist/tap.min.js index df3030f..a3c43f0 100644 --- a/dist/tap.min.js +++ b/dist/tap.min.js @@ -1 +1 @@ -!function(a){var b={},c={};c.attachEvent=function(a,b,c){return a.addEventListener(b,c,!1)},c.fireFakeEvent=function(a,b){return a.target.dispatchEvent(c.createEvent(b))},c.createEvent=function(b){var c=a.document.createEvent("HTMLEvents");return c.initEvent(b,!0,!0),c.eventName=b,c},c.getRealEvent=function(a){return a.originalEvent&&a.originalEvent.touches&&a.originalEvent.touches.length?a.originalEvent.touches[0]:a};var d=[{test:("propertyIsEnumerable"in a||"hasOwnProperty"in document)&&(a.propertyIsEnumerable("ontouchstart")||document.hasOwnProperty("ontouchstart")),events:{start:"touchstart",move:"touchmove",end:"touchend"}},{test:a.navigator.msPointerEnabled,events:{start:"MSPointerDown",move:"MSPointerMove",end:"MSPointerUp"}},{test:a.navigator.pointerEnabled,events:{start:"pointerdown",move:"pointermove",end:"pointerup"}}];b.options={eventName:"tap",fingerMaxOffset:11};var e,f,g,h,i={};e=function(a){return c.attachEvent(document.body,h[a],g[a])},g={start:function(a){a=c.getRealEvent(a),i.start=[a.pageX,a.pageY],i.offset=[0,0]},move:function(a){return i.start||i.move?(a=c.getRealEvent(a),i.move=[a.pageX,a.pageY],void(i.offset=[Math.abs(i.move[0]-i.start[0]),Math.abs(i.move[1]-i.start[1])])):!1},end:function(d){if(d=c.getRealEvent(d),i.offset[0]a;a++)if(d[a].test)return h=d[a].events,e("start"),e("move"),e("end"),!1;return c.attachEvent(document.body,"click",g.click)},c.attachEvent(a,"load",f),a.Tap=b}(window); \ No newline at end of file diff --git a/src/tap.js b/src/tap.js index 22d3908..80616ec 100644 --- a/src/tap.js +++ b/src/tap.js @@ -57,9 +57,7 @@ }; init = function() { - var i = eventMatrix.length; - - while ( i-- ) { + for ( var i = 0, l = eventMatrix.length; i < l; i++ ) { if ( eventMatrix[ i ].test ) { deviceEvents = eventMatrix[ i ].events;