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