Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gesto

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gesto - npm Package Compare versions

Comparing version 1.19.3 to 1.19.4

3

dist/gesto.cjs.js

@@ -7,3 +7,3 @@ /*

repository: git+https://github.com/daybrush/gesto.git
version: 1.19.3
version: 1.19.4
*/

@@ -759,3 +759,2 @@ 'use strict';

}
this._allowMouseEvent();
};

@@ -762,0 +761,0 @@ Gesto.prototype._allowMouseEvent = function () {

@@ -7,3 +7,3 @@ /*

repository: git+https://github.com/daybrush/gesto.git
version: 1.19.3
version: 1.19.4
*/

@@ -757,3 +757,2 @@ import EventEmitter from '@scena/event-emitter';

}
this._allowMouseEvent();
};

@@ -760,0 +759,0 @@ Gesto.prototype._allowMouseEvent = function () {

@@ -7,3 +7,3 @@ /*

repository: git+https://github.com/daybrush/gesto.git
version: 1.19.3
version: 1.19.4
*/

@@ -1164,3 +1164,2 @@ (function (global, factory) {

}
this._allowMouseEvent();
};

@@ -1167,0 +1166,0 @@ Gesto.prototype._allowMouseEvent = function () {

@@ -7,5 +7,5 @@ /*

repository: git+https://github.com/daybrush/gesto.git
version: 1.19.3
version: 1.19.4
*/
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(t="undefined"!=typeof globalThis?globalThis:t||self).Gesto=n()}(this,(function(){"use strict";var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)n.hasOwnProperty(e)&&(t[e]=n[e])},t(n,e)};var n=function(){return n=Object.assign||function(t){for(var n,e=1,i=arguments.length;e<i;e++)for(var o in n=arguments[e])Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o]);return t},n.apply(this,arguments)};function e(t){return 180*(n=[t[0].clientX,t[0].clientY],e=[t[1].clientX,t[1].clientY],i=e[0]-n[0],o=e[1]-n[1],((r=Math.atan2(o,i))>=0?r:r+2*Math.PI)/Math.PI);var n,e,i,o,r}function i(t){return t?t.touches?function(t){for(var n=Math.min(t.length,2),e=[],i=0;i<n;++i)e.push(s(t[i]));return e}(t.touches):[s(t)]:[]}function o(t,n,e){var i=e.length,o=a(t,i),r=o.clientX,s=o.clientY,u=o.originalClientX,c=o.originalClientY,l=a(n,i),h=l.clientX,v=l.clientY,g=a(e,i);return{clientX:u,clientY:c,deltaX:r-h,deltaY:s-v,distX:r-g.clientX,distY:s-g.clientY}}function r(t){return Math.sqrt(Math.pow(t[0].clientX-t[1].clientX,2)+Math.pow(t[0].clientY-t[1].clientY,2))}function s(t){return{clientX:t.clientX,clientY:t.clientY}}function a(t,n){void 0===n&&(n=t.length);for(var e={clientX:0,clientY:0,originalClientX:0,originalClientY:0},i=Math.min(t.length,n),o=0;o<i;++o){var r=t[o];e.originalClientX+="originalClientX"in r?r.originalClientX:r.clientX,e.originalClientY+="originalClientY"in r?r.originalClientY:r.clientY,e.clientX+=r.clientX,e.clientY+=r.clientY}return n?{clientX:e.clientX/n,clientY:e.clientY/n,originalClientX:e.originalClientX/n,originalClientY:e.originalClientY/n}:e}function u(t){return t&&"object"==typeof t}var c=function(){return c=Object.assign||function(t){for(var n,e=1,i=arguments.length;e<i;e++)for(var o in n=arguments[e])Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o]);return t},c.apply(this,arguments)};var l=function(){function t(){this._events={}}var n=t.prototype;return n.on=function(t,n){if(u(t))for(var e in t)this.on(e,t[e]);else this._addEvent(t,n,{});return this},n.off=function(t,n){if(t)if(u(t))for(var e in t)this.off(e);else if(n){var i=this._events[t];if(i){var o=function(t,n,e){void 0===e&&(e=-1);for(var i=t.length,o=0;o<i;++o)if(n(t[o],o,t))return o;return e}(i,(function(t){return t.listener===n}));o>-1&&i.splice(o,1)}}else this._events[t]=[];else this._events={};return this},n.once=function(t,n){var e=this;return n&&this._addEvent(t,n,{once:!0}),new Promise((function(n){e._addEvent(t,n,{once:!0})}))},n.emit=function(t,n){var e=this;void 0===n&&(n={});var i=this._events[t];if(!t||!i)return!0;var o=!1;return n.eventType=t,n.stop=function(){o=!0},n.currentTarget=this,function(){for(var t=0,n=0,e=arguments.length;n<e;n++)t+=arguments[n].length;var i=Array(t),o=0;for(n=0;n<e;n++)for(var r=arguments[n],s=0,a=r.length;s<a;s++,o++)i[o]=r[s];return i}(i).forEach((function(i){i.listener(n),i.once&&e.off(t,i.listener)})),!o},n.trigger=function(t,n){return void 0===n&&(n={}),this.emit(t,n)},n._addEvent=function(t,n,e){var i=this._events;i[t]=i[t]||[],i[t].push(c({listener:n},e))},t}(),h=l;function v(){return Date.now?Date.now():(new Date).getTime()}function g(t,n,e,i){t.addEventListener(n,e,i)}function p(t,n,e,i){t.removeEventListener(n,e,i)}function f(t){var n;return(null===(n=null==t?void 0:t.ownerDocument)||void 0===n?void 0:n.defaultView)||window}var d=function(){function t(t){this.prevClients=[],this.startClients=[],this.movement=0,this.length=0,this.startClients=t,this.prevClients=t,this.length=t.length}return t.prototype.getAngle=function(t){return void 0===t&&(t=this.prevClients),e(t)},t.prototype.getRotation=function(t){return void 0===t&&(t=this.prevClients),e(t)-e(this.startClients)},t.prototype.getPosition=function(t,n){void 0===t&&(t=this.prevClients);var e=o(t||this.prevClients,this.prevClients,this.startClients),i=e.deltaX,r=e.deltaY;return this.movement+=Math.sqrt(i*i+r*r),this.prevClients=t,e},t.prototype.getPositions=function(t){void 0===t&&(t=this.prevClients);for(var n=this.prevClients,e=this.startClients,i=Math.min(this.length,n.length),r=[],s=0;s<i;++s)r[s]=o([t[s]],[n[s]],[e[s]]);return r},t.prototype.getMovement=function(t){var n=this.movement;if(!t)return n;var e=a(t,this.length),i=a(this.prevClients,this.length),o=e.clientX-i.clientX,r=e.clientY-i.clientY;return Math.sqrt(o*o+r*r)+n},t.prototype.getDistance=function(t){return void 0===t&&(t=this.prevClients),r(t)},t.prototype.getScale=function(t){return void 0===t&&(t=this.prevClients),r(t)/r(this.startClients)},t.prototype.move=function(t,n){this.startClients.forEach((function(e){e.clientX-=t,e.clientY-=n})),this.prevClients.forEach((function(e){e.clientX-=t,e.clientY-=n}))},t}(),_=["textarea","input"],E=function(e){function o(t,o){void 0===o&&(o={});var r=e.call(this)||this;r.options={},r.flag=!1,r.pinchFlag=!1,r.data={},r.isDrag=!1,r.isPinch=!1,r.clientStores=[],r.targets=[],r.prevTime=0,r.doubleFlag=!1,r._useMouse=!1,r._useTouch=!1,r._useDrag=!1,r._dragFlag=!1,r._isTrusted=!1,r._isMouseEvent=!1,r._isSecondaryButton=!1,r._preventMouseEvent=!1,r._prevInputEvent=null,r._isDragAPI=!1,r._isIdle=!0,r._preventMouseEventId=0,r._window=window,r.onDragStart=function(t,e){if(void 0===e&&(e=!0),r.flag||!1!==t.cancelable){var o=t.type.indexOf("drag")>=-1;if(!r.flag||!o){r._isDragAPI=!0;var s=r.options,a=s.container,u=s.pinchOutside,c=s.preventWheelClick,l=s.preventRightClick,h=s.preventDefault,f=s.checkInput,E=s.dragFocusedInput,D=s.preventClickEventOnDragStart,C=s.preventClickEventOnDrag,m=s.preventClickEventByCondition,y=r._useTouch,M=!r.flag;if(r._isSecondaryButton=3===t.which||2===t.button,c&&(2===t.which||1===t.button)||l&&(3===t.which||2===t.button))return r.stop(),!1;if(M){var S=r._window.document.activeElement,w=t.target;if(w){var P=w.tagName.toLowerCase(),X=_.indexOf(P)>-1,Y=w.isContentEditable;if(X||Y){if(f||!E&&S===w)return!1;if(S&&(S===w||Y&&S.isContentEditable&&S.contains(w))){if(!E)return!1;w.blur()}}else if((h||"touchstart"===t.type)&&S){var k=S.tagName.toLowerCase();(S.isContentEditable||_.indexOf(k)>-1)&&S.blur()}(D||C||m)&&g(r._window,"click",r._onClick,!0)}r.clientStores=[new d(i(t))],r._isIdle=!1,r.flag=!0,r.isDrag=!1,r._isTrusted=e,r._dragFlag=!0,r._prevInputEvent=t,r.data={},r.doubleFlag=v()-r.prevTime<200,r._isMouseEvent=function(t){return t&&(t.type.indexOf("mouse")>-1||"button"in t)}(t),!r._isMouseEvent&&r._preventMouseEvent&&r._allowMouseEvent(),!1===(r._preventMouseEvent||r.emit("dragStart",n(n({data:r.data,datas:r.data,inputEvent:t,isMouseEvent:r._isMouseEvent,isSecondaryButton:r._isSecondaryButton,isTrusted:e,isDouble:r.doubleFlag},r.getCurrentStore().getPosition()),{preventDefault:function(){t.preventDefault()},preventDrag:function(){r._dragFlag=!1}})))&&r.stop(),r._isMouseEvent&&r.flag&&h&&t.preventDefault()}if(!r.flag)return!1;var T=0;if(M?(r._attchDragEvent(),y&&u&&(T=setTimeout((function(){g(a,"touchstart",r.onDragStart,{passive:!1})})))):y&&u&&p(a,"touchstart",r.onDragStart),r.flag&&function(t){return t.touches&&t.touches.length>=2}(t)){if(clearTimeout(T),M&&t.touches.length!==t.changedTouches.length)return;r.pinchFlag||r.onPinchStart(t)}}}},r.onDrag=function(t,e){if(r.flag){var o=r.options.preventDefault;!r._isMouseEvent&&o&&t.preventDefault(),r._prevInputEvent=t;var s=i(t),a=r.moveClients(s,t,!1);if(r._dragFlag){if(r.pinchFlag||a.deltaX||a.deltaY)if(!1===(r._preventMouseEvent||r.emit("drag",n(n({},a),{isScroll:!!e,inputEvent:t}))))return void r.stop();r.pinchFlag&&r.onPinch(t,s)}r.getCurrentStore().getPosition(s,!0)}},r.onDragEnd=function(t){if(r.flag){var e=r.options,o=e.pinchOutside,s=e.container,a=e.preventClickEventOnDrag,u=e.preventClickEventOnDragStart,c=e.preventClickEventByCondition,l=r.isDrag;(a||u||c)&&requestAnimationFrame((function(){r._allowClickEvent()})),c||u||!a||l||r._allowClickEvent(),r._useTouch&&o&&p(s,"touchstart",r.onDragStart),r.pinchFlag&&r.onPinchEnd(t);var h=(null==t?void 0:t.touches)?i(t):[];0!==h.length&&r.options.keepDragging?r._addStore(new d(h)):r.flag=!1;var g=r._getPosition(),f=v(),_=!l&&r.doubleFlag;r._prevInputEvent=null,r.prevTime=l||_?0:f,r.flag||(r._dettachDragEvent(),r._preventMouseEvent||r.emit("dragEnd",n({data:r.data,datas:r.data,isDouble:_,isDrag:l,isClick:!l,isMouseEvent:r._isMouseEvent,isSecondaryButton:r._isSecondaryButton,inputEvent:t,isTrusted:r._isTrusted},g)),r.clientStores=[],r._isMouseEvent||(r._preventMouseEvent=!0,clearTimeout(r._preventMouseEventId),r._preventMouseEventId=setTimeout((function(){r._preventMouseEvent=!1}),200)),r._isIdle=!0)}},r.onBlur=function(){r.onDragEnd()},r._allowClickEvent=function(){p(r._window,"click",r._onClick,!0)},r._onClick=function(t){r._allowClickEvent(),r._allowMouseEvent();var n=r.options.preventClickEventByCondition;(null==n?void 0:n(t))||(t.stopPropagation(),t.preventDefault())},r._onContextMenu=function(t){r.options.preventRightClick?r.onDragEnd(t):t.preventDefault()},r._passCallback=function(){};var s,a=[].concat(t),u=a[0];r._window=(s=u)&&"postMessage"in s&&"blur"in s&&"self"in s?u:f(u),r.options=n({checkInput:!1,container:u&&!("document"in u)?f(u):u,preventRightClick:!0,preventWheelClick:!0,preventClickEventOnDragStart:!1,preventClickEventOnDrag:!1,preventClickEventByCondition:null,preventDefault:!0,checkWindowBlur:!1,keepDragging:!1,pinchThreshold:0,events:["touch","mouse"]},o);var c=r.options,l=c.container,h=c.events,E=c.checkWindowBlur;if(r._useDrag=h.indexOf("drag")>-1,r._useTouch=h.indexOf("touch")>-1,r._useMouse=h.indexOf("mouse")>-1,r.targets=a,r._useDrag&&a.forEach((function(t){g(t,"dragstart",r.onDragStart)})),r._useMouse&&(a.forEach((function(t){g(t,"mousedown",r.onDragStart),g(t,"mousemove",r._passCallback)})),g(l,"contextmenu",r._onContextMenu)),E&&g(f(),"blur",r.onBlur),r._useTouch){var D={passive:!1};a.forEach((function(t){g(t,"touchstart",r.onDragStart,D),g(t,"touchmove",r._passCallback,D)}))}return r}return function(n,e){function i(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}(o,e),o.prototype.stop=function(){this.isDrag=!1,this.data={},this.clientStores=[],this.pinchFlag=!1,this.doubleFlag=!1,this.prevTime=0,this.flag=!1,this._isIdle=!0,this._allowClickEvent(),this._dettachDragEvent(),this._isDragAPI=!1},o.prototype.getMovement=function(t){return this.getCurrentStore().getMovement(t)+this.clientStores.slice(1).reduce((function(t,n){return t+n.movement}),0)},o.prototype.isDragging=function(){return this.isDrag},o.prototype.isIdle=function(){return this._isIdle},o.prototype.isFlag=function(){return this.flag},o.prototype.isPinchFlag=function(){return this.pinchFlag},o.prototype.isDoubleFlag=function(){return this.doubleFlag},o.prototype.isPinching=function(){return this.isPinch},o.prototype.scrollBy=function(t,n,e,i){void 0===i&&(i=!0),this.flag&&(this.clientStores[0].move(t,n),i&&this.onDrag(e,!0))},o.prototype.move=function(t,n){var e=t[0],i=t[1],o=this.getCurrentStore().prevClients;return this.moveClients(o.map((function(t){var n=t.clientX,o=t.clientY;return{clientX:n+e,clientY:o+i,originalClientX:n,originalClientY:o}})),n,!0)},o.prototype.triggerDragStart=function(t){this.onDragStart(t,!1)},o.prototype.setEventData=function(t){var n=this.data;for(var e in t)n[e]=t[e];return this},o.prototype.setEventDatas=function(t){return this.setEventData(t)},o.prototype.getCurrentEvent=function(t){return void 0===t&&(t=this._prevInputEvent),n(n({data:this.data,datas:this.data},this._getPosition()),{movement:this.getMovement(),isDrag:this.isDrag,isPinch:this.isPinch,isScroll:!1,inputEvent:t})},o.prototype.getEventData=function(){return this.data},o.prototype.getEventDatas=function(){return this.data},o.prototype.unset=function(){var t=this,n=this.targets,e=this.options.container;this.off(),p(this._window,"blur",this.onBlur),this._useDrag&&n.forEach((function(n){p(n,"dragstart",t.onDragStart)})),this._useMouse&&(n.forEach((function(n){p(n,"mousedown",t.onDragStart)})),p(e,"contextmenu",this._onContextMenu)),this._useTouch&&(n.forEach((function(n){p(n,"touchstart",t.onDragStart)})),p(e,"touchstart",this.onDragStart)),this._prevInputEvent=null,this._allowClickEvent(),this._dettachDragEvent()},o.prototype.onPinchStart=function(t){var e=this,o=this.options.pinchThreshold;if(!(this.isDrag&&this.getMovement()>o)){var r=new d(i(t));this.pinchFlag=!0,this._addStore(r),!1===this.emit("pinchStart",n(n({data:this.data,datas:this.data,angle:r.getAngle(),touches:this.getCurrentStore().getPositions()},r.getPosition()),{inputEvent:t,isTrusted:this._isTrusted,preventDefault:function(){t.preventDefault()},preventDrag:function(){e._dragFlag=!1}}))&&(this.pinchFlag=!1)}},o.prototype.onPinch=function(t,e){if(this.flag&&this.pinchFlag&&!(e.length<2)){var i=this.getCurrentStore();this.isPinch=!0,this.emit("pinch",n(n({data:this.data,datas:this.data,movement:this.getMovement(e),angle:i.getAngle(e),rotation:i.getRotation(e),touches:i.getPositions(e),scale:i.getScale(e),distance:i.getDistance(e)},i.getPosition(e)),{inputEvent:t,isTrusted:this._isTrusted}))}},o.prototype.onPinchEnd=function(t){if(this.pinchFlag){var e=this.isPinch;this.isPinch=!1,this.pinchFlag=!1;var i=this.getCurrentStore();this.emit("pinchEnd",n(n({data:this.data,datas:this.data,isPinch:e,touches:i.getPositions()},i.getPosition()),{inputEvent:t}))}},o.prototype.getCurrentStore=function(){return this.clientStores[0]},o.prototype.moveClients=function(t,e,i){var o=this._getPosition(t,i),r=this.isDrag;(o.deltaX||o.deltaY)&&(this.isDrag=!0);var s=!1;return!r&&this.isDrag&&(s=!0),n(n({data:this.data,datas:this.data},o),{movement:this.getMovement(t),isDrag:this.isDrag,isPinch:this.isPinch,isScroll:!1,isMouseEvent:this._isMouseEvent,isSecondaryButton:this._isSecondaryButton,inputEvent:e,isTrusted:this._isTrusted,isFirstDrag:s})},o.prototype._addStore=function(t){this.clientStores.splice(0,0,t)},o.prototype._getPosition=function(t,e){var i=this.getCurrentStore().getPosition(t,e),o=this.clientStores.slice(1).reduce((function(t,n){var e=n.getPosition();return t.distX+=e.distX,t.distY+=e.distY,t}),i),r=o.distX,s=o.distY;return n(n({},i),{distX:r,distY:s})},o.prototype._attchDragEvent=function(){var t=this._window,n=this.options.container,e={passive:!1};this._isDragAPI&&(g(n,"dragover",this.onDrag,e),g(t,"dragend",this.onDragEnd)),this._useMouse&&(g(n,"mousemove",this.onDrag),g(t,"mouseup",this.onDragEnd)),this._useTouch&&(g(n,"touchmove",this.onDrag,e),g(t,"touchend",this.onDragEnd,e),g(t,"touchcancel",this.onDragEnd,e))},o.prototype._dettachDragEvent=function(){var t=this._window,n=this.options.container;this._isDragAPI&&(p(n,"dragover",this.onDrag),p(t,"dragend",this.onDragEnd)),this._useMouse&&(p(n,"mousemove",this.onDrag),p(t,"mouseup",this.onDragEnd)),this._useTouch&&(p(n,"touchstart",this.onDragStart),p(n,"touchmove",this.onDrag),p(t,"touchend",this.onDragEnd),p(t,"touchcancel",this.onDragEnd)),this._allowMouseEvent()},o.prototype._allowMouseEvent=function(){this._preventMouseEvent=!1,clearTimeout(this._preventMouseEventId)},o}(h),D={__proto__:null,default:E};for(var C in D)E[C]=D[C];return E}));
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(t="undefined"!=typeof globalThis?globalThis:t||self).Gesto=n()}(this,(function(){"use strict";var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)n.hasOwnProperty(e)&&(t[e]=n[e])},t(n,e)};var n=function(){return n=Object.assign||function(t){for(var n,e=1,i=arguments.length;e<i;e++)for(var o in n=arguments[e])Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o]);return t},n.apply(this,arguments)};function e(t){return 180*(n=[t[0].clientX,t[0].clientY],e=[t[1].clientX,t[1].clientY],i=e[0]-n[0],o=e[1]-n[1],((r=Math.atan2(o,i))>=0?r:r+2*Math.PI)/Math.PI);var n,e,i,o,r}function i(t){return t?t.touches?function(t){for(var n=Math.min(t.length,2),e=[],i=0;i<n;++i)e.push(s(t[i]));return e}(t.touches):[s(t)]:[]}function o(t,n,e){var i=e.length,o=a(t,i),r=o.clientX,s=o.clientY,u=o.originalClientX,c=o.originalClientY,l=a(n,i),h=l.clientX,v=l.clientY,g=a(e,i);return{clientX:u,clientY:c,deltaX:r-h,deltaY:s-v,distX:r-g.clientX,distY:s-g.clientY}}function r(t){return Math.sqrt(Math.pow(t[0].clientX-t[1].clientX,2)+Math.pow(t[0].clientY-t[1].clientY,2))}function s(t){return{clientX:t.clientX,clientY:t.clientY}}function a(t,n){void 0===n&&(n=t.length);for(var e={clientX:0,clientY:0,originalClientX:0,originalClientY:0},i=Math.min(t.length,n),o=0;o<i;++o){var r=t[o];e.originalClientX+="originalClientX"in r?r.originalClientX:r.clientX,e.originalClientY+="originalClientY"in r?r.originalClientY:r.clientY,e.clientX+=r.clientX,e.clientY+=r.clientY}return n?{clientX:e.clientX/n,clientY:e.clientY/n,originalClientX:e.originalClientX/n,originalClientY:e.originalClientY/n}:e}function u(t){return t&&"object"==typeof t}var c=function(){return c=Object.assign||function(t){for(var n,e=1,i=arguments.length;e<i;e++)for(var o in n=arguments[e])Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o]);return t},c.apply(this,arguments)};var l=function(){function t(){this._events={}}var n=t.prototype;return n.on=function(t,n){if(u(t))for(var e in t)this.on(e,t[e]);else this._addEvent(t,n,{});return this},n.off=function(t,n){if(t)if(u(t))for(var e in t)this.off(e);else if(n){var i=this._events[t];if(i){var o=function(t,n,e){void 0===e&&(e=-1);for(var i=t.length,o=0;o<i;++o)if(n(t[o],o,t))return o;return e}(i,(function(t){return t.listener===n}));o>-1&&i.splice(o,1)}}else this._events[t]=[];else this._events={};return this},n.once=function(t,n){var e=this;return n&&this._addEvent(t,n,{once:!0}),new Promise((function(n){e._addEvent(t,n,{once:!0})}))},n.emit=function(t,n){var e=this;void 0===n&&(n={});var i=this._events[t];if(!t||!i)return!0;var o=!1;return n.eventType=t,n.stop=function(){o=!0},n.currentTarget=this,function(){for(var t=0,n=0,e=arguments.length;n<e;n++)t+=arguments[n].length;var i=Array(t),o=0;for(n=0;n<e;n++)for(var r=arguments[n],s=0,a=r.length;s<a;s++,o++)i[o]=r[s];return i}(i).forEach((function(i){i.listener(n),i.once&&e.off(t,i.listener)})),!o},n.trigger=function(t,n){return void 0===n&&(n={}),this.emit(t,n)},n._addEvent=function(t,n,e){var i=this._events;i[t]=i[t]||[],i[t].push(c({listener:n},e))},t}(),h=l;function v(){return Date.now?Date.now():(new Date).getTime()}function g(t,n,e,i){t.addEventListener(n,e,i)}function p(t,n,e,i){t.removeEventListener(n,e,i)}function f(t){var n;return(null===(n=null==t?void 0:t.ownerDocument)||void 0===n?void 0:n.defaultView)||window}var d=function(){function t(t){this.prevClients=[],this.startClients=[],this.movement=0,this.length=0,this.startClients=t,this.prevClients=t,this.length=t.length}return t.prototype.getAngle=function(t){return void 0===t&&(t=this.prevClients),e(t)},t.prototype.getRotation=function(t){return void 0===t&&(t=this.prevClients),e(t)-e(this.startClients)},t.prototype.getPosition=function(t,n){void 0===t&&(t=this.prevClients);var e=o(t||this.prevClients,this.prevClients,this.startClients),i=e.deltaX,r=e.deltaY;return this.movement+=Math.sqrt(i*i+r*r),this.prevClients=t,e},t.prototype.getPositions=function(t){void 0===t&&(t=this.prevClients);for(var n=this.prevClients,e=this.startClients,i=Math.min(this.length,n.length),r=[],s=0;s<i;++s)r[s]=o([t[s]],[n[s]],[e[s]]);return r},t.prototype.getMovement=function(t){var n=this.movement;if(!t)return n;var e=a(t,this.length),i=a(this.prevClients,this.length),o=e.clientX-i.clientX,r=e.clientY-i.clientY;return Math.sqrt(o*o+r*r)+n},t.prototype.getDistance=function(t){return void 0===t&&(t=this.prevClients),r(t)},t.prototype.getScale=function(t){return void 0===t&&(t=this.prevClients),r(t)/r(this.startClients)},t.prototype.move=function(t,n){this.startClients.forEach((function(e){e.clientX-=t,e.clientY-=n})),this.prevClients.forEach((function(e){e.clientX-=t,e.clientY-=n}))},t}(),_=["textarea","input"],E=function(e){function o(t,o){void 0===o&&(o={});var r=e.call(this)||this;r.options={},r.flag=!1,r.pinchFlag=!1,r.data={},r.isDrag=!1,r.isPinch=!1,r.clientStores=[],r.targets=[],r.prevTime=0,r.doubleFlag=!1,r._useMouse=!1,r._useTouch=!1,r._useDrag=!1,r._dragFlag=!1,r._isTrusted=!1,r._isMouseEvent=!1,r._isSecondaryButton=!1,r._preventMouseEvent=!1,r._prevInputEvent=null,r._isDragAPI=!1,r._isIdle=!0,r._preventMouseEventId=0,r._window=window,r.onDragStart=function(t,e){if(void 0===e&&(e=!0),r.flag||!1!==t.cancelable){var o=t.type.indexOf("drag")>=-1;if(!r.flag||!o){r._isDragAPI=!0;var s=r.options,a=s.container,u=s.pinchOutside,c=s.preventWheelClick,l=s.preventRightClick,h=s.preventDefault,f=s.checkInput,E=s.dragFocusedInput,D=s.preventClickEventOnDragStart,C=s.preventClickEventOnDrag,m=s.preventClickEventByCondition,y=r._useTouch,M=!r.flag;if(r._isSecondaryButton=3===t.which||2===t.button,c&&(2===t.which||1===t.button)||l&&(3===t.which||2===t.button))return r.stop(),!1;if(M){var S=r._window.document.activeElement,w=t.target;if(w){var P=w.tagName.toLowerCase(),X=_.indexOf(P)>-1,Y=w.isContentEditable;if(X||Y){if(f||!E&&S===w)return!1;if(S&&(S===w||Y&&S.isContentEditable&&S.contains(w))){if(!E)return!1;w.blur()}}else if((h||"touchstart"===t.type)&&S){var k=S.tagName.toLowerCase();(S.isContentEditable||_.indexOf(k)>-1)&&S.blur()}(D||C||m)&&g(r._window,"click",r._onClick,!0)}r.clientStores=[new d(i(t))],r._isIdle=!1,r.flag=!0,r.isDrag=!1,r._isTrusted=e,r._dragFlag=!0,r._prevInputEvent=t,r.data={},r.doubleFlag=v()-r.prevTime<200,r._isMouseEvent=function(t){return t&&(t.type.indexOf("mouse")>-1||"button"in t)}(t),!r._isMouseEvent&&r._preventMouseEvent&&r._allowMouseEvent(),!1===(r._preventMouseEvent||r.emit("dragStart",n(n({data:r.data,datas:r.data,inputEvent:t,isMouseEvent:r._isMouseEvent,isSecondaryButton:r._isSecondaryButton,isTrusted:e,isDouble:r.doubleFlag},r.getCurrentStore().getPosition()),{preventDefault:function(){t.preventDefault()},preventDrag:function(){r._dragFlag=!1}})))&&r.stop(),r._isMouseEvent&&r.flag&&h&&t.preventDefault()}if(!r.flag)return!1;var T=0;if(M?(r._attchDragEvent(),y&&u&&(T=setTimeout((function(){g(a,"touchstart",r.onDragStart,{passive:!1})})))):y&&u&&p(a,"touchstart",r.onDragStart),r.flag&&function(t){return t.touches&&t.touches.length>=2}(t)){if(clearTimeout(T),M&&t.touches.length!==t.changedTouches.length)return;r.pinchFlag||r.onPinchStart(t)}}}},r.onDrag=function(t,e){if(r.flag){var o=r.options.preventDefault;!r._isMouseEvent&&o&&t.preventDefault(),r._prevInputEvent=t;var s=i(t),a=r.moveClients(s,t,!1);if(r._dragFlag){if(r.pinchFlag||a.deltaX||a.deltaY)if(!1===(r._preventMouseEvent||r.emit("drag",n(n({},a),{isScroll:!!e,inputEvent:t}))))return void r.stop();r.pinchFlag&&r.onPinch(t,s)}r.getCurrentStore().getPosition(s,!0)}},r.onDragEnd=function(t){if(r.flag){var e=r.options,o=e.pinchOutside,s=e.container,a=e.preventClickEventOnDrag,u=e.preventClickEventOnDragStart,c=e.preventClickEventByCondition,l=r.isDrag;(a||u||c)&&requestAnimationFrame((function(){r._allowClickEvent()})),c||u||!a||l||r._allowClickEvent(),r._useTouch&&o&&p(s,"touchstart",r.onDragStart),r.pinchFlag&&r.onPinchEnd(t);var h=(null==t?void 0:t.touches)?i(t):[];0!==h.length&&r.options.keepDragging?r._addStore(new d(h)):r.flag=!1;var g=r._getPosition(),f=v(),_=!l&&r.doubleFlag;r._prevInputEvent=null,r.prevTime=l||_?0:f,r.flag||(r._dettachDragEvent(),r._preventMouseEvent||r.emit("dragEnd",n({data:r.data,datas:r.data,isDouble:_,isDrag:l,isClick:!l,isMouseEvent:r._isMouseEvent,isSecondaryButton:r._isSecondaryButton,inputEvent:t,isTrusted:r._isTrusted},g)),r.clientStores=[],r._isMouseEvent||(r._preventMouseEvent=!0,clearTimeout(r._preventMouseEventId),r._preventMouseEventId=setTimeout((function(){r._preventMouseEvent=!1}),200)),r._isIdle=!0)}},r.onBlur=function(){r.onDragEnd()},r._allowClickEvent=function(){p(r._window,"click",r._onClick,!0)},r._onClick=function(t){r._allowClickEvent(),r._allowMouseEvent();var n=r.options.preventClickEventByCondition;(null==n?void 0:n(t))||(t.stopPropagation(),t.preventDefault())},r._onContextMenu=function(t){r.options.preventRightClick?r.onDragEnd(t):t.preventDefault()},r._passCallback=function(){};var s,a=[].concat(t),u=a[0];r._window=(s=u)&&"postMessage"in s&&"blur"in s&&"self"in s?u:f(u),r.options=n({checkInput:!1,container:u&&!("document"in u)?f(u):u,preventRightClick:!0,preventWheelClick:!0,preventClickEventOnDragStart:!1,preventClickEventOnDrag:!1,preventClickEventByCondition:null,preventDefault:!0,checkWindowBlur:!1,keepDragging:!1,pinchThreshold:0,events:["touch","mouse"]},o);var c=r.options,l=c.container,h=c.events,E=c.checkWindowBlur;if(r._useDrag=h.indexOf("drag")>-1,r._useTouch=h.indexOf("touch")>-1,r._useMouse=h.indexOf("mouse")>-1,r.targets=a,r._useDrag&&a.forEach((function(t){g(t,"dragstart",r.onDragStart)})),r._useMouse&&(a.forEach((function(t){g(t,"mousedown",r.onDragStart),g(t,"mousemove",r._passCallback)})),g(l,"contextmenu",r._onContextMenu)),E&&g(f(),"blur",r.onBlur),r._useTouch){var D={passive:!1};a.forEach((function(t){g(t,"touchstart",r.onDragStart,D),g(t,"touchmove",r._passCallback,D)}))}return r}return function(n,e){function i(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}(o,e),o.prototype.stop=function(){this.isDrag=!1,this.data={},this.clientStores=[],this.pinchFlag=!1,this.doubleFlag=!1,this.prevTime=0,this.flag=!1,this._isIdle=!0,this._allowClickEvent(),this._dettachDragEvent(),this._isDragAPI=!1},o.prototype.getMovement=function(t){return this.getCurrentStore().getMovement(t)+this.clientStores.slice(1).reduce((function(t,n){return t+n.movement}),0)},o.prototype.isDragging=function(){return this.isDrag},o.prototype.isIdle=function(){return this._isIdle},o.prototype.isFlag=function(){return this.flag},o.prototype.isPinchFlag=function(){return this.pinchFlag},o.prototype.isDoubleFlag=function(){return this.doubleFlag},o.prototype.isPinching=function(){return this.isPinch},o.prototype.scrollBy=function(t,n,e,i){void 0===i&&(i=!0),this.flag&&(this.clientStores[0].move(t,n),i&&this.onDrag(e,!0))},o.prototype.move=function(t,n){var e=t[0],i=t[1],o=this.getCurrentStore().prevClients;return this.moveClients(o.map((function(t){var n=t.clientX,o=t.clientY;return{clientX:n+e,clientY:o+i,originalClientX:n,originalClientY:o}})),n,!0)},o.prototype.triggerDragStart=function(t){this.onDragStart(t,!1)},o.prototype.setEventData=function(t){var n=this.data;for(var e in t)n[e]=t[e];return this},o.prototype.setEventDatas=function(t){return this.setEventData(t)},o.prototype.getCurrentEvent=function(t){return void 0===t&&(t=this._prevInputEvent),n(n({data:this.data,datas:this.data},this._getPosition()),{movement:this.getMovement(),isDrag:this.isDrag,isPinch:this.isPinch,isScroll:!1,inputEvent:t})},o.prototype.getEventData=function(){return this.data},o.prototype.getEventDatas=function(){return this.data},o.prototype.unset=function(){var t=this,n=this.targets,e=this.options.container;this.off(),p(this._window,"blur",this.onBlur),this._useDrag&&n.forEach((function(n){p(n,"dragstart",t.onDragStart)})),this._useMouse&&(n.forEach((function(n){p(n,"mousedown",t.onDragStart)})),p(e,"contextmenu",this._onContextMenu)),this._useTouch&&(n.forEach((function(n){p(n,"touchstart",t.onDragStart)})),p(e,"touchstart",this.onDragStart)),this._prevInputEvent=null,this._allowClickEvent(),this._dettachDragEvent()},o.prototype.onPinchStart=function(t){var e=this,o=this.options.pinchThreshold;if(!(this.isDrag&&this.getMovement()>o)){var r=new d(i(t));this.pinchFlag=!0,this._addStore(r),!1===this.emit("pinchStart",n(n({data:this.data,datas:this.data,angle:r.getAngle(),touches:this.getCurrentStore().getPositions()},r.getPosition()),{inputEvent:t,isTrusted:this._isTrusted,preventDefault:function(){t.preventDefault()},preventDrag:function(){e._dragFlag=!1}}))&&(this.pinchFlag=!1)}},o.prototype.onPinch=function(t,e){if(this.flag&&this.pinchFlag&&!(e.length<2)){var i=this.getCurrentStore();this.isPinch=!0,this.emit("pinch",n(n({data:this.data,datas:this.data,movement:this.getMovement(e),angle:i.getAngle(e),rotation:i.getRotation(e),touches:i.getPositions(e),scale:i.getScale(e),distance:i.getDistance(e)},i.getPosition(e)),{inputEvent:t,isTrusted:this._isTrusted}))}},o.prototype.onPinchEnd=function(t){if(this.pinchFlag){var e=this.isPinch;this.isPinch=!1,this.pinchFlag=!1;var i=this.getCurrentStore();this.emit("pinchEnd",n(n({data:this.data,datas:this.data,isPinch:e,touches:i.getPositions()},i.getPosition()),{inputEvent:t}))}},o.prototype.getCurrentStore=function(){return this.clientStores[0]},o.prototype.moveClients=function(t,e,i){var o=this._getPosition(t,i),r=this.isDrag;(o.deltaX||o.deltaY)&&(this.isDrag=!0);var s=!1;return!r&&this.isDrag&&(s=!0),n(n({data:this.data,datas:this.data},o),{movement:this.getMovement(t),isDrag:this.isDrag,isPinch:this.isPinch,isScroll:!1,isMouseEvent:this._isMouseEvent,isSecondaryButton:this._isSecondaryButton,inputEvent:e,isTrusted:this._isTrusted,isFirstDrag:s})},o.prototype._addStore=function(t){this.clientStores.splice(0,0,t)},o.prototype._getPosition=function(t,e){var i=this.getCurrentStore().getPosition(t,e),o=this.clientStores.slice(1).reduce((function(t,n){var e=n.getPosition();return t.distX+=e.distX,t.distY+=e.distY,t}),i),r=o.distX,s=o.distY;return n(n({},i),{distX:r,distY:s})},o.prototype._attchDragEvent=function(){var t=this._window,n=this.options.container,e={passive:!1};this._isDragAPI&&(g(n,"dragover",this.onDrag,e),g(t,"dragend",this.onDragEnd)),this._useMouse&&(g(n,"mousemove",this.onDrag),g(t,"mouseup",this.onDragEnd)),this._useTouch&&(g(n,"touchmove",this.onDrag,e),g(t,"touchend",this.onDragEnd,e),g(t,"touchcancel",this.onDragEnd,e))},o.prototype._dettachDragEvent=function(){var t=this._window,n=this.options.container;this._isDragAPI&&(p(n,"dragover",this.onDrag),p(t,"dragend",this.onDragEnd)),this._useMouse&&(p(n,"mousemove",this.onDrag),p(t,"mouseup",this.onDragEnd)),this._useTouch&&(p(n,"touchstart",this.onDragStart),p(n,"touchmove",this.onDrag),p(t,"touchend",this.onDragEnd),p(t,"touchcancel",this.onDragEnd))},o.prototype._allowMouseEvent=function(){this._preventMouseEvent=!1,clearTimeout(this._preventMouseEventId)},o}(h),D={__proto__:null,default:E};for(var C in D)E[C]=D[C];return E}));
//# sourceMappingURL=gesto.min.js.map
{
"name": "gesto",
"version": "1.19.3",
"version": "1.19.4",
"description": "You can set up drag, pinch events in any browser.",

@@ -5,0 +5,0 @@ "main": "./dist/gesto.cjs.js",

@@ -692,3 +692,2 @@ import { Client, OnDrag, GestoOptions, GestoEvents } from "./types";

}
this._allowMouseEvent();
};

@@ -695,0 +694,0 @@ private _onClick = (e: MouseEvent) => {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc