index.umd.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  1. (function (global, factory) {
  2. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@antv/g-lite')) :
  3. typeof define === 'function' && define.amd ? define(['exports', '@antv/g-lite'], factory) :
  4. (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.G = global.G || {}, global.G.Dragndrop = {}), global.window.G));
  5. }(this, (function (exports, gLite) { 'use strict';
  6. function _regeneratorRuntime() {
  7. _regeneratorRuntime = function () {
  8. return exports;
  9. };
  10. var exports = {},
  11. Op = Object.prototype,
  12. hasOwn = Op.hasOwnProperty,
  13. defineProperty = Object.defineProperty || function (obj, key, desc) {
  14. obj[key] = desc.value;
  15. },
  16. $Symbol = "function" == typeof Symbol ? Symbol : {},
  17. iteratorSymbol = $Symbol.iterator || "@@iterator",
  18. asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
  19. toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  20. function define(obj, key, value) {
  21. return Object.defineProperty(obj, key, {
  22. value: value,
  23. enumerable: !0,
  24. configurable: !0,
  25. writable: !0
  26. }), obj[key];
  27. }
  28. try {
  29. define({}, "");
  30. } catch (err) {
  31. define = function (obj, key, value) {
  32. return obj[key] = value;
  33. };
  34. }
  35. function wrap(innerFn, outerFn, self, tryLocsList) {
  36. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
  37. generator = Object.create(protoGenerator.prototype),
  38. context = new Context(tryLocsList || []);
  39. return defineProperty(generator, "_invoke", {
  40. value: makeInvokeMethod(innerFn, self, context)
  41. }), generator;
  42. }
  43. function tryCatch(fn, obj, arg) {
  44. try {
  45. return {
  46. type: "normal",
  47. arg: fn.call(obj, arg)
  48. };
  49. } catch (err) {
  50. return {
  51. type: "throw",
  52. arg: err
  53. };
  54. }
  55. }
  56. exports.wrap = wrap;
  57. var ContinueSentinel = {};
  58. function Generator() {}
  59. function GeneratorFunction() {}
  60. function GeneratorFunctionPrototype() {}
  61. var IteratorPrototype = {};
  62. define(IteratorPrototype, iteratorSymbol, function () {
  63. return this;
  64. });
  65. var getProto = Object.getPrototypeOf,
  66. NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  67. NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
  68. var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
  69. function defineIteratorMethods(prototype) {
  70. ["next", "throw", "return"].forEach(function (method) {
  71. define(prototype, method, function (arg) {
  72. return this._invoke(method, arg);
  73. });
  74. });
  75. }
  76. function AsyncIterator(generator, PromiseImpl) {
  77. function invoke(method, arg, resolve, reject) {
  78. var record = tryCatch(generator[method], generator, arg);
  79. if ("throw" !== record.type) {
  80. var result = record.arg,
  81. value = result.value;
  82. return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
  83. invoke("next", value, resolve, reject);
  84. }, function (err) {
  85. invoke("throw", err, resolve, reject);
  86. }) : PromiseImpl.resolve(value).then(function (unwrapped) {
  87. result.value = unwrapped, resolve(result);
  88. }, function (error) {
  89. return invoke("throw", error, resolve, reject);
  90. });
  91. }
  92. reject(record.arg);
  93. }
  94. var previousPromise;
  95. defineProperty(this, "_invoke", {
  96. value: function (method, arg) {
  97. function callInvokeWithMethodAndArg() {
  98. return new PromiseImpl(function (resolve, reject) {
  99. invoke(method, arg, resolve, reject);
  100. });
  101. }
  102. return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
  103. }
  104. });
  105. }
  106. function makeInvokeMethod(innerFn, self, context) {
  107. var state = "suspendedStart";
  108. return function (method, arg) {
  109. if ("executing" === state) throw new Error("Generator is already running");
  110. if ("completed" === state) {
  111. if ("throw" === method) throw arg;
  112. return doneResult();
  113. }
  114. for (context.method = method, context.arg = arg;;) {
  115. var delegate = context.delegate;
  116. if (delegate) {
  117. var delegateResult = maybeInvokeDelegate(delegate, context);
  118. if (delegateResult) {
  119. if (delegateResult === ContinueSentinel) continue;
  120. return delegateResult;
  121. }
  122. }
  123. if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
  124. if ("suspendedStart" === state) throw state = "completed", context.arg;
  125. context.dispatchException(context.arg);
  126. } else "return" === context.method && context.abrupt("return", context.arg);
  127. state = "executing";
  128. var record = tryCatch(innerFn, self, context);
  129. if ("normal" === record.type) {
  130. if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
  131. return {
  132. value: record.arg,
  133. done: context.done
  134. };
  135. }
  136. "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
  137. }
  138. };
  139. }
  140. function maybeInvokeDelegate(delegate, context) {
  141. var methodName = context.method,
  142. method = delegate.iterator[methodName];
  143. 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;
  144. var record = tryCatch(method, delegate.iterator, context.arg);
  145. if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
  146. var info = record.arg;
  147. return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
  148. }
  149. function pushTryEntry(locs) {
  150. var entry = {
  151. tryLoc: locs[0]
  152. };
  153. 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
  154. }
  155. function resetTryEntry(entry) {
  156. var record = entry.completion || {};
  157. record.type = "normal", delete record.arg, entry.completion = record;
  158. }
  159. function Context(tryLocsList) {
  160. this.tryEntries = [{
  161. tryLoc: "root"
  162. }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
  163. }
  164. function values(iterable) {
  165. if (iterable) {
  166. var iteratorMethod = iterable[iteratorSymbol];
  167. if (iteratorMethod) return iteratorMethod.call(iterable);
  168. if ("function" == typeof iterable.next) return iterable;
  169. if (!isNaN(iterable.length)) {
  170. var i = -1,
  171. next = function next() {
  172. for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
  173. return next.value = undefined, next.done = !0, next;
  174. };
  175. return next.next = next;
  176. }
  177. }
  178. return {
  179. next: doneResult
  180. };
  181. }
  182. function doneResult() {
  183. return {
  184. value: undefined,
  185. done: !0
  186. };
  187. }
  188. return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", {
  189. value: GeneratorFunctionPrototype,
  190. configurable: !0
  191. }), defineProperty(GeneratorFunctionPrototype, "constructor", {
  192. value: GeneratorFunction,
  193. configurable: !0
  194. }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
  195. var ctor = "function" == typeof genFun && genFun.constructor;
  196. return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
  197. }, exports.mark = function (genFun) {
  198. return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
  199. }, exports.awrap = function (arg) {
  200. return {
  201. __await: arg
  202. };
  203. }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
  204. return this;
  205. }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
  206. void 0 === PromiseImpl && (PromiseImpl = Promise);
  207. var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
  208. return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
  209. return result.done ? result.value : iter.next();
  210. });
  211. }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
  212. return this;
  213. }), define(Gp, "toString", function () {
  214. return "[object Generator]";
  215. }), exports.keys = function (val) {
  216. var object = Object(val),
  217. keys = [];
  218. for (var key in object) keys.push(key);
  219. return keys.reverse(), function next() {
  220. for (; keys.length;) {
  221. var key = keys.pop();
  222. if (key in object) return next.value = key, next.done = !1, next;
  223. }
  224. return next.done = !0, next;
  225. };
  226. }, exports.values = values, Context.prototype = {
  227. constructor: Context,
  228. reset: function (skipTempReset) {
  229. if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
  230. },
  231. stop: function () {
  232. this.done = !0;
  233. var rootRecord = this.tryEntries[0].completion;
  234. if ("throw" === rootRecord.type) throw rootRecord.arg;
  235. return this.rval;
  236. },
  237. dispatchException: function (exception) {
  238. if (this.done) throw exception;
  239. var context = this;
  240. function handle(loc, caught) {
  241. return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
  242. }
  243. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  244. var entry = this.tryEntries[i],
  245. record = entry.completion;
  246. if ("root" === entry.tryLoc) return handle("end");
  247. if (entry.tryLoc <= this.prev) {
  248. var hasCatch = hasOwn.call(entry, "catchLoc"),
  249. hasFinally = hasOwn.call(entry, "finallyLoc");
  250. if (hasCatch && hasFinally) {
  251. if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
  252. if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
  253. } else if (hasCatch) {
  254. if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
  255. } else {
  256. if (!hasFinally) throw new Error("try statement without catch or finally");
  257. if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
  258. }
  259. }
  260. }
  261. },
  262. abrupt: function (type, arg) {
  263. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  264. var entry = this.tryEntries[i];
  265. if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
  266. var finallyEntry = entry;
  267. break;
  268. }
  269. }
  270. finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
  271. var record = finallyEntry ? finallyEntry.completion : {};
  272. return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
  273. },
  274. complete: function (record, afterLoc) {
  275. if ("throw" === record.type) throw record.arg;
  276. return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
  277. },
  278. finish: function (finallyLoc) {
  279. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  280. var entry = this.tryEntries[i];
  281. if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
  282. }
  283. },
  284. catch: function (tryLoc) {
  285. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  286. var entry = this.tryEntries[i];
  287. if (entry.tryLoc === tryLoc) {
  288. var record = entry.completion;
  289. if ("throw" === record.type) {
  290. var thrown = record.arg;
  291. resetTryEntry(entry);
  292. }
  293. return thrown;
  294. }
  295. }
  296. throw new Error("illegal catch attempt");
  297. },
  298. delegateYield: function (iterable, resultName, nextLoc) {
  299. return this.delegate = {
  300. iterator: values(iterable),
  301. resultName: resultName,
  302. nextLoc: nextLoc
  303. }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
  304. }
  305. }, exports;
  306. }
  307. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
  308. try {
  309. var info = gen[key](arg);
  310. var value = info.value;
  311. } catch (error) {
  312. reject(error);
  313. return;
  314. }
  315. if (info.done) {
  316. resolve(value);
  317. } else {
  318. Promise.resolve(value).then(_next, _throw);
  319. }
  320. }
  321. function _asyncToGenerator(fn) {
  322. return function () {
  323. var self = this,
  324. args = arguments;
  325. return new Promise(function (resolve, reject) {
  326. var gen = fn.apply(self, args);
  327. function _next(value) {
  328. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
  329. }
  330. function _throw(err) {
  331. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
  332. }
  333. _next(undefined);
  334. });
  335. };
  336. }
  337. function _extends() {
  338. _extends = Object.assign ? Object.assign.bind() : function (target) {
  339. for (var i = 1; i < arguments.length; i++) {
  340. var source = arguments[i];
  341. for (var key in source) {
  342. if (Object.prototype.hasOwnProperty.call(source, key)) {
  343. target[key] = source[key];
  344. }
  345. }
  346. }
  347. return target;
  348. };
  349. return _extends.apply(this, arguments);
  350. }
  351. function _inheritsLoose(subClass, superClass) {
  352. subClass.prototype = Object.create(superClass.prototype);
  353. subClass.prototype.constructor = subClass;
  354. _setPrototypeOf(subClass, superClass);
  355. }
  356. function _setPrototypeOf(o, p) {
  357. _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
  358. o.__proto__ = p;
  359. return o;
  360. };
  361. return _setPrototypeOf(o, p);
  362. }
  363. function distanceSquareRoot(a, b) {
  364. return Math.sqrt((a[0] - b[0]) * (a[0] - b[0]) + (a[1] - b[1]) * (a[1] - b[1]));
  365. }
  366. var DragndropPlugin = /*#__PURE__*/function () {
  367. function DragndropPlugin(dragndropPluginOptions) {
  368. this.dragndropPluginOptions = void 0;
  369. this.dragndropPluginOptions = dragndropPluginOptions;
  370. }
  371. var _proto = DragndropPlugin.prototype;
  372. _proto.apply = function apply(context) {
  373. var _this = this;
  374. var renderingService = context.renderingService,
  375. renderingContext = context.renderingContext;
  376. var document = renderingContext.root.ownerDocument;
  377. // TODO: should we add an option like `draggable` to Canvas
  378. var canvas = document.defaultView;
  379. var handlePointerdown = function handlePointerdown(event) {
  380. var target = event.target;
  381. var isDocument = target === document;
  382. var draggableEventTarget = isDocument && _this.dragndropPluginOptions.isDocumentDraggable ? document : target.closest && target.closest('[draggable=true]');
  383. // `draggable` may be set on ancestor nodes:
  384. // @see https://github.com/antvis/G/issues/1088
  385. if (draggableEventTarget) {
  386. // delay triggering dragstart event
  387. var dragstartTriggered = false;
  388. var dragstartTimeStamp = event.timeStamp;
  389. var dragstartClientCoordinates = [event.clientX, event.clientY];
  390. var currentDroppable = null;
  391. var lastDragClientCoordinates = [event.clientX, event.clientY];
  392. // @ts-ignore
  393. // eslint-disable-next-line no-inner-declarations
  394. var handlePointermove = /*#__PURE__*/function () {
  395. var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(event) {
  396. var timeElapsed, distanceMoved, point, elementsBelow, elementBelow, droppableBelow;
  397. return _regeneratorRuntime().wrap(function _callee$(_context) {
  398. while (1) 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 = distanceSquareRoot([event.clientX, event.clientY], dragstartClientCoordinates); // check thresholds
  406. if (!(timeElapsed <= _this.dragndropPluginOptions.dragstartTimeThreshold || distanceMoved <= _this.dragndropPluginOptions.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 = _this.dragndropPluginOptions.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]')) || (_this.dragndropPluginOptions.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);
  444. }
  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);
  450. }
  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);
  458. }
  459. }
  460. case 21:
  461. case "end":
  462. return _context.stop();
  463. }
  464. }, _callee);
  465. }));
  466. return function handlePointermove(_x) {
  467. return _ref.apply(this, arguments);
  468. };
  469. }();
  470. canvas.addEventListener('pointermove', handlePointermove);
  471. var stopDragging = function stopDragging(originalPointerUpEvent) {
  472. if (dragstartTriggered) {
  473. // prevent click event being triggerd
  474. // @see https://github.com/antvis/G/issues/1091
  475. originalPointerUpEvent.detail = {
  476. preventClick: true
  477. };
  478. // clone event first
  479. var _event = originalPointerUpEvent.clone();
  480. // drop should fire before dragend
  481. // @see https://javascript.tutorialink.com/is-there-a-defined-ordering-between-dragend-and-drop-events/
  482. if (currentDroppable) {
  483. // @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/drop_event
  484. _event.type = 'drop';
  485. _event.target = currentDroppable;
  486. currentDroppable.dispatchEvent(_event);
  487. }
  488. // @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/dragend_event
  489. _event.type = 'dragend';
  490. draggableEventTarget.dispatchEvent(_event);
  491. dragstartTriggered = false;
  492. }
  493. canvas.removeEventListener('pointermove', handlePointermove);
  494. };
  495. target.addEventListener('pointerup', stopDragging, {
  496. once: true
  497. });
  498. target.addEventListener('pointerupoutside', stopDragging, {
  499. once: true
  500. });
  501. }
  502. };
  503. renderingService.hooks.init.tap(DragndropPlugin.tag, function () {
  504. canvas.addEventListener('pointerdown', handlePointerdown);
  505. });
  506. renderingService.hooks.destroy.tap(DragndropPlugin.tag, function () {
  507. canvas.removeEventListener('pointerdown', handlePointerdown);
  508. });
  509. };
  510. return DragndropPlugin;
  511. }();
  512. DragndropPlugin.tag = 'Dragndrop';
  513. var Plugin = /*#__PURE__*/function (_AbstractRendererPlug) {
  514. _inheritsLoose(Plugin, _AbstractRendererPlug);
  515. function Plugin(options) {
  516. var _this;
  517. if (options === void 0) {
  518. options = {};
  519. }
  520. _this = _AbstractRendererPlug.call(this) || this;
  521. _this.options = void 0;
  522. _this.name = 'dragndrop';
  523. _this.options = options;
  524. return _this;
  525. }
  526. var _proto = Plugin.prototype;
  527. _proto.init = function init() {
  528. this.addRenderingPlugin(new DragndropPlugin(_extends({
  529. overlap: 'pointer',
  530. isDocumentDraggable: false,
  531. isDocumentDroppable: false,
  532. dragstartDistanceThreshold: 0,
  533. dragstartTimeThreshold: 0
  534. }, this.options)));
  535. };
  536. _proto.destroy = function destroy() {
  537. this.removeAllRenderingPlugins();
  538. };
  539. _proto.setOptions = function setOptions(options) {
  540. Object.assign(this.plugins[0].dragndropPluginOptions, options);
  541. };
  542. return Plugin;
  543. }(gLite.AbstractRendererPlugin);
  544. exports.Plugin = Plugin;
  545. Object.defineProperty(exports, '__esModule', { value: true });
  546. })));