Socket
Socket
Sign inDemoInstall

@antv/g-gesture

Package Overview
Dependencies
Maintainers
64
Versions
153
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@antv/g-gesture - npm Package Compare versions

Comparing version 2.2.8 to 2.2.9

2

dist/index.esm.js

@@ -230,3 +230,2 @@ import { __extends } from 'tslib';

var _a;
e.stopPropagation();
(_a = el.ownerDocument) === null || _a === void 0 ? void 0 : _a.defaultView.addEventListener('pointermove',

@@ -245,3 +244,2 @@ // @ts-ignore

var _a;
e.stopPropagation();
// @ts-ignore

@@ -248,0 +246,0 @@ (_a = el.ownerDocument) === null || _a === void 0 ? void 0 : _a.defaultView.addEventListener('pointerup', _this._end);

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

var _a;
e.stopPropagation();
(_a = el.ownerDocument) === null || _a === void 0 ? void 0 : _a.defaultView.addEventListener('pointermove',

@@ -249,3 +248,2 @@ // @ts-ignore

var _a;
e.stopPropagation();
// @ts-ignore

@@ -252,0 +250,0 @@ (_a = el.ownerDocument) === null || _a === void 0 ? void 0 : _a.defaultView.addEventListener('pointerup', _this._end);

2

dist/index.umd.min.js

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

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("@antv/g-lite")):"function"==typeof define&&define.amd?define(["@antv/g-lite"],e):((t="undefined"!=typeof globalThis?globalThis:t||self).G=t.G||{},t.G.Gesture=e(t.window.G))}(this,(function(t){"use strict";var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},e(t,n)};var n={exports:{}};!function(t){var e=Object.prototype.hasOwnProperty,n="~";function r(){}function o(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function i(t,e,r,i,s){if("function"!=typeof r)throw new TypeError("The listener must be a function");var a=new o(r,i||t,s),c=n?n+e:e;return t._events[c]?t._events[c].fn?t._events[c]=[t._events[c],a]:t._events[c].push(a):(t._events[c]=a,t._eventsCount++),t}function s(t,e){0==--t._eventsCount?t._events=new r:delete t._events[e]}function a(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(n=!1)),a.prototype.eventNames=function(){var t,r,o=[];if(0===this._eventsCount)return o;for(r in t=this._events)e.call(t,r)&&o.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(t)):o},a.prototype.listeners=function(t){var e=this._events[n?n+t:t];if(!e)return[];if(e.fn)return[e.fn];for(var r=0,o=e.length,i=Array(o);o>r;r++)i[r]=e[r].fn;return i},a.prototype.listenerCount=function(t){var e=this._events[n?n+t:t];return e?e.fn?1:e.length:0},a.prototype.emit=function(t,e,r,o,i,s){var a=n?n+t:t;if(!this._events[a])return!1;var c,p,u=this._events[a],v=arguments.length;if(u.fn){switch(u.once&&this.removeListener(t,u.fn,void 0,!0),v){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,e),!0;case 3:return u.fn.call(u.context,e,r),!0;case 4:return u.fn.call(u.context,e,r,o),!0;case 5:return u.fn.call(u.context,e,r,o,i),!0;case 6:return u.fn.call(u.context,e,r,o,i,s),!0}for(p=1,c=Array(v-1);v>p;p++)c[p-1]=arguments[p];u.fn.apply(u.context,c)}else{var l,f=u.length;for(p=0;f>p;p++)switch(u[p].once&&this.removeListener(t,u[p].fn,void 0,!0),v){case 1:u[p].fn.call(u[p].context);break;case 2:u[p].fn.call(u[p].context,e);break;case 3:u[p].fn.call(u[p].context,e,r);break;case 4:u[p].fn.call(u[p].context,e,r,o);break;default:if(!c)for(l=1,c=Array(v-1);v>l;l++)c[l-1]=arguments[l];u[p].fn.apply(u[p].context,c)}}return!0},a.prototype.on=function(t,e,n){return i(this,t,e,n,!1)},a.prototype.once=function(t,e,n){return i(this,t,e,n,!0)},a.prototype.removeListener=function(t,e,r,o){var i=n?n+t:t;if(!this._events[i])return this;if(!e)return s(this,i),this;var a=this._events[i];if(a.fn)a.fn!==e||o&&!a.once||r&&a.context!==r||s(this,i);else{for(var c=0,p=[],u=a.length;u>c;c++)(a[c].fn!==e||o&&!a[c].once||r&&a[c].context!==r)&&p.push(a[c]);p.length?this._events[i]=1===p.length?p[0]:p:s(this,i)}return this},a.prototype.removeAllListeners=function(t){var e;return t?this._events[e=n?n+t:t]&&s(this,e):(this._events=new r,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=n,a.EventEmitter=a,t.exports=a}(n);var r="object"==typeof performance&&performance.now?performance:Date,o=function(t,e){var n=e.x-t.x,r=e.y-t.y;return Math.abs(n)>Math.abs(r)?n>0?"right":"left":r>0?"down":"up"},i=function(t,e){var n=Math.abs(e.x-t.x),r=Math.abs(e.y-t.y);return Math.sqrt(n*n+r*r)},s=function(t,e){return{x:t.x+(e.x-t.x)/2,y:t.y+(e.y-t.y)/2}};return function(n){function a(t){var e=n.call(this)||this;return e.evCache=[],e.startPoints=[],e.processEvent={},e.throttleTimer=0,e.emitThrottles=[],e._start=function(t){e.reset(),e.startTime=r.now();var n=e.evCache,o=e.startPoints;t&&n.push({pointerId:t.pointerId,x:t.x,y:t.y,ev:t});o.length=n.length;for(var a=0;n.length>a;a++){var c=n[a];o[a]={x:c.x,y:c.y}}if(1!==o.length)e.startDistance=i(o[0],o[1]),e.center=s(o[0],o[1]);else{var p=n[0].ev;e.pressTimeout=setTimeout((function(){var t="press",n="none";p.direction=n,p.deltaX=0,p.deltaY=0,p.points=o,e.emitStart(t,p),e.emit(t,p),e.eventType=t,e.direction=n}),250)}},e._move=function(t){e.clearPressTimeout();var n=e.startPoints,a=e.evCache;if(n.length){for(var c=t.x,p=t.y,u=t.pointerId,v=!1,l=0,f=a.length;f>l;l++)if(u===a[l].pointerId){a[l]={pointerId:u,x:c,y:p,ev:t},v=!0;break}if(!v)n.push({x:c,y:p}),a.push({pointerId:u,x:c,y:p,ev:t}),e.startDistance=i(n[0],n[1]),e.center=s(n[0],n[1]);var h={x:c,y:p},y=a.map((function(t){return{x:t.x,y:t.y}})),d=r.now();if(e.prevMoveTime=e.lastMoveTime,e.prevMovePoint=e.lastMovePoint,e.lastMoveTime=d,e.lastMovePoint=h,1===n.length){var m=n[0],_=c-m.x,x=p-m.y,T=e.direction||o(m,h);e.direction=T;var w=e.getEventType(h);return t.direction=T,t.deltaX=_,t.deltaY=x,t.points=y,e.emitStart(w,t),void e.emit(w,t)}var E=e.startDistance,g=i(y[0],y[1]);t.zoom=g/E,t.center=e.center,t.points=y,e.emitStart("pinch",t),e._throttleEmit("pinch",t)}},e._end=function(t){var n=e.evCache,s=e.startPoints,a=n.map((function(t){return{x:t.x,y:t.y}}));if(t.points=a,e.emitEnd(t),1===n.length){var c=r.now(),p=e.lastMoveTime;if(100>c-p){var u=p-(e.prevMoveTime||e.startTime);if(u>0){var v=e.prevMovePoint||s[0],l=e.lastMovePoint||s[0],f=i(v,l)/u;f>.3&&(t.velocity=f,t.direction=o(v,l),e.emit("swipe",t))}}}for(var h=0,y=n.length;y>h;h++)if(n[h].pointerId===t.pointerId){n.splice(h,1),s.splice(h,1);break}e.reset(),n.length>0&&e._start()},e._cancel=function(t){var n=e.evCache.map((function(t){return{x:t.x,y:t.y}}));t.points=n,e.emitEnd(t),e.evCache=[],e.reset()},e.el=t,e._initEvent(),e}return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+n+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}(a,n),a.prototype._initEvent=function(){var e,n,r=this,o=this.el;o.isConnected?null===(e=o.ownerDocument)||void 0===e||e.defaultView.addEventListener("pointermove",this._move):(o.isMutationObserved=!0,o.on(t.ElementEvent.MOUNTED,(function(t){var e;t.stopPropagation(),null===(e=o.ownerDocument)||void 0===e||e.defaultView.addEventListener("pointermove",r._move)}))),o.addEventListener("pointerdown",this._start),o.isConnected?null===(n=o.ownerDocument)||void 0===n||n.defaultView.addEventListener("pointerup",this._end):o.on(t.ElementEvent.MOUNTED,(function(t){var e;t.stopPropagation(),null===(e=o.ownerDocument)||void 0===e||e.defaultView.addEventListener("pointerup",r._end)})),o.addEventListener("pointercancel",this._cancel),o.addEventListener("pointerupoutside",this._end)},a.prototype.getEventType=function(t){var e,n=this,o=n.eventType,s=n.startTime,a=n.startPoints;if(o)return o;this._events.pan?e=r.now()-s>250&&10>i(a[0],t)?"press":"pan":e="press";return this.eventType=e,e},a.prototype.enable=function(t){this.processEvent[t]=!0},a.prototype.isProcess=function(t){return this.processEvent[t]},a.prototype.emitStart=function(t,e){this.isProcess(t)||(this.enable(t),this.emit("".concat(t,"start"),e))},a.prototype._throttleEmit=function(t,e){var n,r,o=this;this.pushEvent(t,e);var i=this,s=i.el,a=i.emitThrottles,c=i.processEvent;if(!i.throttleTimer){var p=(null===(n=s.ownerDocument)||void 0===n?void 0:n.defaultView)||(null===(r=s.document)||void 0===r?void 0:r.defaultView);this.throttleTimer=p.requestAnimationFrame((function(){for(var t=0,e=a.length;e>t;t++){var n=a[t],r=n.type;c[r]&&o.emit(r,n.ev)}o.throttleTimer=0,o.emitThrottles.length=0}))}},a.prototype.emitEnd=function(t){var e=this,n=this.processEvent;Object.keys(n).forEach((function(r){e.emit("".concat(r,"end"),t),delete n[r]}))},a.prototype.pushEvent=function(t,e){for(var n=this.emitThrottles,r={type:t,ev:e},o=0,i=n.length;i>o;o++)if(n[o].type===t)return void n.splice(o,1,r);n.push(r)},a.prototype.clearPressTimeout=function(){this.pressTimeout&&(clearTimeout(this.pressTimeout),this.pressTimeout=null)},a.prototype.reset=function(){this.clearPressTimeout(),this.startTime=0,this.startDistance=0,this.direction=null,this.eventType=null,this.prevMoveTime=0,this.prevMovePoint=null,this.lastMoveTime=0,this.lastMovePoint=null},a}(n.exports)}));
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("@antv/g-lite")):"function"==typeof define&&define.amd?define(["@antv/g-lite"],e):((t="undefined"!=typeof globalThis?globalThis:t||self).G=t.G||{},t.G.Gesture=e(t.window.G))}(this,(function(t){"use strict";var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},e(t,n)};var n={exports:{}};!function(t){var e=Object.prototype.hasOwnProperty,n="~";function r(){}function o(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function i(t,e,r,i,s){if("function"!=typeof r)throw new TypeError("The listener must be a function");var a=new o(r,i||t,s),c=n?n+e:e;return t._events[c]?t._events[c].fn?t._events[c]=[t._events[c],a]:t._events[c].push(a):(t._events[c]=a,t._eventsCount++),t}function s(t,e){0==--t._eventsCount?t._events=new r:delete t._events[e]}function a(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(n=!1)),a.prototype.eventNames=function(){var t,r,o=[];if(0===this._eventsCount)return o;for(r in t=this._events)e.call(t,r)&&o.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(t)):o},a.prototype.listeners=function(t){var e=this._events[n?n+t:t];if(!e)return[];if(e.fn)return[e.fn];for(var r=0,o=e.length,i=Array(o);o>r;r++)i[r]=e[r].fn;return i},a.prototype.listenerCount=function(t){var e=this._events[n?n+t:t];return e?e.fn?1:e.length:0},a.prototype.emit=function(t,e,r,o,i,s){var a=n?n+t:t;if(!this._events[a])return!1;var c,u,v=this._events[a],p=arguments.length;if(v.fn){switch(v.once&&this.removeListener(t,v.fn,void 0,!0),p){case 1:return v.fn.call(v.context),!0;case 2:return v.fn.call(v.context,e),!0;case 3:return v.fn.call(v.context,e,r),!0;case 4:return v.fn.call(v.context,e,r,o),!0;case 5:return v.fn.call(v.context,e,r,o,i),!0;case 6:return v.fn.call(v.context,e,r,o,i,s),!0}for(u=1,c=Array(p-1);p>u;u++)c[u-1]=arguments[u];v.fn.apply(v.context,c)}else{var l,f=v.length;for(u=0;f>u;u++)switch(v[u].once&&this.removeListener(t,v[u].fn,void 0,!0),p){case 1:v[u].fn.call(v[u].context);break;case 2:v[u].fn.call(v[u].context,e);break;case 3:v[u].fn.call(v[u].context,e,r);break;case 4:v[u].fn.call(v[u].context,e,r,o);break;default:if(!c)for(l=1,c=Array(p-1);p>l;l++)c[l-1]=arguments[l];v[u].fn.apply(v[u].context,c)}}return!0},a.prototype.on=function(t,e,n){return i(this,t,e,n,!1)},a.prototype.once=function(t,e,n){return i(this,t,e,n,!0)},a.prototype.removeListener=function(t,e,r,o){var i=n?n+t:t;if(!this._events[i])return this;if(!e)return s(this,i),this;var a=this._events[i];if(a.fn)a.fn!==e||o&&!a.once||r&&a.context!==r||s(this,i);else{for(var c=0,u=[],v=a.length;v>c;c++)(a[c].fn!==e||o&&!a[c].once||r&&a[c].context!==r)&&u.push(a[c]);u.length?this._events[i]=1===u.length?u[0]:u:s(this,i)}return this},a.prototype.removeAllListeners=function(t){var e;return t?this._events[e=n?n+t:t]&&s(this,e):(this._events=new r,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=n,a.EventEmitter=a,t.exports=a}(n);var r="object"==typeof performance&&performance.now?performance:Date,o=function(t,e){var n=e.x-t.x,r=e.y-t.y;return Math.abs(n)>Math.abs(r)?n>0?"right":"left":r>0?"down":"up"},i=function(t,e){var n=Math.abs(e.x-t.x),r=Math.abs(e.y-t.y);return Math.sqrt(n*n+r*r)},s=function(t,e){return{x:t.x+(e.x-t.x)/2,y:t.y+(e.y-t.y)/2}};return function(n){function a(t){var e=n.call(this)||this;return e.evCache=[],e.startPoints=[],e.processEvent={},e.throttleTimer=0,e.emitThrottles=[],e._start=function(t){e.reset(),e.startTime=r.now();var n=e.evCache,o=e.startPoints;t&&n.push({pointerId:t.pointerId,x:t.x,y:t.y,ev:t});o.length=n.length;for(var a=0;n.length>a;a++){var c=n[a];o[a]={x:c.x,y:c.y}}if(1!==o.length)e.startDistance=i(o[0],o[1]),e.center=s(o[0],o[1]);else{var u=n[0].ev;e.pressTimeout=setTimeout((function(){var t="press",n="none";u.direction=n,u.deltaX=0,u.deltaY=0,u.points=o,e.emitStart(t,u),e.emit(t,u),e.eventType=t,e.direction=n}),250)}},e._move=function(t){e.clearPressTimeout();var n=e.startPoints,a=e.evCache;if(n.length){for(var c=t.x,u=t.y,v=t.pointerId,p=!1,l=0,f=a.length;f>l;l++)if(v===a[l].pointerId){a[l]={pointerId:v,x:c,y:u,ev:t},p=!0;break}if(!p)n.push({x:c,y:u}),a.push({pointerId:v,x:c,y:u,ev:t}),e.startDistance=i(n[0],n[1]),e.center=s(n[0],n[1]);var h={x:c,y:u},y=a.map((function(t){return{x:t.x,y:t.y}})),d=r.now();if(e.prevMoveTime=e.lastMoveTime,e.prevMovePoint=e.lastMovePoint,e.lastMoveTime=d,e.lastMovePoint=h,1===n.length){var m=n[0],_=c-m.x,x=u-m.y,T=e.direction||o(m,h);e.direction=T;var w=e.getEventType(h);return t.direction=T,t.deltaX=_,t.deltaY=x,t.points=y,e.emitStart(w,t),void e.emit(w,t)}var E=e.startDistance,b=i(y[0],y[1]);t.zoom=b/E,t.center=e.center,t.points=y,e.emitStart("pinch",t),e._throttleEmit("pinch",t)}},e._end=function(t){var n=e.evCache,s=e.startPoints,a=n.map((function(t){return{x:t.x,y:t.y}}));if(t.points=a,e.emitEnd(t),1===n.length){var c=r.now(),u=e.lastMoveTime;if(100>c-u){var v=u-(e.prevMoveTime||e.startTime);if(v>0){var p=e.prevMovePoint||s[0],l=e.lastMovePoint||s[0],f=i(p,l)/v;f>.3&&(t.velocity=f,t.direction=o(p,l),e.emit("swipe",t))}}}for(var h=0,y=n.length;y>h;h++)if(n[h].pointerId===t.pointerId){n.splice(h,1),s.splice(h,1);break}e.reset(),n.length>0&&e._start()},e._cancel=function(t){var n=e.evCache.map((function(t){return{x:t.x,y:t.y}}));t.points=n,e.emitEnd(t),e.evCache=[],e.reset()},e.el=t,e._initEvent(),e}return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+n+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}(a,n),a.prototype._initEvent=function(){var e,n,r=this,o=this.el;o.isConnected?null===(e=o.ownerDocument)||void 0===e||e.defaultView.addEventListener("pointermove",this._move):(o.isMutationObserved=!0,o.on(t.ElementEvent.MOUNTED,(function(t){var e;null===(e=o.ownerDocument)||void 0===e||e.defaultView.addEventListener("pointermove",r._move)}))),o.addEventListener("pointerdown",this._start),o.isConnected?null===(n=o.ownerDocument)||void 0===n||n.defaultView.addEventListener("pointerup",this._end):o.on(t.ElementEvent.MOUNTED,(function(t){var e;null===(e=o.ownerDocument)||void 0===e||e.defaultView.addEventListener("pointerup",r._end)})),o.addEventListener("pointercancel",this._cancel),o.addEventListener("pointerupoutside",this._end)},a.prototype.getEventType=function(t){var e,n=this,o=n.eventType,s=n.startTime,a=n.startPoints;if(o)return o;this._events.pan?e=r.now()-s>250&&10>i(a[0],t)?"press":"pan":e="press";return this.eventType=e,e},a.prototype.enable=function(t){this.processEvent[t]=!0},a.prototype.isProcess=function(t){return this.processEvent[t]},a.prototype.emitStart=function(t,e){this.isProcess(t)||(this.enable(t),this.emit("".concat(t,"start"),e))},a.prototype._throttleEmit=function(t,e){var n,r,o=this;this.pushEvent(t,e);var i=this,s=i.el,a=i.emitThrottles,c=i.processEvent;if(!i.throttleTimer){var u=(null===(n=s.ownerDocument)||void 0===n?void 0:n.defaultView)||(null===(r=s.document)||void 0===r?void 0:r.defaultView);this.throttleTimer=u.requestAnimationFrame((function(){for(var t=0,e=a.length;e>t;t++){var n=a[t],r=n.type;c[r]&&o.emit(r,n.ev)}o.throttleTimer=0,o.emitThrottles.length=0}))}},a.prototype.emitEnd=function(t){var e=this,n=this.processEvent;Object.keys(n).forEach((function(r){e.emit("".concat(r,"end"),t),delete n[r]}))},a.prototype.pushEvent=function(t,e){for(var n=this.emitThrottles,r={type:t,ev:e},o=0,i=n.length;i>o;o++)if(n[o].type===t)return void n.splice(o,1,r);n.push(r)},a.prototype.clearPressTimeout=function(){this.pressTimeout&&(clearTimeout(this.pressTimeout),this.pressTimeout=null)},a.prototype.reset=function(){this.clearPressTimeout(),this.startTime=0,this.startDistance=0,this.direction=null,this.eventType=null,this.prevMoveTime=0,this.prevMovePoint=null,this.lastMoveTime=0,this.lastMovePoint=null},a}(n.exports)}));
//# sourceMappingURL=index.umd.min.js.map
{
"name": "@antv/g-gesture",
"version": "2.2.8",
"version": "2.2.9",
"description": "G Gesture",

@@ -5,0 +5,0 @@ "keywords": [

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