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