@antv/g-plugin-dragndrop 1.6.31 → 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.esm.js +303 -183
- package/dist/index.js +303 -183
- package/dist/index.umd.js +303 -183
- 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,198 +418,258 @@ 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
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
var
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
var
|
|
391
|
-
var
|
|
392
|
-
|
|
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 <= dragstartTimeThreshold || distanceMoved <= 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 = 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]')) || (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 renderingService = context.renderingService,
|
|
485
|
+
renderingContext = context.renderingContext;
|
|
486
|
+
var document = renderingContext.root.ownerDocument;
|
|
487
|
+
// TODO: should we add an option like `draggable` to Canvas
|
|
488
|
+
var canvas = document.defaultView;
|
|
489
|
+
var _this$dragndropPlugin = this.dragndropPluginOptions,
|
|
490
|
+
overlap = _this$dragndropPlugin.overlap,
|
|
491
|
+
isDocumentDraggable = _this$dragndropPlugin.isDocumentDraggable,
|
|
492
|
+
isDocumentDroppable = _this$dragndropPlugin.isDocumentDroppable,
|
|
493
|
+
dragstartDistanceThreshold = _this$dragndropPlugin.dragstartDistanceThreshold,
|
|
494
|
+
dragstartTimeThreshold = _this$dragndropPlugin.dragstartTimeThreshold;
|
|
495
|
+
var handlePointerdown = function handlePointerdown(event) {
|
|
496
|
+
var target = event.target;
|
|
497
|
+
var isDocument = target === document;
|
|
498
|
+
var draggableEventTarget = isDocument && isDocumentDraggable ? document : target.closest && target.closest('[draggable=true]');
|
|
499
|
+
// `draggable` may be set on ancestor nodes:
|
|
500
|
+
// @see https://github.com/antvis/G/issues/1088
|
|
501
|
+
if (draggableEventTarget) {
|
|
502
|
+
// @ts-ignore
|
|
503
|
+
// eslint-disable-next-line no-inner-declarations
|
|
504
|
+
var handlePointermove = /*#__PURE__*/function () {
|
|
505
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(event) {
|
|
506
|
+
var timeElapsed, distanceMoved, point, elementsBelow, elementBelow, droppableBelow;
|
|
507
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
508
|
+
while (1) {
|
|
509
|
+
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 <= dragstartTimeThreshold || distanceMoved <= 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
|
-
|
|
540
|
+
point = 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]')) || (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
|
+
}
|
|
459
575
|
}
|
|
576
|
+
}, _callee);
|
|
577
|
+
}));
|
|
578
|
+
return function handlePointermove(_x) {
|
|
579
|
+
return _ref.apply(this, arguments);
|
|
580
|
+
};
|
|
581
|
+
}();
|
|
582
|
+
// delay triggering dragstart event
|
|
583
|
+
var dragstartTriggered = false;
|
|
584
|
+
var dragstartTimeStamp = event.timeStamp;
|
|
585
|
+
var dragstartClientCoordinates = [event.clientX, event.clientY];
|
|
586
|
+
var currentDroppable = null;
|
|
587
|
+
var lastDragClientCoordinates = [event.clientX, event.clientY];
|
|
588
|
+
canvas.addEventListener('pointermove', handlePointermove);
|
|
589
|
+
var stopDragging = function stopDragging(originalPointerUpEvent) {
|
|
590
|
+
if (dragstartTriggered) {
|
|
591
|
+
// prevent click event being triggerd
|
|
592
|
+
// @see https://github.com/antvis/G/issues/1091
|
|
593
|
+
originalPointerUpEvent.detail = {
|
|
594
|
+
preventClick: true
|
|
595
|
+
};
|
|
596
|
+
// clone event first
|
|
597
|
+
var _event = originalPointerUpEvent.clone();
|
|
598
|
+
// drop should fire before dragend
|
|
599
|
+
// @see https://javascript.tutorialink.com/is-there-a-defined-ordering-between-dragend-and-drop-events/
|
|
600
|
+
if (currentDroppable) {
|
|
601
|
+
// @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/drop_event
|
|
602
|
+
_event.type = 'drop';
|
|
603
|
+
_event.target = currentDroppable;
|
|
604
|
+
currentDroppable.dispatchEvent(_event);
|
|
460
605
|
}
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
606
|
+
// @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/dragend_event
|
|
607
|
+
_event.type = 'dragend';
|
|
608
|
+
draggableEventTarget.dispatchEvent(_event);
|
|
609
|
+
dragstartTriggered = false;
|
|
610
|
+
}
|
|
611
|
+
canvas.removeEventListener('pointermove', handlePointermove);
|
|
465
612
|
};
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
// drop should fire before dragend
|
|
484
|
-
// @see https://javascript.tutorialink.com/is-there-a-defined-ordering-between-dragend-and-drop-events/
|
|
485
|
-
if (currentDroppable) {
|
|
486
|
-
// @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/drop_event
|
|
487
|
-
_event.type = 'drop';
|
|
488
|
-
_event.target = currentDroppable;
|
|
489
|
-
currentDroppable.dispatchEvent(_event);
|
|
613
|
+
target.addEventListener('pointerup', stopDragging, {
|
|
614
|
+
once: true
|
|
615
|
+
});
|
|
616
|
+
target.addEventListener('pointerupoutside', stopDragging, {
|
|
617
|
+
once: true
|
|
618
|
+
});
|
|
619
|
+
}
|
|
620
|
+
};
|
|
621
|
+
renderingService.hooks.init.tapPromise(DragndropPlugin.tag, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
622
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
623
|
+
while (1) {
|
|
624
|
+
switch (_context2.prev = _context2.next) {
|
|
625
|
+
case 0:
|
|
626
|
+
canvas.addEventListener('pointerdown', handlePointerdown);
|
|
627
|
+
case 1:
|
|
628
|
+
case "end":
|
|
629
|
+
return _context2.stop();
|
|
490
630
|
}
|
|
491
|
-
// @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/dragend_event
|
|
492
|
-
_event.type = 'dragend';
|
|
493
|
-
draggableEventTarget.dispatchEvent(_event);
|
|
494
|
-
dragstartTriggered = false;
|
|
495
631
|
}
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
});
|
|
504
|
-
}
|
|
505
|
-
};
|
|
506
|
-
renderingService.hooks.init.tapPromise(DragndropPlugin.tag, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
507
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
508
|
-
while (1) {
|
|
509
|
-
switch (_context2.prev = _context2.next) {
|
|
510
|
-
case 0:
|
|
511
|
-
canvas.addEventListener('pointerdown', handlePointerdown);
|
|
512
|
-
case 1:
|
|
513
|
-
case "end":
|
|
514
|
-
return _context2.stop();
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
}, _callee2);
|
|
518
|
-
})));
|
|
519
|
-
renderingService.hooks.destroy.tap(DragndropPlugin.tag, function () {
|
|
520
|
-
canvas.removeEventListener('pointerdown', handlePointerdown);
|
|
521
|
-
});
|
|
522
|
-
};
|
|
632
|
+
}, _callee2);
|
|
633
|
+
})));
|
|
634
|
+
renderingService.hooks.destroy.tap(DragndropPlugin.tag, function () {
|
|
635
|
+
canvas.removeEventListener('pointerdown', handlePointerdown);
|
|
636
|
+
});
|
|
637
|
+
}
|
|
638
|
+
}]);
|
|
523
639
|
return DragndropPlugin;
|
|
524
640
|
}();
|
|
525
641
|
DragndropPlugin.tag = 'Dragndrop';
|
|
526
642
|
|
|
527
643
|
var Plugin = /*#__PURE__*/function (_AbstractRendererPlug) {
|
|
528
|
-
|
|
529
|
-
|
|
644
|
+
_inherits(Plugin, _AbstractRendererPlug);
|
|
645
|
+
var _super = _createSuper(Plugin);
|
|
646
|
+
function Plugin() {
|
|
530
647
|
var _this;
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
_this = _AbstractRendererPlug.call(this) || this;
|
|
648
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
649
|
+
_classCallCheck(this, Plugin);
|
|
650
|
+
_this = _super.call(this);
|
|
535
651
|
_this.options = void 0;
|
|
536
652
|
_this.name = 'dragndrop';
|
|
537
653
|
_this.options = options;
|
|
538
654
|
return _this;
|
|
539
655
|
}
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
656
|
+
_createClass(Plugin, [{
|
|
657
|
+
key: "init",
|
|
658
|
+
value: function init() {
|
|
659
|
+
this.addRenderingPlugin(new DragndropPlugin(_objectSpread2({
|
|
660
|
+
overlap: 'pointer',
|
|
661
|
+
isDocumentDraggable: false,
|
|
662
|
+
isDocumentDroppable: false,
|
|
663
|
+
dragstartDistanceThreshold: 0,
|
|
664
|
+
dragstartTimeThreshold: 0
|
|
665
|
+
}, this.options)));
|
|
666
|
+
}
|
|
667
|
+
}, {
|
|
668
|
+
key: "destroy",
|
|
669
|
+
value: function destroy() {
|
|
670
|
+
this.removeAllRenderingPlugins();
|
|
671
|
+
}
|
|
672
|
+
}]);
|
|
553
673
|
return Plugin;
|
|
554
674
|
}(AbstractRendererPlugin);
|
|
555
675
|
|