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