index.js 23 KB

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