swiped-events
Advanced tools
Comparing version 1.1.7 to 1.1.8
/*! | ||
* swiped-events.js - v1.1.7 | ||
* swiped-events.js - v1.1.8 | ||
* Pure JavaScript swipe events | ||
@@ -9,2 +9,2 @@ * https://github.com/john-doherty/swiped-events | ||
*/ | ||
!function(t,e){"use strict";"function"!=typeof t.CustomEvent&&(t.CustomEvent=function(t,n){n=n||{bubbles:!1,cancelable:!1,detail:void 0};var a=e.createEvent("CustomEvent");return a.initCustomEvent(t,n.bubbles,n.cancelable,n.detail),a},t.CustomEvent.prototype=t.Event.prototype),e.addEventListener("touchstart",function(t){if("true"===t.target.getAttribute("data-swipe-ignore"))return;l=t.target,r=Date.now(),n=t.touches[0].clientX,a=t.touches[0].clientY,u=0,i=0},!1),e.addEventListener("touchmove",function(t){if(!n||!a)return;var e=t.touches[0].clientX,r=t.touches[0].clientY;u=n-e,i=a-r},!1),e.addEventListener("touchend",function(t){if(l!==t.target)return;var s=parseInt(o(l,"data-swipe-threshold","20"),10),c=o(l,"data-swipe-unit","px"),d=parseInt(o(l,"data-swipe-timeout","500"),10),p=Date.now()-r,h="",v=t.changedTouches||t.touches||[];"vh"===c&&(s=Math.round(s/100*e.documentElement.clientHeight));"vw"===c&&(s=Math.round(s/100*e.documentElement.clientWidth));Math.abs(u)>Math.abs(i)?Math.abs(u)>s&&p<d&&(h=u>0?"swiped-left":"swiped-right"):Math.abs(i)>s&&p<d&&(h=i>0?"swiped-up":"swiped-down");if(""!==h){var b={dir:h.replace(/swiped-/,""),touchType:(v[0]||{}).touchType||"direct",xStart:parseInt(n,10),xEnd:parseInt((v[0]||{}).clientX||-1,10),yStart:parseInt(a,10),yEnd:parseInt((v[0]||{}).clientY||-1,10)};l.dispatchEvent(new CustomEvent("swiped",{bubbles:!0,cancelable:!0,detail:b})),l.dispatchEvent(new CustomEvent(h,{bubbles:!0,cancelable:!0,detail:b}))}n=null,a=null,r=null},!1);var n=null,a=null,u=null,i=null,r=null,l=null;function o(t,n,a){for(;t&&t!==e.documentElement;){var u=t.getAttribute(n);if(u)return u;t=t.parentNode}return a}}(window,document); | ||
!function(t,e){"use strict";"function"!=typeof t.CustomEvent&&(t.CustomEvent=function(t,n){n=n||{bubbles:!1,cancelable:!1,detail:void 0};var a=e.createEvent("CustomEvent");return a.initCustomEvent(t,n.bubbles,n.cancelable,n.detail),a},t.CustomEvent.prototype=t.Event.prototype),e.addEventListener("touchstart",function(t){if("true"===t.target.getAttribute("data-swipe-ignore"))return;l=t.target,r=Date.now(),n=t.touches[0].clientX,a=t.touches[0].clientY,u=0,i=0,o=t.touches.length},!1),e.addEventListener("touchmove",function(t){if(!n||!a)return;var e=t.touches[0].clientX,r=t.touches[0].clientY;u=n-e,i=a-r},!1),e.addEventListener("touchend",function(t){if(l!==t.target)return;var c=parseInt(s(l,"data-swipe-threshold","20"),10),d=s(l,"data-swipe-unit","px"),p=parseInt(s(l,"data-swipe-timeout","500"),10),h=Date.now()-r,v="",b=t.changedTouches||t.touches||[];"vh"===d&&(c=Math.round(c/100*e.documentElement.clientHeight));"vw"===d&&(c=Math.round(c/100*e.documentElement.clientWidth));Math.abs(u)>Math.abs(i)?Math.abs(u)>c&&h<p&&(v=u>0?"swiped-left":"swiped-right"):Math.abs(i)>c&&h<p&&(v=i>0?"swiped-up":"swiped-down");if(""!==v){var E={dir:v.replace(/swiped-/,""),touchType:(b[0]||{}).touchType||"direct",fingers:o,xStart:parseInt(n,10),xEnd:parseInt((b[0]||{}).clientX||-1,10),yStart:parseInt(a,10),yEnd:parseInt((b[0]||{}).clientY||-1,10)};l.dispatchEvent(new CustomEvent("swiped",{bubbles:!0,cancelable:!0,detail:E})),l.dispatchEvent(new CustomEvent(v,{bubbles:!0,cancelable:!0,detail:E}))}n=null,a=null,r=null},!1);var n=null,a=null,u=null,i=null,r=null,l=null,o=0;function s(t,n,a){for(;t&&t!==e.documentElement;){var u=t.getAttribute(n);if(u)return u;t=t.parentNode}return a}}(window,document); |
{ | ||
"name": "swiped-events", | ||
"version": "1.1.7", | ||
"version": "1.1.8", | ||
"description": "A 1k script that adds swipe events to the DOM for touch enabled devices", | ||
@@ -5,0 +5,0 @@ "main": "src/swiped-events.js", |
@@ -38,2 +38,3 @@ /*! | ||
var startEl = null; | ||
var touchCount = 0; | ||
@@ -88,2 +89,3 @@ /** | ||
touchType: (changedTouches[0] || {}).touchType || 'direct', | ||
fingers: touchCount, // Number of fingers used | ||
xStart: parseInt(xDown, 10), | ||
@@ -107,3 +109,2 @@ xEnd: parseInt((changedTouches[0] || {}).clientX || -1, 10), | ||
} | ||
/** | ||
@@ -126,2 +127,3 @@ * Records current location on touchstart event | ||
yDiff = 0; | ||
touchCount = e.touches.length; | ||
} | ||
@@ -128,0 +130,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
208552
192