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