Socket
Socket
Sign inDemoInstall

@antv/g-plugin-dragndrop

Package Overview
Dependencies
Maintainers
63
Versions
134
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@antv/g-plugin-dragndrop - npm Package Compare versions

Comparing version 1.6.33 to 1.6.34

2

dist/DragndropPlugin.d.ts
import type { RenderingPlugin, RenderingPluginContext } from '@antv/g-lite';
import type { DragndropPluginOptions } from './interfaces';
export declare class DragndropPlugin implements RenderingPlugin {
private dragndropPluginOptions;
dragndropPluginOptions: DragndropPluginOptions;
static tag: string;

@@ -6,0 +6,0 @@ constructor(dragndropPluginOptions: DragndropPluginOptions);

@@ -9,3 +9,4 @@ import { AbstractRendererPlugin } from '@antv/g-lite';

destroy(): void;
setOptions(options: Partial<DragndropPluginOptions>): void;
}
//# sourceMappingURL=index.d.ts.map

@@ -369,2 +369,3 @@ import { AbstractRendererPlugin } from '@antv/g-lite';

_proto.apply = function apply(context) {
var _this = this;
var renderingService = context.renderingService,

@@ -375,15 +376,15 @@ renderingContext = context.renderingContext;

var canvas = document.defaultView;
var _this$dragndropPlugin = this.dragndropPluginOptions,
overlap = _this$dragndropPlugin.overlap,
isDocumentDraggable = _this$dragndropPlugin.isDocumentDraggable,
isDocumentDroppable = _this$dragndropPlugin.isDocumentDroppable,
dragstartDistanceThreshold = _this$dragndropPlugin.dragstartDistanceThreshold,
dragstartTimeThreshold = _this$dragndropPlugin.dragstartTimeThreshold;
var handlePointerdown = function handlePointerdown(event) {
var target = event.target;
var isDocument = target === document;
var draggableEventTarget = isDocument && isDocumentDraggable ? document : target.closest && target.closest('[draggable=true]');
var draggableEventTarget = isDocument && _this.dragndropPluginOptions.isDocumentDraggable ? document : target.closest && target.closest('[draggable=true]');
// `draggable` may be set on ancestor nodes:
// @see https://github.com/antvis/G/issues/1088
if (draggableEventTarget) {
// delay triggering dragstart event
var dragstartTriggered = false;
var dragstartTimeStamp = event.timeStamp;
var dragstartClientCoordinates = [event.clientX, event.clientY];
var currentDroppable = null;
var lastDragClientCoordinates = [event.clientX, event.clientY];
// @ts-ignore

@@ -404,3 +405,3 @@ // eslint-disable-next-line no-inner-declarations

distanceMoved = distanceSquareRoot([event.clientX, event.clientY], dragstartClientCoordinates); // check thresholds
if (!(timeElapsed <= dragstartTimeThreshold || distanceMoved <= dragstartDistanceThreshold)) {
if (!(timeElapsed <= _this.dragndropPluginOptions.dragstartTimeThreshold || distanceMoved <= _this.dragndropPluginOptions.dragstartDistanceThreshold)) {
_context.next = 5;

@@ -428,3 +429,3 @@ break;

}
point = overlap === 'pointer' ? [event.canvasX, event.canvasY] : target.getBounds().center;
point = _this.dragndropPluginOptions.overlap === 'pointer' ? [event.canvasX, event.canvasY] : target.getBounds().center;
_context.next = 17;

@@ -436,3 +437,3 @@ return document.elementsFromPoint(point[0], point[1]);

elementBelow = elementsBelow[elementsBelow.indexOf(target) + 1];
droppableBelow = (elementBelow === null || elementBelow === void 0 ? void 0 : elementBelow.closest('[droppable=true]')) || (isDocumentDroppable ? document : null);
droppableBelow = (elementBelow === null || elementBelow === void 0 ? void 0 : elementBelow.closest('[droppable=true]')) || (_this.dragndropPluginOptions.isDocumentDroppable ? document : null);
if (currentDroppable !== droppableBelow) {

@@ -472,8 +473,2 @@ if (currentDroppable) {

}();
// delay triggering dragstart event
var dragstartTriggered = false;
var dragstartTimeStamp = event.timeStamp;
var dragstartClientCoordinates = [event.clientX, event.clientY];
var currentDroppable = null;
var lastDragClientCoordinates = [event.clientX, event.clientY];
canvas.addEventListener('pointermove', handlePointermove);

@@ -559,2 +554,5 @@ var stopDragging = function stopDragging(originalPointerUpEvent) {

};
_proto.setOptions = function setOptions(options) {
Object.assign(this.plugins[0].dragndropPluginOptions, options);
};
return Plugin;

@@ -561,0 +559,0 @@ }(AbstractRendererPlugin);

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

_proto.apply = function apply(context) {
var _this = this;
var renderingService = context.renderingService,

@@ -379,15 +380,15 @@ renderingContext = context.renderingContext;

var canvas = document.defaultView;
var _this$dragndropPlugin = this.dragndropPluginOptions,
overlap = _this$dragndropPlugin.overlap,
isDocumentDraggable = _this$dragndropPlugin.isDocumentDraggable,
isDocumentDroppable = _this$dragndropPlugin.isDocumentDroppable,
dragstartDistanceThreshold = _this$dragndropPlugin.dragstartDistanceThreshold,
dragstartTimeThreshold = _this$dragndropPlugin.dragstartTimeThreshold;
var handlePointerdown = function handlePointerdown(event) {
var target = event.target;
var isDocument = target === document;
var draggableEventTarget = isDocument && isDocumentDraggable ? document : target.closest && target.closest('[draggable=true]');
var draggableEventTarget = isDocument && _this.dragndropPluginOptions.isDocumentDraggable ? document : target.closest && target.closest('[draggable=true]');
// `draggable` may be set on ancestor nodes:
// @see https://github.com/antvis/G/issues/1088
if (draggableEventTarget) {
// delay triggering dragstart event
var dragstartTriggered = false;
var dragstartTimeStamp = event.timeStamp;
var dragstartClientCoordinates = [event.clientX, event.clientY];
var currentDroppable = null;
var lastDragClientCoordinates = [event.clientX, event.clientY];
// @ts-ignore

@@ -408,3 +409,3 @@ // eslint-disable-next-line no-inner-declarations

distanceMoved = util.distanceSquareRoot([event.clientX, event.clientY], dragstartClientCoordinates); // check thresholds
if (!(timeElapsed <= dragstartTimeThreshold || distanceMoved <= dragstartDistanceThreshold)) {
if (!(timeElapsed <= _this.dragndropPluginOptions.dragstartTimeThreshold || distanceMoved <= _this.dragndropPluginOptions.dragstartDistanceThreshold)) {
_context.next = 5;

@@ -432,3 +433,3 @@ break;

}
point = overlap === 'pointer' ? [event.canvasX, event.canvasY] : target.getBounds().center;
point = _this.dragndropPluginOptions.overlap === 'pointer' ? [event.canvasX, event.canvasY] : target.getBounds().center;
_context.next = 17;

@@ -440,3 +441,3 @@ return document.elementsFromPoint(point[0], point[1]);

elementBelow = elementsBelow[elementsBelow.indexOf(target) + 1];
droppableBelow = (elementBelow === null || elementBelow === void 0 ? void 0 : elementBelow.closest('[droppable=true]')) || (isDocumentDroppable ? document : null);
droppableBelow = (elementBelow === null || elementBelow === void 0 ? void 0 : elementBelow.closest('[droppable=true]')) || (_this.dragndropPluginOptions.isDocumentDroppable ? document : null);
if (currentDroppable !== droppableBelow) {

@@ -476,8 +477,2 @@ if (currentDroppable) {

}();
// delay triggering dragstart event
var dragstartTriggered = false;
var dragstartTimeStamp = event.timeStamp;
var dragstartClientCoordinates = [event.clientX, event.clientY];
var currentDroppable = null;
var lastDragClientCoordinates = [event.clientX, event.clientY];
canvas.addEventListener('pointermove', handlePointermove);

@@ -563,2 +558,5 @@ var stopDragging = function stopDragging(originalPointerUpEvent) {

};
_proto.setOptions = function setOptions(options) {
Object.assign(this.plugins[0].dragndropPluginOptions, options);
};
return Plugin;

@@ -565,0 +563,0 @@ }(gLite.AbstractRendererPlugin);

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

_proto.apply = function apply(context) {
var _this = this;
var renderingService = context.renderingService,

@@ -382,15 +383,15 @@ renderingContext = context.renderingContext;

var canvas = document.defaultView;
var _this$dragndropPlugin = this.dragndropPluginOptions,
overlap = _this$dragndropPlugin.overlap,
isDocumentDraggable = _this$dragndropPlugin.isDocumentDraggable,
isDocumentDroppable = _this$dragndropPlugin.isDocumentDroppable,
dragstartDistanceThreshold = _this$dragndropPlugin.dragstartDistanceThreshold,
dragstartTimeThreshold = _this$dragndropPlugin.dragstartTimeThreshold;
var handlePointerdown = function handlePointerdown(event) {
var target = event.target;
var isDocument = target === document;
var draggableEventTarget = isDocument && isDocumentDraggable ? document : target.closest && target.closest('[draggable=true]');
var draggableEventTarget = isDocument && _this.dragndropPluginOptions.isDocumentDraggable ? document : target.closest && target.closest('[draggable=true]');
// `draggable` may be set on ancestor nodes:
// @see https://github.com/antvis/G/issues/1088
if (draggableEventTarget) {
// delay triggering dragstart event
var dragstartTriggered = false;
var dragstartTimeStamp = event.timeStamp;
var dragstartClientCoordinates = [event.clientX, event.clientY];
var currentDroppable = null;
var lastDragClientCoordinates = [event.clientX, event.clientY];
// @ts-ignore

@@ -411,3 +412,3 @@ // eslint-disable-next-line no-inner-declarations

distanceMoved = distanceSquareRoot([event.clientX, event.clientY], dragstartClientCoordinates); // check thresholds
if (!(timeElapsed <= dragstartTimeThreshold || distanceMoved <= dragstartDistanceThreshold)) {
if (!(timeElapsed <= _this.dragndropPluginOptions.dragstartTimeThreshold || distanceMoved <= _this.dragndropPluginOptions.dragstartDistanceThreshold)) {
_context.next = 5;

@@ -435,3 +436,3 @@ break;

}
point = overlap === 'pointer' ? [event.canvasX, event.canvasY] : target.getBounds().center;
point = _this.dragndropPluginOptions.overlap === 'pointer' ? [event.canvasX, event.canvasY] : target.getBounds().center;
_context.next = 17;

@@ -443,3 +444,3 @@ return document.elementsFromPoint(point[0], point[1]);

elementBelow = elementsBelow[elementsBelow.indexOf(target) + 1];
droppableBelow = (elementBelow === null || elementBelow === void 0 ? void 0 : elementBelow.closest('[droppable=true]')) || (isDocumentDroppable ? document : null);
droppableBelow = (elementBelow === null || elementBelow === void 0 ? void 0 : elementBelow.closest('[droppable=true]')) || (_this.dragndropPluginOptions.isDocumentDroppable ? document : null);
if (currentDroppable !== droppableBelow) {

@@ -479,8 +480,2 @@ if (currentDroppable) {

}();
// delay triggering dragstart event
var dragstartTriggered = false;
var dragstartTimeStamp = event.timeStamp;
var dragstartClientCoordinates = [event.clientX, event.clientY];
var currentDroppable = null;
var lastDragClientCoordinates = [event.clientX, event.clientY];
canvas.addEventListener('pointermove', handlePointermove);

@@ -566,2 +561,5 @@ var stopDragging = function stopDragging(originalPointerUpEvent) {

};
_proto.setOptions = function setOptions(options) {
Object.assign(this.plugins[0].dragndropPluginOptions, options);
};
return Plugin;

@@ -568,0 +566,0 @@ }(gLite.AbstractRendererPlugin);

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

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@antv/g-lite")):"function"==typeof define&&define.amd?define(["exports","@antv/g-lite"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).G=t.G||{},t.G.Dragndrop={}),t.window.G)}(this,(function(t,e){"use strict";function r(){r=function(){return t};var t={},e=Object.prototype,n=e.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function l(t,e,r,n){var i=Object.create((e&&e.prototype instanceof h?e:h).prototype),a=new j(n||[]);return o(i,"_invoke",{value:E(t,r,a)}),i}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=l;var p={};function h(){}function d(){}function v(){}var y={};s(y,a,(function(){return this}));var g=Object.getPrototypeOf,m=g&&g(g(_([])));m&&m!==e&&n.call(m,a)&&(y=m);var w=v.prototype=h.prototype=Object.create(y);function b(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function x(t,e){function r(o,i,a,c){var u=f(t[o],t,i);if("throw"!==u.type){var s=u.arg,l=s.value;return l&&"object"==typeof l&&n.call(l,"__await")?e.resolve(l.__await).then((function(t){r("next",t,a,c)}),(function(t){r("throw",t,a,c)})):e.resolve(l).then((function(t){s.value=t,a(s)}),(function(t){return r("throw",t,a,c)}))}c(u.arg)}var i;o(this,"_invoke",{value:function(t,n){function o(){return new e((function(e,o){r(t,n,e,o)}))}return i=i?i.then(o,o):o()}})}function E(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return k()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=L(a,r);if(c){if(c===p)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=f(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===p)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}function L(t,e){var r=e.method,n=t.iterator[r];if(void 0===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=void 0,L(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),p;var o=f(n,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,p;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,p):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,p)}function O(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(O,this),this.reset(!0)}function _(t){if(t){var e=t[a];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,o=function e(){for(;++r<t.length;)if(n.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:k}}function k(){return{value:void 0,done:!0}}return d.prototype=v,o(w,"constructor",{value:v,configurable:!0}),o(v,"constructor",{value:d,configurable:!0}),d.displayName=s(v,u,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===d||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,v):(t.__proto__=v,s(t,u,"GeneratorFunction")),t.prototype=Object.create(w),t},t.awrap=function(t){return{__await:t}},b(x.prototype),s(x.prototype,c,(function(){return this})),t.AsyncIterator=x,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new x(l(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},b(w),s(w,u,"Generator"),s(w,a,(function(){return this})),s(w,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},t.values=_,j.prototype={constructor:j,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(P),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return r("end");if(this.prev>=i.tryLoc){var c=n.call(i,"catchLoc"),u=n.call(i,"finallyLoc");if(c&&u){if(i.catchLoc>this.prev)return r(i.catchLoc,!0);if(i.finallyLoc>this.prev)return r(i.finallyLoc)}else if(c){if(i.catchLoc>this.prev)return r(i.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(i.finallyLoc>this.prev)return r(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(this.prev>=o.tryLoc&&n.call(o,"finallyLoc")&&o.finallyLoc>this.prev){var i=o;break}}i&&("break"===t||"continue"===t)&&e>=i.tryLoc&&i.finallyLoc>=e&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,p):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),p},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),P(r),p}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;P(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:_(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),p}},t}function n(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function o(t){return function(){var e=this,r=arguments;return new Promise((function(o,i){var a=t.apply(e,r);function c(t){n(a,o,i,c,u,"next",t)}function u(t){n(a,o,i,c,u,"throw",t)}c(void 0)}))}}function i(){return i=Object.assign?Object.assign.bind():function(t){for(var e=1;arguments.length>e;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},i.apply(this,arguments)}function a(t,e){return a=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},a(t,e)}var c=function(){function t(t){this.dragndropPluginOptions=void 0,this.dragndropPluginOptions=t}return t.prototype.apply=function(e){var n=e.renderingService,i=e.renderingContext.root.ownerDocument,a=i.defaultView,c=this.dragndropPluginOptions,u=c.overlap,s=c.isDocumentDraggable,l=c.isDocumentDroppable,f=c.dragstartDistanceThreshold,p=c.dragstartTimeThreshold,h=function(t){var e=t.target,n=e===i,c=n&&s?i:e.closest&&e.closest("[draggable=true]");if(c){var h=function(){var t=o(r().mark((function t(o){var a,s,h,w,b,x;return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(d){t.next=8;break}if(a=o.timeStamp-v,s=Math.sqrt(((r=[o.clientX,o.clientY])[0]-(E=y)[0])*(r[0]-E[0])+(r[1]-E[1])*(r[1]-E[1])),a>p&&s>f){t.next=5;break}return t.abrupt("return");case 5:o.type="dragstart",c.dispatchEvent(o),d=!0;case 8:if(o.type="drag",o.dx=o.clientX-m[0],o.dy=o.clientY-m[1],c.dispatchEvent(o),m=[o.clientX,o.clientY],n){t.next=21;break}return h="pointer"===u?[o.canvasX,o.canvasY]:e.getBounds().center,t.next=17,i.elementsFromPoint(h[0],h[1]);case 17:b=(w=t.sent)[w.indexOf(e)+1],x=(null==b?void 0:b.closest("[droppable=true]"))||(l?i:null),g!==x&&(g&&(o.type="dragleave",o.target=g,g.dispatchEvent(o)),x&&(o.type="dragenter",o.target=x,x.dispatchEvent(o)),(g=x)&&(o.type="dragover",o.target=g,g.dispatchEvent(o)));case 21:case"end":return t.stop()}var r,E}),t)})));return function(e){return t.apply(this,arguments)}}(),d=!1,v=t.timeStamp,y=[t.clientX,t.clientY],g=null,m=[t.clientX,t.clientY];a.addEventListener("pointermove",h);var w=function(t){if(d){t.detail={preventClick:!0};var e=t.clone();g&&(e.type="drop",e.target=g,g.dispatchEvent(e)),e.type="dragend",c.dispatchEvent(e),d=!1}a.removeEventListener("pointermove",h)};e.addEventListener("pointerup",w,{once:!0}),e.addEventListener("pointerupoutside",w,{once:!0})}};n.hooks.init.tapPromise(t.tag,o(r().mark((function t(){return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:a.addEventListener("pointerdown",h);case 1:case"end":return t.stop()}}),t)})))),n.hooks.destroy.tap(t.tag,(function(){a.removeEventListener("pointerdown",h)}))},t}();c.tag="Dragndrop",t.Plugin=function(t){var e,r;function n(e){var r;return void 0===e&&(e={}),(r=t.call(this)||this).options=void 0,r.name="dragndrop",r.options=e,r}(e=n).prototype=Object.create((r=t).prototype),e.prototype.constructor=e,a(e,r);var o=n.prototype;return o.init=function(){this.addRenderingPlugin(new c(i({overlap:"pointer",isDocumentDraggable:!1,isDocumentDroppable:!1,dragstartDistanceThreshold:0,dragstartTimeThreshold:0},this.options)))},o.destroy=function(){this.removeAllRenderingPlugins()},n}(e.AbstractRendererPlugin),Object.defineProperty(t,"__esModule",{value:!0})}));
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@antv/g-lite")):"function"==typeof define&&define.amd?define(["exports","@antv/g-lite"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).G=t.G||{},t.G.Dragndrop={}),t.window.G)}(this,(function(t,e){"use strict";function r(){r=function(){return t};var t={},e=Object.prototype,n=e.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function l(t,e,r,n){var i=Object.create((e&&e.prototype instanceof h?e:h).prototype),a=new j(n||[]);return o(i,"_invoke",{value:E(t,r,a)}),i}function p(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=l;var f={};function h(){}function d(){}function v(){}var g={};s(g,a,(function(){return this}));var y=Object.getPrototypeOf,m=y&&y(y(_([])));m&&m!==e&&n.call(m,a)&&(g=m);var w=v.prototype=h.prototype=Object.create(g);function b(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function x(t,e){function r(o,i,a,c){var u=p(t[o],t,i);if("throw"!==u.type){var s=u.arg,l=s.value;return l&&"object"==typeof l&&n.call(l,"__await")?e.resolve(l.__await).then((function(t){r("next",t,a,c)}),(function(t){r("throw",t,a,c)})):e.resolve(l).then((function(t){s.value=t,a(s)}),(function(t){return r("throw",t,a,c)}))}c(u.arg)}var i;o(this,"_invoke",{value:function(t,n){function o(){return new e((function(e,o){r(t,n,e,o)}))}return i=i?i.then(o,o):o()}})}function E(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return k()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=O(a,r);if(c){if(c===f)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=p(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===f)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}function O(t,e){var r=e.method,n=t.iterator[r];if(void 0===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=void 0,O(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),f;var o=p(n,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,f;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,f):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,f)}function L(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(L,this),this.reset(!0)}function _(t){if(t){var e=t[a];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,o=function e(){for(;++r<t.length;)if(n.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:k}}function k(){return{value:void 0,done:!0}}return d.prototype=v,o(w,"constructor",{value:v,configurable:!0}),o(v,"constructor",{value:d,configurable:!0}),d.displayName=s(v,u,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===d||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,v):(t.__proto__=v,s(t,u,"GeneratorFunction")),t.prototype=Object.create(w),t},t.awrap=function(t){return{__await:t}},b(x.prototype),s(x.prototype,c,(function(){return this})),t.AsyncIterator=x,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new x(l(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},b(w),s(w,u,"Generator"),s(w,a,(function(){return this})),s(w,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},t.values=_,j.prototype={constructor:j,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(P),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return r("end");if(this.prev>=i.tryLoc){var c=n.call(i,"catchLoc"),u=n.call(i,"finallyLoc");if(c&&u){if(i.catchLoc>this.prev)return r(i.catchLoc,!0);if(i.finallyLoc>this.prev)return r(i.finallyLoc)}else if(c){if(i.catchLoc>this.prev)return r(i.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(i.finallyLoc>this.prev)return r(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(this.prev>=o.tryLoc&&n.call(o,"finallyLoc")&&o.finallyLoc>this.prev){var i=o;break}}i&&("break"===t||"continue"===t)&&e>=i.tryLoc&&i.finallyLoc>=e&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,f):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),f},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),P(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;P(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:_(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function n(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function o(t){return function(){var e=this,r=arguments;return new Promise((function(o,i){var a=t.apply(e,r);function c(t){n(a,o,i,c,u,"next",t)}function u(t){n(a,o,i,c,u,"throw",t)}c(void 0)}))}}function i(){return i=Object.assign?Object.assign.bind():function(t){for(var e=1;arguments.length>e;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},i.apply(this,arguments)}function a(t,e){return a=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},a(t,e)}var c=function(){function t(t){this.dragndropPluginOptions=void 0,this.dragndropPluginOptions=t}return t.prototype.apply=function(e){var n=this,i=e.renderingService,a=e.renderingContext.root.ownerDocument,c=a.defaultView,u=function(t){var e=t.target,i=e===a,u=i&&n.dragndropPluginOptions.isDocumentDraggable?a:e.closest&&e.closest("[draggable=true]");if(u){var s=!1,l=t.timeStamp,p=[t.clientX,t.clientY],f=null,h=[t.clientX,t.clientY],d=function(){var t=o(r().mark((function t(o){var c,d,v,g,y,m;return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(s){t.next=8;break}if(c=o.timeStamp-l,d=Math.sqrt(((r=[o.clientX,o.clientY])[0]-(w=p)[0])*(r[0]-w[0])+(r[1]-w[1])*(r[1]-w[1])),c>n.dragndropPluginOptions.dragstartTimeThreshold&&d>n.dragndropPluginOptions.dragstartDistanceThreshold){t.next=5;break}return t.abrupt("return");case 5:o.type="dragstart",u.dispatchEvent(o),s=!0;case 8:if(o.type="drag",o.dx=o.clientX-h[0],o.dy=o.clientY-h[1],u.dispatchEvent(o),h=[o.clientX,o.clientY],i){t.next=21;break}return v="pointer"===n.dragndropPluginOptions.overlap?[o.canvasX,o.canvasY]:e.getBounds().center,t.next=17,a.elementsFromPoint(v[0],v[1]);case 17:y=(g=t.sent)[g.indexOf(e)+1],m=(null==y?void 0:y.closest("[droppable=true]"))||(n.dragndropPluginOptions.isDocumentDroppable?a:null),f!==m&&(f&&(o.type="dragleave",o.target=f,f.dispatchEvent(o)),m&&(o.type="dragenter",o.target=m,m.dispatchEvent(o)),(f=m)&&(o.type="dragover",o.target=f,f.dispatchEvent(o)));case 21:case"end":return t.stop()}var r,w}),t)})));return function(e){return t.apply(this,arguments)}}();c.addEventListener("pointermove",d);var v=function(t){if(s){t.detail={preventClick:!0};var e=t.clone();f&&(e.type="drop",e.target=f,f.dispatchEvent(e)),e.type="dragend",u.dispatchEvent(e),s=!1}c.removeEventListener("pointermove",d)};e.addEventListener("pointerup",v,{once:!0}),e.addEventListener("pointerupoutside",v,{once:!0})}};i.hooks.init.tapPromise(t.tag,o(r().mark((function t(){return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:c.addEventListener("pointerdown",u);case 1:case"end":return t.stop()}}),t)})))),i.hooks.destroy.tap(t.tag,(function(){c.removeEventListener("pointerdown",u)}))},t}();c.tag="Dragndrop",t.Plugin=function(t){var e,r;function n(e){var r;return void 0===e&&(e={}),(r=t.call(this)||this).options=void 0,r.name="dragndrop",r.options=e,r}(e=n).prototype=Object.create((r=t).prototype),e.prototype.constructor=e,a(e,r);var o=n.prototype;return o.init=function(){this.addRenderingPlugin(new c(i({overlap:"pointer",isDocumentDraggable:!1,isDocumentDroppable:!1,dragstartDistanceThreshold:0,dragstartTimeThreshold:0},this.options)))},o.destroy=function(){this.removeAllRenderingPlugins()},o.setOptions=function(t){Object.assign(this.plugins[0].dragndropPluginOptions,t)},n}(e.AbstractRendererPlugin),Object.defineProperty(t,"__esModule",{value:!0})}));
{
"name": "@antv/g-plugin-dragndrop",
"version": "1.6.33",
"version": "1.6.34",
"description": "A G plugin for Drag n Drop implemented with PointerEvents",

@@ -45,3 +45,3 @@ "keywords": [

},
"gitHead": "c3c09705bf97040bbec01d94f55c27cc6f14d230"
"gitHead": "d780322215f8ece20e3a2d8c137c02c0a6b57f84"
}

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