dragselect 2.5.5 → 2.6.0
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 +11 -0
- package/deployment.md +32 -0
- package/dist/DragSelect.d.ts +4 -0
- package/dist/DragSelect.es6m.js +204 -106
- package/dist/DragSelect.js +205 -107
- package/dist/ds.es6m.min.js +1 -1
- package/dist/ds.min.js +1 -1
- package/dist/modules/Selection.d.ts +14 -0
- package/package.json +15 -20
- package/rollup.config.js +1 -34
- package/src/DragSelect.js +4 -2
- package/src/methods/isCollision.js +3 -0
- package/src/modules/Selection.js +31 -13
- 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.
|
|
3
|
+
~~~ Version 2.6.0 ~~~
|
|
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
|
|
@@ -1188,6 +1208,9 @@
|
|
|
1188
1208
|
});
|
|
1189
1209
|
|
|
1190
1210
|
// @ts-check
|
|
1211
|
+
|
|
1212
|
+
// [PUBLICLY EXPOSED METHOD]
|
|
1213
|
+
|
|
1191
1214
|
/**
|
|
1192
1215
|
* Axis-Aligned Bounding Box Collision Detection.
|
|
1193
1216
|
* Imagine following Example:
|
|
@@ -1558,12 +1581,15 @@
|
|
|
1558
1581
|
/** @param {DSArea} area */
|
|
1559
1582
|
_createClass(Area, [{
|
|
1560
1583
|
key: "HTMLNode",
|
|
1584
|
+
get:
|
|
1561
1585
|
/// ///////////////////////////////////////////////////////////////////////////////////
|
|
1562
1586
|
// Node Getters
|
|
1563
|
-
|
|
1587
|
+
|
|
1588
|
+
function get() {
|
|
1564
1589
|
return (/** @type {DSArea} */this._node
|
|
1565
1590
|
);
|
|
1566
1591
|
}
|
|
1592
|
+
|
|
1567
1593
|
/**
|
|
1568
1594
|
* The computed border from the element (caches result)
|
|
1569
1595
|
* @type {{top:number,bottom:number,left:number,right:number}}
|
|
@@ -1579,6 +1605,7 @@
|
|
|
1579
1605
|
right: parseInt(this.computedStyle.borderRightWidth)
|
|
1580
1606
|
};
|
|
1581
1607
|
}
|
|
1608
|
+
|
|
1582
1609
|
/**
|
|
1583
1610
|
* The computed styles from the element (caches result)
|
|
1584
1611
|
* @type {CSSStyleDeclaration}
|
|
@@ -1590,6 +1617,7 @@
|
|
|
1590
1617
|
if (this.HTMLNode instanceof Document) return this._computedStyle = window.getComputedStyle(this.HTMLNode.body || this.HTMLNode.documentElement);
|
|
1591
1618
|
return this._computedStyle = window.getComputedStyle(this.HTMLNode);
|
|
1592
1619
|
}
|
|
1620
|
+
|
|
1593
1621
|
/**
|
|
1594
1622
|
* The element rect (caches result) (without scrollbar or borders)
|
|
1595
1623
|
* @type {DSBoundingRect}
|
|
@@ -1967,6 +1995,7 @@
|
|
|
1967
1995
|
this._itemsInside = null;
|
|
1968
1996
|
this.isDestroyed = true;
|
|
1969
1997
|
}
|
|
1998
|
+
|
|
1970
1999
|
/**
|
|
1971
2000
|
* @returns {DSDropZone}
|
|
1972
2001
|
*/
|
|
@@ -2020,7 +2049,7 @@
|
|
|
2020
2049
|
return DropZone;
|
|
2021
2050
|
}();
|
|
2022
2051
|
|
|
2023
|
-
var DropZones =
|
|
2052
|
+
var DropZones = /*#__PURE__*/_createClass(
|
|
2024
2053
|
/**
|
|
2025
2054
|
* Get the drop zone by the zone element
|
|
2026
2055
|
* @type {Map<DSElement, DropZone>}
|
|
@@ -2149,7 +2178,7 @@
|
|
|
2149
2178
|
/**
|
|
2150
2179
|
* @param {Object} obj
|
|
2151
2180
|
* @param {DSDropZone[]} [obj.dropZones]
|
|
2152
|
-
|
|
2181
|
+
*/);
|
|
2153
2182
|
|
|
2154
2183
|
var Interaction = /*#__PURE__*/function () {
|
|
2155
2184
|
/** @type {boolean} */
|
|
@@ -2221,6 +2250,7 @@
|
|
|
2221
2250
|
var event = _ref2.event;
|
|
2222
2251
|
if (!_this._canInteract(event)) return;
|
|
2223
2252
|
if (event.detail > 0) return; // mouse interaction
|
|
2253
|
+
|
|
2224
2254
|
var _this$DS = _this.DS,
|
|
2225
2255
|
_this$DS$stores = _this$DS.stores,
|
|
2226
2256
|
PointerStore = _this$DS$stores.PointerStore,
|
|
@@ -2310,10 +2340,11 @@
|
|
|
2310
2340
|
}
|
|
2311
2341
|
_createClass(Interaction, [{
|
|
2312
2342
|
key: "_canInteract",
|
|
2343
|
+
value:
|
|
2313
2344
|
/**
|
|
2314
2345
|
* @param {DSEvent} event
|
|
2315
2346
|
*/
|
|
2316
|
-
|
|
2347
|
+
function _canInteract(event) {
|
|
2317
2348
|
var isKeyboardClick = /** @type {MouseEvent} */event.clientX === 0 && /** @type {MouseEvent} */event.clientY === 0 && /** @type {MouseEvent} */event.detail === 0 && event.target;
|
|
2318
2349
|
if ( /** @type {MouseEvent} */event.button === 2 ||
|
|
2319
2350
|
// right-clicks
|
|
@@ -2325,6 +2356,7 @@
|
|
|
2325
2356
|
) return false;
|
|
2326
2357
|
return true;
|
|
2327
2358
|
}
|
|
2359
|
+
|
|
2328
2360
|
/**
|
|
2329
2361
|
* @param {DSEvent} event
|
|
2330
2362
|
*/
|
|
@@ -2332,7 +2364,7 @@
|
|
|
2332
2364
|
return Interaction;
|
|
2333
2365
|
}();
|
|
2334
2366
|
|
|
2335
|
-
var PubSub = function PubSub(_ref) {
|
|
2367
|
+
var PubSub = /*#__PURE__*/_createClass(function PubSub(_ref) {
|
|
2336
2368
|
var _this = this;
|
|
2337
2369
|
var DS = _ref.DS;
|
|
2338
2370
|
_classCallCheck(this, PubSub);
|
|
@@ -2380,7 +2412,7 @@
|
|
|
2380
2412
|
* @param {DSCallbackNames} eventName
|
|
2381
2413
|
* @param {DSCallback} callback
|
|
2382
2414
|
* @returns {number} event id, can be used to unsubscribe more efficiently
|
|
2383
|
-
|
|
2415
|
+
*/);
|
|
2384
2416
|
|
|
2385
2417
|
var SelectableSet = /*#__PURE__*/function (_Set) {
|
|
2386
2418
|
_inherits(SelectableSet, _Set);
|
|
@@ -2457,7 +2489,8 @@
|
|
|
2457
2489
|
}
|
|
2458
2490
|
_createClass(SelectableSet, [{
|
|
2459
2491
|
key: "add",
|
|
2460
|
-
/** @param {DSElement} element */
|
|
2492
|
+
value: /** @param {DSElement} element */
|
|
2493
|
+
function add(element) {
|
|
2461
2494
|
if (_get(_getPrototypeOf(SelectableSet.prototype), "has", this).call(this, element)) return;
|
|
2462
2495
|
var publishData = {
|
|
2463
2496
|
items: this.elements,
|
|
@@ -2480,7 +2513,9 @@
|
|
|
2480
2513
|
});
|
|
2481
2514
|
this.DS.publish('Selectable:added', publishData);
|
|
2482
2515
|
return _get(_getPrototypeOf(SelectableSet.prototype), "add", this).call(this, element);
|
|
2483
|
-
}
|
|
2516
|
+
}
|
|
2517
|
+
|
|
2518
|
+
/** @param {DSElement} element */
|
|
2484
2519
|
}, {
|
|
2485
2520
|
key: "delete",
|
|
2486
2521
|
value: function _delete(element) {
|
|
@@ -2506,7 +2541,8 @@
|
|
|
2506
2541
|
}
|
|
2507
2542
|
}, {
|
|
2508
2543
|
key: "elements",
|
|
2509
|
-
/** @return {DSElements} */
|
|
2544
|
+
get: /** @return {DSElements} */
|
|
2545
|
+
function get() {
|
|
2510
2546
|
return Array.from(this.values());
|
|
2511
2547
|
}
|
|
2512
2548
|
}, {
|
|
@@ -2577,7 +2613,9 @@
|
|
|
2577
2613
|
element.style.zIndex = "".concat((parseInt(element.style.zIndex) || 0) + 1);
|
|
2578
2614
|
this.DS.publish('Selected:added', publishData);
|
|
2579
2615
|
return this;
|
|
2580
|
-
}
|
|
2616
|
+
}
|
|
2617
|
+
|
|
2618
|
+
/** @param {DSElement} element */
|
|
2581
2619
|
}, {
|
|
2582
2620
|
key: "delete",
|
|
2583
2621
|
value: function _delete(element) {
|
|
@@ -2595,18 +2633,22 @@
|
|
|
2595
2633
|
}
|
|
2596
2634
|
}, {
|
|
2597
2635
|
key: "toggle",
|
|
2636
|
+
value:
|
|
2598
2637
|
/**
|
|
2599
2638
|
* Adds/Removes an element. If it is already selected = remove, if not = add.
|
|
2600
2639
|
* @param {DSElement} element
|
|
2601
2640
|
* @return {DSElement}
|
|
2602
2641
|
*/
|
|
2603
|
-
|
|
2642
|
+
function toggle(element) {
|
|
2604
2643
|
if (this.has(element)) this["delete"](element);else this.add(element);
|
|
2605
2644
|
return element;
|
|
2606
|
-
}
|
|
2645
|
+
}
|
|
2646
|
+
|
|
2647
|
+
/** @param {DSElements} elements */
|
|
2607
2648
|
}, {
|
|
2608
2649
|
key: "elements",
|
|
2609
|
-
/** @return {DSElements} */
|
|
2650
|
+
get: /** @return {DSElements} */
|
|
2651
|
+
function get() {
|
|
2610
2652
|
return Array.from(this.values());
|
|
2611
2653
|
}
|
|
2612
2654
|
}]);
|
|
@@ -2646,28 +2688,41 @@
|
|
|
2646
2688
|
SelectableSet = _this$DS.SelectableSet,
|
|
2647
2689
|
SelectorArea = _this$DS.SelectorArea,
|
|
2648
2690
|
Selector = _this$DS.Selector;
|
|
2691
|
+
var multiSelectionToggle = _this.DS.stores.KeyStore.isMultiSelectKeyPressed(event) && _this.Settings.multiSelectToggling;
|
|
2692
|
+
var selectionThreshold = _this.Settings.selectionThreshold;
|
|
2693
|
+
|
|
2649
2694
|
/** @type {any} */
|
|
2650
2695
|
var elRects = SelectableSet.rects;
|
|
2651
|
-
var
|
|
2652
|
-
|
|
2696
|
+
var selectorRect = Selector.rect;
|
|
2697
|
+
|
|
2698
|
+
/** @type {Map<DSElement,DSBoundingRect>} */
|
|
2699
|
+
var select = new Map();
|
|
2700
|
+
/** @type {Map<DSElement,DSBoundingRect>} */
|
|
2701
|
+
var unselect = new Map();
|
|
2653
2702
|
var _iterator = _createForOfIteratorHelper(elRects),
|
|
2654
2703
|
_step;
|
|
2655
2704
|
try {
|
|
2656
2705
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
2657
2706
|
var _step$value = _slicedToArray(_step.value, 2),
|
|
2658
2707
|
element = _step$value[0],
|
|
2659
|
-
|
|
2660
|
-
if (!SelectorArea.isInside(element,
|
|
2661
|
-
if (isCollision(
|
|
2708
|
+
elementRect = _step$value[1];
|
|
2709
|
+
if (!SelectorArea.isInside(element, elementRect)) continue;
|
|
2710
|
+
if (isCollision(elementRect, selectorRect, selectionThreshold)) select.set(element, elementRect);else unselect.set(element, elementRect);
|
|
2662
2711
|
}
|
|
2663
2712
|
} catch (err) {
|
|
2664
2713
|
_iterator.e(err);
|
|
2665
2714
|
} finally {
|
|
2666
2715
|
_iterator.f();
|
|
2667
2716
|
}
|
|
2668
|
-
var multiSelectionToggle = _this.DS.stores.KeyStore.isMultiSelectKeyPressed(event) && _this.Settings.multiSelectToggling;
|
|
2669
2717
|
if (_this.DS["continue"]) return;
|
|
2670
|
-
|
|
2718
|
+
var _this$filterSelected = _this.filterSelected({
|
|
2719
|
+
select: select,
|
|
2720
|
+
unselect: unselect,
|
|
2721
|
+
selectorRect: selectorRect
|
|
2722
|
+
}),
|
|
2723
|
+
filteredSelect = _this$filterSelected.select,
|
|
2724
|
+
filteredUnselect = _this$filterSelected.unselect;
|
|
2725
|
+
filteredSelect.forEach(function (_, element) {
|
|
2671
2726
|
return handleSelection({
|
|
2672
2727
|
element: element,
|
|
2673
2728
|
force: force,
|
|
@@ -2676,7 +2731,7 @@
|
|
|
2676
2731
|
hoverClassName: _this.Settings.hoverClass
|
|
2677
2732
|
});
|
|
2678
2733
|
});
|
|
2679
|
-
|
|
2734
|
+
filteredUnselect.forEach(function (_, element) {
|
|
2680
2735
|
return handleUnSelection({
|
|
2681
2736
|
element: element,
|
|
2682
2737
|
force: force,
|
|
@@ -2686,6 +2741,15 @@
|
|
|
2686
2741
|
});
|
|
2687
2742
|
});
|
|
2688
2743
|
});
|
|
2744
|
+
_defineProperty(this, "filterSelected", function (_ref4) {
|
|
2745
|
+
var select = _ref4.select,
|
|
2746
|
+
unselect = _ref4.unselect;
|
|
2747
|
+
_ref4.selectorRect;
|
|
2748
|
+
return {
|
|
2749
|
+
select: select,
|
|
2750
|
+
unselect: unselect
|
|
2751
|
+
};
|
|
2752
|
+
});
|
|
2689
2753
|
this.DS = DS;
|
|
2690
2754
|
this.Settings = this.DS.stores.SettingsStore.s;
|
|
2691
2755
|
this.DS.subscribe('Interaction:start', this.start);
|
|
@@ -2704,7 +2768,9 @@
|
|
|
2704
2768
|
KeyStore = _this$DS2.stores.KeyStore,
|
|
2705
2769
|
SelectedSet = _this$DS2.SelectedSet;
|
|
2706
2770
|
if (KeyStore.isMultiSelectKeyPressed(event)) this._prevSelectedSet = new Set(SelectedSet);else this._prevSelectedSet = new Set();
|
|
2707
|
-
}
|
|
2771
|
+
}
|
|
2772
|
+
|
|
2773
|
+
/** @param {{event:DSEvent,isDragging:boolean}} event */
|
|
2708
2774
|
}]);
|
|
2709
2775
|
return Selection;
|
|
2710
2776
|
}();
|
|
@@ -2890,12 +2956,13 @@
|
|
|
2890
2956
|
}
|
|
2891
2957
|
_createClass(SelectorArea, [{
|
|
2892
2958
|
key: "isClicked",
|
|
2959
|
+
value:
|
|
2893
2960
|
/**
|
|
2894
2961
|
* checks if the click was triggered on the area.
|
|
2895
2962
|
* @param {DSEvent} [event]
|
|
2896
2963
|
* @returns {boolean}
|
|
2897
2964
|
*/
|
|
2898
|
-
|
|
2965
|
+
function isClicked(event) {
|
|
2899
2966
|
var PointerStore = this.DS.stores.PointerStore;
|
|
2900
2967
|
var initialVal = event ? PointerStore.getPointerPosition(event) : PointerStore.initialVal;
|
|
2901
2968
|
return isCollision({
|
|
@@ -2985,7 +3052,8 @@
|
|
|
2985
3052
|
}
|
|
2986
3053
|
_createClass(KeyStore, [{
|
|
2987
3054
|
key: "isMultiSelectKeyPressed",
|
|
2988
|
-
/** @param {KeyboardEvent|MouseEvent|PointerEvent|TouchEvent} [event] */
|
|
3055
|
+
value: /** @param {KeyboardEvent|MouseEvent|PointerEvent|TouchEvent} [event] */
|
|
3056
|
+
function isMultiSelectKeyPressed(event) {
|
|
2989
3057
|
var _this2 = this;
|
|
2990
3058
|
if (this.DS.stores.SettingsStore.s.multiSelectMode) return true;
|
|
2991
3059
|
var multiSelectKeys = this.DS.stores.SettingsStore.s.multiSelectKeys.map(function (key) {
|
|
@@ -3127,25 +3195,31 @@
|
|
|
3127
3195
|
}
|
|
3128
3196
|
_createClass(PointerStore, [{
|
|
3129
3197
|
key: "start",
|
|
3130
|
-
/** @param {DSEvent} [event] */
|
|
3198
|
+
value: /** @param {DSEvent} [event] */
|
|
3199
|
+
function start(event) {
|
|
3131
3200
|
if (!event) return;
|
|
3132
3201
|
this._isMouseInteraction = true;
|
|
3133
3202
|
this.currentVal = this.initialVal = this.getPointerPosition(event);
|
|
3134
|
-
}
|
|
3203
|
+
}
|
|
3204
|
+
|
|
3205
|
+
/** @param {DSEvent} event */
|
|
3135
3206
|
}, {
|
|
3136
3207
|
key: "_normalizedEvent",
|
|
3208
|
+
value:
|
|
3137
3209
|
/**
|
|
3138
3210
|
* @param {DSEvent} event
|
|
3139
3211
|
* @return {MouseEvent|PointerEvent|Touch}
|
|
3140
3212
|
* @private
|
|
3141
3213
|
*/
|
|
3142
|
-
|
|
3214
|
+
function _normalizedEvent(event) {
|
|
3143
3215
|
// touchend has not touches. so we take the last touch if a touchevent, we need to store the positions
|
|
3144
3216
|
if ('touches' in event && event.type !== 'touchend') this._lastTouch = event;
|
|
3145
3217
|
// if a touchevent, return the last touch rather than the regular event
|
|
3146
3218
|
// we need .touches[0] from that event instead
|
|
3147
3219
|
return 'touches' in event ? this._lastTouch.touches[0] : event;
|
|
3148
|
-
}
|
|
3220
|
+
}
|
|
3221
|
+
|
|
3222
|
+
/** First recorded pointer position within the area */
|
|
3149
3223
|
}, {
|
|
3150
3224
|
key: "initialValArea",
|
|
3151
3225
|
get: function get() {
|
|
@@ -3154,7 +3228,9 @@
|
|
|
3154
3228
|
y: 0
|
|
3155
3229
|
};
|
|
3156
3230
|
return this._initialValArea;
|
|
3157
|
-
}
|
|
3231
|
+
}
|
|
3232
|
+
|
|
3233
|
+
/** Current pointer position within the area */
|
|
3158
3234
|
}, {
|
|
3159
3235
|
key: "currentValArea",
|
|
3160
3236
|
get: function get() {
|
|
@@ -3163,7 +3239,9 @@
|
|
|
3163
3239
|
y: 0
|
|
3164
3240
|
};
|
|
3165
3241
|
return this._currentValArea;
|
|
3166
|
-
}
|
|
3242
|
+
}
|
|
3243
|
+
|
|
3244
|
+
/** Last recorded pointer position within the area */
|
|
3167
3245
|
}, {
|
|
3168
3246
|
key: "lastValArea",
|
|
3169
3247
|
get: function get() {
|
|
@@ -3172,7 +3250,9 @@
|
|
|
3172
3250
|
y: 0
|
|
3173
3251
|
};
|
|
3174
3252
|
return this._lastValArea;
|
|
3175
|
-
}
|
|
3253
|
+
}
|
|
3254
|
+
|
|
3255
|
+
/** First recorded pointer position */
|
|
3176
3256
|
}, {
|
|
3177
3257
|
key: "initialVal",
|
|
3178
3258
|
get: function get() {
|
|
@@ -3181,7 +3261,9 @@
|
|
|
3181
3261
|
y: 0
|
|
3182
3262
|
};
|
|
3183
3263
|
return this._initialVal;
|
|
3184
|
-
}
|
|
3264
|
+
}
|
|
3265
|
+
|
|
3266
|
+
/** Current pointer position */,
|
|
3185
3267
|
set: function set(value) {
|
|
3186
3268
|
this._initialVal = value;
|
|
3187
3269
|
this._initialValArea = value && calc(value, '-', calc(rect2vect(this.DS.Area.rect), '+', rect2vect(this.DS.Area.computedBorder)));
|
|
@@ -3194,7 +3276,9 @@
|
|
|
3194
3276
|
y: 0
|
|
3195
3277
|
};
|
|
3196
3278
|
return this._currentVal;
|
|
3197
|
-
}
|
|
3279
|
+
}
|
|
3280
|
+
|
|
3281
|
+
/** Last recorded pointer position */,
|
|
3198
3282
|
set: function set(value) {
|
|
3199
3283
|
this._currentVal = value;
|
|
3200
3284
|
this._currentValArea = value && calc(value, '-', calc(rect2vect(this.DS.Area.rect), '+', rect2vect(this.DS.Area.computedBorder)));
|
|
@@ -3311,7 +3395,7 @@
|
|
|
3311
3395
|
return ScrollStore;
|
|
3312
3396
|
}();
|
|
3313
3397
|
|
|
3314
|
-
var SettingsStore =
|
|
3398
|
+
var SettingsStore = /*#__PURE__*/_createClass(
|
|
3315
3399
|
/**
|
|
3316
3400
|
* @type {Settings}
|
|
3317
3401
|
* @private
|
|
@@ -3390,7 +3474,7 @@
|
|
|
3390
3474
|
});
|
|
3391
3475
|
}
|
|
3392
3476
|
|
|
3393
|
-
/** @param {{settings: Settings, init?: boolean}} props
|
|
3477
|
+
/** @param {{settings: Settings, init?: boolean}} props */);
|
|
3394
3478
|
|
|
3395
3479
|
// Setup
|
|
3396
3480
|
/// ///////////////////////////////////////////////////////////////////////////////////
|
|
@@ -3531,6 +3615,7 @@
|
|
|
3531
3615
|
*/
|
|
3532
3616
|
_createClass(DragSelect, [{
|
|
3533
3617
|
key: "stop",
|
|
3618
|
+
value:
|
|
3534
3619
|
/**
|
|
3535
3620
|
* Complete function teardown
|
|
3536
3621
|
* Will teardown/stop the whole functionality
|
|
@@ -3538,7 +3623,7 @@
|
|
|
3538
3623
|
* @param {boolean} [fromSelection] - if elements should also be added/removed to the selection.
|
|
3539
3624
|
* @param {boolean} [withCallback] - if elements should also be added/removed to the selection.
|
|
3540
3625
|
*/
|
|
3541
|
-
|
|
3626
|
+
function stop() {
|
|
3542
3627
|
var remove = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
3543
3628
|
var fromSelection = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
3544
3629
|
var withCallback = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
@@ -3557,6 +3642,7 @@
|
|
|
3557
3642
|
if (fromSelection) this.SelectedSet.clear();
|
|
3558
3643
|
this.stopped = true;
|
|
3559
3644
|
}
|
|
3645
|
+
|
|
3560
3646
|
/**
|
|
3561
3647
|
* Utility to override DragSelect internal functionality:
|
|
3562
3648
|
* Break will skip the selection or dragging functionality (until after the callback) but let everything continue to run.
|
|
@@ -3564,6 +3650,7 @@
|
|
|
3564
3650
|
*/
|
|
3565
3651
|
}, {
|
|
3566
3652
|
key: "addSelection",
|
|
3653
|
+
value:
|
|
3567
3654
|
/**
|
|
3568
3655
|
* Adds several elements to the selection list also adds the specific classes and take into account all calculations.
|
|
3569
3656
|
* Does not clear the selection, in contrary to .setSelection. Can add multiple elements at once
|
|
@@ -3572,7 +3659,7 @@
|
|
|
3572
3659
|
* @param {boolean} [dontAddToSelectables] - if element should not be added to the list of selectable elements
|
|
3573
3660
|
* @return {DSElements} all selected elements
|
|
3574
3661
|
*/
|
|
3575
|
-
|
|
3662
|
+
function addSelection(elements) {
|
|
3576
3663
|
var triggerCallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
3577
3664
|
var dontAddToSelectables = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
3578
3665
|
this.SelectedSet.addAll(toArray(elements));
|
|
@@ -3582,6 +3669,7 @@
|
|
|
3582
3669
|
});
|
|
3583
3670
|
return this.getSelection();
|
|
3584
3671
|
}
|
|
3672
|
+
|
|
3585
3673
|
/**
|
|
3586
3674
|
* Removes specific elements from the selection
|
|
3587
3675
|
* Multiple elements can be given at once, in contrary to unselect
|
|
@@ -3602,6 +3690,7 @@
|
|
|
3602
3690
|
});
|
|
3603
3691
|
return this.getSelection();
|
|
3604
3692
|
}
|
|
3693
|
+
|
|
3605
3694
|
/**
|
|
3606
3695
|
* Toggles specific elements from the selection:
|
|
3607
3696
|
* If element is not in selection it will be added, if it is already selected, it will be removed.
|
|
@@ -3625,6 +3714,7 @@
|
|
|
3625
3714
|
});
|
|
3626
3715
|
return this.getSelection();
|
|
3627
3716
|
}
|
|
3717
|
+
|
|
3628
3718
|
/**
|
|
3629
3719
|
* Sets the current selected elements and optionally run the callback
|
|
3630
3720
|
* By default, adds new elements also to the list of selectables
|
|
@@ -3642,6 +3732,7 @@
|
|
|
3642
3732
|
this.addSelection(elements, triggerCallback, dontAddToSelectables);
|
|
3643
3733
|
return this.getSelection();
|
|
3644
3734
|
}
|
|
3735
|
+
|
|
3645
3736
|
/**
|
|
3646
3737
|
* Unselect / Deselect all current selected Nodes
|
|
3647
3738
|
* @param {boolean} [triggerCallback] - if callback should be called
|
|
@@ -3657,6 +3748,7 @@
|
|
|
3657
3748
|
});
|
|
3658
3749
|
return this.getSelection();
|
|
3659
3750
|
}
|
|
3751
|
+
|
|
3660
3752
|
/**
|
|
3661
3753
|
* Add elements that can be selected. No node is added twice
|
|
3662
3754
|
* @param {DSInputElements} elements dom element(s)
|
|
@@ -3675,12 +3767,14 @@
|
|
|
3675
3767
|
});
|
|
3676
3768
|
return elements;
|
|
3677
3769
|
}
|
|
3770
|
+
|
|
3678
3771
|
/**
|
|
3679
3772
|
* Gets all nodes that can potentially be selected
|
|
3680
3773
|
* @return {DSElements} this.selectables
|
|
3681
3774
|
*/
|
|
3682
3775
|
}, {
|
|
3683
3776
|
key: "setSelectables",
|
|
3777
|
+
value:
|
|
3684
3778
|
/**
|
|
3685
3779
|
* Sets all elements that can be selected.
|
|
3686
3780
|
* Removes all current selectables (& their respective classes).
|
|
@@ -3690,13 +3784,14 @@
|
|
|
3690
3784
|
* @param {boolean} [addToSelection] if elements should also be added to current selection
|
|
3691
3785
|
* @return {DSInputElements} elements – the added element(s)
|
|
3692
3786
|
*/
|
|
3693
|
-
|
|
3787
|
+
function setSelectables(elements) {
|
|
3694
3788
|
var removeFromSelection = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
3695
3789
|
var addToSelection = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
3696
3790
|
console.warn('[DragSelect] DEPRECATION ".setSelectables" is deprecated and will be removed soon. Please use "ds.setSettings({ selectables: << new dom elements >> })" instead (see docs)');
|
|
3697
3791
|
this.removeSelectables(elements, removeFromSelection);
|
|
3698
3792
|
return this.addSelectables(elements, addToSelection);
|
|
3699
3793
|
}
|
|
3794
|
+
|
|
3700
3795
|
/**
|
|
3701
3796
|
* Remove elements from the elements that can be selected.
|
|
3702
3797
|
* @param {DSInputElements} elements – dom element(s)
|
|
@@ -3713,11 +3808,14 @@
|
|
|
3713
3808
|
items: this.getSelection()
|
|
3714
3809
|
});
|
|
3715
3810
|
return elements;
|
|
3716
|
-
}
|
|
3811
|
+
}
|
|
3812
|
+
|
|
3813
|
+
/** The starting/initial position of the cursor/selector @return {Vect2} */
|
|
3717
3814
|
}]);
|
|
3718
3815
|
return DragSelect;
|
|
3719
3816
|
}();
|
|
3817
|
+
DragSelect.isCollision = isCollision;
|
|
3720
3818
|
|
|
3721
3819
|
return DragSelect;
|
|
3722
3820
|
|
|
3723
|
-
}))
|
|
3821
|
+
}));
|