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