@antv/g-plugin-dragndrop 1.6.33 → 1.6.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  import type { RenderingPlugin, RenderingPluginContext } from '@antv/g-lite';
2
2
  import type { DragndropPluginOptions } from './interfaces';
3
3
  export declare class DragndropPlugin implements RenderingPlugin {
4
- private dragndropPluginOptions;
4
+ dragndropPluginOptions: DragndropPluginOptions;
5
5
  static tag: string;
6
6
  constructor(dragndropPluginOptions: DragndropPluginOptions);
7
7
  apply(context: RenderingPluginContext): void;
@@ -1 +1 @@
1
- {"version":3,"file":"DragndropPlugin.d.ts","sourceRoot":"","sources":["../src/DragndropPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,eAAe,EACf,sBAAsB,EACvB,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAE3D,qBAAa,eAAgB,YAAW,eAAe;IAGzC,OAAO,CAAC,sBAAsB;IAF1C,MAAM,CAAC,GAAG,SAAe;gBAEL,sBAAsB,EAAE,sBAAsB;IAElE,KAAK,CAAC,OAAO,EAAE,sBAAsB;CAoKtC"}
1
+ {"version":3,"file":"DragndropPlugin.d.ts","sourceRoot":"","sources":["../src/DragndropPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,eAAe,EACf,sBAAsB,EACvB,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAE3D,qBAAa,eAAgB,YAAW,eAAe;IAGlC,sBAAsB,EAAE,sBAAsB;IAFjE,MAAM,CAAC,GAAG,SAAe;gBAEN,sBAAsB,EAAE,sBAAsB;IAEjE,KAAK,CAAC,OAAO,EAAE,sBAAsB;CAiKtC"}
package/dist/index.d.ts CHANGED
@@ -6,5 +6,6 @@ export declare class Plugin extends AbstractRendererPlugin {
6
6
  constructor(options?: Partial<DragndropPluginOptions>);
7
7
  init(): void;
8
8
  destroy(): void;
9
+ setOptions(options: Partial<DragndropPluginOptions>): void;
9
10
  }
10
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAEtD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAE3D,qBAAa,MAAO,SAAQ,sBAAsB;IAGpC,OAAO,CAAC,OAAO;IAF3B,IAAI,SAAe;gBAEC,OAAO,GAAE,OAAO,CAAC,sBAAsB,CAAM;IAIjE,IAAI,IAAI,IAAI;IAYZ,OAAO,IAAI,IAAI;CAGhB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAEtD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAE3D,qBAAa,MAAO,SAAQ,sBAAsB;IAGpC,OAAO,CAAC,OAAO;IAF3B,IAAI,SAAe;gBAEC,OAAO,GAAE,OAAO,CAAC,sBAAsB,CAAM;IAIjE,IAAI,IAAI,IAAI;IAYZ,OAAO,IAAI,IAAI;IAGf,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,sBAAsB,CAAC,GAAG,IAAI;CAM3D"}
package/dist/index.esm.js CHANGED
@@ -366,24 +366,25 @@ var DragndropPlugin = /*#__PURE__*/function () {
366
366
  }
367
367
  var _proto = DragndropPlugin.prototype;
368
368
  _proto.apply = function apply(context) {
369
+ var _this = this;
369
370
  var renderingService = context.renderingService,
370
371
  renderingContext = context.renderingContext;
371
372
  var document = renderingContext.root.ownerDocument;
372
373
  // TODO: should we add an option like `draggable` to Canvas
373
374
  var canvas = document.defaultView;
374
- var _this$dragndropPlugin = this.dragndropPluginOptions,
375
- overlap = _this$dragndropPlugin.overlap,
376
- isDocumentDraggable = _this$dragndropPlugin.isDocumentDraggable,
377
- isDocumentDroppable = _this$dragndropPlugin.isDocumentDroppable,
378
- dragstartDistanceThreshold = _this$dragndropPlugin.dragstartDistanceThreshold,
379
- dragstartTimeThreshold = _this$dragndropPlugin.dragstartTimeThreshold;
380
375
  var handlePointerdown = function handlePointerdown(event) {
381
376
  var target = event.target;
382
377
  var isDocument = target === document;
383
- var draggableEventTarget = isDocument && isDocumentDraggable ? document : target.closest && target.closest('[draggable=true]');
378
+ var draggableEventTarget = isDocument && _this.dragndropPluginOptions.isDocumentDraggable ? document : target.closest && target.closest('[draggable=true]');
384
379
  // `draggable` may be set on ancestor nodes:
385
380
  // @see https://github.com/antvis/G/issues/1088
386
381
  if (draggableEventTarget) {
382
+ // delay triggering dragstart event
383
+ var dragstartTriggered = false;
384
+ var dragstartTimeStamp = event.timeStamp;
385
+ var dragstartClientCoordinates = [event.clientX, event.clientY];
386
+ var currentDroppable = null;
387
+ var lastDragClientCoordinates = [event.clientX, event.clientY];
387
388
  // @ts-ignore
388
389
  // eslint-disable-next-line no-inner-declarations
389
390
  var handlePointermove = /*#__PURE__*/function () {
@@ -399,7 +400,7 @@ var DragndropPlugin = /*#__PURE__*/function () {
399
400
  }
400
401
  timeElapsed = event.timeStamp - dragstartTimeStamp;
401
402
  distanceMoved = distanceSquareRoot([event.clientX, event.clientY], dragstartClientCoordinates); // check thresholds
402
- if (!(timeElapsed <= dragstartTimeThreshold || distanceMoved <= dragstartDistanceThreshold)) {
403
+ if (!(timeElapsed <= _this.dragndropPluginOptions.dragstartTimeThreshold || distanceMoved <= _this.dragndropPluginOptions.dragstartDistanceThreshold)) {
403
404
  _context.next = 5;
404
405
  break;
405
406
  }
@@ -422,14 +423,14 @@ var DragndropPlugin = /*#__PURE__*/function () {
422
423
  _context.next = 21;
423
424
  break;
424
425
  }
425
- point = overlap === 'pointer' ? [event.canvasX, event.canvasY] : target.getBounds().center;
426
+ point = _this.dragndropPluginOptions.overlap === 'pointer' ? [event.canvasX, event.canvasY] : target.getBounds().center;
426
427
  _context.next = 17;
427
428
  return document.elementsFromPoint(point[0], point[1]);
428
429
  case 17:
429
430
  elementsBelow = _context.sent;
430
431
  // prevent from picking the dragging element
431
432
  elementBelow = elementsBelow[elementsBelow.indexOf(target) + 1];
432
- droppableBelow = (elementBelow === null || elementBelow === void 0 ? void 0 : elementBelow.closest('[droppable=true]')) || (isDocumentDroppable ? document : null);
433
+ droppableBelow = (elementBelow === null || elementBelow === void 0 ? void 0 : elementBelow.closest('[droppable=true]')) || (_this.dragndropPluginOptions.isDocumentDroppable ? document : null);
433
434
  if (currentDroppable !== droppableBelow) {
434
435
  if (currentDroppable) {
435
436
  // null when we were not over a droppable before this event
@@ -464,12 +465,6 @@ var DragndropPlugin = /*#__PURE__*/function () {
464
465
  return _ref.apply(this, arguments);
465
466
  };
466
467
  }();
467
- // delay triggering dragstart event
468
- var dragstartTriggered = false;
469
- var dragstartTimeStamp = event.timeStamp;
470
- var dragstartClientCoordinates = [event.clientX, event.clientY];
471
- var currentDroppable = null;
472
- var lastDragClientCoordinates = [event.clientX, event.clientY];
473
468
  canvas.addEventListener('pointermove', handlePointermove);
474
469
  var stopDragging = function stopDragging(originalPointerUpEvent) {
475
470
  if (dragstartTriggered) {
@@ -550,6 +545,9 @@ var Plugin = /*#__PURE__*/function (_AbstractRendererPlug) {
550
545
  _proto.destroy = function destroy() {
551
546
  this.removeAllRenderingPlugins();
552
547
  };
548
+ _proto.setOptions = function setOptions(options) {
549
+ Object.assign(this.plugins[0].dragndropPluginOptions, options);
550
+ };
553
551
  return Plugin;
554
552
  }(AbstractRendererPlugin);
555
553
 
package/dist/index.js CHANGED
@@ -370,24 +370,25 @@ var DragndropPlugin = /*#__PURE__*/function () {
370
370
  }
371
371
  var _proto = DragndropPlugin.prototype;
372
372
  _proto.apply = function apply(context) {
373
+ var _this = this;
373
374
  var renderingService = context.renderingService,
374
375
  renderingContext = context.renderingContext;
375
376
  var document = renderingContext.root.ownerDocument;
376
377
  // TODO: should we add an option like `draggable` to Canvas
377
378
  var canvas = document.defaultView;
378
- var _this$dragndropPlugin = this.dragndropPluginOptions,
379
- overlap = _this$dragndropPlugin.overlap,
380
- isDocumentDraggable = _this$dragndropPlugin.isDocumentDraggable,
381
- isDocumentDroppable = _this$dragndropPlugin.isDocumentDroppable,
382
- dragstartDistanceThreshold = _this$dragndropPlugin.dragstartDistanceThreshold,
383
- dragstartTimeThreshold = _this$dragndropPlugin.dragstartTimeThreshold;
384
379
  var handlePointerdown = function handlePointerdown(event) {
385
380
  var target = event.target;
386
381
  var isDocument = target === document;
387
- var draggableEventTarget = isDocument && isDocumentDraggable ? document : target.closest && target.closest('[draggable=true]');
382
+ var draggableEventTarget = isDocument && _this.dragndropPluginOptions.isDocumentDraggable ? document : target.closest && target.closest('[draggable=true]');
388
383
  // `draggable` may be set on ancestor nodes:
389
384
  // @see https://github.com/antvis/G/issues/1088
390
385
  if (draggableEventTarget) {
386
+ // delay triggering dragstart event
387
+ var dragstartTriggered = false;
388
+ var dragstartTimeStamp = event.timeStamp;
389
+ var dragstartClientCoordinates = [event.clientX, event.clientY];
390
+ var currentDroppable = null;
391
+ var lastDragClientCoordinates = [event.clientX, event.clientY];
391
392
  // @ts-ignore
392
393
  // eslint-disable-next-line no-inner-declarations
393
394
  var handlePointermove = /*#__PURE__*/function () {
@@ -403,7 +404,7 @@ var DragndropPlugin = /*#__PURE__*/function () {
403
404
  }
404
405
  timeElapsed = event.timeStamp - dragstartTimeStamp;
405
406
  distanceMoved = util.distanceSquareRoot([event.clientX, event.clientY], dragstartClientCoordinates); // check thresholds
406
- if (!(timeElapsed <= dragstartTimeThreshold || distanceMoved <= dragstartDistanceThreshold)) {
407
+ if (!(timeElapsed <= _this.dragndropPluginOptions.dragstartTimeThreshold || distanceMoved <= _this.dragndropPluginOptions.dragstartDistanceThreshold)) {
407
408
  _context.next = 5;
408
409
  break;
409
410
  }
@@ -426,14 +427,14 @@ var DragndropPlugin = /*#__PURE__*/function () {
426
427
  _context.next = 21;
427
428
  break;
428
429
  }
429
- point = overlap === 'pointer' ? [event.canvasX, event.canvasY] : target.getBounds().center;
430
+ point = _this.dragndropPluginOptions.overlap === 'pointer' ? [event.canvasX, event.canvasY] : target.getBounds().center;
430
431
  _context.next = 17;
431
432
  return document.elementsFromPoint(point[0], point[1]);
432
433
  case 17:
433
434
  elementsBelow = _context.sent;
434
435
  // prevent from picking the dragging element
435
436
  elementBelow = elementsBelow[elementsBelow.indexOf(target) + 1];
436
- droppableBelow = (elementBelow === null || elementBelow === void 0 ? void 0 : elementBelow.closest('[droppable=true]')) || (isDocumentDroppable ? document : null);
437
+ droppableBelow = (elementBelow === null || elementBelow === void 0 ? void 0 : elementBelow.closest('[droppable=true]')) || (_this.dragndropPluginOptions.isDocumentDroppable ? document : null);
437
438
  if (currentDroppable !== droppableBelow) {
438
439
  if (currentDroppable) {
439
440
  // null when we were not over a droppable before this event
@@ -468,12 +469,6 @@ var DragndropPlugin = /*#__PURE__*/function () {
468
469
  return _ref.apply(this, arguments);
469
470
  };
470
471
  }();
471
- // delay triggering dragstart event
472
- var dragstartTriggered = false;
473
- var dragstartTimeStamp = event.timeStamp;
474
- var dragstartClientCoordinates = [event.clientX, event.clientY];
475
- var currentDroppable = null;
476
- var lastDragClientCoordinates = [event.clientX, event.clientY];
477
472
  canvas.addEventListener('pointermove', handlePointermove);
478
473
  var stopDragging = function stopDragging(originalPointerUpEvent) {
479
474
  if (dragstartTriggered) {
@@ -554,6 +549,9 @@ var Plugin = /*#__PURE__*/function (_AbstractRendererPlug) {
554
549
  _proto.destroy = function destroy() {
555
550
  this.removeAllRenderingPlugins();
556
551
  };
552
+ _proto.setOptions = function setOptions(options) {
553
+ Object.assign(this.plugins[0].dragndropPluginOptions, options);
554
+ };
557
555
  return Plugin;
558
556
  }(gLite.AbstractRendererPlugin);
559
557
 
package/dist/index.umd.js CHANGED
@@ -373,24 +373,25 @@
373
373
  }
374
374
  var _proto = DragndropPlugin.prototype;
375
375
  _proto.apply = function apply(context) {
376
+ var _this = this;
376
377
  var renderingService = context.renderingService,
377
378
  renderingContext = context.renderingContext;
378
379
  var document = renderingContext.root.ownerDocument;
379
380
  // TODO: should we add an option like `draggable` to Canvas
380
381
  var canvas = document.defaultView;
381
- var _this$dragndropPlugin = this.dragndropPluginOptions,
382
- overlap = _this$dragndropPlugin.overlap,
383
- isDocumentDraggable = _this$dragndropPlugin.isDocumentDraggable,
384
- isDocumentDroppable = _this$dragndropPlugin.isDocumentDroppable,
385
- dragstartDistanceThreshold = _this$dragndropPlugin.dragstartDistanceThreshold,
386
- dragstartTimeThreshold = _this$dragndropPlugin.dragstartTimeThreshold;
387
382
  var handlePointerdown = function handlePointerdown(event) {
388
383
  var target = event.target;
389
384
  var isDocument = target === document;
390
- var draggableEventTarget = isDocument && isDocumentDraggable ? document : target.closest && target.closest('[draggable=true]');
385
+ var draggableEventTarget = isDocument && _this.dragndropPluginOptions.isDocumentDraggable ? document : target.closest && target.closest('[draggable=true]');
391
386
  // `draggable` may be set on ancestor nodes:
392
387
  // @see https://github.com/antvis/G/issues/1088
393
388
  if (draggableEventTarget) {
389
+ // delay triggering dragstart event
390
+ var dragstartTriggered = false;
391
+ var dragstartTimeStamp = event.timeStamp;
392
+ var dragstartClientCoordinates = [event.clientX, event.clientY];
393
+ var currentDroppable = null;
394
+ var lastDragClientCoordinates = [event.clientX, event.clientY];
394
395
  // @ts-ignore
395
396
  // eslint-disable-next-line no-inner-declarations
396
397
  var handlePointermove = /*#__PURE__*/function () {
@@ -406,7 +407,7 @@
406
407
  }
407
408
  timeElapsed = event.timeStamp - dragstartTimeStamp;
408
409
  distanceMoved = distanceSquareRoot([event.clientX, event.clientY], dragstartClientCoordinates); // check thresholds
409
- if (!(timeElapsed <= dragstartTimeThreshold || distanceMoved <= dragstartDistanceThreshold)) {
410
+ if (!(timeElapsed <= _this.dragndropPluginOptions.dragstartTimeThreshold || distanceMoved <= _this.dragndropPluginOptions.dragstartDistanceThreshold)) {
410
411
  _context.next = 5;
411
412
  break;
412
413
  }
@@ -429,14 +430,14 @@
429
430
  _context.next = 21;
430
431
  break;
431
432
  }
432
- point = overlap === 'pointer' ? [event.canvasX, event.canvasY] : target.getBounds().center;
433
+ point = _this.dragndropPluginOptions.overlap === 'pointer' ? [event.canvasX, event.canvasY] : target.getBounds().center;
433
434
  _context.next = 17;
434
435
  return document.elementsFromPoint(point[0], point[1]);
435
436
  case 17:
436
437
  elementsBelow = _context.sent;
437
438
  // prevent from picking the dragging element
438
439
  elementBelow = elementsBelow[elementsBelow.indexOf(target) + 1];
439
- droppableBelow = (elementBelow === null || elementBelow === void 0 ? void 0 : elementBelow.closest('[droppable=true]')) || (isDocumentDroppable ? document : null);
440
+ droppableBelow = (elementBelow === null || elementBelow === void 0 ? void 0 : elementBelow.closest('[droppable=true]')) || (_this.dragndropPluginOptions.isDocumentDroppable ? document : null);
440
441
  if (currentDroppable !== droppableBelow) {
441
442
  if (currentDroppable) {
442
443
  // null when we were not over a droppable before this event
@@ -471,12 +472,6 @@
471
472
  return _ref.apply(this, arguments);
472
473
  };
473
474
  }();
474
- // delay triggering dragstart event
475
- var dragstartTriggered = false;
476
- var dragstartTimeStamp = event.timeStamp;
477
- var dragstartClientCoordinates = [event.clientX, event.clientY];
478
- var currentDroppable = null;
479
- var lastDragClientCoordinates = [event.clientX, event.clientY];
480
475
  canvas.addEventListener('pointermove', handlePointermove);
481
476
  var stopDragging = function stopDragging(originalPointerUpEvent) {
482
477
  if (dragstartTriggered) {
@@ -557,6 +552,9 @@
557
552
  _proto.destroy = function destroy() {
558
553
  this.removeAllRenderingPlugins();
559
554
  };
555
+ _proto.setOptions = function setOptions(options) {
556
+ Object.assign(this.plugins[0].dragndropPluginOptions, options);
557
+ };
560
558
  return Plugin;
561
559
  }(gLite.AbstractRendererPlugin);
562
560
 
@@ -1 +1 @@
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})}));
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 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})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/g-plugin-dragndrop",
3
- "version": "1.6.33",
3
+ "version": "1.6.35",
4
4
  "description": "A G plugin for Drag n Drop implemented with PointerEvents",
5
5
  "keywords": [
6
6
  "antv",
@@ -42,5 +42,5 @@
42
42
  "publishConfig": {
43
43
  "access": "public"
44
44
  },
45
- "gitHead": "c3c09705bf97040bbec01d94f55c27cc6f14d230"
45
+ "gitHead": "68409e02757817d8beadf1b6edccc19e27ef8e14"
46
46
  }