@antv/g-plugin-dragndrop 1.6.30 → 1.6.32

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,6 +4,27 @@
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
+ }
7
28
  function _regeneratorRuntime() {
8
29
  _regeneratorRuntime = function () {
9
30
  return exports;
@@ -139,14 +160,9 @@
139
160
  };
140
161
  }
141
162
  function maybeInvokeDelegate(delegate, context) {
142
- var method = delegate.iterator[context.method];
143
- if (undefined === method) {
144
- if (context.delegate = null, "throw" === context.method) {
145
- if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
146
- context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
147
- }
148
- return ContinueSentinel;
149
- }
163
+ var methodName = context.method,
164
+ method = delegate.iterator[methodName];
165
+ if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel;
150
166
  var record = tryCatch(method, delegate.iterator, context.arg);
151
167
  if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
152
168
  var info = record.arg;
@@ -340,24 +356,63 @@
340
356
  });
341
357
  };
342
358
  }
343
- function _extends() {
344
- _extends = Object.assign ? Object.assign.bind() : function (target) {
345
- for (var i = 1; i < arguments.length; i++) {
346
- var source = arguments[i];
347
- for (var key in source) {
348
- if (Object.prototype.hasOwnProperty.call(source, key)) {
349
- target[key] = source[key];
350
- }
351
- }
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
352
404
  }
353
- return target;
354
- };
355
- return _extends.apply(this, arguments);
405
+ });
406
+ Object.defineProperty(subClass, "prototype", {
407
+ writable: false
408
+ });
409
+ if (superClass) _setPrototypeOf(subClass, superClass);
356
410
  }
357
- function _inheritsLoose(subClass, superClass) {
358
- subClass.prototype = Object.create(superClass.prototype);
359
- subClass.prototype.constructor = subClass;
360
- _setPrototypeOf(subClass, superClass);
411
+ function _getPrototypeOf(o) {
412
+ _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
413
+ return o.__proto__ || Object.getPrototypeOf(o);
414
+ };
415
+ return _getPrototypeOf(o);
361
416
  }
362
417
  function _setPrototypeOf(o, p) {
363
418
  _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
@@ -366,6 +421,59 @@
366
421
  };
367
422
  return _setPrototypeOf(o, p);
368
423
  }
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
+ }
369
477
 
370
478
  function distanceSquareRoot(a, b) {
371
479
  return Math.sqrt((a[0] - b[0]) * (a[0] - b[0]) + (a[1] - b[1]) * (a[1] - b[1]));
@@ -373,195 +481,202 @@
373
481
 
374
482
  var DragndropPlugin = /*#__PURE__*/function () {
375
483
  function DragndropPlugin(dragndropPluginOptions) {
484
+ _classCallCheck(this, DragndropPlugin);
376
485
  this.dragndropPluginOptions = void 0;
377
486
  this.dragndropPluginOptions = dragndropPluginOptions;
378
487
  }
379
- var _proto = DragndropPlugin.prototype;
380
- _proto.apply = function apply(context) {
381
- var renderingService = context.renderingService,
382
- renderingContext = context.renderingContext;
383
- var document = renderingContext.root.ownerDocument;
384
- // TODO: should we add an option like `draggable` to Canvas
385
- var canvas = document.defaultView;
386
- var _this$dragndropPlugin = this.dragndropPluginOptions,
387
- overlap = _this$dragndropPlugin.overlap,
388
- isDocumentDraggable = _this$dragndropPlugin.isDocumentDraggable,
389
- isDocumentDroppable = _this$dragndropPlugin.isDocumentDroppable,
390
- dragstartDistanceThreshold = _this$dragndropPlugin.dragstartDistanceThreshold,
391
- dragstartTimeThreshold = _this$dragndropPlugin.dragstartTimeThreshold;
392
- var handlePointerdown = function handlePointerdown(event) {
393
- var target = event.target;
394
- var isDocument = target === document;
395
- var draggableEventTarget = isDocument && isDocumentDraggable ? document : target.closest && target.closest('[draggable=true]');
396
- // `draggable` may be set on ancestor nodes:
397
- // @see https://github.com/antvis/G/issues/1088
398
- if (draggableEventTarget) {
399
- // @ts-ignore
400
- // eslint-disable-next-line no-inner-declarations
401
- var handlePointermove = /*#__PURE__*/function () {
402
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(event) {
403
- var timeElapsed, distanceMoved, point, elementsBelow, elementBelow, droppableBelow;
404
- return _regeneratorRuntime().wrap(function _callee$(_context) {
405
- while (1) {
406
- switch (_context.prev = _context.next) {
407
- case 0:
408
- if (dragstartTriggered) {
409
- _context.next = 8;
410
- break;
411
- }
412
- timeElapsed = event.timeStamp - dragstartTimeStamp;
413
- distanceMoved = distanceSquareRoot([event.clientX, event.clientY], dragstartClientCoordinates); // check thresholds
414
- if (!(timeElapsed <= dragstartTimeThreshold || distanceMoved <= dragstartDistanceThreshold)) {
415
- _context.next = 5;
416
- break;
417
- }
418
- return _context.abrupt("return");
419
- case 5:
420
- // @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/dragstart_event
421
- event.type = 'dragstart';
422
- draggableEventTarget.dispatchEvent(event);
423
- dragstartTriggered = true;
424
- case 8:
425
- // @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/drag_event
426
- event.type = 'drag';
427
- // @ts-ignore
428
- event.dx = event.clientX - lastDragClientCoordinates[0];
429
- // @ts-ignore
430
- event.dy = event.clientY - lastDragClientCoordinates[1];
431
- draggableEventTarget.dispatchEvent(event);
432
- lastDragClientCoordinates = [event.clientX, event.clientY];
433
- if (isDocument) {
434
- _context.next = 21;
435
- break;
436
- }
437
- point = overlap === 'pointer' ? [event.canvasX, event.canvasY] : target.getBounds().center;
438
- _context.next = 17;
439
- return document.elementsFromPoint(point[0], point[1]);
440
- case 17:
441
- elementsBelow = _context.sent;
442
- // prevent from picking the dragging element
443
- elementBelow = elementsBelow[elementsBelow.indexOf(target) + 1];
444
- droppableBelow = (elementBelow === null || elementBelow === void 0 ? void 0 : elementBelow.closest('[droppable=true]')) || (isDocumentDroppable ? document : null);
445
- if (currentDroppable !== droppableBelow) {
446
- if (currentDroppable) {
447
- // null when we were not over a droppable before this event
448
- // @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/dragleave_event
449
- event.type = 'dragleave';
450
- event.target = currentDroppable;
451
- currentDroppable.dispatchEvent(event);
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;
521
+ }
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;
452
527
  }
453
- if (droppableBelow) {
454
- // @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/dragleave_event
455
- event.type = 'dragenter';
456
- event.target = droppableBelow;
457
- droppableBelow.dispatchEvent(event);
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;
458
546
  }
459
- currentDroppable = droppableBelow;
460
- if (currentDroppable) {
461
- // null if we're not coming over a droppable now
462
- // @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/dragover_event
463
- event.type = 'dragover';
464
- event.target = currentDroppable;
465
- currentDroppable.dispatchEvent(event);
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
+ }
466
577
  }
467
- }
468
- case 21:
469
- case "end":
470
- return _context.stop();
578
+ case 21:
579
+ case "end":
580
+ return _context.stop();
581
+ }
471
582
  }
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);
472
612
  }
473
- }, _callee);
474
- }));
475
- return function handlePointermove(_x) {
476
- return _ref.apply(this, arguments);
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);
477
619
  };
478
- }();
479
- // delay triggering dragstart event
480
- var dragstartTriggered = false;
481
- var dragstartTimeStamp = event.timeStamp;
482
- var dragstartClientCoordinates = [event.clientX, event.clientY];
483
- var currentDroppable = null;
484
- var lastDragClientCoordinates = [event.clientX, event.clientY];
485
- canvas.addEventListener('pointermove', handlePointermove);
486
- var stopDragging = function stopDragging(originalPointerUpEvent) {
487
- if (dragstartTriggered) {
488
- // prevent click event being triggerd
489
- // @see https://github.com/antvis/G/issues/1091
490
- originalPointerUpEvent.detail = {
491
- preventClick: true
492
- };
493
- // clone event first
494
- var _event = originalPointerUpEvent.clone();
495
- // drop should fire before dragend
496
- // @see https://javascript.tutorialink.com/is-there-a-defined-ordering-between-dragend-and-drop-events/
497
- if (currentDroppable) {
498
- // @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/drop_event
499
- _event.type = 'drop';
500
- _event.target = currentDroppable;
501
- currentDroppable.dispatchEvent(_event);
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();
502
637
  }
503
- // @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/dragend_event
504
- _event.type = 'dragend';
505
- draggableEventTarget.dispatchEvent(_event);
506
- dragstartTriggered = false;
507
638
  }
508
- canvas.removeEventListener('pointermove', handlePointermove);
509
- };
510
- target.addEventListener('pointerup', stopDragging, {
511
- once: true
512
- });
513
- target.addEventListener('pointerupoutside', stopDragging, {
514
- once: true
515
- });
516
- }
517
- };
518
- renderingService.hooks.init.tapPromise(DragndropPlugin.tag, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
519
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
520
- while (1) {
521
- switch (_context2.prev = _context2.next) {
522
- case 0:
523
- canvas.addEventListener('pointerdown', handlePointerdown);
524
- case 1:
525
- case "end":
526
- return _context2.stop();
527
- }
528
- }
529
- }, _callee2);
530
- })));
531
- renderingService.hooks.destroy.tap(DragndropPlugin.tag, function () {
532
- canvas.removeEventListener('pointerdown', handlePointerdown);
533
- });
534
- };
639
+ }, _callee2);
640
+ })));
641
+ renderingService.hooks.destroy.tap(DragndropPlugin.tag, function () {
642
+ canvas.removeEventListener('pointerdown', handlePointerdown);
643
+ });
644
+ }
645
+ }]);
535
646
  return DragndropPlugin;
536
647
  }();
537
648
  DragndropPlugin.tag = 'Dragndrop';
538
649
 
539
650
  var Plugin = /*#__PURE__*/function (_AbstractRendererPlug) {
540
- _inheritsLoose(Plugin, _AbstractRendererPlug);
541
- function Plugin(options) {
651
+ _inherits(Plugin, _AbstractRendererPlug);
652
+ var _super = _createSuper(Plugin);
653
+ function Plugin() {
542
654
  var _this;
543
- if (options === void 0) {
544
- options = {};
545
- }
546
- _this = _AbstractRendererPlug.call(this) || this;
655
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
656
+ _classCallCheck(this, Plugin);
657
+ _this = _super.call(this);
547
658
  _this.options = void 0;
548
659
  _this.name = 'dragndrop';
549
660
  _this.options = options;
550
661
  return _this;
551
662
  }
552
- var _proto = Plugin.prototype;
553
- _proto.init = function init() {
554
- this.addRenderingPlugin(new DragndropPlugin(_extends({
555
- overlap: 'pointer',
556
- isDocumentDraggable: false,
557
- isDocumentDroppable: false,
558
- dragstartDistanceThreshold: 0,
559
- dragstartTimeThreshold: 0
560
- }, this.options)));
561
- };
562
- _proto.destroy = function destroy() {
563
- this.removeAllRenderingPlugins();
564
- };
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
+ }]);
565
680
  return Plugin;
566
681
  }(gLite.AbstractRendererPlugin);
567
682
 
@@ -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=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,L(t,e),"throw"===e.method))return p;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return p}var n=f(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,p;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,p):o:(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(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})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/g-plugin-dragndrop",
3
- "version": "1.6.30",
3
+ "version": "1.6.32",
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": "28fd2d84bf0525523836447be314ab15b9997e32"
45
+ "gitHead": "a4ea86f17b561d0483129ca2022586fcd9e42b7b"
46
46
  }