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