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.18.1 to 1.19.0

5

declaration/Gesto.d.ts

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

private isPinch;
private isMouse;
private isTouch;
private clientStores;

@@ -21,2 +19,5 @@ private targets;

private doubleFlag;
private _useMouse;
private _useTouch;
private _useDrag;
private _dragFlag;

@@ -23,0 +24,0 @@ private _isTrusted;

2

declaration/types.d.ts

@@ -148,3 +148,3 @@ import { IObject } from "@daybrush/utils";

*/
events?: Array<"mouse" | "touch">;
events?: Array<"drag" | "mouse" | "touch">;
/**

@@ -151,0 +151,0 @@ * Whether to prevent dragging of the right mouse button

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

repository: git+https://github.com/daybrush/gesto.git
version: 1.18.1
version: 1.19.0
*/

@@ -230,4 +230,2 @@ 'use strict';

_this.isPinch = false;
_this.isMouse = false;
_this.isTouch = false;
_this.clientStores = [];

@@ -237,2 +235,5 @@ _this.targets = [];

_this.doubleFlag = false;
_this._useMouse = false;
_this._useTouch = false;
_this._useDrag = false;
_this._dragFlag = false;

@@ -258,3 +259,3 @@ _this._isTrusted = false;

var _a = _this.options, container = _a.container, pinchOutside = _a.pinchOutside, preventWheelClick = _a.preventWheelClick, preventRightClick = _a.preventRightClick, preventDefault = _a.preventDefault, checkInput = _a.checkInput, dragFocusedInput = _a.dragFocusedInput, preventClickEventOnDragStart = _a.preventClickEventOnDragStart, preventClickEventOnDrag = _a.preventClickEventOnDrag, preventClickEventByCondition = _a.preventClickEventByCondition;
var isTouch = _this.isTouch;
var useTouch = _this._useTouch;
var isDragStart = !_this.flag;

@@ -332,3 +333,3 @@ _this._isSecondaryButton = e.which === 3 || e.button === 2;

// wait pinch
if (isTouch && pinchOutside) {
if (useTouch && pinchOutside) {
timer = setTimeout(function () {

@@ -341,3 +342,3 @@ utils.addEvent(container, "touchstart", _this.onDragStart, {

}
else if (isTouch && pinchOutside) {
else if (useTouch && pinchOutside) {
// pinch is occured

@@ -395,3 +396,3 @@ utils.removeEvent(container, "touchstart", _this.onDragStart);

}
if (_this.isTouch && pinchOutside) {
if (_this._useTouch && pinchOutside) {
utils.removeEvent(container, "touchstart", _this.onDragStart);

@@ -461,7 +462,13 @@ }

var _a = _this.options, container = _a.container, events = _a.events, checkWindowBlur = _a.checkWindowBlur;
_this.isTouch = events.indexOf("touch") > -1;
_this.isMouse = events.indexOf("mouse") > -1;
_this._useDrag = events.indexOf("drag") > -1;
_this._useTouch = events.indexOf("touch") > -1;
_this._useMouse = events.indexOf("mouse") > -1;
_this.targets = elements;
if (_this.isMouse) {
if (_this._useDrag) {
elements.forEach(function (el) {
utils.addEvent(el, "dragstart", _this.onDragStart);
});
}
if (_this._useMouse) {
elements.forEach(function (el) {
utils.addEvent(el, "mousedown", _this.onDragStart);

@@ -475,3 +482,3 @@ utils.addEvent(el, "mousemove", _this._passCallback);

}
if (_this.isTouch) {
if (_this._useTouch) {
var passive_1 = {

@@ -629,3 +636,8 @@ passive: false,

utils.removeEvent(this._window, "blur", this.onBlur);
if (this.isMouse) {
if (this._useDrag) {
targets.forEach(function (el) {
utils.removeEvent(el, "dragstart", _this.onDragStart);
});
}
if (this._useMouse) {
targets.forEach(function (target) {

@@ -636,3 +648,3 @@ utils.removeEvent(target, "mousedown", _this.onDragStart);

}
if (this.isTouch) {
if (this._useTouch) {
targets.forEach(function (target) {

@@ -713,2 +725,3 @@ utils.removeEvent(target, "touchstart", _this.onDragStart);

Gesto.prototype._attchDragEvent = function () {
var win = this._window;
var container = this.options.container;

@@ -719,30 +732,31 @@ var passive = {

if (this._isDragAPI) {
utils.addEvent(container, "dragover", this.onDrag);
utils.addEvent(container, "dragend", this.onDragEnd);
utils.addEvent(container, "dragover", this.onDrag, passive);
utils.addEvent(win, "dragend", this.onDragEnd);
}
if (this.isMouse) {
if (this._useMouse) {
utils.addEvent(container, "mousemove", this.onDrag);
utils.addEvent(container, "mouseup", this.onDragEnd);
utils.addEvent(win, "mouseup", this.onDragEnd);
}
if (this.isTouch) {
if (this._useTouch) {
utils.addEvent(container, "touchmove", this.onDrag, passive);
utils.addEvent(container, "touchend", this.onDragEnd, passive);
utils.addEvent(container, "touchcancel", this.onDragEnd, passive);
utils.addEvent(win, "touchend", this.onDragEnd, passive);
utils.addEvent(win, "touchcancel", this.onDragEnd, passive);
}
};
Gesto.prototype._dettachDragEvent = function () {
var win = this._window;
var container = this.options.container;
if (this._isDragAPI) {
utils.removeEvent(container, "dragover", this.onDrag);
utils.removeEvent(container, "dragend", this.onDragEnd);
utils.removeEvent(win, "dragend", this.onDragEnd);
}
if (this.isMouse) {
if (this._useMouse) {
utils.removeEvent(container, "mousemove", this.onDrag);
utils.removeEvent(container, "mouseup", this.onDragEnd);
utils.removeEvent(win, "mouseup", this.onDragEnd);
}
if (this.isTouch) {
if (this._useTouch) {
utils.removeEvent(container, "touchstart", this.onDragStart);
utils.removeEvent(container, "touchmove", this.onDrag);
utils.removeEvent(container, "touchend", this.onDragEnd);
utils.removeEvent(container, "touchcancel", this.onDragEnd);
utils.removeEvent(win, "touchend", this.onDragEnd);
utils.removeEvent(win, "touchcancel", this.onDragEnd);
}

@@ -749,0 +763,0 @@ };

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

repository: git+https://github.com/daybrush/gesto.git
version: 1.18.1
version: 1.19.0
*/

@@ -228,4 +228,2 @@ import EventEmitter from '@scena/event-emitter';

_this.isPinch = false;
_this.isMouse = false;
_this.isTouch = false;
_this.clientStores = [];

@@ -235,2 +233,5 @@ _this.targets = [];

_this.doubleFlag = false;
_this._useMouse = false;
_this._useTouch = false;
_this._useDrag = false;
_this._dragFlag = false;

@@ -256,3 +257,3 @@ _this._isTrusted = false;

var _a = _this.options, container = _a.container, pinchOutside = _a.pinchOutside, preventWheelClick = _a.preventWheelClick, preventRightClick = _a.preventRightClick, preventDefault = _a.preventDefault, checkInput = _a.checkInput, dragFocusedInput = _a.dragFocusedInput, preventClickEventOnDragStart = _a.preventClickEventOnDragStart, preventClickEventOnDrag = _a.preventClickEventOnDrag, preventClickEventByCondition = _a.preventClickEventByCondition;
var isTouch = _this.isTouch;
var useTouch = _this._useTouch;
var isDragStart = !_this.flag;

@@ -330,3 +331,3 @@ _this._isSecondaryButton = e.which === 3 || e.button === 2;

// wait pinch
if (isTouch && pinchOutside) {
if (useTouch && pinchOutside) {
timer = setTimeout(function () {

@@ -339,3 +340,3 @@ addEvent(container, "touchstart", _this.onDragStart, {

}
else if (isTouch && pinchOutside) {
else if (useTouch && pinchOutside) {
// pinch is occured

@@ -393,3 +394,3 @@ removeEvent(container, "touchstart", _this.onDragStart);

}
if (_this.isTouch && pinchOutside) {
if (_this._useTouch && pinchOutside) {
removeEvent(container, "touchstart", _this.onDragStart);

@@ -459,7 +460,13 @@ }

var _a = _this.options, container = _a.container, events = _a.events, checkWindowBlur = _a.checkWindowBlur;
_this.isTouch = events.indexOf("touch") > -1;
_this.isMouse = events.indexOf("mouse") > -1;
_this._useDrag = events.indexOf("drag") > -1;
_this._useTouch = events.indexOf("touch") > -1;
_this._useMouse = events.indexOf("mouse") > -1;
_this.targets = elements;
if (_this.isMouse) {
if (_this._useDrag) {
elements.forEach(function (el) {
addEvent(el, "dragstart", _this.onDragStart);
});
}
if (_this._useMouse) {
elements.forEach(function (el) {
addEvent(el, "mousedown", _this.onDragStart);

@@ -473,3 +480,3 @@ addEvent(el, "mousemove", _this._passCallback);

}
if (_this.isTouch) {
if (_this._useTouch) {
var passive_1 = {

@@ -627,3 +634,8 @@ passive: false,

removeEvent(this._window, "blur", this.onBlur);
if (this.isMouse) {
if (this._useDrag) {
targets.forEach(function (el) {
removeEvent(el, "dragstart", _this.onDragStart);
});
}
if (this._useMouse) {
targets.forEach(function (target) {

@@ -634,3 +646,3 @@ removeEvent(target, "mousedown", _this.onDragStart);

}
if (this.isTouch) {
if (this._useTouch) {
targets.forEach(function (target) {

@@ -711,2 +723,3 @@ removeEvent(target, "touchstart", _this.onDragStart);

Gesto.prototype._attchDragEvent = function () {
var win = this._window;
var container = this.options.container;

@@ -717,30 +730,31 @@ var passive = {

if (this._isDragAPI) {
addEvent(container, "dragover", this.onDrag);
addEvent(container, "dragend", this.onDragEnd);
addEvent(container, "dragover", this.onDrag, passive);
addEvent(win, "dragend", this.onDragEnd);
}
if (this.isMouse) {
if (this._useMouse) {
addEvent(container, "mousemove", this.onDrag);
addEvent(container, "mouseup", this.onDragEnd);
addEvent(win, "mouseup", this.onDragEnd);
}
if (this.isTouch) {
if (this._useTouch) {
addEvent(container, "touchmove", this.onDrag, passive);
addEvent(container, "touchend", this.onDragEnd, passive);
addEvent(container, "touchcancel", this.onDragEnd, passive);
addEvent(win, "touchend", this.onDragEnd, passive);
addEvent(win, "touchcancel", this.onDragEnd, passive);
}
};
Gesto.prototype._dettachDragEvent = function () {
var win = this._window;
var container = this.options.container;
if (this._isDragAPI) {
removeEvent(container, "dragover", this.onDrag);
removeEvent(container, "dragend", this.onDragEnd);
removeEvent(win, "dragend", this.onDragEnd);
}
if (this.isMouse) {
if (this._useMouse) {
removeEvent(container, "mousemove", this.onDrag);
removeEvent(container, "mouseup", this.onDragEnd);
removeEvent(win, "mouseup", this.onDragEnd);
}
if (this.isTouch) {
if (this._useTouch) {
removeEvent(container, "touchstart", this.onDragStart);
removeEvent(container, "touchmove", this.onDrag);
removeEvent(container, "touchend", this.onDragEnd);
removeEvent(container, "touchcancel", this.onDragEnd);
removeEvent(win, "touchend", this.onDragEnd);
removeEvent(win, "touchcancel", this.onDragEnd);
}

@@ -747,0 +761,0 @@ };

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

repository: git+https://github.com/daybrush/gesto.git
version: 1.18.1
version: 1.19.0
*/

@@ -632,4 +632,2 @@ (function (global, factory) {

_this.isPinch = false;
_this.isMouse = false;
_this.isTouch = false;
_this.clientStores = [];

@@ -639,2 +637,5 @@ _this.targets = [];

_this.doubleFlag = false;
_this._useMouse = false;
_this._useTouch = false;
_this._useDrag = false;
_this._dragFlag = false;

@@ -660,3 +661,3 @@ _this._isTrusted = false;

var _a = _this.options, container = _a.container, pinchOutside = _a.pinchOutside, preventWheelClick = _a.preventWheelClick, preventRightClick = _a.preventRightClick, preventDefault = _a.preventDefault, checkInput = _a.checkInput, dragFocusedInput = _a.dragFocusedInput, preventClickEventOnDragStart = _a.preventClickEventOnDragStart, preventClickEventOnDrag = _a.preventClickEventOnDrag, preventClickEventByCondition = _a.preventClickEventByCondition;
var isTouch = _this.isTouch;
var useTouch = _this._useTouch;
var isDragStart = !_this.flag;

@@ -734,3 +735,3 @@ _this._isSecondaryButton = e.which === 3 || e.button === 2;

// wait pinch
if (isTouch && pinchOutside) {
if (useTouch && pinchOutside) {
timer = setTimeout(function () {

@@ -743,3 +744,3 @@ addEvent(container, "touchstart", _this.onDragStart, {

}
else if (isTouch && pinchOutside) {
else if (useTouch && pinchOutside) {
// pinch is occured

@@ -797,3 +798,3 @@ removeEvent(container, "touchstart", _this.onDragStart);

}
if (_this.isTouch && pinchOutside) {
if (_this._useTouch && pinchOutside) {
removeEvent(container, "touchstart", _this.onDragStart);

@@ -863,7 +864,13 @@ }

var _a = _this.options, container = _a.container, events = _a.events, checkWindowBlur = _a.checkWindowBlur;
_this.isTouch = events.indexOf("touch") > -1;
_this.isMouse = events.indexOf("mouse") > -1;
_this._useDrag = events.indexOf("drag") > -1;
_this._useTouch = events.indexOf("touch") > -1;
_this._useMouse = events.indexOf("mouse") > -1;
_this.targets = elements;
if (_this.isMouse) {
if (_this._useDrag) {
elements.forEach(function (el) {
addEvent(el, "dragstart", _this.onDragStart);
});
}
if (_this._useMouse) {
elements.forEach(function (el) {
addEvent(el, "mousedown", _this.onDragStart);

@@ -877,3 +884,3 @@ addEvent(el, "mousemove", _this._passCallback);

}
if (_this.isTouch) {
if (_this._useTouch) {
var passive_1 = {

@@ -1031,3 +1038,8 @@ passive: false,

removeEvent(this._window, "blur", this.onBlur);
if (this.isMouse) {
if (this._useDrag) {
targets.forEach(function (el) {
removeEvent(el, "dragstart", _this.onDragStart);
});
}
if (this._useMouse) {
targets.forEach(function (target) {

@@ -1038,3 +1050,3 @@ removeEvent(target, "mousedown", _this.onDragStart);

}
if (this.isTouch) {
if (this._useTouch) {
targets.forEach(function (target) {

@@ -1115,2 +1127,3 @@ removeEvent(target, "touchstart", _this.onDragStart);

Gesto.prototype._attchDragEvent = function () {
var win = this._window;
var container = this.options.container;

@@ -1121,30 +1134,31 @@ var passive = {

if (this._isDragAPI) {
addEvent(container, "dragover", this.onDrag);
addEvent(container, "dragend", this.onDragEnd);
addEvent(container, "dragover", this.onDrag, passive);
addEvent(win, "dragend", this.onDragEnd);
}
if (this.isMouse) {
if (this._useMouse) {
addEvent(container, "mousemove", this.onDrag);
addEvent(container, "mouseup", this.onDragEnd);
addEvent(win, "mouseup", this.onDragEnd);
}
if (this.isTouch) {
if (this._useTouch) {
addEvent(container, "touchmove", this.onDrag, passive);
addEvent(container, "touchend", this.onDragEnd, passive);
addEvent(container, "touchcancel", this.onDragEnd, passive);
addEvent(win, "touchend", this.onDragEnd, passive);
addEvent(win, "touchcancel", this.onDragEnd, passive);
}
};
Gesto.prototype._dettachDragEvent = function () {
var win = this._window;
var container = this.options.container;
if (this._isDragAPI) {
removeEvent(container, "dragover", this.onDrag);
removeEvent(container, "dragend", this.onDragEnd);
removeEvent(win, "dragend", this.onDragEnd);
}
if (this.isMouse) {
if (this._useMouse) {
removeEvent(container, "mousemove", this.onDrag);
removeEvent(container, "mouseup", this.onDragEnd);
removeEvent(win, "mouseup", this.onDragEnd);
}
if (this.isTouch) {
if (this._useTouch) {
removeEvent(container, "touchstart", this.onDragStart);
removeEvent(container, "touchmove", this.onDrag);
removeEvent(container, "touchend", this.onDragEnd);
removeEvent(container, "touchcancel", this.onDragEnd);
removeEvent(win, "touchend", this.onDragEnd);
removeEvent(win, "touchcancel", this.onDragEnd);
}

@@ -1151,0 +1165,0 @@ };

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

repository: git+https://github.com/daybrush/gesto.git
version: 1.18.1
version: 1.19.0
*/
!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,p=a(e,i);return{clientX:u,clientY:c,deltaX:r-h,deltaY:s-v,distX:r-p.clientX,distY:s-p.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=0;i<n;++i){var o=t[i];e.originalClientX+="originalClientX"in o?o.originalClientX:o.clientX,e.originalClientY+="originalClientY"in o?o.originalClientY:o.clientY,e.clientX+=o.clientX,e.clientY+=o.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 p(t,n,e,i){t.addEventListener(n,e,i)}function g(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);var n=this.prevClients;return this.startClients.map((function(e,i){return o([t[i]],[n[i]],[e])}))},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.isMouse=!1,r.isTouch=!1,r.clientStores=[],r.targets=[],r.prevTime=0,r.doubleFlag=!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._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.isTouch,S=!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(S){var w=r._window.document.activeElement,P=t.target;if(P){var M=P.tagName.toLowerCase(),X=_.indexOf(M)>-1,Y=P.isContentEditable;if(X||Y){if(f||!E&&w===P)return!1;if(w&&(w===P||Y&&w.isContentEditable&&w.contains(P))){if(!E)return!1;P.blur()}}else if((h||"touchstart"===t.type)&&w){var k=w.tagName.toLowerCase();(w.isContentEditable||_.indexOf(k)>-1)&&w.blur()}(D||C||m)&&p(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._preventMouseEvent=!1),!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 b=0;if(S?(r._attchDragEvent(),y&&u&&(b=setTimeout((function(){p(a,"touchstart",r.onDragStart,{passive:!1})})))):y&&u&&g(a,"touchstart",r.onDragStart),r.flag&&function(t){return t.touches&&t.touches.length>=2}(t)){if(clearTimeout(b),S&&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.isTouch&&o&&g(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 p=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},p)),r.clientStores=[],r._isMouseEvent||(r._preventMouseEvent=!0,requestAnimationFrame((function(){requestAnimationFrame((function(){r._preventMouseEvent=!1}))}))),r._isIdle=!0)}},r.onBlur=function(){r.onDragEnd()},r._allowClickEvent=function(){g(r._window,"click",r._onClick,!0)},r._onClick=function(t){r._allowClickEvent(),r._preventMouseEvent=!1;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=[].concat(t),a=s[0];r._window=a&&!("document"in a)?f(a):window,r.options=n({checkInput:!1,container:a&&!("document"in a)?f(a):a,preventRightClick:!0,preventWheelClick:!0,preventClickEventOnDragStart:!1,preventClickEventOnDrag:!1,preventClickEventByCondition:null,preventDefault:!0,checkWindowBlur:!1,keepDragging:!1,pinchThreshold:0,events:["touch","mouse"]},o);var u=r.options,c=u.container,l=u.events,h=u.checkWindowBlur;if(r.isTouch=l.indexOf("touch")>-1,r.isMouse=l.indexOf("mouse")>-1,r.targets=s,r.isMouse&&(s.forEach((function(t){p(t,"mousedown",r.onDragStart),p(t,"mousemove",r._passCallback)})),p(c,"contextmenu",r._onContextMenu)),h&&p(f(),"blur",r.onBlur),r.isTouch){var E={passive:!1};s.forEach((function(t){p(t,"touchstart",r.onDragStart,E),p(t,"touchmove",r._passCallback,E)}))}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(),g(this._window,"blur",this.onBlur),this.isMouse&&(n.forEach((function(n){g(n,"mousedown",t.onDragStart)})),g(e,"contextmenu",this._onContextMenu)),this.isTouch&&(n.forEach((function(n){g(n,"touchstart",t.onDragStart)})),g(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.options.container,n={passive:!1};this._isDragAPI&&(p(t,"dragover",this.onDrag),p(t,"dragend",this.onDragEnd)),this.isMouse&&(p(t,"mousemove",this.onDrag),p(t,"mouseup",this.onDragEnd)),this.isTouch&&(p(t,"touchmove",this.onDrag,n),p(t,"touchend",this.onDragEnd,n),p(t,"touchcancel",this.onDragEnd,n))},o.prototype._dettachDragEvent=function(){var t=this.options.container;this._isDragAPI&&(g(t,"dragover",this.onDrag),g(t,"dragend",this.onDragEnd)),this.isMouse&&(g(t,"mousemove",this.onDrag),g(t,"mouseup",this.onDragEnd)),this.isTouch&&(g(t,"touchstart",this.onDragStart),g(t,"touchmove",this.onDrag),g(t,"touchend",this.onDragEnd),g(t,"touchcancel",this.onDragEnd))},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=0;i<n;++i){var o=t[i];e.originalClientX+="originalClientX"in o?o.originalClientX:o.clientX,e.originalClientY+="originalClientY"in o?o.originalClientY:o.clientY,e.clientX+=o.clientX,e.clientY+=o.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);var n=this.prevClients;return this.startClients.map((function(e,i){return o([t[i]],[n[i]],[e])}))},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"],D=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._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,D=s.dragFocusedInput,E=s.preventClickEventOnDragStart,C=s.preventClickEventOnDrag,m=s.preventClickEventByCondition,y=r._useTouch,S=!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(S){var w=r._window.document.activeElement,P=t.target;if(P){var M=P.tagName.toLowerCase(),X=_.indexOf(M)>-1,Y=P.isContentEditable;if(X||Y){if(f||!D&&w===P)return!1;if(w&&(w===P||Y&&w.isContentEditable&&w.contains(P))){if(!D)return!1;P.blur()}}else if((h||"touchstart"===t.type)&&w){var k=w.tagName.toLowerCase();(w.isContentEditable||_.indexOf(k)>-1)&&w.blur()}(E||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._preventMouseEvent=!1),!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 b=0;if(S?(r._attchDragEvent(),y&&u&&(b=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(b),S&&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,requestAnimationFrame((function(){requestAnimationFrame((function(){r._preventMouseEvent=!1}))}))),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._preventMouseEvent=!1;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=[].concat(t),a=s[0];r._window=a&&!("document"in a)?f(a):window,r.options=n({checkInput:!1,container:a&&!("document"in a)?f(a):a,preventRightClick:!0,preventWheelClick:!0,preventClickEventOnDragStart:!1,preventClickEventOnDrag:!1,preventClickEventByCondition:null,preventDefault:!0,checkWindowBlur:!1,keepDragging:!1,pinchThreshold:0,events:["touch","mouse"]},o);var u=r.options,c=u.container,l=u.events,h=u.checkWindowBlur;if(r._useDrag=l.indexOf("drag")>-1,r._useTouch=l.indexOf("touch")>-1,r._useMouse=l.indexOf("mouse")>-1,r.targets=s,r._useDrag&&s.forEach((function(t){g(t,"dragstart",r.onDragStart)})),r._useMouse&&(s.forEach((function(t){g(t,"mousedown",r.onDragStart),g(t,"mousemove",r._passCallback)})),g(c,"contextmenu",r._onContextMenu)),h&&g(f(),"blur",r.onBlur),r._useTouch){var D={passive:!1};s.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}(h),E={__proto__:null,default:D};for(var C in E)D[C]=E[C];return D}));
//# sourceMappingURL=gesto.min.js.map
{
"name": "gesto",
"version": "1.18.1",
"version": "1.19.0",
"description": "You can set up drag, pinch events in any browser.",

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

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

private isPinch = false;
private isMouse = false;
private isTouch = false;
private clientStores: ClientStore[] = [];

@@ -28,2 +27,5 @@ private targets: Array<Element | Window> = [];

private doubleFlag: boolean = false;
private _useMouse = false;
private _useTouch = false;
private _useDrag = false;
private _dragFlag = false;

@@ -66,8 +68,14 @@ private _isTrusted = false;

this.isTouch = events!.indexOf("touch") > -1;
this.isMouse = events!.indexOf("mouse") > -1;
this._useDrag = events!.indexOf("drag") > -1;
this._useTouch = events!.indexOf("touch") > -1;
this._useMouse = events!.indexOf("mouse") > -1;
this.targets = elements;
if (this.isMouse) {
if (this._useDrag) {
elements.forEach(el => {
addEvent(el, "dragstart", this.onDragStart);
});
}
if (this._useMouse) {
elements.forEach(el => {
addEvent(el, "mousedown", this.onDragStart);

@@ -81,3 +89,3 @@ addEvent(el, "mousemove", this._passCallback);

}
if (this.isTouch) {
if (this._useTouch) {
const passive = {

@@ -243,3 +251,9 @@ passive: false,

removeEvent(this._window, "blur", this.onBlur);
if (this.isMouse) {
if (this._useDrag) {
targets.forEach(el => {
removeEvent(el, "dragstart", this.onDragStart);
});
}
if (this._useMouse) {
targets.forEach(target => {

@@ -250,3 +264,3 @@ removeEvent(target, "mousedown", this.onDragStart);

}
if (this.isTouch) {
if (this._useTouch) {
targets.forEach(target => {

@@ -284,3 +298,3 @@ removeEvent(target, "touchstart", this.onDragStart);

} = this.options;
const isTouch = this.isTouch;
const useTouch = this._useTouch;
const isDragStart = !this.flag;

@@ -382,3 +396,3 @@

// wait pinch
if (isTouch && pinchOutside) {
if (useTouch && pinchOutside) {
timer = setTimeout(() => {

@@ -390,3 +404,3 @@ addEvent(container!, "touchstart", this.onDragStart, {

}
} else if (isTouch && pinchOutside) {
} else if (useTouch && pinchOutside) {
// pinch is occured

@@ -462,3 +476,3 @@ removeEvent(container!, "touchstart", this.onDragStart);

if (this.isTouch && pinchOutside) {
if (this._useTouch && pinchOutside) {
removeEvent(container!, "touchstart", this.onDragStart);

@@ -646,2 +660,3 @@ }

private _attchDragEvent() {
const win = this._window;
const container = this.options.container!;

@@ -653,17 +668,18 @@ const passive = {

if (this._isDragAPI) {
addEvent(container, "dragover", this.onDrag);
addEvent(container, "dragend", this.onDragEnd);
addEvent(container, "dragover", this.onDrag, passive);
addEvent(win, "dragend", this.onDragEnd);
}
if (this.isMouse) {
if (this._useMouse) {
addEvent(container, "mousemove", this.onDrag);
addEvent(container, "mouseup", this.onDragEnd);
addEvent(win, "mouseup", this.onDragEnd);
}
if (this.isTouch) {
if (this._useTouch) {
addEvent(container, "touchmove", this.onDrag, passive);
addEvent(container, "touchend", this.onDragEnd, passive);
addEvent(container, "touchcancel", this.onDragEnd, passive);
addEvent(win, "touchend", this.onDragEnd, passive);
addEvent(win, "touchcancel", this.onDragEnd, passive);
}
};
private _dettachDragEvent() {
const win = this._window;
const container = this.options.container!;

@@ -673,14 +689,14 @@

removeEvent(container, "dragover", this.onDrag);
removeEvent(container, "dragend", this.onDragEnd);
removeEvent(win, "dragend", this.onDragEnd);
}
if (this.isMouse) {
if (this._useMouse) {
removeEvent(container, "mousemove", this.onDrag);
removeEvent(container, "mouseup", this.onDragEnd);
removeEvent(win, "mouseup", this.onDragEnd);
}
if (this.isTouch) {
if (this._useTouch) {
removeEvent(container, "touchstart", this.onDragStart);
removeEvent(container, "touchmove", this.onDrag);
removeEvent(container, "touchend", this.onDragEnd);
removeEvent(container, "touchcancel", this.onDragEnd);
removeEvent(win, "touchend", this.onDragEnd);
removeEvent(win, "touchcancel", this.onDragEnd);
}

@@ -687,0 +703,0 @@ };

@@ -148,3 +148,3 @@ import { IObject } from "@daybrush/utils";

*/
events?: Array<"mouse" | "touch">;
events?: Array<"drag" |"mouse" | "touch">;
/**

@@ -151,0 +151,0 @@ * Whether to prevent dragging of the right mouse button

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