Socket
Socket
Sign inDemoInstall

better-gesture

Package Overview
Dependencies
10
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.4 to 0.1.5

2

lib/better-gesture.umd.min.js

@@ -1,2 +0,2 @@

(function(e,t){"object"===typeof exports&&"object"===typeof module?module.exports=t():"function"===typeof define&&define.amd?define([],t):"object"===typeof exports?exports["better-gesture"]=t():e["better-gesture"]=t()})("undefined"!==typeof self?self:this,(function(){return function(e){var t={};function i(s){if(t[s])return t[s].exports;var r=t[s]={i:s,l:!1,exports:{}};return e[s].call(r.exports,r,r.exports,i),r.l=!0,r.exports}return i.m=e,i.c=t,i.d=function(e,t,s){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:s})},i.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"===typeof e&&e&&e.__esModule)return e;var s=Object.create(null);if(i.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)i.d(s,r,function(t){return e[t]}.bind(null,r));return s},i.n=function(e){var t=e&&e.__esModule?function(){return e["default"]}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i(i.s="fb15")}({8875:function(e,t,i){var s,r,n;(function(i,o){r=[],s=o,n="function"===typeof s?s.apply(t,r):s,void 0===n||(e.exports=n)})("undefined"!==typeof self&&self,(function(){function e(){const t=Object.getOwnPropertyDescriptor(document,"currentScript");if(!t&&"currentScript"in document&&document.currentScript)return document.currentScript;if(t&&t.get!==e&&document.currentScript)return document.currentScript;try{throw new Error}catch(v){var i,s,r,n=/.*at [^(]*\((.*):(.+):(.+)\)$/gi,o=/@([^@]*):(\d+):(\d+)\s*$/gi,u=n.exec(v.stack)||o.exec(v.stack),h=u&&u[1]||!1,a=u&&u[2]||!1,l=document.location.href.replace(document.location.hash,""),c=document.getElementsByTagName("script");h===l&&(i=document.documentElement.outerHTML,s=new RegExp("(?:[^\\n]+?\\n){0,"+(a-2)+"}[^<]*<script>([\\d\\D]*?)<\\/script>[\\d\\D]*","i"),r=i.replace(s,"$1").trim());for(var p=0;p<c.length;p++){if("interactive"===c[p].readyState)return c[p];if(c[p].src===h)return c[p];if(h===l&&c[p].innerHTML&&c[p].innerHTML.trim()===r)return c[p]}return null}}return e}))},b91a:function(e,t,i){function s(e){return s="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"===typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},s(e)}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var i=0;i<t.length;i++){var s=t[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,s.key,s)}}function o(e,t,i){return t&&n(e.prototype,t),i&&n(e,i),e}function u(e){return Math.sqrt(e.x*e.x+e.y*e.y)}function h(e,t){return e.x*t.x+e.y*t.y}function a(e,t){var i=u(e)*u(t);if(0===i)return 0;var s=h(e,t)/i;return s>1&&(s=1),Math.acos(s)}function l(e,t){return e.x*t.y-t.x*e.y}function c(e,t){var i=a(e,t);return l(e,t)>0&&(i*=-1),180*i/Math.PI}function p(){return/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)?"Mobile":"PC"}var v=function(){"use strict";function e(t){r(this,e),this._Observer={},this.el=t}return o(e,[{key:"register",value:function(e,t){"function"===typeof t&&("undefined"===typeof this._Observer[e]?this._Observer[e]=[t]:this._Observer[e].push(t))}},{key:"dispatch",value:function(e,t){if(this._Observer[e]){var i=this;t.gesture={event:Object.keys(this._Observer),on:function(e,t){i.register(e,t)},off:function(e){i.remove(e)},destroy:function(){i._Observer={}}};for(var s=0,r=this._Observer[e].length;s<r;s++){var n=this._Observer[e][s];"function"===typeof n&&n.call(this.el,t)}}}},{key:"remove",value:function(e){if(this._Observer[e]instanceof Array)for(var t=this._Observer[e].length-1;t>=0;t--)this._Observer[e].splice(t,1)}}]),e}(),m=function(){"use strict";function e(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};r(this,e),this.element="string"==typeof t?document.querySelector(t):t,this.userAgent=p(),this.start=this.start.bind(this),this.move=this.move.bind(this),this.end=this.end.bind(this),this.cancel=this.cancel.bind(this),this.mouseOver=this.mouseOver.bind(this),this.mouseOut=this.mouseOut.bind(this),this.Observer=new v(this.element),"Mobile"===this.userAgent?(this.element.addEventListener("touchstart",this.start,!1),this.element.addEventListener("touchmove",this.move,!1),this.element.addEventListener("touchend",this.end,!1),this.element.addEventListener("touchcancel",this.cancel,!1),this.Observer.register("touchStart",i.touchStart),this.Observer.register("touchMove",i.touchMove),this.Observer.register("touchEnd",i.touchEnd),this.Observer.register("touchCancel",i.touchCancel),this.Observer.register("multipointStart",i.multipointStart),this.Observer.register("multipointEnd",i.multipointEnd),this.Observer.register("pinch",i.pinch),this.Observer.register("twoFingerPressMove",i.twoFingerPressMove),this.Observer.register("rotate",i.rotate)):(this.element.addEventListener("mousedown",this.start,!1),this.element.addEventListener("mousemove",this.move,!1),this.element.addEventListener("mouseup",this.end,!1),this.element.addEventListener("mouseover",this.mouseOver,!1),this.element.addEventListener("mouseout",this.mouseOut,!1),this.Observer.register("mouseDown",i.mouseDown),this.Observer.register("mouseMove",i.mouseMove),this.Observer.register("mouseUp",i.mouseUp),this.Observer.register("mouseOver",i.mouseOver),this.Observer.register("mouseOut",i.mouseOut)),this.Observer.register("swipe",i.swipe),this.Observer.register("tap",i.tap),this.Observer.register("doubleTap",i.doubleTap),this.Observer.register("longTap",i.longTap),this.Observer.register("singleTap",i.singleTap),this.Observer.register("pressMove",i.pressMove),this._cancelAllHandler=this.cancelAll.bind(this),window.addEventListener("scroll",this._cancelAllHandler),this.preV={x:null,y:null},this.pinchStartLen=null,this.zoom=1,this.isDoubleTap=!1,this.delta=null,this.last=null,this.now=null,this.tapTimeout=null,this.singleTapTimeout=null,this.longTapTimeout=null,this.swipeTimeout=null,this.x1=this.x2=this.y1=this.y2=null,this.preTapPosition={x:null,y:null},this.isPress=!1}return o(e,[{key:"start",value:function(e){this.now=Date.now(),this.isPress=!0,"Mobile"===this.userAgent?(this.x1=e.touches[0].pageX,this.y1=e.touches[0].pageY):(this.x1=e.pageX,this.y1=e.pageY),this.delta=this.now-(this.last||this.now),this.Observer.dispatch("Mobile"===this.userAgent?"touchStart":"mouseDown",e),null!==this.preTapPosition.x&&(this.isDoubleTap=this.delta>0&&this.delta<=250&&Math.abs(this.preTapPosition.x-this.x1)<30&&Math.abs(this.preTapPosition.y-this.y1)<30,this.isDoubleTap&&clearTimeout(this.singleTapTimeout)),this.preTapPosition.x=this.x1,this.preTapPosition.y=this.y1,this.last=this.now;var t=this.preV;if(e.touches&&e.touches.length>1){this._cancelLongTap(),this._cancelSingleTap();var i={x:e.touches[1].pageX-this.x1,y:e.touches[1].pageY-this.y1};t.x=i.x,t.y=i.y,this.pinchStartLen=u(t),this.Observer.dispatch("multipointStart",e)}this._preventTap=!1,this.longTapTimeout=setTimeout(function(){this.Observer.dispatch("longTap",e),this._preventTap=!0}.bind(this),750)}},{key:"move",value:function(e){var t=this.preV,i=0,s=e.pageY||e.touches[0].pageY;if("Mobile"===this.userAgent?(i=e.touches[0].pageX,s=e.touches[0].pageY):(i=e.pageX,s=e.pageY),this.isDoubleTap=!1,e.touches&&e.touches.length>1){var r=e.touches[1].pageX,n=e.touches[1].pageY,o={x:e.touches[1].pageX-i,y:e.touches[1].pageY-s};null!==t.x&&(this.pinchStartLen>0&&(e.zoom=u(o)/this.pinchStartLen,this.Observer.dispatch("pinch",e)),e.angle=c(o,t),this.Observer.dispatch("rotate",e)),t.x=o.x,t.y=o.y,null!==this.x2&&null!==this.sx2?(e.deltaX=(i-this.x2+r-this.sx2)/2,e.deltaY=(s-this.y2+n-this.sy2)/2):(e.deltaX=0,e.deltaY=0),this.Observer.dispatch("twoFingerPressMove",e),this.sx2=r,this.sy2=n}else{if(null!==this.x2){e.deltaX=i-this.x2,e.deltaY=s-this.y2;var h=Math.abs(this.x1-this.x2),a=Math.abs(this.y1-this.y2);(h>10||a>10)&&(this._preventTap=!0)}else e.deltaX=0,e.deltaY=0;this.isPress&&this.Observer.dispatch("pressMove",e)}this.Observer.dispatch("Mobile"===this.userAgent?"touchMove":"mouseMove",e),this._cancelLongTap(),this.x2=i,this.y2=s,e.touches&&e.touches.length>1&&e.preventDefault()}},{key:"end",value:function(e){this._cancelLongTap(),this.isPress=!1;var t=this;e.touches&&e.touches.length<2&&(this.Observer.dispatch("multipointEnd",e),this.sx2=this.sy2=null),this.x2&&Math.abs(this.x1-this.x2)>30||this.y2&&Math.abs(this.y1-this.y2)>30?(e.direction=this._swipeDirection(this.x1,this.x2,this.y1,this.y2),this.swipeTimeout=setTimeout((function(){t.Observer.dispatch("swipe",e)}),0)):(this.tapTimeout=setTimeout((function(){t._preventTap||t.Observer.dispatch("tap",e),t.isDoubleTap&&(t.Observer.dispatch("doubleTap",e),t.isDoubleTap=!1)}),0),t.isDoubleTap||(t.singleTapTimeout=setTimeout((function(){t.Observer.dispatch("singleTap",e)}),250))),this.Observer.dispatch("Mobile"===this.userAgent?"touchEnd":"mouseUp",e),this.preV.x=0,this.preV.y=0,this.zoom=1,this.pinchStartLen=null,this.x1=this.x2=this.y1=this.y2=null}},{key:"mouseOver",value:function(e){this.Observer.dispatch("mouseOver",e)}},{key:"mouseOut",value:function(e){this.Observer.dispatch("mouseOut",e)}},{key:"cancel",value:function(e){this.cancelAll(),this.Observer.dispatch("touchCancel",e)}},{key:"cancelAll",value:function(){this._preventTap=!0,clearTimeout(this.singleTapTimeout),clearTimeout(this.tapTimeout),clearTimeout(this.longTapTimeout),clearTimeout(this.swipeTimeout)}},{key:"_cancelLongTap",value:function(){clearTimeout(this.longTapTimeout)}},{key:"_cancelSingleTap",value:function(){clearTimeout(this.singleTapTimeout)}},{key:"_swipeDirection",value:function(e,t,i,s){return Math.abs(e-t)>=Math.abs(i-s)?e-t>0?"Left":"Right":i-s>0?"Up":"Down"}},{key:"on",value:function(e,t){this.Observer.register(e,t)}},{key:"off",value:function(e,t){this.Observer.remove(e,t)}},{key:"destroy",value:function(){return this.singleTapTimeout&&clearTimeout(this.singleTapTimeout),this.tapTimeout&&clearTimeout(this.tapTimeout),this.longTapTimeout&&clearTimeout(this.longTapTimeout),this.swipeTimeout&&clearTimeout(this.swipeTimeout),"Mobile"===this.userAgent?(this.element.removeEventListener("touchstart",this.start),this.element.removeEventListener("touchmove",this.move),this.element.removeEventListener("touchend",this.end),this.element.removeEventListener("touchcancel",this.cancel)):(this.element.removeEventListener("mousedown",this.start),this.element.removeEventListener("mousemove",this.move),this.element.removeEventListener("mouseup",this.end),this.element.removeEventListener("mouseup",this.end),this.element.removeEventListener("mouseover",this.mouseOver)),this.Observer._Observer={},this.preV=this.pinchStartLen=this.zoom=this.isDoubleTap=this.delta=this.last=this.now=this.tapTimeout=this.singleTapTimeout=this.longTapTimeout=this.swipeTimeout=this.x1=this.x2=this.y1=this.y2=this.preTapPosition=null,window.removeEventListener("scroll",this._cancelAllHandler),null}}]),e}();(function(){"object"===s(t)?e.exports=m:window.BetterGesture=m})()},fb15:function(e,t,i){"use strict";if(i.r(t),"undefined"!==typeof window){var s=window.document.currentScript,r=i("8875");s=r(),"currentScript"in document||Object.defineProperty(document,"currentScript",{get:r});var n=s&&s.src.match(/(.+\/)[^/]+\.js(\?.*)?$/);n&&(i.p=n[1])}var o=i("b91a"),u=[],h=function(e){for(var t=0,i=u.length;t<i;t++)if(u[t].elem===e)return t;return null},a=function(e,t){var i=t.eventName,s=t.elem,r=t.func,n=t.oldFunc;e&&e.gesture?(e.gesture.off&&n&&e.gesture.off(i,n),e.gesture.on&&r&&e.gesture.on(i,r)):(t={},t[i]=r,u.push({elem:s,gesture:new o(s,t)}))},l=function(e){return e.replace(/-(\w)/g,(function(e,t){return t.toUpperCase()}))},c={install:function(e){e.directive("gesture",{bind:function(e,t){var i=t.value,s=t.oldValue,r=u[h(e)];a(r,{elem:e,func:i,oldFunc:s,eventName:l(t.arg)})},unbind:function(e){var t=h(e);if(!isNaN(t)){var i=u.splice(t,1);i.length&&i[0]&&i[0].gesture.destroy&&i[0].gesture.destroy()}}})}};t["default"]=c}})}));
(function(e,t){"object"===typeof exports&&"object"===typeof module?module.exports=t():"function"===typeof define&&define.amd?define([],t):"object"===typeof exports?exports["better-gesture"]=t():e["better-gesture"]=t()})("undefined"!==typeof self?self:this,(function(){return function(e){var t={};function i(s){if(t[s])return t[s].exports;var r=t[s]={i:s,l:!1,exports:{}};return e[s].call(r.exports,r,r.exports,i),r.l=!0,r.exports}return i.m=e,i.c=t,i.d=function(e,t,s){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:s})},i.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"===typeof e&&e&&e.__esModule)return e;var s=Object.create(null);if(i.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)i.d(s,r,function(t){return e[t]}.bind(null,r));return s},i.n=function(e){var t=e&&e.__esModule?function(){return e["default"]}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i(i.s="fb15")}({8875:function(e,t,i){var s,r,n;(function(i,o){r=[],s=o,n="function"===typeof s?s.apply(t,r):s,void 0===n||(e.exports=n)})("undefined"!==typeof self&&self,(function(){function e(){const t=Object.getOwnPropertyDescriptor(document,"currentScript");if(!t&&"currentScript"in document&&document.currentScript)return document.currentScript;if(t&&t.get!==e&&document.currentScript)return document.currentScript;try{throw new Error}catch(v){var i,s,r,n=/.*at [^(]*\((.*):(.+):(.+)\)$/gi,o=/@([^@]*):(\d+):(\d+)\s*$/gi,u=n.exec(v.stack)||o.exec(v.stack),h=u&&u[1]||!1,a=u&&u[2]||!1,l=document.location.href.replace(document.location.hash,""),c=document.getElementsByTagName("script");h===l&&(i=document.documentElement.outerHTML,s=new RegExp("(?:[^\\n]+?\\n){0,"+(a-2)+"}[^<]*<script>([\\d\\D]*?)<\\/script>[\\d\\D]*","i"),r=i.replace(s,"$1").trim());for(var p=0;p<c.length;p++){if("interactive"===c[p].readyState)return c[p];if(c[p].src===h)return c[p];if(h===l&&c[p].innerHTML&&c[p].innerHTML.trim()===r)return c[p]}return null}}return e}))},b91a:function(e,t,i){"use strict";(function(e){function s(e){return s="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"===typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},s(e)}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var i=0;i<t.length;i++){var s=t[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,s.key,s)}}function o(e,t,i){return t&&n(e.prototype,t),i&&n(e,i),e}function u(e){return Math.sqrt(e.x*e.x+e.y*e.y)}function h(e,t){return e.x*t.x+e.y*t.y}function a(e,t){var i=u(e)*u(t);if(0===i)return 0;var s=h(e,t)/i;return s>1&&(s=1),Math.acos(s)}function l(e,t){return e.x*t.y-t.x*e.y}function c(e,t){var i=a(e,t);return l(e,t)>0&&(i*=-1),180*i/Math.PI}function p(){return/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)?"Mobile":"PC"}i.d(t,"a",(function(){return m}));var v=function(){function e(t){r(this,e),this._Observer={},this.el=t}return o(e,[{key:"register",value:function(e,t){"function"===typeof t&&("undefined"===typeof this._Observer[e]?this._Observer[e]=[t]:this._Observer[e].push(t))}},{key:"dispatch",value:function(e,t){if(this._Observer[e]){var i=this;t.gesture={event:Object.keys(this._Observer),on:function(e,t){i.register(e,t)},off:function(e){i.remove(e)},destroy:function(){i._Observer={}}};for(var s=0,r=this._Observer[e].length;s<r;s++){var n=this._Observer[e][s];"function"===typeof n&&n.call(this.el,t)}}}},{key:"remove",value:function(e){if(this._Observer[e]instanceof Array)for(var t=this._Observer[e].length-1;t>=0;t--)this._Observer[e].splice(t,1)}}]),e}(),m=function(){function e(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};r(this,e),this.element="string"==typeof t?document.querySelector(t):t,this.userAgent=p(),this.start=this.start.bind(this),this.move=this.move.bind(this),this.end=this.end.bind(this),this.cancel=this.cancel.bind(this),this.mouseOver=this.mouseOver.bind(this),this.mouseOut=this.mouseOut.bind(this),this.Observer=new v(this.element),"Mobile"===this.userAgent?(this.element.addEventListener("touchstart",this.start,!1),this.element.addEventListener("touchmove",this.move,!1),this.element.addEventListener("touchend",this.end,!1),this.element.addEventListener("touchcancel",this.cancel,!1),this.Observer.register("touchStart",i.touchStart),this.Observer.register("touchMove",i.touchMove),this.Observer.register("touchEnd",i.touchEnd),this.Observer.register("touchCancel",i.touchCancel),this.Observer.register("multipointStart",i.multipointStart),this.Observer.register("multipointEnd",i.multipointEnd),this.Observer.register("pinch",i.pinch),this.Observer.register("twoFingerPressMove",i.twoFingerPressMove),this.Observer.register("rotate",i.rotate)):(this.element.addEventListener("mousedown",this.start,!1),this.element.addEventListener("mousemove",this.move,!1),this.element.addEventListener("mouseup",this.end,!1),this.element.addEventListener("mouseover",this.mouseOver,!1),this.element.addEventListener("mouseout",this.mouseOut,!1),this.Observer.register("mouseDown",i.mouseDown),this.Observer.register("mouseMove",i.mouseMove),this.Observer.register("mouseUp",i.mouseUp),this.Observer.register("mouseOver",i.mouseOver),this.Observer.register("mouseOut",i.mouseOut)),this.Observer.register("swipe",i.swipe),this.Observer.register("tap",i.tap),this.Observer.register("doubleTap",i.doubleTap),this.Observer.register("longTap",i.longTap),this.Observer.register("singleTap",i.singleTap),this.Observer.register("pressMove",i.pressMove),this._cancelAllHandler=this.cancelAll.bind(this),window.addEventListener("scroll",this._cancelAllHandler),this.preV={x:null,y:null},this.pinchStartLen=null,this.zoom=1,this.isDoubleTap=!1,this.delta=null,this.last=null,this.now=null,this.tapTimeout=null,this.singleTapTimeout=null,this.longTapTimeout=null,this.swipeTimeout=null,this.x1=this.x2=this.y1=this.y2=null,this.preTapPosition={x:null,y:null},this.isPress=!1}return o(e,[{key:"start",value:function(e){this.now=Date.now(),this.isPress=!0,"Mobile"===this.userAgent?(this.x1=e.touches[0].pageX,this.y1=e.touches[0].pageY):(this.x1=e.pageX,this.y1=e.pageY),this.delta=this.now-(this.last||this.now),this.Observer.dispatch("Mobile"===this.userAgent?"touchStart":"mouseDown",e),null!==this.preTapPosition.x&&(this.isDoubleTap=this.delta>0&&this.delta<=250&&Math.abs(this.preTapPosition.x-this.x1)<30&&Math.abs(this.preTapPosition.y-this.y1)<30,this.isDoubleTap&&clearTimeout(this.singleTapTimeout)),this.preTapPosition.x=this.x1,this.preTapPosition.y=this.y1,this.last=this.now;var t=this.preV;if(e.touches&&e.touches.length>1){this._cancelLongTap(),this._cancelSingleTap();var i={x:e.touches[1].pageX-this.x1,y:e.touches[1].pageY-this.y1};t.x=i.x,t.y=i.y,this.pinchStartLen=u(t),this.Observer.dispatch("multipointStart",e)}this._preventTap=!1,this.longTapTimeout=setTimeout(function(){this.Observer.dispatch("longTap",e),this._preventTap=!0}.bind(this),750)}},{key:"move",value:function(e){var t=this.preV,i=0,s=e.pageY||e.touches[0].pageY;if("Mobile"===this.userAgent?(i=e.touches[0].pageX,s=e.touches[0].pageY):(i=e.pageX,s=e.pageY),this.isDoubleTap=!1,e.touches&&e.touches.length>1){var r=e.touches[1].pageX,n=e.touches[1].pageY,o={x:e.touches[1].pageX-i,y:e.touches[1].pageY-s};null!==t.x&&(this.pinchStartLen>0&&(e.zoom=u(o)/this.pinchStartLen,this.Observer.dispatch("pinch",e)),e.angle=c(o,t),this.Observer.dispatch("rotate",e)),t.x=o.x,t.y=o.y,null!==this.x2&&null!==this.sx2?(e.deltaX=(i-this.x2+r-this.sx2)/2,e.deltaY=(s-this.y2+n-this.sy2)/2):(e.deltaX=0,e.deltaY=0),this.Observer.dispatch("twoFingerPressMove",e),this.sx2=r,this.sy2=n}else{if(null!==this.x2){e.deltaX=i-this.x2,e.deltaY=s-this.y2;var h=Math.abs(this.x1-this.x2),a=Math.abs(this.y1-this.y2);(h>10||a>10)&&(this._preventTap=!0)}else e.deltaX=0,e.deltaY=0;this.isPress&&this.Observer.dispatch("pressMove",e)}this.Observer.dispatch("Mobile"===this.userAgent?"touchMove":"mouseMove",e),this._cancelLongTap(),this.x2=i,this.y2=s,e.touches&&e.touches.length>1&&e.preventDefault()}},{key:"end",value:function(e){this._cancelLongTap(),this.isPress=!1;var t=this;e.touches&&e.touches.length<2&&(this.Observer.dispatch("multipointEnd",e),this.sx2=this.sy2=null),this.x2&&Math.abs(this.x1-this.x2)>30||this.y2&&Math.abs(this.y1-this.y2)>30?(e.direction=this._swipeDirection(this.x1,this.x2,this.y1,this.y2),this.swipeTimeout=setTimeout((function(){t.Observer.dispatch("swipe",e)}),0)):(this.tapTimeout=setTimeout((function(){t._preventTap||t.Observer.dispatch("tap",e),t.isDoubleTap&&(t.Observer.dispatch("doubleTap",e),t.isDoubleTap=!1)}),0),t.isDoubleTap||(t.singleTapTimeout=setTimeout((function(){t.Observer.dispatch("singleTap",e)}),250))),this.Observer.dispatch("Mobile"===this.userAgent?"touchEnd":"mouseUp",e),this.preV.x=0,this.preV.y=0,this.zoom=1,this.pinchStartLen=null,this.x1=this.x2=this.y1=this.y2=null}},{key:"mouseOver",value:function(e){this.Observer.dispatch("mouseOver",e)}},{key:"mouseOut",value:function(e){this.Observer.dispatch("mouseOut",e)}},{key:"cancel",value:function(e){this.cancelAll(),this.Observer.dispatch("touchCancel",e)}},{key:"cancelAll",value:function(){this._preventTap=!0,clearTimeout(this.singleTapTimeout),clearTimeout(this.tapTimeout),clearTimeout(this.longTapTimeout),clearTimeout(this.swipeTimeout)}},{key:"_cancelLongTap",value:function(){clearTimeout(this.longTapTimeout)}},{key:"_cancelSingleTap",value:function(){clearTimeout(this.singleTapTimeout)}},{key:"_swipeDirection",value:function(e,t,i,s){return Math.abs(e-t)>=Math.abs(i-s)?e-t>0?"Left":"Right":i-s>0?"Up":"Down"}},{key:"on",value:function(e,t){this.Observer.register(e,t)}},{key:"off",value:function(e,t){this.Observer.remove(e,t)}},{key:"destroy",value:function(){return this.singleTapTimeout&&clearTimeout(this.singleTapTimeout),this.tapTimeout&&clearTimeout(this.tapTimeout),this.longTapTimeout&&clearTimeout(this.longTapTimeout),this.swipeTimeout&&clearTimeout(this.swipeTimeout),"Mobile"===this.userAgent?(this.element.removeEventListener("touchstart",this.start),this.element.removeEventListener("touchmove",this.move),this.element.removeEventListener("touchend",this.end),this.element.removeEventListener("touchcancel",this.cancel)):(this.element.removeEventListener("mousedown",this.start),this.element.removeEventListener("mousemove",this.move),this.element.removeEventListener("mouseup",this.end),this.element.removeEventListener("mouseup",this.end),this.element.removeEventListener("mouseover",this.mouseOver)),this.Observer._Observer={},this.preV=this.pinchStartLen=this.zoom=this.isDoubleTap=this.delta=this.last=this.now=this.tapTimeout=this.singleTapTimeout=this.longTapTimeout=this.swipeTimeout=this.x1=this.x2=this.y1=this.y2=this.preTapPosition=null,window.removeEventListener("scroll",this._cancelAllHandler),null}}]),e}();(function(){"object"===("undefined"===typeof exports?"undefined":s(exports))?e.exports=m:window.BetterGesture=m})()}).call(this,i("dd40")(e))},dd40:function(e,t){e.exports=function(e){if(!e.webpackPolyfill){var t=Object.create(e);t.children||(t.children=[]),Object.defineProperty(t,"loaded",{enumerable:!0,get:function(){return t.l}}),Object.defineProperty(t,"id",{enumerable:!0,get:function(){return t.i}}),Object.defineProperty(t,"exports",{enumerable:!0}),t.webpackPolyfill=1}return t}},fb15:function(e,t,i){"use strict";if(i.r(t),"undefined"!==typeof window){var s=window.document.currentScript,r=i("8875");s=r(),"currentScript"in document||Object.defineProperty(document,"currentScript",{get:r});var n=s&&s.src.match(/(.+\/)[^/]+\.js(\?.*)?$/);n&&(i.p=n[1])}var o=i("b91a"),u=[],h=function(e){for(var t=0,i=u.length;t<i;t++)if(u[t].elem===e)return t;return null},a=function(e,t){var i=t.eventName,s=t.elem,r=t.func,n=t.oldFunc;e&&e.gesture?(e.gesture.off&&n&&e.gesture.off(i,n),e.gesture.on&&r&&e.gesture.on(i,r)):(t={},t[i]=r,u.push({elem:s,gesture:new o["a"](s,t)}))},l=function(e){return e.replace(/-(\w)/g,(function(e,t){return t.toUpperCase()}))},c={install:function(e){e.directive("gesture",{bind:function(e,t){var i=t.value,s=t.oldValue,r=u[h(e)];a(r,{elem:e,func:i,oldFunc:s,eventName:l(t.arg)})},unbind:function(e){var t=h(e);if(!isNaN(t)){var i=u.splice(t,1);i.length&&i[0]&&i[0].gesture.destroy&&i[0].gesture.destroy()}}})}};t["default"]=c}})}));
//# sourceMappingURL=better-gesture.umd.min.js.map
{
"name": "better-gesture",
"version": "0.1.4",
"version": "0.1.5",
"private": false,
"author": "wensiyuan siyusnseven@gmail.com",
"description": "A very small multi-terminal gesture library compatible with PC, Mobile, and small programs",
"description": "A gesture library compatible with multiple terminals (native, PC, mobile, Vue, applet)",
"scripts": {

@@ -8,0 +8,0 @@ "serve": "vue-cli-service serve",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc