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.es6m.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,10 +25,58 @@
|
|
|
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
|
*/
|
|
32
|
+
function _iterableToArrayLimit(arr, i) {
|
|
33
|
+
var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
|
|
34
|
+
if (null != _i) {
|
|
35
|
+
var _s,
|
|
36
|
+
_e,
|
|
37
|
+
_x,
|
|
38
|
+
_r,
|
|
39
|
+
_arr = [],
|
|
40
|
+
_n = !0,
|
|
41
|
+
_d = !1;
|
|
42
|
+
try {
|
|
43
|
+
if (_x = (_i = _i.call(arr)).next, 0 === i) {
|
|
44
|
+
if (Object(_i) !== _i) return;
|
|
45
|
+
_n = !1;
|
|
46
|
+
} else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);
|
|
47
|
+
} catch (err) {
|
|
48
|
+
_d = !0, _e = err;
|
|
49
|
+
} finally {
|
|
50
|
+
try {
|
|
51
|
+
if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return;
|
|
52
|
+
} finally {
|
|
53
|
+
if (_d) throw _e;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return _arr;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function ownKeys(object, enumerableOnly) {
|
|
60
|
+
var keys = Object.keys(object);
|
|
61
|
+
if (Object.getOwnPropertySymbols) {
|
|
62
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
63
|
+
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
64
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
65
|
+
})), keys.push.apply(keys, symbols);
|
|
66
|
+
}
|
|
67
|
+
return keys;
|
|
68
|
+
}
|
|
69
|
+
function _objectSpread2(target) {
|
|
70
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
71
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
72
|
+
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
|
|
73
|
+
_defineProperty(target, key, source[key]);
|
|
74
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
|
|
75
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
return target;
|
|
79
|
+
}
|
|
32
80
|
function _classCallCheck(instance, Constructor) {
|
|
33
81
|
if (!(instance instanceof Constructor)) {
|
|
34
82
|
throw new TypeError("Cannot call a class as a function");
|
|
@@ -40,15 +88,19 @@ function _defineProperties(target, props) {
|
|
|
40
88
|
descriptor.enumerable = descriptor.enumerable || false;
|
|
41
89
|
descriptor.configurable = true;
|
|
42
90
|
if ("value" in descriptor) descriptor.writable = true;
|
|
43
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
91
|
+
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
|
44
92
|
}
|
|
45
93
|
}
|
|
46
94
|
function _createClass(Constructor, protoProps, staticProps) {
|
|
47
95
|
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
48
96
|
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
97
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
98
|
+
writable: false
|
|
99
|
+
});
|
|
49
100
|
return Constructor;
|
|
50
101
|
}
|
|
51
102
|
function _defineProperty(obj, key, value) {
|
|
103
|
+
key = _toPropertyKey(key);
|
|
52
104
|
if (key in obj) {
|
|
53
105
|
Object.defineProperty(obj, key, {
|
|
54
106
|
value: value,
|
|
@@ -61,34 +113,6 @@ function _defineProperty(obj, key, value) {
|
|
|
61
113
|
}
|
|
62
114
|
return obj;
|
|
63
115
|
}
|
|
64
|
-
function ownKeys(object, enumerableOnly) {
|
|
65
|
-
var keys = Object.keys(object);
|
|
66
|
-
if (Object.getOwnPropertySymbols) {
|
|
67
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
68
|
-
if (enumerableOnly) symbols = symbols.filter(function (sym) {
|
|
69
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
70
|
-
});
|
|
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 = arguments[i] != null ? arguments[i] : {};
|
|
78
|
-
if (i % 2) {
|
|
79
|
-
ownKeys(Object(source), true).forEach(function (key) {
|
|
80
|
-
_defineProperty(target, key, source[key]);
|
|
81
|
-
});
|
|
82
|
-
} else if (Object.getOwnPropertyDescriptors) {
|
|
83
|
-
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
84
|
-
} else {
|
|
85
|
-
ownKeys(Object(source)).forEach(function (key) {
|
|
86
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
return target;
|
|
91
|
-
}
|
|
92
116
|
function _inherits(subClass, superClass) {
|
|
93
117
|
if (typeof superClass !== "function" && superClass !== null) {
|
|
94
118
|
throw new TypeError("Super expression must either be null or a function");
|
|
@@ -100,16 +124,19 @@ function _inherits(subClass, superClass) {
|
|
|
100
124
|
configurable: true
|
|
101
125
|
}
|
|
102
126
|
});
|
|
127
|
+
Object.defineProperty(subClass, "prototype", {
|
|
128
|
+
writable: false
|
|
129
|
+
});
|
|
103
130
|
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
104
131
|
}
|
|
105
132
|
function _getPrototypeOf(o) {
|
|
106
|
-
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
|
133
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
|
107
134
|
return o.__proto__ || Object.getPrototypeOf(o);
|
|
108
135
|
};
|
|
109
136
|
return _getPrototypeOf(o);
|
|
110
137
|
}
|
|
111
138
|
function _setPrototypeOf(o, p) {
|
|
112
|
-
_setPrototypeOf = Object.setPrototypeOf
|
|
139
|
+
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
113
140
|
o.__proto__ = p;
|
|
114
141
|
return o;
|
|
115
142
|
};
|
|
@@ -120,7 +147,7 @@ function _isNativeReflectConstruct() {
|
|
|
120
147
|
if (Reflect.construct.sham) return false;
|
|
121
148
|
if (typeof Proxy === "function") return true;
|
|
122
149
|
try {
|
|
123
|
-
|
|
150
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
124
151
|
return true;
|
|
125
152
|
} catch (e) {
|
|
126
153
|
return false;
|
|
@@ -128,7 +155,7 @@ function _isNativeReflectConstruct() {
|
|
|
128
155
|
}
|
|
129
156
|
function _construct(Parent, args, Class) {
|
|
130
157
|
if (_isNativeReflectConstruct()) {
|
|
131
|
-
_construct = Reflect.construct;
|
|
158
|
+
_construct = Reflect.construct.bind();
|
|
132
159
|
} else {
|
|
133
160
|
_construct = function _construct(Parent, args, Class) {
|
|
134
161
|
var a = [null];
|
|
@@ -179,6 +206,8 @@ function _assertThisInitialized(self) {
|
|
|
179
206
|
function _possibleConstructorReturn(self, call) {
|
|
180
207
|
if (call && (typeof call === "object" || typeof call === "function")) {
|
|
181
208
|
return call;
|
|
209
|
+
} else if (call !== void 0) {
|
|
210
|
+
throw new TypeError("Derived constructors may only return object or undefined");
|
|
182
211
|
}
|
|
183
212
|
return _assertThisInitialized(self);
|
|
184
213
|
}
|
|
@@ -203,21 +232,21 @@ function _superPropBase(object, property) {
|
|
|
203
232
|
}
|
|
204
233
|
return object;
|
|
205
234
|
}
|
|
206
|
-
function _get(
|
|
235
|
+
function _get() {
|
|
207
236
|
if (typeof Reflect !== "undefined" && Reflect.get) {
|
|
208
|
-
_get = Reflect.get;
|
|
237
|
+
_get = Reflect.get.bind();
|
|
209
238
|
} else {
|
|
210
239
|
_get = function _get(target, property, receiver) {
|
|
211
240
|
var base = _superPropBase(target, property);
|
|
212
241
|
if (!base) return;
|
|
213
242
|
var desc = Object.getOwnPropertyDescriptor(base, property);
|
|
214
243
|
if (desc.get) {
|
|
215
|
-
return desc.get.call(receiver);
|
|
244
|
+
return desc.get.call(arguments.length < 3 ? target : receiver);
|
|
216
245
|
}
|
|
217
246
|
return desc.value;
|
|
218
247
|
};
|
|
219
248
|
}
|
|
220
|
-
return _get(
|
|
249
|
+
return _get.apply(this, arguments);
|
|
221
250
|
}
|
|
222
251
|
function _slicedToArray(arr, i) {
|
|
223
252
|
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
@@ -232,30 +261,7 @@ function _arrayWithHoles(arr) {
|
|
|
232
261
|
if (Array.isArray(arr)) return arr;
|
|
233
262
|
}
|
|
234
263
|
function _iterableToArray(iter) {
|
|
235
|
-
if (typeof Symbol !== "undefined" && Symbol.iterator
|
|
236
|
-
}
|
|
237
|
-
function _iterableToArrayLimit(arr, i) {
|
|
238
|
-
if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
|
|
239
|
-
var _arr = [];
|
|
240
|
-
var _n = true;
|
|
241
|
-
var _d = false;
|
|
242
|
-
var _e = undefined;
|
|
243
|
-
try {
|
|
244
|
-
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
|
|
245
|
-
_arr.push(_s.value);
|
|
246
|
-
if (i && _arr.length === i) break;
|
|
247
|
-
}
|
|
248
|
-
} catch (err) {
|
|
249
|
-
_d = true;
|
|
250
|
-
_e = err;
|
|
251
|
-
} finally {
|
|
252
|
-
try {
|
|
253
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
254
|
-
} finally {
|
|
255
|
-
if (_d) throw _e;
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
return _arr;
|
|
264
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
259
265
|
}
|
|
260
266
|
function _unsupportedIterableToArray(o, minLen) {
|
|
261
267
|
if (!o) return;
|
|
@@ -277,8 +283,8 @@ function _nonIterableRest() {
|
|
|
277
283
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
278
284
|
}
|
|
279
285
|
function _createForOfIteratorHelper(o, allowArrayLike) {
|
|
280
|
-
var it;
|
|
281
|
-
if (
|
|
286
|
+
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
287
|
+
if (!it) {
|
|
282
288
|
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
283
289
|
if (it) o = it;
|
|
284
290
|
var i = 0;
|
|
@@ -307,7 +313,7 @@ function _createForOfIteratorHelper(o, allowArrayLike) {
|
|
|
307
313
|
err;
|
|
308
314
|
return {
|
|
309
315
|
s: function () {
|
|
310
|
-
it =
|
|
316
|
+
it = it.call(o);
|
|
311
317
|
},
|
|
312
318
|
n: function () {
|
|
313
319
|
var step = it.next();
|
|
@@ -327,6 +333,20 @@ function _createForOfIteratorHelper(o, allowArrayLike) {
|
|
|
327
333
|
}
|
|
328
334
|
};
|
|
329
335
|
}
|
|
336
|
+
function _toPrimitive(input, hint) {
|
|
337
|
+
if (typeof input !== "object" || input === null) return input;
|
|
338
|
+
var prim = input[Symbol.toPrimitive];
|
|
339
|
+
if (prim !== undefined) {
|
|
340
|
+
var res = prim.call(input, hint || "default");
|
|
341
|
+
if (typeof res !== "object") return res;
|
|
342
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
343
|
+
}
|
|
344
|
+
return (hint === "string" ? String : Number)(input);
|
|
345
|
+
}
|
|
346
|
+
function _toPropertyKey(arg) {
|
|
347
|
+
var key = _toPrimitive(arg, "string");
|
|
348
|
+
return typeof key === "symbol" ? key : String(key);
|
|
349
|
+
}
|
|
330
350
|
|
|
331
351
|
/**
|
|
332
352
|
* The Settings to be passed to the Class
|
|
@@ -1182,6 +1202,9 @@ var hydrateSettings = (function (settings, withFallback) {
|
|
|
1182
1202
|
});
|
|
1183
1203
|
|
|
1184
1204
|
// @ts-check
|
|
1205
|
+
|
|
1206
|
+
// [PUBLICLY EXPOSED METHOD]
|
|
1207
|
+
|
|
1185
1208
|
/**
|
|
1186
1209
|
* Axis-Aligned Bounding Box Collision Detection.
|
|
1187
1210
|
* Imagine following Example:
|
|
@@ -1552,12 +1575,15 @@ var Area = /*#__PURE__*/function () {
|
|
|
1552
1575
|
/** @param {DSArea} area */
|
|
1553
1576
|
_createClass(Area, [{
|
|
1554
1577
|
key: "HTMLNode",
|
|
1578
|
+
get:
|
|
1555
1579
|
/// ///////////////////////////////////////////////////////////////////////////////////
|
|
1556
1580
|
// Node Getters
|
|
1557
|
-
|
|
1581
|
+
|
|
1582
|
+
function get() {
|
|
1558
1583
|
return (/** @type {DSArea} */this._node
|
|
1559
1584
|
);
|
|
1560
1585
|
}
|
|
1586
|
+
|
|
1561
1587
|
/**
|
|
1562
1588
|
* The computed border from the element (caches result)
|
|
1563
1589
|
* @type {{top:number,bottom:number,left:number,right:number}}
|
|
@@ -1573,6 +1599,7 @@ var Area = /*#__PURE__*/function () {
|
|
|
1573
1599
|
right: parseInt(this.computedStyle.borderRightWidth)
|
|
1574
1600
|
};
|
|
1575
1601
|
}
|
|
1602
|
+
|
|
1576
1603
|
/**
|
|
1577
1604
|
* The computed styles from the element (caches result)
|
|
1578
1605
|
* @type {CSSStyleDeclaration}
|
|
@@ -1584,6 +1611,7 @@ var Area = /*#__PURE__*/function () {
|
|
|
1584
1611
|
if (this.HTMLNode instanceof Document) return this._computedStyle = window.getComputedStyle(this.HTMLNode.body || this.HTMLNode.documentElement);
|
|
1585
1612
|
return this._computedStyle = window.getComputedStyle(this.HTMLNode);
|
|
1586
1613
|
}
|
|
1614
|
+
|
|
1587
1615
|
/**
|
|
1588
1616
|
* The element rect (caches result) (without scrollbar or borders)
|
|
1589
1617
|
* @type {DSBoundingRect}
|
|
@@ -1961,6 +1989,7 @@ var DropZone = /*#__PURE__*/function () {
|
|
|
1961
1989
|
this._itemsInside = null;
|
|
1962
1990
|
this.isDestroyed = true;
|
|
1963
1991
|
}
|
|
1992
|
+
|
|
1964
1993
|
/**
|
|
1965
1994
|
* @returns {DSDropZone}
|
|
1966
1995
|
*/
|
|
@@ -2014,7 +2043,7 @@ var DropZone = /*#__PURE__*/function () {
|
|
|
2014
2043
|
return DropZone;
|
|
2015
2044
|
}();
|
|
2016
2045
|
|
|
2017
|
-
var DropZones =
|
|
2046
|
+
var DropZones = /*#__PURE__*/_createClass(
|
|
2018
2047
|
/**
|
|
2019
2048
|
* Get the drop zone by the zone element
|
|
2020
2049
|
* @type {Map<DSElement, DropZone>}
|
|
@@ -2143,7 +2172,7 @@ function DropZones(_ref) {
|
|
|
2143
2172
|
/**
|
|
2144
2173
|
* @param {Object} obj
|
|
2145
2174
|
* @param {DSDropZone[]} [obj.dropZones]
|
|
2146
|
-
|
|
2175
|
+
*/);
|
|
2147
2176
|
|
|
2148
2177
|
var Interaction = /*#__PURE__*/function () {
|
|
2149
2178
|
/** @type {boolean} */
|
|
@@ -2215,6 +2244,7 @@ var Interaction = /*#__PURE__*/function () {
|
|
|
2215
2244
|
var event = _ref2.event;
|
|
2216
2245
|
if (!_this._canInteract(event)) return;
|
|
2217
2246
|
if (event.detail > 0) return; // mouse interaction
|
|
2247
|
+
|
|
2218
2248
|
var _this$DS = _this.DS,
|
|
2219
2249
|
_this$DS$stores = _this$DS.stores,
|
|
2220
2250
|
PointerStore = _this$DS$stores.PointerStore,
|
|
@@ -2304,10 +2334,11 @@ var Interaction = /*#__PURE__*/function () {
|
|
|
2304
2334
|
}
|
|
2305
2335
|
_createClass(Interaction, [{
|
|
2306
2336
|
key: "_canInteract",
|
|
2337
|
+
value:
|
|
2307
2338
|
/**
|
|
2308
2339
|
* @param {DSEvent} event
|
|
2309
2340
|
*/
|
|
2310
|
-
|
|
2341
|
+
function _canInteract(event) {
|
|
2311
2342
|
var isKeyboardClick = /** @type {MouseEvent} */event.clientX === 0 && /** @type {MouseEvent} */event.clientY === 0 && /** @type {MouseEvent} */event.detail === 0 && event.target;
|
|
2312
2343
|
if ( /** @type {MouseEvent} */event.button === 2 ||
|
|
2313
2344
|
// right-clicks
|
|
@@ -2319,6 +2350,7 @@ var Interaction = /*#__PURE__*/function () {
|
|
|
2319
2350
|
) return false;
|
|
2320
2351
|
return true;
|
|
2321
2352
|
}
|
|
2353
|
+
|
|
2322
2354
|
/**
|
|
2323
2355
|
* @param {DSEvent} event
|
|
2324
2356
|
*/
|
|
@@ -2326,7 +2358,7 @@ var Interaction = /*#__PURE__*/function () {
|
|
|
2326
2358
|
return Interaction;
|
|
2327
2359
|
}();
|
|
2328
2360
|
|
|
2329
|
-
var PubSub = function PubSub(_ref) {
|
|
2361
|
+
var PubSub = /*#__PURE__*/_createClass(function PubSub(_ref) {
|
|
2330
2362
|
var _this = this;
|
|
2331
2363
|
var DS = _ref.DS;
|
|
2332
2364
|
_classCallCheck(this, PubSub);
|
|
@@ -2374,7 +2406,7 @@ var PubSub = function PubSub(_ref) {
|
|
|
2374
2406
|
* @param {DSCallbackNames} eventName
|
|
2375
2407
|
* @param {DSCallback} callback
|
|
2376
2408
|
* @returns {number} event id, can be used to unsubscribe more efficiently
|
|
2377
|
-
|
|
2409
|
+
*/);
|
|
2378
2410
|
|
|
2379
2411
|
var SelectableSet = /*#__PURE__*/function (_Set) {
|
|
2380
2412
|
_inherits(SelectableSet, _Set);
|
|
@@ -2451,7 +2483,8 @@ var SelectableSet = /*#__PURE__*/function (_Set) {
|
|
|
2451
2483
|
}
|
|
2452
2484
|
_createClass(SelectableSet, [{
|
|
2453
2485
|
key: "add",
|
|
2454
|
-
/** @param {DSElement} element */
|
|
2486
|
+
value: /** @param {DSElement} element */
|
|
2487
|
+
function add(element) {
|
|
2455
2488
|
if (_get(_getPrototypeOf(SelectableSet.prototype), "has", this).call(this, element)) return;
|
|
2456
2489
|
var publishData = {
|
|
2457
2490
|
items: this.elements,
|
|
@@ -2474,7 +2507,9 @@ var SelectableSet = /*#__PURE__*/function (_Set) {
|
|
|
2474
2507
|
});
|
|
2475
2508
|
this.DS.publish('Selectable:added', publishData);
|
|
2476
2509
|
return _get(_getPrototypeOf(SelectableSet.prototype), "add", this).call(this, element);
|
|
2477
|
-
}
|
|
2510
|
+
}
|
|
2511
|
+
|
|
2512
|
+
/** @param {DSElement} element */
|
|
2478
2513
|
}, {
|
|
2479
2514
|
key: "delete",
|
|
2480
2515
|
value: function _delete(element) {
|
|
@@ -2500,7 +2535,8 @@ var SelectableSet = /*#__PURE__*/function (_Set) {
|
|
|
2500
2535
|
}
|
|
2501
2536
|
}, {
|
|
2502
2537
|
key: "elements",
|
|
2503
|
-
/** @return {DSElements} */
|
|
2538
|
+
get: /** @return {DSElements} */
|
|
2539
|
+
function get() {
|
|
2504
2540
|
return Array.from(this.values());
|
|
2505
2541
|
}
|
|
2506
2542
|
}, {
|
|
@@ -2571,7 +2607,9 @@ var SelectedSet = /*#__PURE__*/function (_Set) {
|
|
|
2571
2607
|
element.style.zIndex = "".concat((parseInt(element.style.zIndex) || 0) + 1);
|
|
2572
2608
|
this.DS.publish('Selected:added', publishData);
|
|
2573
2609
|
return this;
|
|
2574
|
-
}
|
|
2610
|
+
}
|
|
2611
|
+
|
|
2612
|
+
/** @param {DSElement} element */
|
|
2575
2613
|
}, {
|
|
2576
2614
|
key: "delete",
|
|
2577
2615
|
value: function _delete(element) {
|
|
@@ -2589,18 +2627,22 @@ var SelectedSet = /*#__PURE__*/function (_Set) {
|
|
|
2589
2627
|
}
|
|
2590
2628
|
}, {
|
|
2591
2629
|
key: "toggle",
|
|
2630
|
+
value:
|
|
2592
2631
|
/**
|
|
2593
2632
|
* Adds/Removes an element. If it is already selected = remove, if not = add.
|
|
2594
2633
|
* @param {DSElement} element
|
|
2595
2634
|
* @return {DSElement}
|
|
2596
2635
|
*/
|
|
2597
|
-
|
|
2636
|
+
function toggle(element) {
|
|
2598
2637
|
if (this.has(element)) this["delete"](element);else this.add(element);
|
|
2599
2638
|
return element;
|
|
2600
|
-
}
|
|
2639
|
+
}
|
|
2640
|
+
|
|
2641
|
+
/** @param {DSElements} elements */
|
|
2601
2642
|
}, {
|
|
2602
2643
|
key: "elements",
|
|
2603
|
-
/** @return {DSElements} */
|
|
2644
|
+
get: /** @return {DSElements} */
|
|
2645
|
+
function get() {
|
|
2604
2646
|
return Array.from(this.values());
|
|
2605
2647
|
}
|
|
2606
2648
|
}]);
|
|
@@ -2640,28 +2682,41 @@ var Selection = /*#__PURE__*/function () {
|
|
|
2640
2682
|
SelectableSet = _this$DS.SelectableSet,
|
|
2641
2683
|
SelectorArea = _this$DS.SelectorArea,
|
|
2642
2684
|
Selector = _this$DS.Selector;
|
|
2685
|
+
var multiSelectionToggle = _this.DS.stores.KeyStore.isMultiSelectKeyPressed(event) && _this.Settings.multiSelectToggling;
|
|
2686
|
+
var selectionThreshold = _this.Settings.selectionThreshold;
|
|
2687
|
+
|
|
2643
2688
|
/** @type {any} */
|
|
2644
2689
|
var elRects = SelectableSet.rects;
|
|
2645
|
-
var
|
|
2646
|
-
|
|
2690
|
+
var selectorRect = Selector.rect;
|
|
2691
|
+
|
|
2692
|
+
/** @type {Map<DSElement,DSBoundingRect>} */
|
|
2693
|
+
var select = new Map();
|
|
2694
|
+
/** @type {Map<DSElement,DSBoundingRect>} */
|
|
2695
|
+
var unselect = new Map();
|
|
2647
2696
|
var _iterator = _createForOfIteratorHelper(elRects),
|
|
2648
2697
|
_step;
|
|
2649
2698
|
try {
|
|
2650
2699
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
2651
2700
|
var _step$value = _slicedToArray(_step.value, 2),
|
|
2652
2701
|
element = _step$value[0],
|
|
2653
|
-
|
|
2654
|
-
if (!SelectorArea.isInside(element,
|
|
2655
|
-
if (isCollision(
|
|
2702
|
+
elementRect = _step$value[1];
|
|
2703
|
+
if (!SelectorArea.isInside(element, elementRect)) continue;
|
|
2704
|
+
if (isCollision(elementRect, selectorRect, selectionThreshold)) select.set(element, elementRect);else unselect.set(element, elementRect);
|
|
2656
2705
|
}
|
|
2657
2706
|
} catch (err) {
|
|
2658
2707
|
_iterator.e(err);
|
|
2659
2708
|
} finally {
|
|
2660
2709
|
_iterator.f();
|
|
2661
2710
|
}
|
|
2662
|
-
var multiSelectionToggle = _this.DS.stores.KeyStore.isMultiSelectKeyPressed(event) && _this.Settings.multiSelectToggling;
|
|
2663
2711
|
if (_this.DS["continue"]) return;
|
|
2664
|
-
|
|
2712
|
+
var _this$filterSelected = _this.filterSelected({
|
|
2713
|
+
select: select,
|
|
2714
|
+
unselect: unselect,
|
|
2715
|
+
selectorRect: selectorRect
|
|
2716
|
+
}),
|
|
2717
|
+
filteredSelect = _this$filterSelected.select,
|
|
2718
|
+
filteredUnselect = _this$filterSelected.unselect;
|
|
2719
|
+
filteredSelect.forEach(function (_, element) {
|
|
2665
2720
|
return handleSelection({
|
|
2666
2721
|
element: element,
|
|
2667
2722
|
force: force,
|
|
@@ -2670,7 +2725,7 @@ var Selection = /*#__PURE__*/function () {
|
|
|
2670
2725
|
hoverClassName: _this.Settings.hoverClass
|
|
2671
2726
|
});
|
|
2672
2727
|
});
|
|
2673
|
-
|
|
2728
|
+
filteredUnselect.forEach(function (_, element) {
|
|
2674
2729
|
return handleUnSelection({
|
|
2675
2730
|
element: element,
|
|
2676
2731
|
force: force,
|
|
@@ -2680,6 +2735,15 @@ var Selection = /*#__PURE__*/function () {
|
|
|
2680
2735
|
});
|
|
2681
2736
|
});
|
|
2682
2737
|
});
|
|
2738
|
+
_defineProperty(this, "filterSelected", function (_ref4) {
|
|
2739
|
+
var select = _ref4.select,
|
|
2740
|
+
unselect = _ref4.unselect;
|
|
2741
|
+
_ref4.selectorRect;
|
|
2742
|
+
return {
|
|
2743
|
+
select: select,
|
|
2744
|
+
unselect: unselect
|
|
2745
|
+
};
|
|
2746
|
+
});
|
|
2683
2747
|
this.DS = DS;
|
|
2684
2748
|
this.Settings = this.DS.stores.SettingsStore.s;
|
|
2685
2749
|
this.DS.subscribe('Interaction:start', this.start);
|
|
@@ -2698,7 +2762,9 @@ var Selection = /*#__PURE__*/function () {
|
|
|
2698
2762
|
KeyStore = _this$DS2.stores.KeyStore,
|
|
2699
2763
|
SelectedSet = _this$DS2.SelectedSet;
|
|
2700
2764
|
if (KeyStore.isMultiSelectKeyPressed(event)) this._prevSelectedSet = new Set(SelectedSet);else this._prevSelectedSet = new Set();
|
|
2701
|
-
}
|
|
2765
|
+
}
|
|
2766
|
+
|
|
2767
|
+
/** @param {{event:DSEvent,isDragging:boolean}} event */
|
|
2702
2768
|
}]);
|
|
2703
2769
|
return Selection;
|
|
2704
2770
|
}();
|
|
@@ -2884,12 +2950,13 @@ var SelectorArea = /*#__PURE__*/function () {
|
|
|
2884
2950
|
}
|
|
2885
2951
|
_createClass(SelectorArea, [{
|
|
2886
2952
|
key: "isClicked",
|
|
2953
|
+
value:
|
|
2887
2954
|
/**
|
|
2888
2955
|
* checks if the click was triggered on the area.
|
|
2889
2956
|
* @param {DSEvent} [event]
|
|
2890
2957
|
* @returns {boolean}
|
|
2891
2958
|
*/
|
|
2892
|
-
|
|
2959
|
+
function isClicked(event) {
|
|
2893
2960
|
var PointerStore = this.DS.stores.PointerStore;
|
|
2894
2961
|
var initialVal = event ? PointerStore.getPointerPosition(event) : PointerStore.initialVal;
|
|
2895
2962
|
return isCollision({
|
|
@@ -2979,7 +3046,8 @@ var KeyStore = /*#__PURE__*/function () {
|
|
|
2979
3046
|
}
|
|
2980
3047
|
_createClass(KeyStore, [{
|
|
2981
3048
|
key: "isMultiSelectKeyPressed",
|
|
2982
|
-
/** @param {KeyboardEvent|MouseEvent|PointerEvent|TouchEvent} [event] */
|
|
3049
|
+
value: /** @param {KeyboardEvent|MouseEvent|PointerEvent|TouchEvent} [event] */
|
|
3050
|
+
function isMultiSelectKeyPressed(event) {
|
|
2983
3051
|
var _this2 = this;
|
|
2984
3052
|
if (this.DS.stores.SettingsStore.s.multiSelectMode) return true;
|
|
2985
3053
|
var multiSelectKeys = this.DS.stores.SettingsStore.s.multiSelectKeys.map(function (key) {
|
|
@@ -3121,25 +3189,31 @@ var PointerStore = /*#__PURE__*/function () {
|
|
|
3121
3189
|
}
|
|
3122
3190
|
_createClass(PointerStore, [{
|
|
3123
3191
|
key: "start",
|
|
3124
|
-
/** @param {DSEvent} [event] */
|
|
3192
|
+
value: /** @param {DSEvent} [event] */
|
|
3193
|
+
function start(event) {
|
|
3125
3194
|
if (!event) return;
|
|
3126
3195
|
this._isMouseInteraction = true;
|
|
3127
3196
|
this.currentVal = this.initialVal = this.getPointerPosition(event);
|
|
3128
|
-
}
|
|
3197
|
+
}
|
|
3198
|
+
|
|
3199
|
+
/** @param {DSEvent} event */
|
|
3129
3200
|
}, {
|
|
3130
3201
|
key: "_normalizedEvent",
|
|
3202
|
+
value:
|
|
3131
3203
|
/**
|
|
3132
3204
|
* @param {DSEvent} event
|
|
3133
3205
|
* @return {MouseEvent|PointerEvent|Touch}
|
|
3134
3206
|
* @private
|
|
3135
3207
|
*/
|
|
3136
|
-
|
|
3208
|
+
function _normalizedEvent(event) {
|
|
3137
3209
|
// touchend has not touches. so we take the last touch if a touchevent, we need to store the positions
|
|
3138
3210
|
if ('touches' in event && event.type !== 'touchend') this._lastTouch = event;
|
|
3139
3211
|
// if a touchevent, return the last touch rather than the regular event
|
|
3140
3212
|
// we need .touches[0] from that event instead
|
|
3141
3213
|
return 'touches' in event ? this._lastTouch.touches[0] : event;
|
|
3142
|
-
}
|
|
3214
|
+
}
|
|
3215
|
+
|
|
3216
|
+
/** First recorded pointer position within the area */
|
|
3143
3217
|
}, {
|
|
3144
3218
|
key: "initialValArea",
|
|
3145
3219
|
get: function get() {
|
|
@@ -3148,7 +3222,9 @@ var PointerStore = /*#__PURE__*/function () {
|
|
|
3148
3222
|
y: 0
|
|
3149
3223
|
};
|
|
3150
3224
|
return this._initialValArea;
|
|
3151
|
-
}
|
|
3225
|
+
}
|
|
3226
|
+
|
|
3227
|
+
/** Current pointer position within the area */
|
|
3152
3228
|
}, {
|
|
3153
3229
|
key: "currentValArea",
|
|
3154
3230
|
get: function get() {
|
|
@@ -3157,7 +3233,9 @@ var PointerStore = /*#__PURE__*/function () {
|
|
|
3157
3233
|
y: 0
|
|
3158
3234
|
};
|
|
3159
3235
|
return this._currentValArea;
|
|
3160
|
-
}
|
|
3236
|
+
}
|
|
3237
|
+
|
|
3238
|
+
/** Last recorded pointer position within the area */
|
|
3161
3239
|
}, {
|
|
3162
3240
|
key: "lastValArea",
|
|
3163
3241
|
get: function get() {
|
|
@@ -3166,7 +3244,9 @@ var PointerStore = /*#__PURE__*/function () {
|
|
|
3166
3244
|
y: 0
|
|
3167
3245
|
};
|
|
3168
3246
|
return this._lastValArea;
|
|
3169
|
-
}
|
|
3247
|
+
}
|
|
3248
|
+
|
|
3249
|
+
/** First recorded pointer position */
|
|
3170
3250
|
}, {
|
|
3171
3251
|
key: "initialVal",
|
|
3172
3252
|
get: function get() {
|
|
@@ -3175,7 +3255,9 @@ var PointerStore = /*#__PURE__*/function () {
|
|
|
3175
3255
|
y: 0
|
|
3176
3256
|
};
|
|
3177
3257
|
return this._initialVal;
|
|
3178
|
-
}
|
|
3258
|
+
}
|
|
3259
|
+
|
|
3260
|
+
/** Current pointer position */,
|
|
3179
3261
|
set: function set(value) {
|
|
3180
3262
|
this._initialVal = value;
|
|
3181
3263
|
this._initialValArea = value && calc(value, '-', calc(rect2vect(this.DS.Area.rect), '+', rect2vect(this.DS.Area.computedBorder)));
|
|
@@ -3188,7 +3270,9 @@ var PointerStore = /*#__PURE__*/function () {
|
|
|
3188
3270
|
y: 0
|
|
3189
3271
|
};
|
|
3190
3272
|
return this._currentVal;
|
|
3191
|
-
}
|
|
3273
|
+
}
|
|
3274
|
+
|
|
3275
|
+
/** Last recorded pointer position */,
|
|
3192
3276
|
set: function set(value) {
|
|
3193
3277
|
this._currentVal = value;
|
|
3194
3278
|
this._currentValArea = value && calc(value, '-', calc(rect2vect(this.DS.Area.rect), '+', rect2vect(this.DS.Area.computedBorder)));
|
|
@@ -3305,7 +3389,7 @@ var ScrollStore = /*#__PURE__*/function () {
|
|
|
3305
3389
|
return ScrollStore;
|
|
3306
3390
|
}();
|
|
3307
3391
|
|
|
3308
|
-
var SettingsStore =
|
|
3392
|
+
var SettingsStore = /*#__PURE__*/_createClass(
|
|
3309
3393
|
/**
|
|
3310
3394
|
* @type {Settings}
|
|
3311
3395
|
* @private
|
|
@@ -3384,7 +3468,7 @@ function SettingsStore(_ref) {
|
|
|
3384
3468
|
});
|
|
3385
3469
|
}
|
|
3386
3470
|
|
|
3387
|
-
/** @param {{settings: Settings, init?: boolean}} props
|
|
3471
|
+
/** @param {{settings: Settings, init?: boolean}} props */);
|
|
3388
3472
|
|
|
3389
3473
|
// Setup
|
|
3390
3474
|
/// ///////////////////////////////////////////////////////////////////////////////////
|
|
@@ -3525,6 +3609,7 @@ var DragSelect = /*#__PURE__*/function () {
|
|
|
3525
3609
|
*/
|
|
3526
3610
|
_createClass(DragSelect, [{
|
|
3527
3611
|
key: "stop",
|
|
3612
|
+
value:
|
|
3528
3613
|
/**
|
|
3529
3614
|
* Complete function teardown
|
|
3530
3615
|
* Will teardown/stop the whole functionality
|
|
@@ -3532,7 +3617,7 @@ var DragSelect = /*#__PURE__*/function () {
|
|
|
3532
3617
|
* @param {boolean} [fromSelection] - if elements should also be added/removed to the selection.
|
|
3533
3618
|
* @param {boolean} [withCallback] - if elements should also be added/removed to the selection.
|
|
3534
3619
|
*/
|
|
3535
|
-
|
|
3620
|
+
function stop() {
|
|
3536
3621
|
var remove = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
3537
3622
|
var fromSelection = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
3538
3623
|
var withCallback = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
@@ -3551,6 +3636,7 @@ var DragSelect = /*#__PURE__*/function () {
|
|
|
3551
3636
|
if (fromSelection) this.SelectedSet.clear();
|
|
3552
3637
|
this.stopped = true;
|
|
3553
3638
|
}
|
|
3639
|
+
|
|
3554
3640
|
/**
|
|
3555
3641
|
* Utility to override DragSelect internal functionality:
|
|
3556
3642
|
* Break will skip the selection or dragging functionality (until after the callback) but let everything continue to run.
|
|
@@ -3558,6 +3644,7 @@ var DragSelect = /*#__PURE__*/function () {
|
|
|
3558
3644
|
*/
|
|
3559
3645
|
}, {
|
|
3560
3646
|
key: "addSelection",
|
|
3647
|
+
value:
|
|
3561
3648
|
/**
|
|
3562
3649
|
* Adds several elements to the selection list also adds the specific classes and take into account all calculations.
|
|
3563
3650
|
* Does not clear the selection, in contrary to .setSelection. Can add multiple elements at once
|
|
@@ -3566,7 +3653,7 @@ var DragSelect = /*#__PURE__*/function () {
|
|
|
3566
3653
|
* @param {boolean} [dontAddToSelectables] - if element should not be added to the list of selectable elements
|
|
3567
3654
|
* @return {DSElements} all selected elements
|
|
3568
3655
|
*/
|
|
3569
|
-
|
|
3656
|
+
function addSelection(elements) {
|
|
3570
3657
|
var triggerCallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
3571
3658
|
var dontAddToSelectables = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
3572
3659
|
this.SelectedSet.addAll(toArray(elements));
|
|
@@ -3576,6 +3663,7 @@ var DragSelect = /*#__PURE__*/function () {
|
|
|
3576
3663
|
});
|
|
3577
3664
|
return this.getSelection();
|
|
3578
3665
|
}
|
|
3666
|
+
|
|
3579
3667
|
/**
|
|
3580
3668
|
* Removes specific elements from the selection
|
|
3581
3669
|
* Multiple elements can be given at once, in contrary to unselect
|
|
@@ -3596,6 +3684,7 @@ var DragSelect = /*#__PURE__*/function () {
|
|
|
3596
3684
|
});
|
|
3597
3685
|
return this.getSelection();
|
|
3598
3686
|
}
|
|
3687
|
+
|
|
3599
3688
|
/**
|
|
3600
3689
|
* Toggles specific elements from the selection:
|
|
3601
3690
|
* If element is not in selection it will be added, if it is already selected, it will be removed.
|
|
@@ -3619,6 +3708,7 @@ var DragSelect = /*#__PURE__*/function () {
|
|
|
3619
3708
|
});
|
|
3620
3709
|
return this.getSelection();
|
|
3621
3710
|
}
|
|
3711
|
+
|
|
3622
3712
|
/**
|
|
3623
3713
|
* Sets the current selected elements and optionally run the callback
|
|
3624
3714
|
* By default, adds new elements also to the list of selectables
|
|
@@ -3636,6 +3726,7 @@ var DragSelect = /*#__PURE__*/function () {
|
|
|
3636
3726
|
this.addSelection(elements, triggerCallback, dontAddToSelectables);
|
|
3637
3727
|
return this.getSelection();
|
|
3638
3728
|
}
|
|
3729
|
+
|
|
3639
3730
|
/**
|
|
3640
3731
|
* Unselect / Deselect all current selected Nodes
|
|
3641
3732
|
* @param {boolean} [triggerCallback] - if callback should be called
|
|
@@ -3651,6 +3742,7 @@ var DragSelect = /*#__PURE__*/function () {
|
|
|
3651
3742
|
});
|
|
3652
3743
|
return this.getSelection();
|
|
3653
3744
|
}
|
|
3745
|
+
|
|
3654
3746
|
/**
|
|
3655
3747
|
* Add elements that can be selected. No node is added twice
|
|
3656
3748
|
* @param {DSInputElements} elements dom element(s)
|
|
@@ -3669,12 +3761,14 @@ var DragSelect = /*#__PURE__*/function () {
|
|
|
3669
3761
|
});
|
|
3670
3762
|
return elements;
|
|
3671
3763
|
}
|
|
3764
|
+
|
|
3672
3765
|
/**
|
|
3673
3766
|
* Gets all nodes that can potentially be selected
|
|
3674
3767
|
* @return {DSElements} this.selectables
|
|
3675
3768
|
*/
|
|
3676
3769
|
}, {
|
|
3677
3770
|
key: "setSelectables",
|
|
3771
|
+
value:
|
|
3678
3772
|
/**
|
|
3679
3773
|
* Sets all elements that can be selected.
|
|
3680
3774
|
* Removes all current selectables (& their respective classes).
|
|
@@ -3684,13 +3778,14 @@ var DragSelect = /*#__PURE__*/function () {
|
|
|
3684
3778
|
* @param {boolean} [addToSelection] if elements should also be added to current selection
|
|
3685
3779
|
* @return {DSInputElements} elements – the added element(s)
|
|
3686
3780
|
*/
|
|
3687
|
-
|
|
3781
|
+
function setSelectables(elements) {
|
|
3688
3782
|
var removeFromSelection = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
3689
3783
|
var addToSelection = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
3690
3784
|
console.warn('[DragSelect] DEPRECATION ".setSelectables" is deprecated and will be removed soon. Please use "ds.setSettings({ selectables: << new dom elements >> })" instead (see docs)');
|
|
3691
3785
|
this.removeSelectables(elements, removeFromSelection);
|
|
3692
3786
|
return this.addSelectables(elements, addToSelection);
|
|
3693
3787
|
}
|
|
3788
|
+
|
|
3694
3789
|
/**
|
|
3695
3790
|
* Remove elements from the elements that can be selected.
|
|
3696
3791
|
* @param {DSInputElements} elements – dom element(s)
|
|
@@ -3707,9 +3802,12 @@ var DragSelect = /*#__PURE__*/function () {
|
|
|
3707
3802
|
items: this.getSelection()
|
|
3708
3803
|
});
|
|
3709
3804
|
return elements;
|
|
3710
|
-
}
|
|
3805
|
+
}
|
|
3806
|
+
|
|
3807
|
+
/** The starting/initial position of the cursor/selector @return {Vect2} */
|
|
3711
3808
|
}]);
|
|
3712
3809
|
return DragSelect;
|
|
3713
3810
|
}();
|
|
3811
|
+
DragSelect.isCollision = isCollision;
|
|
3714
3812
|
|
|
3715
|
-
export default
|
|
3813
|
+
export { DragSelect as default };
|