@antv/g-plugin-dragndrop 1.6.32 → 1.6.33

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.
package/dist/index.umd.js CHANGED
@@ -4,27 +4,6 @@
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.G = global.G || {}, global.G.Dragndrop = {}), global.window.G));
5
5
  }(this, (function (exports, gLite) { 'use strict';
6
6
 
7
- function ownKeys(object, enumerableOnly) {
8
- var keys = Object.keys(object);
9
- if (Object.getOwnPropertySymbols) {
10
- var symbols = Object.getOwnPropertySymbols(object);
11
- enumerableOnly && (symbols = symbols.filter(function (sym) {
12
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
13
- })), keys.push.apply(keys, symbols);
14
- }
15
- return keys;
16
- }
17
- function _objectSpread2(target) {
18
- for (var i = 1; i < arguments.length; i++) {
19
- var source = null != arguments[i] ? arguments[i] : {};
20
- i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
21
- _defineProperty(target, key, source[key]);
22
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
23
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
24
- });
25
- }
26
- return target;
27
- }
28
7
  function _regeneratorRuntime() {
29
8
  _regeneratorRuntime = function () {
30
9
  return exports;
@@ -356,63 +335,24 @@
356
335
  });
357
336
  };
358
337
  }
359
- function _classCallCheck(instance, Constructor) {
360
- if (!(instance instanceof Constructor)) {
361
- throw new TypeError("Cannot call a class as a function");
362
- }
363
- }
364
- function _defineProperties(target, props) {
365
- for (var i = 0; i < props.length; i++) {
366
- var descriptor = props[i];
367
- descriptor.enumerable = descriptor.enumerable || false;
368
- descriptor.configurable = true;
369
- if ("value" in descriptor) descriptor.writable = true;
370
- Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
371
- }
372
- }
373
- function _createClass(Constructor, protoProps, staticProps) {
374
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
375
- if (staticProps) _defineProperties(Constructor, staticProps);
376
- Object.defineProperty(Constructor, "prototype", {
377
- writable: false
378
- });
379
- return Constructor;
380
- }
381
- function _defineProperty(obj, key, value) {
382
- key = _toPropertyKey(key);
383
- if (key in obj) {
384
- Object.defineProperty(obj, key, {
385
- value: value,
386
- enumerable: true,
387
- configurable: true,
388
- writable: true
389
- });
390
- } else {
391
- obj[key] = value;
392
- }
393
- return obj;
394
- }
395
- function _inherits(subClass, superClass) {
396
- if (typeof superClass !== "function" && superClass !== null) {
397
- throw new TypeError("Super expression must either be null or a function");
398
- }
399
- subClass.prototype = Object.create(superClass && superClass.prototype, {
400
- constructor: {
401
- value: subClass,
402
- writable: true,
403
- configurable: true
338
+ function _extends() {
339
+ _extends = Object.assign ? Object.assign.bind() : function (target) {
340
+ for (var i = 1; i < arguments.length; i++) {
341
+ var source = arguments[i];
342
+ for (var key in source) {
343
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
344
+ target[key] = source[key];
345
+ }
346
+ }
404
347
  }
405
- });
406
- Object.defineProperty(subClass, "prototype", {
407
- writable: false
408
- });
409
- if (superClass) _setPrototypeOf(subClass, superClass);
410
- }
411
- function _getPrototypeOf(o) {
412
- _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
413
- return o.__proto__ || Object.getPrototypeOf(o);
348
+ return target;
414
349
  };
415
- return _getPrototypeOf(o);
350
+ return _extends.apply(this, arguments);
351
+ }
352
+ function _inheritsLoose(subClass, superClass) {
353
+ subClass.prototype = Object.create(superClass.prototype);
354
+ subClass.prototype.constructor = subClass;
355
+ _setPrototypeOf(subClass, superClass);
416
356
  }
417
357
  function _setPrototypeOf(o, p) {
418
358
  _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
@@ -421,59 +361,6 @@
421
361
  };
422
362
  return _setPrototypeOf(o, p);
423
363
  }
424
- function _isNativeReflectConstruct() {
425
- if (typeof Reflect === "undefined" || !Reflect.construct) return false;
426
- if (Reflect.construct.sham) return false;
427
- if (typeof Proxy === "function") return true;
428
- try {
429
- Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
430
- return true;
431
- } catch (e) {
432
- return false;
433
- }
434
- }
435
- function _assertThisInitialized(self) {
436
- if (self === void 0) {
437
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
438
- }
439
- return self;
440
- }
441
- function _possibleConstructorReturn(self, call) {
442
- if (call && (typeof call === "object" || typeof call === "function")) {
443
- return call;
444
- } else if (call !== void 0) {
445
- throw new TypeError("Derived constructors may only return object or undefined");
446
- }
447
- return _assertThisInitialized(self);
448
- }
449
- function _createSuper(Derived) {
450
- var hasNativeReflectConstruct = _isNativeReflectConstruct();
451
- return function _createSuperInternal() {
452
- var Super = _getPrototypeOf(Derived),
453
- result;
454
- if (hasNativeReflectConstruct) {
455
- var NewTarget = _getPrototypeOf(this).constructor;
456
- result = Reflect.construct(Super, arguments, NewTarget);
457
- } else {
458
- result = Super.apply(this, arguments);
459
- }
460
- return _possibleConstructorReturn(this, result);
461
- };
462
- }
463
- function _toPrimitive(input, hint) {
464
- if (typeof input !== "object" || input === null) return input;
465
- var prim = input[Symbol.toPrimitive];
466
- if (prim !== undefined) {
467
- var res = prim.call(input, hint || "default");
468
- if (typeof res !== "object") return res;
469
- throw new TypeError("@@toPrimitive must return a primitive value.");
470
- }
471
- return (hint === "string" ? String : Number)(input);
472
- }
473
- function _toPropertyKey(arg) {
474
- var key = _toPrimitive(arg, "string");
475
- return typeof key === "symbol" ? key : String(key);
476
- }
477
364
 
478
365
  function distanceSquareRoot(a, b) {
479
366
  return Math.sqrt((a[0] - b[0]) * (a[0] - b[0]) + (a[1] - b[1]) * (a[1] - b[1]));
@@ -481,202 +368,195 @@
481
368
 
482
369
  var DragndropPlugin = /*#__PURE__*/function () {
483
370
  function DragndropPlugin(dragndropPluginOptions) {
484
- _classCallCheck(this, DragndropPlugin);
485
371
  this.dragndropPluginOptions = void 0;
486
372
  this.dragndropPluginOptions = dragndropPluginOptions;
487
373
  }
488
- _createClass(DragndropPlugin, [{
489
- key: "apply",
490
- value: function apply(context) {
491
- var renderingService = context.renderingService,
492
- renderingContext = context.renderingContext;
493
- var document = renderingContext.root.ownerDocument;
494
- // TODO: should we add an option like `draggable` to Canvas
495
- var canvas = document.defaultView;
496
- var _this$dragndropPlugin = this.dragndropPluginOptions,
497
- overlap = _this$dragndropPlugin.overlap,
498
- isDocumentDraggable = _this$dragndropPlugin.isDocumentDraggable,
499
- isDocumentDroppable = _this$dragndropPlugin.isDocumentDroppable,
500
- dragstartDistanceThreshold = _this$dragndropPlugin.dragstartDistanceThreshold,
501
- dragstartTimeThreshold = _this$dragndropPlugin.dragstartTimeThreshold;
502
- var handlePointerdown = function handlePointerdown(event) {
503
- var target = event.target;
504
- var isDocument = target === document;
505
- var draggableEventTarget = isDocument && isDocumentDraggable ? document : target.closest && target.closest('[draggable=true]');
506
- // `draggable` may be set on ancestor nodes:
507
- // @see https://github.com/antvis/G/issues/1088
508
- if (draggableEventTarget) {
509
- // @ts-ignore
510
- // eslint-disable-next-line no-inner-declarations
511
- var handlePointermove = /*#__PURE__*/function () {
512
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(event) {
513
- var timeElapsed, distanceMoved, point, elementsBelow, elementBelow, droppableBelow;
514
- return _regeneratorRuntime().wrap(function _callee$(_context) {
515
- while (1) {
516
- switch (_context.prev = _context.next) {
517
- case 0:
518
- if (dragstartTriggered) {
519
- _context.next = 8;
520
- break;
374
+ var _proto = DragndropPlugin.prototype;
375
+ _proto.apply = function apply(context) {
376
+ var renderingService = context.renderingService,
377
+ renderingContext = context.renderingContext;
378
+ var document = renderingContext.root.ownerDocument;
379
+ // TODO: should we add an option like `draggable` to Canvas
380
+ 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
+ var handlePointerdown = function handlePointerdown(event) {
388
+ var target = event.target;
389
+ var isDocument = target === document;
390
+ var draggableEventTarget = isDocument && isDocumentDraggable ? document : target.closest && target.closest('[draggable=true]');
391
+ // `draggable` may be set on ancestor nodes:
392
+ // @see https://github.com/antvis/G/issues/1088
393
+ if (draggableEventTarget) {
394
+ // @ts-ignore
395
+ // eslint-disable-next-line no-inner-declarations
396
+ var handlePointermove = /*#__PURE__*/function () {
397
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(event) {
398
+ var timeElapsed, distanceMoved, point, elementsBelow, elementBelow, droppableBelow;
399
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
400
+ while (1) {
401
+ switch (_context.prev = _context.next) {
402
+ case 0:
403
+ if (dragstartTriggered) {
404
+ _context.next = 8;
405
+ break;
406
+ }
407
+ timeElapsed = event.timeStamp - dragstartTimeStamp;
408
+ distanceMoved = distanceSquareRoot([event.clientX, event.clientY], dragstartClientCoordinates); // check thresholds
409
+ if (!(timeElapsed <= dragstartTimeThreshold || distanceMoved <= dragstartDistanceThreshold)) {
410
+ _context.next = 5;
411
+ break;
412
+ }
413
+ return _context.abrupt("return");
414
+ case 5:
415
+ // @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/dragstart_event
416
+ event.type = 'dragstart';
417
+ draggableEventTarget.dispatchEvent(event);
418
+ dragstartTriggered = true;
419
+ case 8:
420
+ // @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/drag_event
421
+ event.type = 'drag';
422
+ // @ts-ignore
423
+ event.dx = event.clientX - lastDragClientCoordinates[0];
424
+ // @ts-ignore
425
+ event.dy = event.clientY - lastDragClientCoordinates[1];
426
+ draggableEventTarget.dispatchEvent(event);
427
+ lastDragClientCoordinates = [event.clientX, event.clientY];
428
+ if (isDocument) {
429
+ _context.next = 21;
430
+ break;
431
+ }
432
+ point = overlap === 'pointer' ? [event.canvasX, event.canvasY] : target.getBounds().center;
433
+ _context.next = 17;
434
+ return document.elementsFromPoint(point[0], point[1]);
435
+ case 17:
436
+ elementsBelow = _context.sent;
437
+ // prevent from picking the dragging element
438
+ elementBelow = elementsBelow[elementsBelow.indexOf(target) + 1];
439
+ droppableBelow = (elementBelow === null || elementBelow === void 0 ? void 0 : elementBelow.closest('[droppable=true]')) || (isDocumentDroppable ? document : null);
440
+ if (currentDroppable !== droppableBelow) {
441
+ if (currentDroppable) {
442
+ // null when we were not over a droppable before this event
443
+ // @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/dragleave_event
444
+ event.type = 'dragleave';
445
+ event.target = currentDroppable;
446
+ currentDroppable.dispatchEvent(event);
521
447
  }
522
- timeElapsed = event.timeStamp - dragstartTimeStamp;
523
- distanceMoved = distanceSquareRoot([event.clientX, event.clientY], dragstartClientCoordinates); // check thresholds
524
- if (!(timeElapsed <= dragstartTimeThreshold || distanceMoved <= dragstartDistanceThreshold)) {
525
- _context.next = 5;
526
- break;
448
+ if (droppableBelow) {
449
+ // @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/dragleave_event
450
+ event.type = 'dragenter';
451
+ event.target = droppableBelow;
452
+ droppableBelow.dispatchEvent(event);
527
453
  }
528
- return _context.abrupt("return");
529
- case 5:
530
- // @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/dragstart_event
531
- event.type = 'dragstart';
532
- draggableEventTarget.dispatchEvent(event);
533
- dragstartTriggered = true;
534
- case 8:
535
- // @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/drag_event
536
- event.type = 'drag';
537
- // @ts-ignore
538
- event.dx = event.clientX - lastDragClientCoordinates[0];
539
- // @ts-ignore
540
- event.dy = event.clientY - lastDragClientCoordinates[1];
541
- draggableEventTarget.dispatchEvent(event);
542
- lastDragClientCoordinates = [event.clientX, event.clientY];
543
- if (isDocument) {
544
- _context.next = 21;
545
- break;
454
+ currentDroppable = droppableBelow;
455
+ if (currentDroppable) {
456
+ // null if we're not coming over a droppable now
457
+ // @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/dragover_event
458
+ event.type = 'dragover';
459
+ event.target = currentDroppable;
460
+ currentDroppable.dispatchEvent(event);
546
461
  }
547
- point = overlap === 'pointer' ? [event.canvasX, event.canvasY] : target.getBounds().center;
548
- _context.next = 17;
549
- return document.elementsFromPoint(point[0], point[1]);
550
- case 17:
551
- elementsBelow = _context.sent;
552
- // prevent from picking the dragging element
553
- elementBelow = elementsBelow[elementsBelow.indexOf(target) + 1];
554
- droppableBelow = (elementBelow === null || elementBelow === void 0 ? void 0 : elementBelow.closest('[droppable=true]')) || (isDocumentDroppable ? document : null);
555
- if (currentDroppable !== droppableBelow) {
556
- if (currentDroppable) {
557
- // null when we were not over a droppable before this event
558
- // @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/dragleave_event
559
- event.type = 'dragleave';
560
- event.target = currentDroppable;
561
- currentDroppable.dispatchEvent(event);
562
- }
563
- if (droppableBelow) {
564
- // @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/dragleave_event
565
- event.type = 'dragenter';
566
- event.target = droppableBelow;
567
- droppableBelow.dispatchEvent(event);
568
- }
569
- currentDroppable = droppableBelow;
570
- if (currentDroppable) {
571
- // null if we're not coming over a droppable now
572
- // @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/dragover_event
573
- event.type = 'dragover';
574
- event.target = currentDroppable;
575
- currentDroppable.dispatchEvent(event);
576
- }
577
- }
578
- case 21:
579
- case "end":
580
- return _context.stop();
581
- }
462
+ }
463
+ case 21:
464
+ case "end":
465
+ return _context.stop();
582
466
  }
583
- }, _callee);
584
- }));
585
- return function handlePointermove(_x) {
586
- return _ref.apply(this, arguments);
587
- };
588
- }();
589
- // delay triggering dragstart event
590
- var dragstartTriggered = false;
591
- var dragstartTimeStamp = event.timeStamp;
592
- var dragstartClientCoordinates = [event.clientX, event.clientY];
593
- var currentDroppable = null;
594
- var lastDragClientCoordinates = [event.clientX, event.clientY];
595
- canvas.addEventListener('pointermove', handlePointermove);
596
- var stopDragging = function stopDragging(originalPointerUpEvent) {
597
- if (dragstartTriggered) {
598
- // prevent click event being triggerd
599
- // @see https://github.com/antvis/G/issues/1091
600
- originalPointerUpEvent.detail = {
601
- preventClick: true
602
- };
603
- // clone event first
604
- var _event = originalPointerUpEvent.clone();
605
- // drop should fire before dragend
606
- // @see https://javascript.tutorialink.com/is-there-a-defined-ordering-between-dragend-and-drop-events/
607
- if (currentDroppable) {
608
- // @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/drop_event
609
- _event.type = 'drop';
610
- _event.target = currentDroppable;
611
- currentDroppable.dispatchEvent(_event);
612
467
  }
613
- // @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/dragend_event
614
- _event.type = 'dragend';
615
- draggableEventTarget.dispatchEvent(_event);
616
- dragstartTriggered = false;
617
- }
618
- canvas.removeEventListener('pointermove', handlePointermove);
468
+ }, _callee);
469
+ }));
470
+ return function handlePointermove(_x) {
471
+ return _ref.apply(this, arguments);
619
472
  };
620
- target.addEventListener('pointerup', stopDragging, {
621
- once: true
622
- });
623
- target.addEventListener('pointerupoutside', stopDragging, {
624
- once: true
625
- });
626
- }
627
- };
628
- renderingService.hooks.init.tapPromise(DragndropPlugin.tag, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
629
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
630
- while (1) {
631
- switch (_context2.prev = _context2.next) {
632
- case 0:
633
- canvas.addEventListener('pointerdown', handlePointerdown);
634
- case 1:
635
- case "end":
636
- return _context2.stop();
473
+ }();
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
+ canvas.addEventListener('pointermove', handlePointermove);
481
+ var stopDragging = function stopDragging(originalPointerUpEvent) {
482
+ if (dragstartTriggered) {
483
+ // prevent click event being triggerd
484
+ // @see https://github.com/antvis/G/issues/1091
485
+ originalPointerUpEvent.detail = {
486
+ preventClick: true
487
+ };
488
+ // clone event first
489
+ var _event = originalPointerUpEvent.clone();
490
+ // drop should fire before dragend
491
+ // @see https://javascript.tutorialink.com/is-there-a-defined-ordering-between-dragend-and-drop-events/
492
+ if (currentDroppable) {
493
+ // @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/drop_event
494
+ _event.type = 'drop';
495
+ _event.target = currentDroppable;
496
+ currentDroppable.dispatchEvent(_event);
637
497
  }
498
+ // @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/dragend_event
499
+ _event.type = 'dragend';
500
+ draggableEventTarget.dispatchEvent(_event);
501
+ dragstartTriggered = false;
638
502
  }
639
- }, _callee2);
640
- })));
641
- renderingService.hooks.destroy.tap(DragndropPlugin.tag, function () {
642
- canvas.removeEventListener('pointerdown', handlePointerdown);
643
- });
644
- }
645
- }]);
503
+ canvas.removeEventListener('pointermove', handlePointermove);
504
+ };
505
+ target.addEventListener('pointerup', stopDragging, {
506
+ once: true
507
+ });
508
+ target.addEventListener('pointerupoutside', stopDragging, {
509
+ once: true
510
+ });
511
+ }
512
+ };
513
+ renderingService.hooks.init.tapPromise(DragndropPlugin.tag, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
514
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
515
+ while (1) {
516
+ switch (_context2.prev = _context2.next) {
517
+ case 0:
518
+ canvas.addEventListener('pointerdown', handlePointerdown);
519
+ case 1:
520
+ case "end":
521
+ return _context2.stop();
522
+ }
523
+ }
524
+ }, _callee2);
525
+ })));
526
+ renderingService.hooks.destroy.tap(DragndropPlugin.tag, function () {
527
+ canvas.removeEventListener('pointerdown', handlePointerdown);
528
+ });
529
+ };
646
530
  return DragndropPlugin;
647
531
  }();
648
532
  DragndropPlugin.tag = 'Dragndrop';
649
533
 
650
534
  var Plugin = /*#__PURE__*/function (_AbstractRendererPlug) {
651
- _inherits(Plugin, _AbstractRendererPlug);
652
- var _super = _createSuper(Plugin);
653
- function Plugin() {
535
+ _inheritsLoose(Plugin, _AbstractRendererPlug);
536
+ function Plugin(options) {
654
537
  var _this;
655
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
656
- _classCallCheck(this, Plugin);
657
- _this = _super.call(this);
538
+ if (options === void 0) {
539
+ options = {};
540
+ }
541
+ _this = _AbstractRendererPlug.call(this) || this;
658
542
  _this.options = void 0;
659
543
  _this.name = 'dragndrop';
660
544
  _this.options = options;
661
545
  return _this;
662
546
  }
663
- _createClass(Plugin, [{
664
- key: "init",
665
- value: function init() {
666
- this.addRenderingPlugin(new DragndropPlugin(_objectSpread2({
667
- overlap: 'pointer',
668
- isDocumentDraggable: false,
669
- isDocumentDroppable: false,
670
- dragstartDistanceThreshold: 0,
671
- dragstartTimeThreshold: 0
672
- }, this.options)));
673
- }
674
- }, {
675
- key: "destroy",
676
- value: function destroy() {
677
- this.removeAllRenderingPlugins();
678
- }
679
- }]);
547
+ var _proto = Plugin.prototype;
548
+ _proto.init = function init() {
549
+ this.addRenderingPlugin(new DragndropPlugin(_extends({
550
+ overlap: 'pointer',
551
+ isDocumentDraggable: false,
552
+ isDocumentDroppable: false,
553
+ dragstartDistanceThreshold: 0,
554
+ dragstartTimeThreshold: 0
555
+ }, this.options)));
556
+ };
557
+ _proto.destroy = function destroy() {
558
+ this.removeAllRenderingPlugins();
559
+ };
680
560
  return Plugin;
681
561
  }(gLite.AbstractRendererPlugin);
682
562
 
@@ -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(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function n(){n=function(){return t};var t={},e=Object.prototype,r=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 f(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{f({},"")}catch(t){f=function(t,e,r){return t[e]=r}}function s(t,e,r,n){var i=Object.create((e&&e.prototype instanceof h?e:h).prototype),a=new L(n||[]);return o(i,"_invoke",{value:E(t,r,a)}),i}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=s;var p={};function h(){}function d(){}function v(){}var y={};f(y,a,(function(){return this}));var g=Object.getPrototypeOf,m=g&&g(g(_([])));m&&m!==e&&r.call(m,a)&&(y=m);var b=v.prototype=h.prototype=Object.create(y);function w(t){["next","throw","return"].forEach((function(e){f(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function n(o,i,a,c){var u=l(t[o],t,i);if("throw"!==u.type){var f=u.arg,s=f.value;return s&&"object"==typeof s&&r.call(s,"__await")?e.resolve(s.__await).then((function(t){n("next",t,a,c)}),(function(t){n("throw",t,a,c)})):e.resolve(s).then((function(t){f.value=t,a(f)}),(function(t){return n("throw",t,a,c)}))}c(u.arg)}var i;o(this,"_invoke",{value:function(t,r){function o(){return new e((function(e,o){n(t,r,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=x(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=l(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 x(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,x(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=l(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 j(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 L(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(j,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 n=-1,o=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],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(b,"constructor",{value:v,configurable:!0}),o(v,"constructor",{value:d,configurable:!0}),d.displayName=f(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,f(t,u,"GeneratorFunction")),t.prototype=Object.create(b),t},t.awrap=function(t){return{__await:t}},w(O.prototype),f(O.prototype,c,(function(){return this})),t.AsyncIterator=O,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new O(s(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},w(b),f(b,u,"Generator"),f(b,a,(function(){return this})),f(b,"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=_,L.prototype={constructor:L,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)&&r.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 n(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 n("end");if(this.prev>=i.tryLoc){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(i.catchLoc>this.prev)return n(i.catchLoc,!0);if(i.finallyLoc>this.prev)return n(i.finallyLoc)}else if(c){if(i.catchLoc>this.prev)return n(i.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(i.finallyLoc>this.prev)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(this.prev>=o.tryLoc&&r.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 o(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 i(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var a=t.apply(e,r);function c(t){o(a,n,i,c,u,"next",t)}function u(t){o(a,n,i,c,u,"throw",t)}c(void 0)}))}}function a(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function c(t,e){for(var r=0;e.length>r;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,d(n.key),n)}}function u(t,e,r){return e&&c(t.prototype,e),r&&c(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function f(t,e,r){return(e=d(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function s(t){return s=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},s(t)}function l(t,e){return l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},l(t,e)}function p(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function h(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,n=s(t);if(e){var o=s(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return p(this,r)}}function d(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}var v=function(){function t(e){a(this,t),this.dragndropPluginOptions=void 0,this.dragndropPluginOptions=e}return u(t,[{key:"apply",value:function(e){var r=e.renderingService,o=e.renderingContext.root.ownerDocument,a=o.defaultView,c=this.dragndropPluginOptions,u=c.overlap,f=c.isDocumentDraggable,s=c.isDocumentDroppable,l=c.dragstartDistanceThreshold,p=c.dragstartTimeThreshold,h=function(t){var e=t.target,r=e===o,c=r&&f?o:e.closest&&e.closest("[draggable=true]");if(c){var h=function(){var t=i(n().mark((function t(i){var a,f,h,b,w,O;return n().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(d){t.next=8;break}if(a=i.timeStamp-v,f=Math.sqrt(((n=[i.clientX,i.clientY])[0]-(E=y)[0])*(n[0]-E[0])+(n[1]-E[1])*(n[1]-E[1])),a>p&&f>l){t.next=5;break}return t.abrupt("return");case 5:i.type="dragstart",c.dispatchEvent(i),d=!0;case 8:if(i.type="drag",i.dx=i.clientX-m[0],i.dy=i.clientY-m[1],c.dispatchEvent(i),m=[i.clientX,i.clientY],r){t.next=21;break}return h="pointer"===u?[i.canvasX,i.canvasY]:e.getBounds().center,t.next=17,o.elementsFromPoint(h[0],h[1]);case 17:w=(b=t.sent)[b.indexOf(e)+1],O=(null==w?void 0:w.closest("[droppable=true]"))||(s?o:null),g!==O&&(g&&(i.type="dragleave",i.target=g,g.dispatchEvent(i)),O&&(i.type="dragenter",i.target=O,O.dispatchEvent(i)),(g=O)&&(i.type="dragover",i.target=g,g.dispatchEvent(i)));case 21:case"end":return t.stop()}var n,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 b=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",b,{once:!0}),e.addEventListener("pointerupoutside",b,{once:!0})}};r.hooks.init.tapPromise(t.tag,i(n().mark((function t(){return n().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:a.addEventListener("pointerdown",h);case 1:case"end":return t.stop()}}),t)})))),r.hooks.destroy.tap(t.tag,(function(){a.removeEventListener("pointerdown",h)}))}}]),t}();v.tag="Dragndrop";var y=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&l(t,e)}(n,t);var e=h(n);function n(){var t,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return a(this,n),(t=e.call(this)).options=void 0,t.name="dragndrop",t.options=r,t}return u(n,[{key:"init",value:function(){this.addRenderingPlugin(new v(function(t){for(var e=1;arguments.length>e;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?r(Object(n),!0).forEach((function(e){f(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):r(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}({overlap:"pointer",isDocumentDraggable:!1,isDocumentDroppable:!1,dragstartDistanceThreshold:0,dragstartTimeThreshold:0},this.options)))}},{key:"destroy",value:function(){this.removeAllRenderingPlugins()}}]),n}(e.AbstractRendererPlugin);t.Plugin=y,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 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})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/g-plugin-dragndrop",
3
- "version": "1.6.32",
3
+ "version": "1.6.33",
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": "a4ea86f17b561d0483129ca2022586fcd9e42b7b"
45
+ "gitHead": "c3c09705bf97040bbec01d94f55c27cc6f14d230"
46
46
  }