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