dragselect 2.5.5 → 2.5.6
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/CHANGELOG.md +4 -0
- package/deployment.md +32 -0
- package/dist/DragSelect.es6m.js +171 -98
- package/dist/DragSelect.js +172 -99
- package/dist/ds.es6m.min.js +1 -1
- package/dist/ds.min.js +1 -1
- package/package.json +15 -20
- package/rollup.config.js +1 -34
- package/src/DragSelect.js +1 -1
- package/CODE_OF_CONDUCT.md +0 -128
- package/CONTRIBUTING.md +0 -48
- package/LICENSE +0 -21
- package/README.md +0 -478
- package/deploying.md +0 -36
package/dist/DragSelect.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/***
|
|
2
2
|
|
|
3
|
-
~~~ Version 2.5.
|
|
3
|
+
~~~ Version 2.5.6 ~~~
|
|
4
4
|
|
|
5
5
|
******************************************
|
|
6
6
|
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
********* The MIT License (MIT) **********
|
|
26
26
|
******************************************
|
|
27
27
|
Created 2017 by ThibaultJanBeyer
|
|
28
|
-
web: http://www.
|
|
28
|
+
web: http://www.DragSelect.com/
|
|
29
29
|
github: https://github.com/ThibaultJanBeyer/DragSelect
|
|
30
30
|
|
|
31
31
|
*/
|
|
@@ -33,8 +33,56 @@
|
|
|
33
33
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
34
34
|
typeof define === 'function' && define.amd ? define(factory) :
|
|
35
35
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.DragSelect = factory());
|
|
36
|
-
}(this, (function () { 'use strict';
|
|
36
|
+
})(this, (function () { 'use strict';
|
|
37
37
|
|
|
38
|
+
function _iterableToArrayLimit(arr, i) {
|
|
39
|
+
var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
|
|
40
|
+
if (null != _i) {
|
|
41
|
+
var _s,
|
|
42
|
+
_e,
|
|
43
|
+
_x,
|
|
44
|
+
_r,
|
|
45
|
+
_arr = [],
|
|
46
|
+
_n = !0,
|
|
47
|
+
_d = !1;
|
|
48
|
+
try {
|
|
49
|
+
if (_x = (_i = _i.call(arr)).next, 0 === i) {
|
|
50
|
+
if (Object(_i) !== _i) return;
|
|
51
|
+
_n = !1;
|
|
52
|
+
} else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);
|
|
53
|
+
} catch (err) {
|
|
54
|
+
_d = !0, _e = err;
|
|
55
|
+
} finally {
|
|
56
|
+
try {
|
|
57
|
+
if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return;
|
|
58
|
+
} finally {
|
|
59
|
+
if (_d) throw _e;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return _arr;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function ownKeys(object, enumerableOnly) {
|
|
66
|
+
var keys = Object.keys(object);
|
|
67
|
+
if (Object.getOwnPropertySymbols) {
|
|
68
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
69
|
+
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
70
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
71
|
+
})), keys.push.apply(keys, symbols);
|
|
72
|
+
}
|
|
73
|
+
return keys;
|
|
74
|
+
}
|
|
75
|
+
function _objectSpread2(target) {
|
|
76
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
77
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
78
|
+
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
|
|
79
|
+
_defineProperty(target, key, source[key]);
|
|
80
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
|
|
81
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
return target;
|
|
85
|
+
}
|
|
38
86
|
function _classCallCheck(instance, Constructor) {
|
|
39
87
|
if (!(instance instanceof Constructor)) {
|
|
40
88
|
throw new TypeError("Cannot call a class as a function");
|
|
@@ -46,15 +94,19 @@
|
|
|
46
94
|
descriptor.enumerable = descriptor.enumerable || false;
|
|
47
95
|
descriptor.configurable = true;
|
|
48
96
|
if ("value" in descriptor) descriptor.writable = true;
|
|
49
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
97
|
+
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
|
50
98
|
}
|
|
51
99
|
}
|
|
52
100
|
function _createClass(Constructor, protoProps, staticProps) {
|
|
53
101
|
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
54
102
|
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
103
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
104
|
+
writable: false
|
|
105
|
+
});
|
|
55
106
|
return Constructor;
|
|
56
107
|
}
|
|
57
108
|
function _defineProperty(obj, key, value) {
|
|
109
|
+
key = _toPropertyKey(key);
|
|
58
110
|
if (key in obj) {
|
|
59
111
|
Object.defineProperty(obj, key, {
|
|
60
112
|
value: value,
|
|
@@ -67,34 +119,6 @@
|
|
|
67
119
|
}
|
|
68
120
|
return obj;
|
|
69
121
|
}
|
|
70
|
-
function ownKeys(object, enumerableOnly) {
|
|
71
|
-
var keys = Object.keys(object);
|
|
72
|
-
if (Object.getOwnPropertySymbols) {
|
|
73
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
74
|
-
if (enumerableOnly) symbols = symbols.filter(function (sym) {
|
|
75
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
76
|
-
});
|
|
77
|
-
keys.push.apply(keys, symbols);
|
|
78
|
-
}
|
|
79
|
-
return keys;
|
|
80
|
-
}
|
|
81
|
-
function _objectSpread2(target) {
|
|
82
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
83
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
84
|
-
if (i % 2) {
|
|
85
|
-
ownKeys(Object(source), true).forEach(function (key) {
|
|
86
|
-
_defineProperty(target, key, source[key]);
|
|
87
|
-
});
|
|
88
|
-
} else if (Object.getOwnPropertyDescriptors) {
|
|
89
|
-
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
90
|
-
} else {
|
|
91
|
-
ownKeys(Object(source)).forEach(function (key) {
|
|
92
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
return target;
|
|
97
|
-
}
|
|
98
122
|
function _inherits(subClass, superClass) {
|
|
99
123
|
if (typeof superClass !== "function" && superClass !== null) {
|
|
100
124
|
throw new TypeError("Super expression must either be null or a function");
|
|
@@ -106,16 +130,19 @@
|
|
|
106
130
|
configurable: true
|
|
107
131
|
}
|
|
108
132
|
});
|
|
133
|
+
Object.defineProperty(subClass, "prototype", {
|
|
134
|
+
writable: false
|
|
135
|
+
});
|
|
109
136
|
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
110
137
|
}
|
|
111
138
|
function _getPrototypeOf(o) {
|
|
112
|
-
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
|
139
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
|
113
140
|
return o.__proto__ || Object.getPrototypeOf(o);
|
|
114
141
|
};
|
|
115
142
|
return _getPrototypeOf(o);
|
|
116
143
|
}
|
|
117
144
|
function _setPrototypeOf(o, p) {
|
|
118
|
-
_setPrototypeOf = Object.setPrototypeOf
|
|
145
|
+
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
119
146
|
o.__proto__ = p;
|
|
120
147
|
return o;
|
|
121
148
|
};
|
|
@@ -126,7 +153,7 @@
|
|
|
126
153
|
if (Reflect.construct.sham) return false;
|
|
127
154
|
if (typeof Proxy === "function") return true;
|
|
128
155
|
try {
|
|
129
|
-
|
|
156
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
130
157
|
return true;
|
|
131
158
|
} catch (e) {
|
|
132
159
|
return false;
|
|
@@ -134,7 +161,7 @@
|
|
|
134
161
|
}
|
|
135
162
|
function _construct(Parent, args, Class) {
|
|
136
163
|
if (_isNativeReflectConstruct()) {
|
|
137
|
-
_construct = Reflect.construct;
|
|
164
|
+
_construct = Reflect.construct.bind();
|
|
138
165
|
} else {
|
|
139
166
|
_construct = function _construct(Parent, args, Class) {
|
|
140
167
|
var a = [null];
|
|
@@ -185,6 +212,8 @@
|
|
|
185
212
|
function _possibleConstructorReturn(self, call) {
|
|
186
213
|
if (call && (typeof call === "object" || typeof call === "function")) {
|
|
187
214
|
return call;
|
|
215
|
+
} else if (call !== void 0) {
|
|
216
|
+
throw new TypeError("Derived constructors may only return object or undefined");
|
|
188
217
|
}
|
|
189
218
|
return _assertThisInitialized(self);
|
|
190
219
|
}
|
|
@@ -209,21 +238,21 @@
|
|
|
209
238
|
}
|
|
210
239
|
return object;
|
|
211
240
|
}
|
|
212
|
-
function _get(
|
|
241
|
+
function _get() {
|
|
213
242
|
if (typeof Reflect !== "undefined" && Reflect.get) {
|
|
214
|
-
_get = Reflect.get;
|
|
243
|
+
_get = Reflect.get.bind();
|
|
215
244
|
} else {
|
|
216
245
|
_get = function _get(target, property, receiver) {
|
|
217
246
|
var base = _superPropBase(target, property);
|
|
218
247
|
if (!base) return;
|
|
219
248
|
var desc = Object.getOwnPropertyDescriptor(base, property);
|
|
220
249
|
if (desc.get) {
|
|
221
|
-
return desc.get.call(receiver);
|
|
250
|
+
return desc.get.call(arguments.length < 3 ? target : receiver);
|
|
222
251
|
}
|
|
223
252
|
return desc.value;
|
|
224
253
|
};
|
|
225
254
|
}
|
|
226
|
-
return _get(
|
|
255
|
+
return _get.apply(this, arguments);
|
|
227
256
|
}
|
|
228
257
|
function _slicedToArray(arr, i) {
|
|
229
258
|
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
@@ -238,30 +267,7 @@
|
|
|
238
267
|
if (Array.isArray(arr)) return arr;
|
|
239
268
|
}
|
|
240
269
|
function _iterableToArray(iter) {
|
|
241
|
-
if (typeof Symbol !== "undefined" && Symbol.iterator
|
|
242
|
-
}
|
|
243
|
-
function _iterableToArrayLimit(arr, i) {
|
|
244
|
-
if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
|
|
245
|
-
var _arr = [];
|
|
246
|
-
var _n = true;
|
|
247
|
-
var _d = false;
|
|
248
|
-
var _e = undefined;
|
|
249
|
-
try {
|
|
250
|
-
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
|
|
251
|
-
_arr.push(_s.value);
|
|
252
|
-
if (i && _arr.length === i) break;
|
|
253
|
-
}
|
|
254
|
-
} catch (err) {
|
|
255
|
-
_d = true;
|
|
256
|
-
_e = err;
|
|
257
|
-
} finally {
|
|
258
|
-
try {
|
|
259
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
260
|
-
} finally {
|
|
261
|
-
if (_d) throw _e;
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
return _arr;
|
|
270
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
265
271
|
}
|
|
266
272
|
function _unsupportedIterableToArray(o, minLen) {
|
|
267
273
|
if (!o) return;
|
|
@@ -283,8 +289,8 @@
|
|
|
283
289
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
284
290
|
}
|
|
285
291
|
function _createForOfIteratorHelper(o, allowArrayLike) {
|
|
286
|
-
var it;
|
|
287
|
-
if (
|
|
292
|
+
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
293
|
+
if (!it) {
|
|
288
294
|
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
289
295
|
if (it) o = it;
|
|
290
296
|
var i = 0;
|
|
@@ -313,7 +319,7 @@
|
|
|
313
319
|
err;
|
|
314
320
|
return {
|
|
315
321
|
s: function () {
|
|
316
|
-
it =
|
|
322
|
+
it = it.call(o);
|
|
317
323
|
},
|
|
318
324
|
n: function () {
|
|
319
325
|
var step = it.next();
|
|
@@ -333,6 +339,20 @@
|
|
|
333
339
|
}
|
|
334
340
|
};
|
|
335
341
|
}
|
|
342
|
+
function _toPrimitive(input, hint) {
|
|
343
|
+
if (typeof input !== "object" || input === null) return input;
|
|
344
|
+
var prim = input[Symbol.toPrimitive];
|
|
345
|
+
if (prim !== undefined) {
|
|
346
|
+
var res = prim.call(input, hint || "default");
|
|
347
|
+
if (typeof res !== "object") return res;
|
|
348
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
349
|
+
}
|
|
350
|
+
return (hint === "string" ? String : Number)(input);
|
|
351
|
+
}
|
|
352
|
+
function _toPropertyKey(arg) {
|
|
353
|
+
var key = _toPrimitive(arg, "string");
|
|
354
|
+
return typeof key === "symbol" ? key : String(key);
|
|
355
|
+
}
|
|
336
356
|
|
|
337
357
|
/**
|
|
338
358
|
* The Settings to be passed to the Class
|
|
@@ -1558,12 +1578,15 @@
|
|
|
1558
1578
|
/** @param {DSArea} area */
|
|
1559
1579
|
_createClass(Area, [{
|
|
1560
1580
|
key: "HTMLNode",
|
|
1581
|
+
get:
|
|
1561
1582
|
/// ///////////////////////////////////////////////////////////////////////////////////
|
|
1562
1583
|
// Node Getters
|
|
1563
|
-
|
|
1584
|
+
|
|
1585
|
+
function get() {
|
|
1564
1586
|
return (/** @type {DSArea} */this._node
|
|
1565
1587
|
);
|
|
1566
1588
|
}
|
|
1589
|
+
|
|
1567
1590
|
/**
|
|
1568
1591
|
* The computed border from the element (caches result)
|
|
1569
1592
|
* @type {{top:number,bottom:number,left:number,right:number}}
|
|
@@ -1579,6 +1602,7 @@
|
|
|
1579
1602
|
right: parseInt(this.computedStyle.borderRightWidth)
|
|
1580
1603
|
};
|
|
1581
1604
|
}
|
|
1605
|
+
|
|
1582
1606
|
/**
|
|
1583
1607
|
* The computed styles from the element (caches result)
|
|
1584
1608
|
* @type {CSSStyleDeclaration}
|
|
@@ -1590,6 +1614,7 @@
|
|
|
1590
1614
|
if (this.HTMLNode instanceof Document) return this._computedStyle = window.getComputedStyle(this.HTMLNode.body || this.HTMLNode.documentElement);
|
|
1591
1615
|
return this._computedStyle = window.getComputedStyle(this.HTMLNode);
|
|
1592
1616
|
}
|
|
1617
|
+
|
|
1593
1618
|
/**
|
|
1594
1619
|
* The element rect (caches result) (without scrollbar or borders)
|
|
1595
1620
|
* @type {DSBoundingRect}
|
|
@@ -1967,6 +1992,7 @@
|
|
|
1967
1992
|
this._itemsInside = null;
|
|
1968
1993
|
this.isDestroyed = true;
|
|
1969
1994
|
}
|
|
1995
|
+
|
|
1970
1996
|
/**
|
|
1971
1997
|
* @returns {DSDropZone}
|
|
1972
1998
|
*/
|
|
@@ -2020,7 +2046,7 @@
|
|
|
2020
2046
|
return DropZone;
|
|
2021
2047
|
}();
|
|
2022
2048
|
|
|
2023
|
-
var DropZones =
|
|
2049
|
+
var DropZones = /*#__PURE__*/_createClass(
|
|
2024
2050
|
/**
|
|
2025
2051
|
* Get the drop zone by the zone element
|
|
2026
2052
|
* @type {Map<DSElement, DropZone>}
|
|
@@ -2149,7 +2175,7 @@
|
|
|
2149
2175
|
/**
|
|
2150
2176
|
* @param {Object} obj
|
|
2151
2177
|
* @param {DSDropZone[]} [obj.dropZones]
|
|
2152
|
-
|
|
2178
|
+
*/);
|
|
2153
2179
|
|
|
2154
2180
|
var Interaction = /*#__PURE__*/function () {
|
|
2155
2181
|
/** @type {boolean} */
|
|
@@ -2221,6 +2247,7 @@
|
|
|
2221
2247
|
var event = _ref2.event;
|
|
2222
2248
|
if (!_this._canInteract(event)) return;
|
|
2223
2249
|
if (event.detail > 0) return; // mouse interaction
|
|
2250
|
+
|
|
2224
2251
|
var _this$DS = _this.DS,
|
|
2225
2252
|
_this$DS$stores = _this$DS.stores,
|
|
2226
2253
|
PointerStore = _this$DS$stores.PointerStore,
|
|
@@ -2310,10 +2337,11 @@
|
|
|
2310
2337
|
}
|
|
2311
2338
|
_createClass(Interaction, [{
|
|
2312
2339
|
key: "_canInteract",
|
|
2340
|
+
value:
|
|
2313
2341
|
/**
|
|
2314
2342
|
* @param {DSEvent} event
|
|
2315
2343
|
*/
|
|
2316
|
-
|
|
2344
|
+
function _canInteract(event) {
|
|
2317
2345
|
var isKeyboardClick = /** @type {MouseEvent} */event.clientX === 0 && /** @type {MouseEvent} */event.clientY === 0 && /** @type {MouseEvent} */event.detail === 0 && event.target;
|
|
2318
2346
|
if ( /** @type {MouseEvent} */event.button === 2 ||
|
|
2319
2347
|
// right-clicks
|
|
@@ -2325,6 +2353,7 @@
|
|
|
2325
2353
|
) return false;
|
|
2326
2354
|
return true;
|
|
2327
2355
|
}
|
|
2356
|
+
|
|
2328
2357
|
/**
|
|
2329
2358
|
* @param {DSEvent} event
|
|
2330
2359
|
*/
|
|
@@ -2332,7 +2361,7 @@
|
|
|
2332
2361
|
return Interaction;
|
|
2333
2362
|
}();
|
|
2334
2363
|
|
|
2335
|
-
var PubSub = function PubSub(_ref) {
|
|
2364
|
+
var PubSub = /*#__PURE__*/_createClass(function PubSub(_ref) {
|
|
2336
2365
|
var _this = this;
|
|
2337
2366
|
var DS = _ref.DS;
|
|
2338
2367
|
_classCallCheck(this, PubSub);
|
|
@@ -2380,7 +2409,7 @@
|
|
|
2380
2409
|
* @param {DSCallbackNames} eventName
|
|
2381
2410
|
* @param {DSCallback} callback
|
|
2382
2411
|
* @returns {number} event id, can be used to unsubscribe more efficiently
|
|
2383
|
-
|
|
2412
|
+
*/);
|
|
2384
2413
|
|
|
2385
2414
|
var SelectableSet = /*#__PURE__*/function (_Set) {
|
|
2386
2415
|
_inherits(SelectableSet, _Set);
|
|
@@ -2457,7 +2486,8 @@
|
|
|
2457
2486
|
}
|
|
2458
2487
|
_createClass(SelectableSet, [{
|
|
2459
2488
|
key: "add",
|
|
2460
|
-
/** @param {DSElement} element */
|
|
2489
|
+
value: /** @param {DSElement} element */
|
|
2490
|
+
function add(element) {
|
|
2461
2491
|
if (_get(_getPrototypeOf(SelectableSet.prototype), "has", this).call(this, element)) return;
|
|
2462
2492
|
var publishData = {
|
|
2463
2493
|
items: this.elements,
|
|
@@ -2480,7 +2510,9 @@
|
|
|
2480
2510
|
});
|
|
2481
2511
|
this.DS.publish('Selectable:added', publishData);
|
|
2482
2512
|
return _get(_getPrototypeOf(SelectableSet.prototype), "add", this).call(this, element);
|
|
2483
|
-
}
|
|
2513
|
+
}
|
|
2514
|
+
|
|
2515
|
+
/** @param {DSElement} element */
|
|
2484
2516
|
}, {
|
|
2485
2517
|
key: "delete",
|
|
2486
2518
|
value: function _delete(element) {
|
|
@@ -2506,7 +2538,8 @@
|
|
|
2506
2538
|
}
|
|
2507
2539
|
}, {
|
|
2508
2540
|
key: "elements",
|
|
2509
|
-
/** @return {DSElements} */
|
|
2541
|
+
get: /** @return {DSElements} */
|
|
2542
|
+
function get() {
|
|
2510
2543
|
return Array.from(this.values());
|
|
2511
2544
|
}
|
|
2512
2545
|
}, {
|
|
@@ -2577,7 +2610,9 @@
|
|
|
2577
2610
|
element.style.zIndex = "".concat((parseInt(element.style.zIndex) || 0) + 1);
|
|
2578
2611
|
this.DS.publish('Selected:added', publishData);
|
|
2579
2612
|
return this;
|
|
2580
|
-
}
|
|
2613
|
+
}
|
|
2614
|
+
|
|
2615
|
+
/** @param {DSElement} element */
|
|
2581
2616
|
}, {
|
|
2582
2617
|
key: "delete",
|
|
2583
2618
|
value: function _delete(element) {
|
|
@@ -2595,18 +2630,22 @@
|
|
|
2595
2630
|
}
|
|
2596
2631
|
}, {
|
|
2597
2632
|
key: "toggle",
|
|
2633
|
+
value:
|
|
2598
2634
|
/**
|
|
2599
2635
|
* Adds/Removes an element. If it is already selected = remove, if not = add.
|
|
2600
2636
|
* @param {DSElement} element
|
|
2601
2637
|
* @return {DSElement}
|
|
2602
2638
|
*/
|
|
2603
|
-
|
|
2639
|
+
function toggle(element) {
|
|
2604
2640
|
if (this.has(element)) this["delete"](element);else this.add(element);
|
|
2605
2641
|
return element;
|
|
2606
|
-
}
|
|
2642
|
+
}
|
|
2643
|
+
|
|
2644
|
+
/** @param {DSElements} elements */
|
|
2607
2645
|
}, {
|
|
2608
2646
|
key: "elements",
|
|
2609
|
-
/** @return {DSElements} */
|
|
2647
|
+
get: /** @return {DSElements} */
|
|
2648
|
+
function get() {
|
|
2610
2649
|
return Array.from(this.values());
|
|
2611
2650
|
}
|
|
2612
2651
|
}]);
|
|
@@ -2646,6 +2685,7 @@
|
|
|
2646
2685
|
SelectableSet = _this$DS.SelectableSet,
|
|
2647
2686
|
SelectorArea = _this$DS.SelectorArea,
|
|
2648
2687
|
Selector = _this$DS.Selector;
|
|
2688
|
+
|
|
2649
2689
|
/** @type {any} */
|
|
2650
2690
|
var elRects = SelectableSet.rects;
|
|
2651
2691
|
var select = [];
|
|
@@ -2704,7 +2744,9 @@
|
|
|
2704
2744
|
KeyStore = _this$DS2.stores.KeyStore,
|
|
2705
2745
|
SelectedSet = _this$DS2.SelectedSet;
|
|
2706
2746
|
if (KeyStore.isMultiSelectKeyPressed(event)) this._prevSelectedSet = new Set(SelectedSet);else this._prevSelectedSet = new Set();
|
|
2707
|
-
}
|
|
2747
|
+
}
|
|
2748
|
+
|
|
2749
|
+
/** @param {{event:DSEvent,isDragging:boolean}} event */
|
|
2708
2750
|
}]);
|
|
2709
2751
|
return Selection;
|
|
2710
2752
|
}();
|
|
@@ -2890,12 +2932,13 @@
|
|
|
2890
2932
|
}
|
|
2891
2933
|
_createClass(SelectorArea, [{
|
|
2892
2934
|
key: "isClicked",
|
|
2935
|
+
value:
|
|
2893
2936
|
/**
|
|
2894
2937
|
* checks if the click was triggered on the area.
|
|
2895
2938
|
* @param {DSEvent} [event]
|
|
2896
2939
|
* @returns {boolean}
|
|
2897
2940
|
*/
|
|
2898
|
-
|
|
2941
|
+
function isClicked(event) {
|
|
2899
2942
|
var PointerStore = this.DS.stores.PointerStore;
|
|
2900
2943
|
var initialVal = event ? PointerStore.getPointerPosition(event) : PointerStore.initialVal;
|
|
2901
2944
|
return isCollision({
|
|
@@ -2985,7 +3028,8 @@
|
|
|
2985
3028
|
}
|
|
2986
3029
|
_createClass(KeyStore, [{
|
|
2987
3030
|
key: "isMultiSelectKeyPressed",
|
|
2988
|
-
/** @param {KeyboardEvent|MouseEvent|PointerEvent|TouchEvent} [event] */
|
|
3031
|
+
value: /** @param {KeyboardEvent|MouseEvent|PointerEvent|TouchEvent} [event] */
|
|
3032
|
+
function isMultiSelectKeyPressed(event) {
|
|
2989
3033
|
var _this2 = this;
|
|
2990
3034
|
if (this.DS.stores.SettingsStore.s.multiSelectMode) return true;
|
|
2991
3035
|
var multiSelectKeys = this.DS.stores.SettingsStore.s.multiSelectKeys.map(function (key) {
|
|
@@ -3127,25 +3171,31 @@
|
|
|
3127
3171
|
}
|
|
3128
3172
|
_createClass(PointerStore, [{
|
|
3129
3173
|
key: "start",
|
|
3130
|
-
/** @param {DSEvent} [event] */
|
|
3174
|
+
value: /** @param {DSEvent} [event] */
|
|
3175
|
+
function start(event) {
|
|
3131
3176
|
if (!event) return;
|
|
3132
3177
|
this._isMouseInteraction = true;
|
|
3133
3178
|
this.currentVal = this.initialVal = this.getPointerPosition(event);
|
|
3134
|
-
}
|
|
3179
|
+
}
|
|
3180
|
+
|
|
3181
|
+
/** @param {DSEvent} event */
|
|
3135
3182
|
}, {
|
|
3136
3183
|
key: "_normalizedEvent",
|
|
3184
|
+
value:
|
|
3137
3185
|
/**
|
|
3138
3186
|
* @param {DSEvent} event
|
|
3139
3187
|
* @return {MouseEvent|PointerEvent|Touch}
|
|
3140
3188
|
* @private
|
|
3141
3189
|
*/
|
|
3142
|
-
|
|
3190
|
+
function _normalizedEvent(event) {
|
|
3143
3191
|
// touchend has not touches. so we take the last touch if a touchevent, we need to store the positions
|
|
3144
3192
|
if ('touches' in event && event.type !== 'touchend') this._lastTouch = event;
|
|
3145
3193
|
// if a touchevent, return the last touch rather than the regular event
|
|
3146
3194
|
// we need .touches[0] from that event instead
|
|
3147
3195
|
return 'touches' in event ? this._lastTouch.touches[0] : event;
|
|
3148
|
-
}
|
|
3196
|
+
}
|
|
3197
|
+
|
|
3198
|
+
/** First recorded pointer position within the area */
|
|
3149
3199
|
}, {
|
|
3150
3200
|
key: "initialValArea",
|
|
3151
3201
|
get: function get() {
|
|
@@ -3154,7 +3204,9 @@
|
|
|
3154
3204
|
y: 0
|
|
3155
3205
|
};
|
|
3156
3206
|
return this._initialValArea;
|
|
3157
|
-
}
|
|
3207
|
+
}
|
|
3208
|
+
|
|
3209
|
+
/** Current pointer position within the area */
|
|
3158
3210
|
}, {
|
|
3159
3211
|
key: "currentValArea",
|
|
3160
3212
|
get: function get() {
|
|
@@ -3163,7 +3215,9 @@
|
|
|
3163
3215
|
y: 0
|
|
3164
3216
|
};
|
|
3165
3217
|
return this._currentValArea;
|
|
3166
|
-
}
|
|
3218
|
+
}
|
|
3219
|
+
|
|
3220
|
+
/** Last recorded pointer position within the area */
|
|
3167
3221
|
}, {
|
|
3168
3222
|
key: "lastValArea",
|
|
3169
3223
|
get: function get() {
|
|
@@ -3172,7 +3226,9 @@
|
|
|
3172
3226
|
y: 0
|
|
3173
3227
|
};
|
|
3174
3228
|
return this._lastValArea;
|
|
3175
|
-
}
|
|
3229
|
+
}
|
|
3230
|
+
|
|
3231
|
+
/** First recorded pointer position */
|
|
3176
3232
|
}, {
|
|
3177
3233
|
key: "initialVal",
|
|
3178
3234
|
get: function get() {
|
|
@@ -3181,7 +3237,9 @@
|
|
|
3181
3237
|
y: 0
|
|
3182
3238
|
};
|
|
3183
3239
|
return this._initialVal;
|
|
3184
|
-
}
|
|
3240
|
+
}
|
|
3241
|
+
|
|
3242
|
+
/** Current pointer position */,
|
|
3185
3243
|
set: function set(value) {
|
|
3186
3244
|
this._initialVal = value;
|
|
3187
3245
|
this._initialValArea = value && calc(value, '-', calc(rect2vect(this.DS.Area.rect), '+', rect2vect(this.DS.Area.computedBorder)));
|
|
@@ -3194,7 +3252,9 @@
|
|
|
3194
3252
|
y: 0
|
|
3195
3253
|
};
|
|
3196
3254
|
return this._currentVal;
|
|
3197
|
-
}
|
|
3255
|
+
}
|
|
3256
|
+
|
|
3257
|
+
/** Last recorded pointer position */,
|
|
3198
3258
|
set: function set(value) {
|
|
3199
3259
|
this._currentVal = value;
|
|
3200
3260
|
this._currentValArea = value && calc(value, '-', calc(rect2vect(this.DS.Area.rect), '+', rect2vect(this.DS.Area.computedBorder)));
|
|
@@ -3311,7 +3371,7 @@
|
|
|
3311
3371
|
return ScrollStore;
|
|
3312
3372
|
}();
|
|
3313
3373
|
|
|
3314
|
-
var SettingsStore =
|
|
3374
|
+
var SettingsStore = /*#__PURE__*/_createClass(
|
|
3315
3375
|
/**
|
|
3316
3376
|
* @type {Settings}
|
|
3317
3377
|
* @private
|
|
@@ -3390,7 +3450,7 @@
|
|
|
3390
3450
|
});
|
|
3391
3451
|
}
|
|
3392
3452
|
|
|
3393
|
-
/** @param {{settings: Settings, init?: boolean}} props
|
|
3453
|
+
/** @param {{settings: Settings, init?: boolean}} props */);
|
|
3394
3454
|
|
|
3395
3455
|
// Setup
|
|
3396
3456
|
/// ///////////////////////////////////////////////////////////////////////////////////
|
|
@@ -3531,6 +3591,7 @@
|
|
|
3531
3591
|
*/
|
|
3532
3592
|
_createClass(DragSelect, [{
|
|
3533
3593
|
key: "stop",
|
|
3594
|
+
value:
|
|
3534
3595
|
/**
|
|
3535
3596
|
* Complete function teardown
|
|
3536
3597
|
* Will teardown/stop the whole functionality
|
|
@@ -3538,7 +3599,7 @@
|
|
|
3538
3599
|
* @param {boolean} [fromSelection] - if elements should also be added/removed to the selection.
|
|
3539
3600
|
* @param {boolean} [withCallback] - if elements should also be added/removed to the selection.
|
|
3540
3601
|
*/
|
|
3541
|
-
|
|
3602
|
+
function stop() {
|
|
3542
3603
|
var remove = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
3543
3604
|
var fromSelection = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
3544
3605
|
var withCallback = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
@@ -3557,6 +3618,7 @@
|
|
|
3557
3618
|
if (fromSelection) this.SelectedSet.clear();
|
|
3558
3619
|
this.stopped = true;
|
|
3559
3620
|
}
|
|
3621
|
+
|
|
3560
3622
|
/**
|
|
3561
3623
|
* Utility to override DragSelect internal functionality:
|
|
3562
3624
|
* Break will skip the selection or dragging functionality (until after the callback) but let everything continue to run.
|
|
@@ -3564,6 +3626,7 @@
|
|
|
3564
3626
|
*/
|
|
3565
3627
|
}, {
|
|
3566
3628
|
key: "addSelection",
|
|
3629
|
+
value:
|
|
3567
3630
|
/**
|
|
3568
3631
|
* Adds several elements to the selection list also adds the specific classes and take into account all calculations.
|
|
3569
3632
|
* Does not clear the selection, in contrary to .setSelection. Can add multiple elements at once
|
|
@@ -3572,7 +3635,7 @@
|
|
|
3572
3635
|
* @param {boolean} [dontAddToSelectables] - if element should not be added to the list of selectable elements
|
|
3573
3636
|
* @return {DSElements} all selected elements
|
|
3574
3637
|
*/
|
|
3575
|
-
|
|
3638
|
+
function addSelection(elements) {
|
|
3576
3639
|
var triggerCallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
3577
3640
|
var dontAddToSelectables = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
3578
3641
|
this.SelectedSet.addAll(toArray(elements));
|
|
@@ -3582,6 +3645,7 @@
|
|
|
3582
3645
|
});
|
|
3583
3646
|
return this.getSelection();
|
|
3584
3647
|
}
|
|
3648
|
+
|
|
3585
3649
|
/**
|
|
3586
3650
|
* Removes specific elements from the selection
|
|
3587
3651
|
* Multiple elements can be given at once, in contrary to unselect
|
|
@@ -3602,6 +3666,7 @@
|
|
|
3602
3666
|
});
|
|
3603
3667
|
return this.getSelection();
|
|
3604
3668
|
}
|
|
3669
|
+
|
|
3605
3670
|
/**
|
|
3606
3671
|
* Toggles specific elements from the selection:
|
|
3607
3672
|
* If element is not in selection it will be added, if it is already selected, it will be removed.
|
|
@@ -3625,6 +3690,7 @@
|
|
|
3625
3690
|
});
|
|
3626
3691
|
return this.getSelection();
|
|
3627
3692
|
}
|
|
3693
|
+
|
|
3628
3694
|
/**
|
|
3629
3695
|
* Sets the current selected elements and optionally run the callback
|
|
3630
3696
|
* By default, adds new elements also to the list of selectables
|
|
@@ -3642,6 +3708,7 @@
|
|
|
3642
3708
|
this.addSelection(elements, triggerCallback, dontAddToSelectables);
|
|
3643
3709
|
return this.getSelection();
|
|
3644
3710
|
}
|
|
3711
|
+
|
|
3645
3712
|
/**
|
|
3646
3713
|
* Unselect / Deselect all current selected Nodes
|
|
3647
3714
|
* @param {boolean} [triggerCallback] - if callback should be called
|
|
@@ -3657,6 +3724,7 @@
|
|
|
3657
3724
|
});
|
|
3658
3725
|
return this.getSelection();
|
|
3659
3726
|
}
|
|
3727
|
+
|
|
3660
3728
|
/**
|
|
3661
3729
|
* Add elements that can be selected. No node is added twice
|
|
3662
3730
|
* @param {DSInputElements} elements dom element(s)
|
|
@@ -3675,12 +3743,14 @@
|
|
|
3675
3743
|
});
|
|
3676
3744
|
return elements;
|
|
3677
3745
|
}
|
|
3746
|
+
|
|
3678
3747
|
/**
|
|
3679
3748
|
* Gets all nodes that can potentially be selected
|
|
3680
3749
|
* @return {DSElements} this.selectables
|
|
3681
3750
|
*/
|
|
3682
3751
|
}, {
|
|
3683
3752
|
key: "setSelectables",
|
|
3753
|
+
value:
|
|
3684
3754
|
/**
|
|
3685
3755
|
* Sets all elements that can be selected.
|
|
3686
3756
|
* Removes all current selectables (& their respective classes).
|
|
@@ -3690,13 +3760,14 @@
|
|
|
3690
3760
|
* @param {boolean} [addToSelection] if elements should also be added to current selection
|
|
3691
3761
|
* @return {DSInputElements} elements – the added element(s)
|
|
3692
3762
|
*/
|
|
3693
|
-
|
|
3763
|
+
function setSelectables(elements) {
|
|
3694
3764
|
var removeFromSelection = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
3695
3765
|
var addToSelection = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
3696
3766
|
console.warn('[DragSelect] DEPRECATION ".setSelectables" is deprecated and will be removed soon. Please use "ds.setSettings({ selectables: << new dom elements >> })" instead (see docs)');
|
|
3697
3767
|
this.removeSelectables(elements, removeFromSelection);
|
|
3698
3768
|
return this.addSelectables(elements, addToSelection);
|
|
3699
3769
|
}
|
|
3770
|
+
|
|
3700
3771
|
/**
|
|
3701
3772
|
* Remove elements from the elements that can be selected.
|
|
3702
3773
|
* @param {DSInputElements} elements – dom element(s)
|
|
@@ -3713,11 +3784,13 @@
|
|
|
3713
3784
|
items: this.getSelection()
|
|
3714
3785
|
});
|
|
3715
3786
|
return elements;
|
|
3716
|
-
}
|
|
3787
|
+
}
|
|
3788
|
+
|
|
3789
|
+
/** The starting/initial position of the cursor/selector @return {Vect2} */
|
|
3717
3790
|
}]);
|
|
3718
3791
|
return DragSelect;
|
|
3719
3792
|
}();
|
|
3720
3793
|
|
|
3721
3794
|
return DragSelect;
|
|
3722
3795
|
|
|
3723
|
-
}))
|
|
3796
|
+
}));
|