diff --git a/js/dist/swiftclick.min.js b/js/dist/swiftclick.min.js index d715aec..41a9a4a 100644 --- a/js/dist/swiftclick.min.js +++ b/js/dist/swiftclick.min.js @@ -1 +1 @@ -function SwiftClick(a){function b(){"function"==typeof k&&(j.addEventListener("click",c,!1),j.onclick=null),j.addEventListener("touchstart",d,!1),j.addEventListener("click",f,!0)}function c(a){k(a)}function d(a){var b=a.target,c=b.nodeName.toLowerCase(),d=a.changedTouches[0];return m.x=d.pageX,m.y=d.pageY,n=h(),"undefined"==typeof i.options.elements[c]?!0:l?(o=!1,!0):(a.stopPropagation(),l=!0,b.addEventListener("touchend",e,!1),void 0)}function e(a){var b,c=a.target,d=!0;return c.removeEventListener("touchend",e,!1),b=a.changedTouches[0],!o||Math.abs(_touchEnd.pageX-m.x)>i.options.maxTouchDrift||Math.abs(_touchEnd.pageY-m.y)>i.options.maxTouchDrift||Math.abs(h().x-n.x)>i.options.maxTouchDrift||Math.abs(h().y-n.y)>i.options.maxTouchDrift?(l&&(a.stopPropagation(),a.preventDefault(),d=!1),l=!1,o=!0,d):(a.stopPropagation(),a.preventDefault(),p=!1,c.focus(),g(c,b),l=!1,o=!0,!1)}function f(a){var b=a.target,c=b.nodeName.toLowerCase();if("undefined"!=typeof i.options.elements[c]){if(p)return p=!1,a.stopPropagation(),a.preventDefault(),!1;p=!0}}function g(a,b){var c=document.createEvent("MouseEvents");c.initMouseEvent("click",!0,!0,window,1,b.screenX,b.screenY,b.clientX,b.clientY,!1,!1,!1,!1,0,null),a.dispatchEvent(c)}function h(){var a={x:window.pageXOffset||document.body.scrollLeft||document.documentElement.scrollLeft||0,y:window.pageYOffset||document.body.scrollTop||document.documentElement.scrollTop||0};return a}if("undefined"!=typeof SwiftClick.swiftDictionary[a])return SwiftClick.swiftDictionary[a];SwiftClick.swiftDictionary[a]=this,this.options={elements:{a:"a",div:"div",span:"span",button:"button"},maxTouchDrift:30};var i=this,j=a,k=j.onclick,l=!1,m={x:0,y:0},n={x:0,y:0},o=!0,p=!1;"onorientationchange"in window&&"ontouchstart"in window&&b(),i.addNodeNamesToTrack=function(a){var b,c=0,d=a.length;for(c;d>c;c++){if("string"!=typeof a[c])throw new TypeError("all values within the 'nodeNames' array must be of type 'string'");b=a[c].toLowerCase(),i.options.elements[b]=b}},i.replaceNodeNamesToTrack=function(a){i.options.elements={},i.addNodeNamesToTrack(a)}}SwiftClick.swiftDictionary={},SwiftClick.attach=function(a){"use strict";return"undefined"!=typeof SwiftClick.swiftDictionary[a]?SwiftClick.swiftDictionary[a]:new SwiftClick(a)},"undefined"!=typeof define&&define.amd?define(function(){"use strict";return SwiftClick}):"undefined"!=typeof module&&module.exports?module.exports=SwiftClick:window.SwiftClick=SwiftClick; \ No newline at end of file +function SwiftClick(a){function b(){"function"==typeof k&&(j.addEventListener("click",c,!1),j.onclick=null),j.addEventListener("touchstart",d,!1),j.addEventListener("click",f,!0)}function c(a){k(a)}function d(a){var b=a.target,c=b.nodeName.toLowerCase(),d=a.changedTouches[0];return m.x=d.pageX,m.y=d.pageY,n=h(),"undefined"==typeof i.options.elements[c]?!0:l?(o=!1,!0):(a.stopPropagation(),l=!0,b.removeEventListener("touchend",e,!1),b.addEventListener("touchend",e,!1),void 0)}function e(a){var b,c=a.target,d=!0;return c.removeEventListener("touchend",e,!1),b=a.changedTouches[0],!o||Math.abs(b.pageX-m.x)>i.options.maxTouchDrift||Math.abs(b.pageY-m.y)>i.options.maxTouchDrift||Math.abs(h().x-n.x)>i.options.maxTouchDrift||Math.abs(h().y-n.y)>i.options.maxTouchDrift?(l&&(a.stopPropagation(),a.preventDefault(),d=!1),l=!1,o=!0,d):(a.stopPropagation(),a.preventDefault(),p=!1,c.focus(),g(c,b),l=!1,o=!0,!1)}function f(a){var b=a.target,c=b.nodeName.toLowerCase();if("undefined"!=typeof i.options.elements[c]){if(p)return p=!1,a.stopPropagation(),a.preventDefault(),!1;p=!0}}function g(a,b){var c=document.createEvent("MouseEvents");c.initMouseEvent("click",!0,!0,window,1,b.screenX,b.screenY,b.clientX,b.clientY,!1,!1,!1,!1,0,null),a.dispatchEvent(c)}function h(){var a={x:window.pageXOffset||document.body.scrollLeft||document.documentElement.scrollLeft||0,y:window.pageYOffset||document.body.scrollTop||document.documentElement.scrollTop||0};return a}if("undefined"!=typeof SwiftClick.swiftDictionary[a])return SwiftClick.swiftDictionary[a];SwiftClick.swiftDictionary[a]=this,this.options={elements:{a:"a",div:"div",span:"span",button:"button"},maxTouchDrift:30};var i=this,j=a,k=j.onclick,l=!1,m={x:0,y:0},n={x:0,y:0},o=!0,p=!1;"onorientationchange"in window&&"ontouchstart"in window&&b(),i.addNodeNamesToTrack=function(a){var b,c=0,d=a.length;for(c;d>c;c++){if("string"!=typeof a[c])throw new TypeError("all values within the 'nodeNames' array must be of type 'string'");b=a[c].toLowerCase(),i.options.elements[b]=b}},i.replaceNodeNamesToTrack=function(a){i.options.elements={},i.addNodeNamesToTrack(a)}}SwiftClick.swiftDictionary={},SwiftClick.attach=function(a){"use strict";return"undefined"!=typeof SwiftClick.swiftDictionary[a]?SwiftClick.swiftDictionary[a]:new SwiftClick(a)},"undefined"!=typeof define&&define.amd?define(function(){"use strict";return SwiftClick}):"undefined"!=typeof module&&module.exports?module.exports=SwiftClick:window.SwiftClick=SwiftClick; \ No newline at end of file diff --git a/js/libs/swiftclick.js b/js/libs/swiftclick.js index 26432bb..c207566 100644 --- a/js/libs/swiftclick.js +++ b/js/libs/swiftclick.js @@ -79,6 +79,7 @@ function SwiftClick (contextEl) _currentlyTrackingTouch = true; // only add the 'touchend' listener now that we know the element should be tracked. + targetEl.removeEventListener("touchend", touchEndHandler, false); targetEl.addEventListener("touchend", touchEndHandler, false); } @@ -94,8 +95,8 @@ function SwiftClick (contextEl) // cancel the touch if the node type is unacceptable (not in the dictionary), or if the touchpoint position has drifted significantly. if (!_shouldSynthesizeClickEvent || - Math.abs(_touchEnd.pageX - _touchStartPoint.x) > _self.options.maxTouchDrift || - Math.abs(_touchEnd.pageY - _touchStartPoint.y) > _self.options.maxTouchDrift || + Math.abs(touchend.pageX - _touchStartPoint.x) > _self.options.maxTouchDrift || + Math.abs(touchend.pageY - _touchStartPoint.y) > _self.options.maxTouchDrift || Math.abs(getScrollPoint().x - _scrollStartPoint.x) > _self.options.maxTouchDrift || Math.abs(getScrollPoint().y - _scrollStartPoint.y) > _self.options.maxTouchDrift) {