@antv/g-plugin-dragndrop 1.6.32 → 1.6.33
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 +183 -303
- package/dist/index.js +183 -303
- package/dist/index.umd.js +183 -303
- package/dist/index.umd.min.js +1 -1
- package/package.json +2 -2
package/dist/index.esm.js
CHANGED
|
@@ -1,27 +1,6 @@
|
|
|
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
|
-
}
|
|
25
4
|
function _regeneratorRuntime() {
|
|
26
5
|
_regeneratorRuntime = function () {
|
|
27
6
|
return exports;
|
|
@@ -353,63 +332,24 @@ function _asyncToGenerator(fn) {
|
|
|
353
332
|
});
|
|
354
333
|
};
|
|
355
334
|
}
|
|
356
|
-
function
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
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
|
|
335
|
+
function _extends() {
|
|
336
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
337
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
338
|
+
var source = arguments[i];
|
|
339
|
+
for (var key in source) {
|
|
340
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
341
|
+
target[key] = source[key];
|
|
342
|
+
}
|
|
343
|
+
}
|
|
401
344
|
}
|
|
402
|
-
|
|
403
|
-
Object.defineProperty(subClass, "prototype", {
|
|
404
|
-
writable: false
|
|
405
|
-
});
|
|
406
|
-
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
407
|
-
}
|
|
408
|
-
function _getPrototypeOf(o) {
|
|
409
|
-
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
|
410
|
-
return o.__proto__ || Object.getPrototypeOf(o);
|
|
345
|
+
return target;
|
|
411
346
|
};
|
|
412
|
-
return
|
|
347
|
+
return _extends.apply(this, arguments);
|
|
348
|
+
}
|
|
349
|
+
function _inheritsLoose(subClass, superClass) {
|
|
350
|
+
subClass.prototype = Object.create(superClass.prototype);
|
|
351
|
+
subClass.prototype.constructor = subClass;
|
|
352
|
+
_setPrototypeOf(subClass, superClass);
|
|
413
353
|
}
|
|
414
354
|
function _setPrototypeOf(o, p) {
|
|
415
355
|
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
@@ -418,258 +358,198 @@ function _setPrototypeOf(o, p) {
|
|
|
418
358
|
};
|
|
419
359
|
return _setPrototypeOf(o, p);
|
|
420
360
|
}
|
|
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
|
-
}
|
|
474
361
|
|
|
475
362
|
var DragndropPlugin = /*#__PURE__*/function () {
|
|
476
363
|
function DragndropPlugin(dragndropPluginOptions) {
|
|
477
|
-
_classCallCheck(this, DragndropPlugin);
|
|
478
364
|
this.dragndropPluginOptions = void 0;
|
|
479
365
|
this.dragndropPluginOptions = dragndropPluginOptions;
|
|
480
366
|
}
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
var
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
var
|
|
505
|
-
var
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
367
|
+
var _proto = DragndropPlugin.prototype;
|
|
368
|
+
_proto.apply = function apply(context) {
|
|
369
|
+
var renderingService = context.renderingService,
|
|
370
|
+
renderingContext = context.renderingContext;
|
|
371
|
+
var document = renderingContext.root.ownerDocument;
|
|
372
|
+
// TODO: should we add an option like `draggable` to Canvas
|
|
373
|
+
var canvas = document.defaultView;
|
|
374
|
+
var _this$dragndropPlugin = this.dragndropPluginOptions,
|
|
375
|
+
overlap = _this$dragndropPlugin.overlap,
|
|
376
|
+
isDocumentDraggable = _this$dragndropPlugin.isDocumentDraggable,
|
|
377
|
+
isDocumentDroppable = _this$dragndropPlugin.isDocumentDroppable,
|
|
378
|
+
dragstartDistanceThreshold = _this$dragndropPlugin.dragstartDistanceThreshold,
|
|
379
|
+
dragstartTimeThreshold = _this$dragndropPlugin.dragstartTimeThreshold;
|
|
380
|
+
var handlePointerdown = function handlePointerdown(event) {
|
|
381
|
+
var target = event.target;
|
|
382
|
+
var isDocument = target === document;
|
|
383
|
+
var draggableEventTarget = isDocument && isDocumentDraggable ? document : target.closest && target.closest('[draggable=true]');
|
|
384
|
+
// `draggable` may be set on ancestor nodes:
|
|
385
|
+
// @see https://github.com/antvis/G/issues/1088
|
|
386
|
+
if (draggableEventTarget) {
|
|
387
|
+
// @ts-ignore
|
|
388
|
+
// eslint-disable-next-line no-inner-declarations
|
|
389
|
+
var handlePointermove = /*#__PURE__*/function () {
|
|
390
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(event) {
|
|
391
|
+
var timeElapsed, distanceMoved, point, elementsBelow, elementBelow, droppableBelow;
|
|
392
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
393
|
+
while (1) {
|
|
394
|
+
switch (_context.prev = _context.next) {
|
|
395
|
+
case 0:
|
|
396
|
+
if (dragstartTriggered) {
|
|
397
|
+
_context.next = 8;
|
|
398
|
+
break;
|
|
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);
|
|
514
440
|
}
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
441
|
+
if (droppableBelow) {
|
|
442
|
+
// @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/dragleave_event
|
|
443
|
+
event.type = 'dragenter';
|
|
444
|
+
event.target = droppableBelow;
|
|
445
|
+
droppableBelow.dispatchEvent(event);
|
|
520
446
|
}
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
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;
|
|
447
|
+
currentDroppable = droppableBelow;
|
|
448
|
+
if (currentDroppable) {
|
|
449
|
+
// null if we're not coming over a droppable now
|
|
450
|
+
// @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/dragover_event
|
|
451
|
+
event.type = 'dragover';
|
|
452
|
+
event.target = currentDroppable;
|
|
453
|
+
currentDroppable.dispatchEvent(event);
|
|
539
454
|
}
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
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
|
-
}
|
|
455
|
+
}
|
|
456
|
+
case 21:
|
|
457
|
+
case "end":
|
|
458
|
+
return _context.stop();
|
|
575
459
|
}
|
|
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);
|
|
605
460
|
}
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
}
|
|
611
|
-
canvas.removeEventListener('pointermove', handlePointermove);
|
|
461
|
+
}, _callee);
|
|
462
|
+
}));
|
|
463
|
+
return function handlePointermove(_x) {
|
|
464
|
+
return _ref.apply(this, arguments);
|
|
612
465
|
};
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
466
|
+
}();
|
|
467
|
+
// delay triggering dragstart event
|
|
468
|
+
var dragstartTriggered = false;
|
|
469
|
+
var dragstartTimeStamp = event.timeStamp;
|
|
470
|
+
var dragstartClientCoordinates = [event.clientX, event.clientY];
|
|
471
|
+
var currentDroppable = null;
|
|
472
|
+
var lastDragClientCoordinates = [event.clientX, event.clientY];
|
|
473
|
+
canvas.addEventListener('pointermove', handlePointermove);
|
|
474
|
+
var stopDragging = function stopDragging(originalPointerUpEvent) {
|
|
475
|
+
if (dragstartTriggered) {
|
|
476
|
+
// prevent click event being triggerd
|
|
477
|
+
// @see https://github.com/antvis/G/issues/1091
|
|
478
|
+
originalPointerUpEvent.detail = {
|
|
479
|
+
preventClick: true
|
|
480
|
+
};
|
|
481
|
+
// clone event first
|
|
482
|
+
var _event = originalPointerUpEvent.clone();
|
|
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);
|
|
630
490
|
}
|
|
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;
|
|
631
495
|
}
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
496
|
+
canvas.removeEventListener('pointermove', handlePointermove);
|
|
497
|
+
};
|
|
498
|
+
target.addEventListener('pointerup', stopDragging, {
|
|
499
|
+
once: true
|
|
500
|
+
});
|
|
501
|
+
target.addEventListener('pointerupoutside', stopDragging, {
|
|
502
|
+
once: true
|
|
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
|
+
};
|
|
639
523
|
return DragndropPlugin;
|
|
640
524
|
}();
|
|
641
525
|
DragndropPlugin.tag = 'Dragndrop';
|
|
642
526
|
|
|
643
527
|
var Plugin = /*#__PURE__*/function (_AbstractRendererPlug) {
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
function Plugin() {
|
|
528
|
+
_inheritsLoose(Plugin, _AbstractRendererPlug);
|
|
529
|
+
function Plugin(options) {
|
|
647
530
|
var _this;
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
531
|
+
if (options === void 0) {
|
|
532
|
+
options = {};
|
|
533
|
+
}
|
|
534
|
+
_this = _AbstractRendererPlug.call(this) || this;
|
|
651
535
|
_this.options = void 0;
|
|
652
536
|
_this.name = 'dragndrop';
|
|
653
537
|
_this.options = options;
|
|
654
538
|
return _this;
|
|
655
539
|
}
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
value: function destroy() {
|
|
670
|
-
this.removeAllRenderingPlugins();
|
|
671
|
-
}
|
|
672
|
-
}]);
|
|
540
|
+
var _proto = Plugin.prototype;
|
|
541
|
+
_proto.init = function init() {
|
|
542
|
+
this.addRenderingPlugin(new DragndropPlugin(_extends({
|
|
543
|
+
overlap: 'pointer',
|
|
544
|
+
isDocumentDraggable: false,
|
|
545
|
+
isDocumentDroppable: false,
|
|
546
|
+
dragstartDistanceThreshold: 0,
|
|
547
|
+
dragstartTimeThreshold: 0
|
|
548
|
+
}, this.options)));
|
|
549
|
+
};
|
|
550
|
+
_proto.destroy = function destroy() {
|
|
551
|
+
this.removeAllRenderingPlugins();
|
|
552
|
+
};
|
|
673
553
|
return Plugin;
|
|
674
554
|
}(AbstractRendererPlugin);
|
|
675
555
|
|