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