@antv/g-plugin-dragndrop 1.0.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018 AntV team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,15 @@
1
+ # @antv/g-plugin-dragndrop
2
+
3
+ Orbit control with Hammer.js.
4
+
5
+ ## Getting Started
6
+
7
+ ```js
8
+ import { Plugin } from '@antv/g-plugin-dragndrop';
9
+
10
+ // create a renderer
11
+ const canvasRenderer = new CanvasRenderer();
12
+
13
+ // register Control plugin
14
+ canvasRenderer.registerPlugin(new Plugin());
15
+ ```
@@ -0,0 +1,10 @@
1
+ import type { RenderingPlugin, RenderingService } from '@antv/g';
2
+ import { SceneGraphService } from '@antv/g';
3
+ export declare class DragndropPlugin implements RenderingPlugin {
4
+ static tag: string;
5
+ protected sceneGraphService: SceneGraphService;
6
+ private renderingContext;
7
+ private dragndropPluginOptions;
8
+ apply(renderingService: RenderingService): void;
9
+ }
10
+ //# sourceMappingURL=DragndropPlugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DragndropPlugin.d.ts","sourceRoot":"","sources":["../src/DragndropPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,eAAe,EACf,gBAAgB,EACjB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAiD,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAI3F,qBACa,eAAgB,YAAW,eAAe;IACrD,MAAM,CAAC,GAAG,SAAe;IAGzB,SAAS,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;IAG/C,OAAO,CAAC,gBAAgB,CAAmB;IAG3C,OAAO,CAAC,sBAAsB,CAAyB;IAEvD,KAAK,CAAC,gBAAgB,EAAE,gBAAgB;CAmGzC"}
@@ -0,0 +1,11 @@
1
+ import type { RendererPlugin } from '@antv/g';
2
+ import type { Syringe } from 'mana-syringe';
3
+ import { DragndropPluginOptions } from './tokens';
4
+ export declare class Plugin implements RendererPlugin {
5
+ private options;
6
+ name: string;
7
+ constructor(options: Partial<DragndropPluginOptions>);
8
+ init(container: Syringe.Container): void;
9
+ destroy(container: Syringe.Container): void;
10
+ }
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAC9C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAG5C,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAMlD,qBAAa,MAAO,YAAW,cAAc;IAG/B,OAAO,CAAC,OAAO;IAF3B,IAAI,SAAe;gBAEC,OAAO,EAAE,OAAO,CAAC,sBAAsB,CAAC;IAE5D,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,SAAS,GAAG,IAAI;IASxC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,SAAS,GAAG,IAAI;CAI5C"}
@@ -0,0 +1,594 @@
1
+ import { Syringe, inject, singleton, Module } from 'mana-syringe';
2
+ import { __decorate, __metadata } from 'tslib';
3
+ import { SceneGraphService, RenderingContext, RenderingPluginContribution } from '@antv/g';
4
+
5
+ function _regeneratorRuntime() {
6
+ /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
7
+
8
+ _regeneratorRuntime = function () {
9
+ return exports;
10
+ };
11
+
12
+ var exports = {},
13
+ Op = Object.prototype,
14
+ hasOwn = Op.hasOwnProperty,
15
+ $Symbol = "function" == typeof Symbol ? Symbol : {},
16
+ iteratorSymbol = $Symbol.iterator || "@@iterator",
17
+ asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
18
+ toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
19
+
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
+
29
+ try {
30
+ define({}, "");
31
+ } catch (err) {
32
+ define = function (obj, key, value) {
33
+ return obj[key] = value;
34
+ };
35
+ }
36
+
37
+ function wrap(innerFn, outerFn, self, tryLocsList) {
38
+ var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
39
+ generator = Object.create(protoGenerator.prototype),
40
+ context = new Context(tryLocsList || []);
41
+ return generator._invoke = function (innerFn, self, context) {
42
+ var state = "suspendedStart";
43
+ return function (method, arg) {
44
+ if ("executing" === state) throw new Error("Generator is already running");
45
+
46
+ if ("completed" === state) {
47
+ if ("throw" === method) throw arg;
48
+ return doneResult();
49
+ }
50
+
51
+ for (context.method = method, context.arg = arg;;) {
52
+ var delegate = context.delegate;
53
+
54
+ if (delegate) {
55
+ var delegateResult = maybeInvokeDelegate(delegate, context);
56
+
57
+ if (delegateResult) {
58
+ if (delegateResult === ContinueSentinel) continue;
59
+ return delegateResult;
60
+ }
61
+ }
62
+
63
+ if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
64
+ if ("suspendedStart" === state) throw state = "completed", context.arg;
65
+ context.dispatchException(context.arg);
66
+ } else "return" === context.method && context.abrupt("return", context.arg);
67
+ state = "executing";
68
+ var record = tryCatch(innerFn, self, context);
69
+
70
+ if ("normal" === record.type) {
71
+ if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
72
+ return {
73
+ value: record.arg,
74
+ done: context.done
75
+ };
76
+ }
77
+
78
+ "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
79
+ }
80
+ };
81
+ }(innerFn, self, context), generator;
82
+ }
83
+
84
+ function tryCatch(fn, obj, arg) {
85
+ try {
86
+ return {
87
+ type: "normal",
88
+ arg: fn.call(obj, arg)
89
+ };
90
+ } catch (err) {
91
+ return {
92
+ type: "throw",
93
+ arg: err
94
+ };
95
+ }
96
+ }
97
+
98
+ exports.wrap = wrap;
99
+ var ContinueSentinel = {};
100
+
101
+ function Generator() {}
102
+
103
+ function GeneratorFunction() {}
104
+
105
+ function GeneratorFunctionPrototype() {}
106
+
107
+ var IteratorPrototype = {};
108
+ define(IteratorPrototype, iteratorSymbol, function () {
109
+ return this;
110
+ });
111
+ var getProto = Object.getPrototypeOf,
112
+ NativeIteratorPrototype = getProto && getProto(getProto(values([])));
113
+ NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
114
+ var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
115
+
116
+ function defineIteratorMethods(prototype) {
117
+ ["next", "throw", "return"].forEach(function (method) {
118
+ define(prototype, method, function (arg) {
119
+ return this._invoke(method, arg);
120
+ });
121
+ });
122
+ }
123
+
124
+ function AsyncIterator(generator, PromiseImpl) {
125
+ function invoke(method, arg, resolve, reject) {
126
+ var record = tryCatch(generator[method], generator, arg);
127
+
128
+ if ("throw" !== record.type) {
129
+ var result = record.arg,
130
+ value = result.value;
131
+ return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
132
+ invoke("next", value, resolve, reject);
133
+ }, function (err) {
134
+ invoke("throw", err, resolve, reject);
135
+ }) : PromiseImpl.resolve(value).then(function (unwrapped) {
136
+ result.value = unwrapped, resolve(result);
137
+ }, function (error) {
138
+ return invoke("throw", error, resolve, reject);
139
+ });
140
+ }
141
+
142
+ reject(record.arg);
143
+ }
144
+
145
+ var previousPromise;
146
+
147
+ this._invoke = function (method, arg) {
148
+ function callInvokeWithMethodAndArg() {
149
+ return new PromiseImpl(function (resolve, reject) {
150
+ invoke(method, arg, resolve, reject);
151
+ });
152
+ }
153
+
154
+ return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
155
+ };
156
+ }
157
+
158
+ function maybeInvokeDelegate(delegate, context) {
159
+ var method = delegate.iterator[context.method];
160
+
161
+ if (undefined === method) {
162
+ if (context.delegate = null, "throw" === context.method) {
163
+ if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
164
+ context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
165
+ }
166
+
167
+ return ContinueSentinel;
168
+ }
169
+
170
+ var record = tryCatch(method, delegate.iterator, context.arg);
171
+ if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
172
+ var info = record.arg;
173
+ 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);
174
+ }
175
+
176
+ function pushTryEntry(locs) {
177
+ var entry = {
178
+ tryLoc: locs[0]
179
+ };
180
+ 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
181
+ }
182
+
183
+ function resetTryEntry(entry) {
184
+ var record = entry.completion || {};
185
+ record.type = "normal", delete record.arg, entry.completion = record;
186
+ }
187
+
188
+ function Context(tryLocsList) {
189
+ this.tryEntries = [{
190
+ tryLoc: "root"
191
+ }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
192
+ }
193
+
194
+ function values(iterable) {
195
+ if (iterable) {
196
+ var iteratorMethod = iterable[iteratorSymbol];
197
+ if (iteratorMethod) return iteratorMethod.call(iterable);
198
+ if ("function" == typeof iterable.next) return iterable;
199
+
200
+ if (!isNaN(iterable.length)) {
201
+ var i = -1,
202
+ next = function next() {
203
+ for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
204
+
205
+ return next.value = undefined, next.done = !0, next;
206
+ };
207
+
208
+ return next.next = next;
209
+ }
210
+ }
211
+
212
+ return {
213
+ next: doneResult
214
+ };
215
+ }
216
+
217
+ function doneResult() {
218
+ return {
219
+ value: undefined,
220
+ done: !0
221
+ };
222
+ }
223
+
224
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
225
+ var ctor = "function" == typeof genFun && genFun.constructor;
226
+ return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
227
+ }, exports.mark = function (genFun) {
228
+ return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
229
+ }, exports.awrap = function (arg) {
230
+ return {
231
+ __await: arg
232
+ };
233
+ }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
234
+ return this;
235
+ }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
236
+ void 0 === PromiseImpl && (PromiseImpl = Promise);
237
+ var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
238
+ return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
239
+ return result.done ? result.value : iter.next();
240
+ });
241
+ }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
242
+ return this;
243
+ }), define(Gp, "toString", function () {
244
+ return "[object Generator]";
245
+ }), exports.keys = function (object) {
246
+ var keys = [];
247
+
248
+ for (var key in object) keys.push(key);
249
+
250
+ return keys.reverse(), function next() {
251
+ for (; keys.length;) {
252
+ var key = keys.pop();
253
+ if (key in object) return next.value = key, next.done = !1, next;
254
+ }
255
+
256
+ return next.done = !0, next;
257
+ };
258
+ }, exports.values = values, Context.prototype = {
259
+ constructor: Context,
260
+ reset: function (skipTempReset) {
261
+ 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);
262
+ },
263
+ stop: function () {
264
+ this.done = !0;
265
+ var rootRecord = this.tryEntries[0].completion;
266
+ if ("throw" === rootRecord.type) throw rootRecord.arg;
267
+ return this.rval;
268
+ },
269
+ dispatchException: function (exception) {
270
+ if (this.done) throw exception;
271
+ var context = this;
272
+
273
+ function handle(loc, caught) {
274
+ return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
275
+ }
276
+
277
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
278
+ var entry = this.tryEntries[i],
279
+ record = entry.completion;
280
+ if ("root" === entry.tryLoc) return handle("end");
281
+
282
+ if (entry.tryLoc <= this.prev) {
283
+ var hasCatch = hasOwn.call(entry, "catchLoc"),
284
+ hasFinally = hasOwn.call(entry, "finallyLoc");
285
+
286
+ if (hasCatch && hasFinally) {
287
+ if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
288
+ if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
289
+ } else if (hasCatch) {
290
+ if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
291
+ } else {
292
+ if (!hasFinally) throw new Error("try statement without catch or finally");
293
+ if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
294
+ }
295
+ }
296
+ }
297
+ },
298
+ abrupt: function (type, arg) {
299
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
300
+ var entry = this.tryEntries[i];
301
+
302
+ if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
303
+ var finallyEntry = entry;
304
+ break;
305
+ }
306
+ }
307
+
308
+ finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
309
+ var record = finallyEntry ? finallyEntry.completion : {};
310
+ return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
311
+ },
312
+ complete: function (record, afterLoc) {
313
+ if ("throw" === record.type) throw record.arg;
314
+ 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;
315
+ },
316
+ finish: function (finallyLoc) {
317
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
318
+ var entry = this.tryEntries[i];
319
+ if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
320
+ }
321
+ },
322
+ catch: function (tryLoc) {
323
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
324
+ var entry = this.tryEntries[i];
325
+
326
+ if (entry.tryLoc === tryLoc) {
327
+ var record = entry.completion;
328
+
329
+ if ("throw" === record.type) {
330
+ var thrown = record.arg;
331
+ resetTryEntry(entry);
332
+ }
333
+
334
+ return thrown;
335
+ }
336
+ }
337
+
338
+ throw new Error("illegal catch attempt");
339
+ },
340
+ delegateYield: function (iterable, resultName, nextLoc) {
341
+ return this.delegate = {
342
+ iterator: values(iterable),
343
+ resultName: resultName,
344
+ nextLoc: nextLoc
345
+ }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
346
+ }
347
+ }, exports;
348
+ }
349
+
350
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
351
+ try {
352
+ var info = gen[key](arg);
353
+ var value = info.value;
354
+ } catch (error) {
355
+ reject(error);
356
+ return;
357
+ }
358
+
359
+ if (info.done) {
360
+ resolve(value);
361
+ } else {
362
+ Promise.resolve(value).then(_next, _throw);
363
+ }
364
+ }
365
+
366
+ function _asyncToGenerator(fn) {
367
+ return function () {
368
+ var self = this,
369
+ args = arguments;
370
+ return new Promise(function (resolve, reject) {
371
+ var gen = fn.apply(self, args);
372
+
373
+ function _next(value) {
374
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
375
+ }
376
+
377
+ function _throw(err) {
378
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
379
+ }
380
+
381
+ _next(undefined);
382
+ });
383
+ };
384
+ }
385
+
386
+ function _extends() {
387
+ _extends = Object.assign || function (target) {
388
+ for (var i = 1; i < arguments.length; i++) {
389
+ var source = arguments[i];
390
+
391
+ for (var key in source) {
392
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
393
+ target[key] = source[key];
394
+ }
395
+ }
396
+ }
397
+
398
+ return target;
399
+ };
400
+
401
+ return _extends.apply(this, arguments);
402
+ }
403
+
404
+ var DragndropPluginOptions = Syringe.defineToken('DragndropPluginOptions');
405
+
406
+ var _class;
407
+
408
+ var DragndropPlugin_1;
409
+ var DragndropPlugin = DragndropPlugin_1 = (_class = /*#__PURE__*/function () {
410
+ function DragndropPlugin() {
411
+ this.sceneGraphService = void 0;
412
+ this.renderingContext = void 0;
413
+ this.dragndropPluginOptions = void 0;
414
+ }
415
+
416
+ var _proto = DragndropPlugin.prototype;
417
+
418
+ _proto.apply = function apply(renderingService) {
419
+ var _this = this;
420
+
421
+ var document = this.renderingContext.root.ownerDocument;
422
+ var overlap = this.dragndropPluginOptions.overlap;
423
+
424
+ var handlePointerdown = function handlePointerdown(event) {
425
+ var target = event.target;
426
+
427
+ if (target.getAttribute('draggable')) {
428
+ // @ts-ignore
429
+ var moveAt = function moveAt(canvasX, canvasY) {
430
+ target.setPosition(canvasX - shiftX, canvasY - shiftY);
431
+ };
432
+
433
+ // @ts-ignore
434
+ var onMouseMove = /*#__PURE__*/function () {
435
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(event) {
436
+ var pointerEventsOldValue, point, elemBelow, droppableBelow;
437
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
438
+ while (1) {
439
+ switch (_context.prev = _context.next) {
440
+ case 0:
441
+ // @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/drag_event
442
+ event.type = 'drag';
443
+ target.dispatchEvent(event);
444
+ moveAt(event.canvasX, event.canvasY); // prevent from picking the dragging element
445
+
446
+ pointerEventsOldValue = target.style.pointerEvents;
447
+ target.style.pointerEvents = 'none';
448
+ point = overlap === 'pointer' ? [event.canvasX, event.canvasY] : target.getBounds().center;
449
+ _context.next = 8;
450
+ return document.elementFromPoint(point[0], point[1]);
451
+
452
+ case 8:
453
+ elemBelow = _context.sent;
454
+ target.style.pointerEvents = pointerEventsOldValue;
455
+
456
+ if (elemBelow) {
457
+ _context.next = 12;
458
+ break;
459
+ }
460
+
461
+ return _context.abrupt("return");
462
+
463
+ case 12:
464
+ droppableBelow = elemBelow.closest('[droppable=true]');
465
+
466
+ if (currentDroppable !== droppableBelow) {
467
+ if (currentDroppable) {
468
+ // null when we were not over a droppable before this event
469
+ // @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/dragleave_event
470
+ event.type = 'dragleave';
471
+ event.target = currentDroppable;
472
+ currentDroppable.dispatchEvent(event);
473
+ }
474
+
475
+ if (droppableBelow) {
476
+ // @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/dragleave_event
477
+ event.type = 'dragenter';
478
+ event.target = droppableBelow;
479
+ droppableBelow.dispatchEvent(event);
480
+ }
481
+
482
+ currentDroppable = droppableBelow;
483
+
484
+ if (currentDroppable) {
485
+ // null if we're not coming over a droppable now
486
+ // @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/dragover_event
487
+ event.type = 'dragover';
488
+ event.target = currentDroppable;
489
+ currentDroppable.dispatchEvent(event);
490
+ }
491
+ }
492
+
493
+ case 14:
494
+ case "end":
495
+ return _context.stop();
496
+ }
497
+ }
498
+ }, _callee);
499
+ }));
500
+
501
+ return function onMouseMove(_x) {
502
+ return _ref.apply(this, arguments);
503
+ };
504
+ }();
505
+
506
+ // @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/dragstart_event
507
+ event.type = 'dragstart';
508
+ target.dispatchEvent(event);
509
+ var shiftX = event.clientX - target.getBoundingClientRect().left;
510
+ var shiftY = event.clientY - target.getBoundingClientRect().top;
511
+ moveAt(event.canvasX, event.canvasY);
512
+ var currentDroppable = null;
513
+ document.addEventListener('pointermove', onMouseMove);
514
+ target.addEventListener('pointerup', function () {
515
+ // @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/dragend_event
516
+ event.type = 'dragend';
517
+ target.dispatchEvent(event);
518
+
519
+ if (currentDroppable) {
520
+ // @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/drop_event
521
+ event.type = 'drop';
522
+ event.target = currentDroppable;
523
+ currentDroppable.dispatchEvent(event);
524
+ }
525
+
526
+ document.removeEventListener('pointermove', onMouseMove);
527
+ }, {
528
+ once: true
529
+ });
530
+ }
531
+ };
532
+
533
+ renderingService.hooks.init.tapPromise(DragndropPlugin_1.tag, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
534
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
535
+ while (1) {
536
+ switch (_context2.prev = _context2.next) {
537
+ case 0:
538
+ _this.renderingContext.root.addEventListener('pointerdown', handlePointerdown);
539
+
540
+ case 1:
541
+ case "end":
542
+ return _context2.stop();
543
+ }
544
+ }
545
+ }, _callee2);
546
+ })));
547
+ renderingService.hooks.destroy.tap(DragndropPlugin_1.tag, function () {
548
+ _this.renderingContext.root.removeEventListener('pointerdown', handlePointerdown);
549
+ });
550
+ };
551
+
552
+ return DragndropPlugin;
553
+ }(), _class.tag = 'Dragndrop', _class);
554
+
555
+ __decorate([inject(SceneGraphService), __metadata("design:type", Object)], DragndropPlugin.prototype, "sceneGraphService", void 0);
556
+
557
+ __decorate([inject(RenderingContext), __metadata("design:type", Object)], DragndropPlugin.prototype, "renderingContext", void 0);
558
+
559
+ __decorate([inject(DragndropPluginOptions), __metadata("design:type", Object)], DragndropPlugin.prototype, "dragndropPluginOptions", void 0);
560
+
561
+ DragndropPlugin = DragndropPlugin_1 = __decorate([singleton({
562
+ contrib: RenderingPluginContribution
563
+ })], DragndropPlugin);
564
+
565
+ var containerModule = Module(function (register) {
566
+ register(DragndropPlugin);
567
+ });
568
+ var Plugin = /*#__PURE__*/function () {
569
+ function Plugin(options) {
570
+ this.options = void 0;
571
+ this.name = 'dragndrop';
572
+ this.options = options;
573
+ }
574
+
575
+ var _proto = Plugin.prototype;
576
+
577
+ _proto.init = function init(container) {
578
+ container.register(DragndropPluginOptions, {
579
+ useValue: _extends({
580
+ overlap: 'pointer'
581
+ }, this.options)
582
+ });
583
+ container.load(containerModule, true);
584
+ };
585
+
586
+ _proto.destroy = function destroy(container) {
587
+ container.remove(DragndropPluginOptions);
588
+ container.unload(containerModule);
589
+ };
590
+
591
+ return Plugin;
592
+ }();
593
+
594
+ export { Plugin };