@antv/g-plugin-dragndrop 1.6.30 → 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 +306 -191
- package/dist/index.js +306 -191
- package/dist/index.umd.js +306 -191
- 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;
|
|
@@ -136,14 +157,9 @@ function _regeneratorRuntime() {
|
|
|
136
157
|
};
|
|
137
158
|
}
|
|
138
159
|
function maybeInvokeDelegate(delegate, context) {
|
|
139
|
-
var
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
|
|
143
|
-
context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
|
|
144
|
-
}
|
|
145
|
-
return ContinueSentinel;
|
|
146
|
-
}
|
|
160
|
+
var methodName = context.method,
|
|
161
|
+
method = delegate.iterator[methodName];
|
|
162
|
+
if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel;
|
|
147
163
|
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
148
164
|
if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
|
|
149
165
|
var info = record.arg;
|
|
@@ -337,24 +353,63 @@ function _asyncToGenerator(fn) {
|
|
|
337
353
|
});
|
|
338
354
|
};
|
|
339
355
|
}
|
|
340
|
-
function
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
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
|
|
349
401
|
}
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
402
|
+
});
|
|
403
|
+
Object.defineProperty(subClass, "prototype", {
|
|
404
|
+
writable: false
|
|
405
|
+
});
|
|
406
|
+
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
353
407
|
}
|
|
354
|
-
function
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
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);
|
|
358
413
|
}
|
|
359
414
|
function _setPrototypeOf(o, p) {
|
|
360
415
|
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
@@ -363,198 +418,258 @@ function _setPrototypeOf(o, p) {
|
|
|
363
418
|
};
|
|
364
419
|
return _setPrototypeOf(o, p);
|
|
365
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
|
+
}
|
|
366
474
|
|
|
367
475
|
var DragndropPlugin = /*#__PURE__*/function () {
|
|
368
476
|
function DragndropPlugin(dragndropPluginOptions) {
|
|
477
|
+
_classCallCheck(this, DragndropPlugin);
|
|
369
478
|
this.dragndropPluginOptions = void 0;
|
|
370
479
|
this.dragndropPluginOptions = dragndropPluginOptions;
|
|
371
480
|
}
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
var
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
var
|
|
396
|
-
var
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
return _context.abrupt("return");
|
|
412
|
-
case 5:
|
|
413
|
-
// @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/dragstart_event
|
|
414
|
-
event.type = 'dragstart';
|
|
415
|
-
draggableEventTarget.dispatchEvent(event);
|
|
416
|
-
dragstartTriggered = true;
|
|
417
|
-
case 8:
|
|
418
|
-
// @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/drag_event
|
|
419
|
-
event.type = 'drag';
|
|
420
|
-
// @ts-ignore
|
|
421
|
-
event.dx = event.clientX - lastDragClientCoordinates[0];
|
|
422
|
-
// @ts-ignore
|
|
423
|
-
event.dy = event.clientY - lastDragClientCoordinates[1];
|
|
424
|
-
draggableEventTarget.dispatchEvent(event);
|
|
425
|
-
lastDragClientCoordinates = [event.clientX, event.clientY];
|
|
426
|
-
if (isDocument) {
|
|
427
|
-
_context.next = 21;
|
|
428
|
-
break;
|
|
429
|
-
}
|
|
430
|
-
point = overlap === 'pointer' ? [event.canvasX, event.canvasY] : target.getBounds().center;
|
|
431
|
-
_context.next = 17;
|
|
432
|
-
return document.elementsFromPoint(point[0], point[1]);
|
|
433
|
-
case 17:
|
|
434
|
-
elementsBelow = _context.sent;
|
|
435
|
-
// prevent from picking the dragging element
|
|
436
|
-
elementBelow = elementsBelow[elementsBelow.indexOf(target) + 1];
|
|
437
|
-
droppableBelow = (elementBelow === null || elementBelow === void 0 ? void 0 : elementBelow.closest('[droppable=true]')) || (isDocumentDroppable ? document : null);
|
|
438
|
-
if (currentDroppable !== droppableBelow) {
|
|
439
|
-
if (currentDroppable) {
|
|
440
|
-
// null when we were not over a droppable before this event
|
|
441
|
-
// @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/dragleave_event
|
|
442
|
-
event.type = 'dragleave';
|
|
443
|
-
event.target = currentDroppable;
|
|
444
|
-
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;
|
|
514
|
+
}
|
|
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;
|
|
445
520
|
}
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
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;
|
|
451
539
|
}
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
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
|
+
}
|
|
459
570
|
}
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
571
|
+
case 21:
|
|
572
|
+
case "end":
|
|
573
|
+
return _context.stop();
|
|
574
|
+
}
|
|
464
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);
|
|
465
605
|
}
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
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);
|
|
470
612
|
};
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
// drop should fire before dragend
|
|
489
|
-
// @see https://javascript.tutorialink.com/is-there-a-defined-ordering-between-dragend-and-drop-events/
|
|
490
|
-
if (currentDroppable) {
|
|
491
|
-
// @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/drop_event
|
|
492
|
-
_event.type = 'drop';
|
|
493
|
-
_event.target = currentDroppable;
|
|
494
|
-
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();
|
|
495
630
|
}
|
|
496
|
-
// @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/dragend_event
|
|
497
|
-
_event.type = 'dragend';
|
|
498
|
-
draggableEventTarget.dispatchEvent(_event);
|
|
499
|
-
dragstartTriggered = false;
|
|
500
631
|
}
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
});
|
|
509
|
-
}
|
|
510
|
-
};
|
|
511
|
-
renderingService.hooks.init.tapPromise(DragndropPlugin.tag, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
512
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
513
|
-
while (1) {
|
|
514
|
-
switch (_context2.prev = _context2.next) {
|
|
515
|
-
case 0:
|
|
516
|
-
canvas.addEventListener('pointerdown', handlePointerdown);
|
|
517
|
-
case 1:
|
|
518
|
-
case "end":
|
|
519
|
-
return _context2.stop();
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
}, _callee2);
|
|
523
|
-
})));
|
|
524
|
-
renderingService.hooks.destroy.tap(DragndropPlugin.tag, function () {
|
|
525
|
-
canvas.removeEventListener('pointerdown', handlePointerdown);
|
|
526
|
-
});
|
|
527
|
-
};
|
|
632
|
+
}, _callee2);
|
|
633
|
+
})));
|
|
634
|
+
renderingService.hooks.destroy.tap(DragndropPlugin.tag, function () {
|
|
635
|
+
canvas.removeEventListener('pointerdown', handlePointerdown);
|
|
636
|
+
});
|
|
637
|
+
}
|
|
638
|
+
}]);
|
|
528
639
|
return DragndropPlugin;
|
|
529
640
|
}();
|
|
530
641
|
DragndropPlugin.tag = 'Dragndrop';
|
|
531
642
|
|
|
532
643
|
var Plugin = /*#__PURE__*/function (_AbstractRendererPlug) {
|
|
533
|
-
|
|
534
|
-
|
|
644
|
+
_inherits(Plugin, _AbstractRendererPlug);
|
|
645
|
+
var _super = _createSuper(Plugin);
|
|
646
|
+
function Plugin() {
|
|
535
647
|
var _this;
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
_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);
|
|
540
651
|
_this.options = void 0;
|
|
541
652
|
_this.name = 'dragndrop';
|
|
542
653
|
_this.options = options;
|
|
543
654
|
return _this;
|
|
544
655
|
}
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
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
|
+
}]);
|
|
558
673
|
return Plugin;
|
|
559
674
|
}(AbstractRendererPlugin);
|
|
560
675
|
|