dragselect 2.5.4 → 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 +8 -0
- package/deployment.md +32 -0
- package/dist/DragSelect.d.ts +2 -2
- package/dist/DragSelect.es6m.js +193 -114
- package/dist/DragSelect.js +194 -115
- package/dist/ds.es6m.min.js +1 -1
- package/dist/ds.min.js +1 -1
- package/dist/modules/Interaction.d.ts +1 -1
- package/package.json +16 -23
- package/rollup.config.js +4 -23
- package/src/DragSelect.js +45 -11
- package/src/modules/Area.js +3 -2
- package/src/modules/Interaction.js +8 -5
- package/CODE_OF_CONDUCT.md +0 -128
- package/CONTRIBUTING.md +0 -48
- package/LICENSE +0 -21
- package/README.md +0 -470
- package/deploying.md +0 -36
- package/jsdoc.json +0 -18
- package/todos.md +0 -10
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
|
|
@@ -1494,6 +1514,7 @@
|
|
|
1494
1514
|
_defineProperty(this, "_computedBorder", void 0);
|
|
1495
1515
|
_defineProperty(this, "_rect", void 0);
|
|
1496
1516
|
_defineProperty(this, "setArea", function (area) {
|
|
1517
|
+
_this.reset();
|
|
1497
1518
|
_this._node = area;
|
|
1498
1519
|
handleElementPositionAttribute({
|
|
1499
1520
|
computedStyle: _this.computedStyle,
|
|
@@ -1548,7 +1569,7 @@
|
|
|
1548
1569
|
// @ts-ignore: @todo: update to typescript
|
|
1549
1570
|
this.DS.PubSub.subscribe('Settings:updated:area', function (_ref2) {
|
|
1550
1571
|
var settings = _ref2.settings;
|
|
1551
|
-
|
|
1572
|
+
_this.setArea(settings.area);
|
|
1552
1573
|
});
|
|
1553
1574
|
this.DS.PubSub.subscribe('Interaction:init', this.start);
|
|
1554
1575
|
this.DS.PubSub.subscribe('Interaction:end', this.reset);
|
|
@@ -1557,12 +1578,15 @@
|
|
|
1557
1578
|
/** @param {DSArea} area */
|
|
1558
1579
|
_createClass(Area, [{
|
|
1559
1580
|
key: "HTMLNode",
|
|
1581
|
+
get:
|
|
1560
1582
|
/// ///////////////////////////////////////////////////////////////////////////////////
|
|
1561
1583
|
// Node Getters
|
|
1562
|
-
|
|
1584
|
+
|
|
1585
|
+
function get() {
|
|
1563
1586
|
return (/** @type {DSArea} */this._node
|
|
1564
1587
|
);
|
|
1565
1588
|
}
|
|
1589
|
+
|
|
1566
1590
|
/**
|
|
1567
1591
|
* The computed border from the element (caches result)
|
|
1568
1592
|
* @type {{top:number,bottom:number,left:number,right:number}}
|
|
@@ -1578,6 +1602,7 @@
|
|
|
1578
1602
|
right: parseInt(this.computedStyle.borderRightWidth)
|
|
1579
1603
|
};
|
|
1580
1604
|
}
|
|
1605
|
+
|
|
1581
1606
|
/**
|
|
1582
1607
|
* The computed styles from the element (caches result)
|
|
1583
1608
|
* @type {CSSStyleDeclaration}
|
|
@@ -1589,6 +1614,7 @@
|
|
|
1589
1614
|
if (this.HTMLNode instanceof Document) return this._computedStyle = window.getComputedStyle(this.HTMLNode.body || this.HTMLNode.documentElement);
|
|
1590
1615
|
return this._computedStyle = window.getComputedStyle(this.HTMLNode);
|
|
1591
1616
|
}
|
|
1617
|
+
|
|
1592
1618
|
/**
|
|
1593
1619
|
* The element rect (caches result) (without scrollbar or borders)
|
|
1594
1620
|
* @type {DSBoundingRect}
|
|
@@ -1966,6 +1992,7 @@
|
|
|
1966
1992
|
this._itemsInside = null;
|
|
1967
1993
|
this.isDestroyed = true;
|
|
1968
1994
|
}
|
|
1995
|
+
|
|
1969
1996
|
/**
|
|
1970
1997
|
* @returns {DSDropZone}
|
|
1971
1998
|
*/
|
|
@@ -2019,7 +2046,7 @@
|
|
|
2019
2046
|
return DropZone;
|
|
2020
2047
|
}();
|
|
2021
2048
|
|
|
2022
|
-
var DropZones =
|
|
2049
|
+
var DropZones = /*#__PURE__*/_createClass(
|
|
2023
2050
|
/**
|
|
2024
2051
|
* Get the drop zone by the zone element
|
|
2025
2052
|
* @type {Map<DSElement, DropZone>}
|
|
@@ -2148,7 +2175,7 @@
|
|
|
2148
2175
|
/**
|
|
2149
2176
|
* @param {Object} obj
|
|
2150
2177
|
* @param {DSDropZone[]} [obj.dropZones]
|
|
2151
|
-
|
|
2178
|
+
*/);
|
|
2152
2179
|
|
|
2153
2180
|
var Interaction = /*#__PURE__*/function () {
|
|
2154
2181
|
/** @type {boolean} */
|
|
@@ -2220,6 +2247,7 @@
|
|
|
2220
2247
|
var event = _ref2.event;
|
|
2221
2248
|
if (!_this._canInteract(event)) return;
|
|
2222
2249
|
if (event.detail > 0) return; // mouse interaction
|
|
2250
|
+
|
|
2223
2251
|
var _this$DS = _this.DS,
|
|
2224
2252
|
_this$DS$stores = _this$DS.stores,
|
|
2225
2253
|
PointerStore = _this$DS$stores.PointerStore,
|
|
@@ -2234,22 +2262,23 @@
|
|
|
2234
2262
|
_this.reset(); // simulate mouse-up (that does not exist on keyboard)
|
|
2235
2263
|
});
|
|
2236
2264
|
_defineProperty(this, "stop", function () {
|
|
2265
|
+
var area = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _this.DS.Area.HTMLNode;
|
|
2237
2266
|
_this.isInteracting = false;
|
|
2238
2267
|
_this.isDragging = false;
|
|
2239
2268
|
|
|
2240
2269
|
// @TODO: fix pointer events mixing issue see [PR](https://github.com/ThibaultJanBeyer/DragSelect/pull/128#issuecomment-1154885289)
|
|
2241
2270
|
if (_this.Settings.usePointerEvents) {
|
|
2242
|
-
|
|
2271
|
+
area.removeEventListener('pointerdown', _this.start, {
|
|
2243
2272
|
// @ts-ignore
|
|
2244
2273
|
passive: false
|
|
2245
2274
|
});
|
|
2246
2275
|
document.removeEventListener('pointerup', _this.reset);
|
|
2247
2276
|
document.removeEventListener('pointercancel', _this.reset);
|
|
2248
2277
|
} else {
|
|
2249
|
-
|
|
2278
|
+
area.removeEventListener('mousedown', _this.start);
|
|
2250
2279
|
document.removeEventListener('mouseup', _this.reset);
|
|
2251
2280
|
}
|
|
2252
|
-
|
|
2281
|
+
area.removeEventListener('touchstart', _this.start, {
|
|
2253
2282
|
// @ts-ignore
|
|
2254
2283
|
passive: false
|
|
2255
2284
|
});
|
|
@@ -2284,30 +2313,35 @@
|
|
|
2284
2313
|
this.DS = DS;
|
|
2285
2314
|
this.Settings = DS.stores.SettingsStore.s;
|
|
2286
2315
|
// @ts-ignore: @todo: update to typescript
|
|
2287
|
-
this.DS.subscribe('Settings:updated:area',
|
|
2316
|
+
this.DS.subscribe('Settings:updated:area', function (_ref4) {
|
|
2317
|
+
var settings = _ref4.settings;
|
|
2318
|
+
_this.stop(settings['area:pre']);
|
|
2319
|
+
_this.init();
|
|
2320
|
+
});
|
|
2288
2321
|
this.DS.subscribe('PointerStore:updated', this.update);
|
|
2289
2322
|
this.DS.subscribe('Selectable:click', this.onClick);
|
|
2290
|
-
this.DS.subscribe('Selectable:pointer', function (
|
|
2291
|
-
var event =
|
|
2323
|
+
this.DS.subscribe('Selectable:pointer', function (_ref5) {
|
|
2324
|
+
var event = _ref5.event;
|
|
2292
2325
|
return _this.start(event);
|
|
2293
2326
|
});
|
|
2294
|
-
this.DS.subscribe('Interaction:start:pre', function (
|
|
2295
|
-
var event =
|
|
2327
|
+
this.DS.subscribe('Interaction:start:pre', function (_ref6) {
|
|
2328
|
+
var event = _ref6.event;
|
|
2296
2329
|
return _this._start(event);
|
|
2297
2330
|
});
|
|
2298
2331
|
this.DS.subscribe('Interaction:init:pre', this._init);
|
|
2299
|
-
this.DS.subscribe('Interaction:end:pre', function (
|
|
2300
|
-
var event =
|
|
2332
|
+
this.DS.subscribe('Interaction:end:pre', function (_ref7) {
|
|
2333
|
+
var event = _ref7.event;
|
|
2301
2334
|
return _this._reset(event);
|
|
2302
2335
|
});
|
|
2303
2336
|
this.DS.subscribe('Area:scroll', this.update);
|
|
2304
2337
|
}
|
|
2305
2338
|
_createClass(Interaction, [{
|
|
2306
2339
|
key: "_canInteract",
|
|
2340
|
+
value:
|
|
2307
2341
|
/**
|
|
2308
2342
|
* @param {DSEvent} event
|
|
2309
2343
|
*/
|
|
2310
|
-
|
|
2344
|
+
function _canInteract(event) {
|
|
2311
2345
|
var isKeyboardClick = /** @type {MouseEvent} */event.clientX === 0 && /** @type {MouseEvent} */event.clientY === 0 && /** @type {MouseEvent} */event.detail === 0 && event.target;
|
|
2312
2346
|
if ( /** @type {MouseEvent} */event.button === 2 ||
|
|
2313
2347
|
// right-clicks
|
|
@@ -2319,6 +2353,7 @@
|
|
|
2319
2353
|
) return false;
|
|
2320
2354
|
return true;
|
|
2321
2355
|
}
|
|
2356
|
+
|
|
2322
2357
|
/**
|
|
2323
2358
|
* @param {DSEvent} event
|
|
2324
2359
|
*/
|
|
@@ -2326,7 +2361,7 @@
|
|
|
2326
2361
|
return Interaction;
|
|
2327
2362
|
}();
|
|
2328
2363
|
|
|
2329
|
-
var PubSub = function PubSub(_ref) {
|
|
2364
|
+
var PubSub = /*#__PURE__*/_createClass(function PubSub(_ref) {
|
|
2330
2365
|
var _this = this;
|
|
2331
2366
|
var DS = _ref.DS;
|
|
2332
2367
|
_classCallCheck(this, PubSub);
|
|
@@ -2374,7 +2409,7 @@
|
|
|
2374
2409
|
* @param {DSCallbackNames} eventName
|
|
2375
2410
|
* @param {DSCallback} callback
|
|
2376
2411
|
* @returns {number} event id, can be used to unsubscribe more efficiently
|
|
2377
|
-
|
|
2412
|
+
*/);
|
|
2378
2413
|
|
|
2379
2414
|
var SelectableSet = /*#__PURE__*/function (_Set) {
|
|
2380
2415
|
_inherits(SelectableSet, _Set);
|
|
@@ -2451,7 +2486,8 @@
|
|
|
2451
2486
|
}
|
|
2452
2487
|
_createClass(SelectableSet, [{
|
|
2453
2488
|
key: "add",
|
|
2454
|
-
/** @param {DSElement} element */
|
|
2489
|
+
value: /** @param {DSElement} element */
|
|
2490
|
+
function add(element) {
|
|
2455
2491
|
if (_get(_getPrototypeOf(SelectableSet.prototype), "has", this).call(this, element)) return;
|
|
2456
2492
|
var publishData = {
|
|
2457
2493
|
items: this.elements,
|
|
@@ -2474,7 +2510,9 @@
|
|
|
2474
2510
|
});
|
|
2475
2511
|
this.DS.publish('Selectable:added', publishData);
|
|
2476
2512
|
return _get(_getPrototypeOf(SelectableSet.prototype), "add", this).call(this, element);
|
|
2477
|
-
}
|
|
2513
|
+
}
|
|
2514
|
+
|
|
2515
|
+
/** @param {DSElement} element */
|
|
2478
2516
|
}, {
|
|
2479
2517
|
key: "delete",
|
|
2480
2518
|
value: function _delete(element) {
|
|
@@ -2500,7 +2538,8 @@
|
|
|
2500
2538
|
}
|
|
2501
2539
|
}, {
|
|
2502
2540
|
key: "elements",
|
|
2503
|
-
/** @return {DSElements} */
|
|
2541
|
+
get: /** @return {DSElements} */
|
|
2542
|
+
function get() {
|
|
2504
2543
|
return Array.from(this.values());
|
|
2505
2544
|
}
|
|
2506
2545
|
}, {
|
|
@@ -2571,7 +2610,9 @@
|
|
|
2571
2610
|
element.style.zIndex = "".concat((parseInt(element.style.zIndex) || 0) + 1);
|
|
2572
2611
|
this.DS.publish('Selected:added', publishData);
|
|
2573
2612
|
return this;
|
|
2574
|
-
}
|
|
2613
|
+
}
|
|
2614
|
+
|
|
2615
|
+
/** @param {DSElement} element */
|
|
2575
2616
|
}, {
|
|
2576
2617
|
key: "delete",
|
|
2577
2618
|
value: function _delete(element) {
|
|
@@ -2589,18 +2630,22 @@
|
|
|
2589
2630
|
}
|
|
2590
2631
|
}, {
|
|
2591
2632
|
key: "toggle",
|
|
2633
|
+
value:
|
|
2592
2634
|
/**
|
|
2593
2635
|
* Adds/Removes an element. If it is already selected = remove, if not = add.
|
|
2594
2636
|
* @param {DSElement} element
|
|
2595
2637
|
* @return {DSElement}
|
|
2596
2638
|
*/
|
|
2597
|
-
|
|
2639
|
+
function toggle(element) {
|
|
2598
2640
|
if (this.has(element)) this["delete"](element);else this.add(element);
|
|
2599
2641
|
return element;
|
|
2600
|
-
}
|
|
2642
|
+
}
|
|
2643
|
+
|
|
2644
|
+
/** @param {DSElements} elements */
|
|
2601
2645
|
}, {
|
|
2602
2646
|
key: "elements",
|
|
2603
|
-
/** @return {DSElements} */
|
|
2647
|
+
get: /** @return {DSElements} */
|
|
2648
|
+
function get() {
|
|
2604
2649
|
return Array.from(this.values());
|
|
2605
2650
|
}
|
|
2606
2651
|
}]);
|
|
@@ -2640,6 +2685,7 @@
|
|
|
2640
2685
|
SelectableSet = _this$DS.SelectableSet,
|
|
2641
2686
|
SelectorArea = _this$DS.SelectorArea,
|
|
2642
2687
|
Selector = _this$DS.Selector;
|
|
2688
|
+
|
|
2643
2689
|
/** @type {any} */
|
|
2644
2690
|
var elRects = SelectableSet.rects;
|
|
2645
2691
|
var select = [];
|
|
@@ -2698,7 +2744,9 @@
|
|
|
2698
2744
|
KeyStore = _this$DS2.stores.KeyStore,
|
|
2699
2745
|
SelectedSet = _this$DS2.SelectedSet;
|
|
2700
2746
|
if (KeyStore.isMultiSelectKeyPressed(event)) this._prevSelectedSet = new Set(SelectedSet);else this._prevSelectedSet = new Set();
|
|
2701
|
-
}
|
|
2747
|
+
}
|
|
2748
|
+
|
|
2749
|
+
/** @param {{event:DSEvent,isDragging:boolean}} event */
|
|
2702
2750
|
}]);
|
|
2703
2751
|
return Selection;
|
|
2704
2752
|
}();
|
|
@@ -2884,12 +2932,13 @@
|
|
|
2884
2932
|
}
|
|
2885
2933
|
_createClass(SelectorArea, [{
|
|
2886
2934
|
key: "isClicked",
|
|
2935
|
+
value:
|
|
2887
2936
|
/**
|
|
2888
2937
|
* checks if the click was triggered on the area.
|
|
2889
2938
|
* @param {DSEvent} [event]
|
|
2890
2939
|
* @returns {boolean}
|
|
2891
2940
|
*/
|
|
2892
|
-
|
|
2941
|
+
function isClicked(event) {
|
|
2893
2942
|
var PointerStore = this.DS.stores.PointerStore;
|
|
2894
2943
|
var initialVal = event ? PointerStore.getPointerPosition(event) : PointerStore.initialVal;
|
|
2895
2944
|
return isCollision({
|
|
@@ -2979,7 +3028,8 @@
|
|
|
2979
3028
|
}
|
|
2980
3029
|
_createClass(KeyStore, [{
|
|
2981
3030
|
key: "isMultiSelectKeyPressed",
|
|
2982
|
-
/** @param {KeyboardEvent|MouseEvent|PointerEvent|TouchEvent} [event] */
|
|
3031
|
+
value: /** @param {KeyboardEvent|MouseEvent|PointerEvent|TouchEvent} [event] */
|
|
3032
|
+
function isMultiSelectKeyPressed(event) {
|
|
2983
3033
|
var _this2 = this;
|
|
2984
3034
|
if (this.DS.stores.SettingsStore.s.multiSelectMode) return true;
|
|
2985
3035
|
var multiSelectKeys = this.DS.stores.SettingsStore.s.multiSelectKeys.map(function (key) {
|
|
@@ -3121,25 +3171,31 @@
|
|
|
3121
3171
|
}
|
|
3122
3172
|
_createClass(PointerStore, [{
|
|
3123
3173
|
key: "start",
|
|
3124
|
-
/** @param {DSEvent} [event] */
|
|
3174
|
+
value: /** @param {DSEvent} [event] */
|
|
3175
|
+
function start(event) {
|
|
3125
3176
|
if (!event) return;
|
|
3126
3177
|
this._isMouseInteraction = true;
|
|
3127
3178
|
this.currentVal = this.initialVal = this.getPointerPosition(event);
|
|
3128
|
-
}
|
|
3179
|
+
}
|
|
3180
|
+
|
|
3181
|
+
/** @param {DSEvent} event */
|
|
3129
3182
|
}, {
|
|
3130
3183
|
key: "_normalizedEvent",
|
|
3184
|
+
value:
|
|
3131
3185
|
/**
|
|
3132
3186
|
* @param {DSEvent} event
|
|
3133
3187
|
* @return {MouseEvent|PointerEvent|Touch}
|
|
3134
3188
|
* @private
|
|
3135
3189
|
*/
|
|
3136
|
-
|
|
3190
|
+
function _normalizedEvent(event) {
|
|
3137
3191
|
// touchend has not touches. so we take the last touch if a touchevent, we need to store the positions
|
|
3138
3192
|
if ('touches' in event && event.type !== 'touchend') this._lastTouch = event;
|
|
3139
3193
|
// if a touchevent, return the last touch rather than the regular event
|
|
3140
3194
|
// we need .touches[0] from that event instead
|
|
3141
3195
|
return 'touches' in event ? this._lastTouch.touches[0] : event;
|
|
3142
|
-
}
|
|
3196
|
+
}
|
|
3197
|
+
|
|
3198
|
+
/** First recorded pointer position within the area */
|
|
3143
3199
|
}, {
|
|
3144
3200
|
key: "initialValArea",
|
|
3145
3201
|
get: function get() {
|
|
@@ -3148,7 +3204,9 @@
|
|
|
3148
3204
|
y: 0
|
|
3149
3205
|
};
|
|
3150
3206
|
return this._initialValArea;
|
|
3151
|
-
}
|
|
3207
|
+
}
|
|
3208
|
+
|
|
3209
|
+
/** Current pointer position within the area */
|
|
3152
3210
|
}, {
|
|
3153
3211
|
key: "currentValArea",
|
|
3154
3212
|
get: function get() {
|
|
@@ -3157,7 +3215,9 @@
|
|
|
3157
3215
|
y: 0
|
|
3158
3216
|
};
|
|
3159
3217
|
return this._currentValArea;
|
|
3160
|
-
}
|
|
3218
|
+
}
|
|
3219
|
+
|
|
3220
|
+
/** Last recorded pointer position within the area */
|
|
3161
3221
|
}, {
|
|
3162
3222
|
key: "lastValArea",
|
|
3163
3223
|
get: function get() {
|
|
@@ -3166,7 +3226,9 @@
|
|
|
3166
3226
|
y: 0
|
|
3167
3227
|
};
|
|
3168
3228
|
return this._lastValArea;
|
|
3169
|
-
}
|
|
3229
|
+
}
|
|
3230
|
+
|
|
3231
|
+
/** First recorded pointer position */
|
|
3170
3232
|
}, {
|
|
3171
3233
|
key: "initialVal",
|
|
3172
3234
|
get: function get() {
|
|
@@ -3175,7 +3237,9 @@
|
|
|
3175
3237
|
y: 0
|
|
3176
3238
|
};
|
|
3177
3239
|
return this._initialVal;
|
|
3178
|
-
}
|
|
3240
|
+
}
|
|
3241
|
+
|
|
3242
|
+
/** Current pointer position */,
|
|
3179
3243
|
set: function set(value) {
|
|
3180
3244
|
this._initialVal = value;
|
|
3181
3245
|
this._initialValArea = value && calc(value, '-', calc(rect2vect(this.DS.Area.rect), '+', rect2vect(this.DS.Area.computedBorder)));
|
|
@@ -3188,7 +3252,9 @@
|
|
|
3188
3252
|
y: 0
|
|
3189
3253
|
};
|
|
3190
3254
|
return this._currentVal;
|
|
3191
|
-
}
|
|
3255
|
+
}
|
|
3256
|
+
|
|
3257
|
+
/** Last recorded pointer position */,
|
|
3192
3258
|
set: function set(value) {
|
|
3193
3259
|
this._currentVal = value;
|
|
3194
3260
|
this._currentValArea = value && calc(value, '-', calc(rect2vect(this.DS.Area.rect), '+', rect2vect(this.DS.Area.computedBorder)));
|
|
@@ -3305,7 +3371,7 @@
|
|
|
3305
3371
|
return ScrollStore;
|
|
3306
3372
|
}();
|
|
3307
3373
|
|
|
3308
|
-
var SettingsStore =
|
|
3374
|
+
var SettingsStore = /*#__PURE__*/_createClass(
|
|
3309
3375
|
/**
|
|
3310
3376
|
* @type {Settings}
|
|
3311
3377
|
* @private
|
|
@@ -3384,10 +3450,10 @@
|
|
|
3384
3450
|
});
|
|
3385
3451
|
}
|
|
3386
3452
|
|
|
3387
|
-
/** @param {{settings: Settings, init?: boolean}} props
|
|
3453
|
+
/** @param {{settings: Settings, init?: boolean}} props */);
|
|
3388
3454
|
|
|
3389
3455
|
// Setup
|
|
3390
|
-
|
|
3456
|
+
/// ///////////////////////////////////////////////////////////////////////////////////
|
|
3391
3457
|
var DragSelect = /*#__PURE__*/function () {
|
|
3392
3458
|
/**
|
|
3393
3459
|
* used to skip all current Selection and dragNdrop functionality
|
|
@@ -3518,13 +3584,14 @@
|
|
|
3518
3584
|
}
|
|
3519
3585
|
|
|
3520
3586
|
// Useful methods for the user
|
|
3521
|
-
|
|
3587
|
+
/// ///////////////////////////////////////////////////////////////////////////////////
|
|
3522
3588
|
/**
|
|
3523
3589
|
* Initializes the functionality. Automatically triggered when created.
|
|
3524
3590
|
* Also, reset the functionality after a teardown
|
|
3525
3591
|
*/
|
|
3526
3592
|
_createClass(DragSelect, [{
|
|
3527
3593
|
key: "stop",
|
|
3594
|
+
value:
|
|
3528
3595
|
/**
|
|
3529
3596
|
* Complete function teardown
|
|
3530
3597
|
* Will teardown/stop the whole functionality
|
|
@@ -3532,7 +3599,7 @@
|
|
|
3532
3599
|
* @param {boolean} [fromSelection] - if elements should also be added/removed to the selection.
|
|
3533
3600
|
* @param {boolean} [withCallback] - if elements should also be added/removed to the selection.
|
|
3534
3601
|
*/
|
|
3535
|
-
|
|
3602
|
+
function stop() {
|
|
3536
3603
|
var remove = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
3537
3604
|
var fromSelection = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
3538
3605
|
var withCallback = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
@@ -3551,6 +3618,7 @@
|
|
|
3551
3618
|
if (fromSelection) this.SelectedSet.clear();
|
|
3552
3619
|
this.stopped = true;
|
|
3553
3620
|
}
|
|
3621
|
+
|
|
3554
3622
|
/**
|
|
3555
3623
|
* Utility to override DragSelect internal functionality:
|
|
3556
3624
|
* Break will skip the selection or dragging functionality (until after the callback) but let everything continue to run.
|
|
@@ -3558,6 +3626,7 @@
|
|
|
3558
3626
|
*/
|
|
3559
3627
|
}, {
|
|
3560
3628
|
key: "addSelection",
|
|
3629
|
+
value:
|
|
3561
3630
|
/**
|
|
3562
3631
|
* Adds several elements to the selection list also adds the specific classes and take into account all calculations.
|
|
3563
3632
|
* Does not clear the selection, in contrary to .setSelection. Can add multiple elements at once
|
|
@@ -3566,7 +3635,7 @@
|
|
|
3566
3635
|
* @param {boolean} [dontAddToSelectables] - if element should not be added to the list of selectable elements
|
|
3567
3636
|
* @return {DSElements} all selected elements
|
|
3568
3637
|
*/
|
|
3569
|
-
|
|
3638
|
+
function addSelection(elements) {
|
|
3570
3639
|
var triggerCallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
3571
3640
|
var dontAddToSelectables = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
3572
3641
|
this.SelectedSet.addAll(toArray(elements));
|
|
@@ -3576,6 +3645,7 @@
|
|
|
3576
3645
|
});
|
|
3577
3646
|
return this.getSelection();
|
|
3578
3647
|
}
|
|
3648
|
+
|
|
3579
3649
|
/**
|
|
3580
3650
|
* Removes specific elements from the selection
|
|
3581
3651
|
* Multiple elements can be given at once, in contrary to unselect
|
|
@@ -3596,13 +3666,14 @@
|
|
|
3596
3666
|
});
|
|
3597
3667
|
return this.getSelection();
|
|
3598
3668
|
}
|
|
3669
|
+
|
|
3599
3670
|
/**
|
|
3600
3671
|
* Toggles specific elements from the selection:
|
|
3601
3672
|
* If element is not in selection it will be added, if it is already selected, it will be removed.
|
|
3602
3673
|
* Multiple elements can be given at once.
|
|
3603
3674
|
* @param {DSInputElements} elements one or multiple elements
|
|
3604
3675
|
* @param {boolean} [triggerCallback] - if callback should be called
|
|
3605
|
-
* @param {boolean} [
|
|
3676
|
+
* @param {boolean} [removeFromSelectables] - if element should not be added/removed to the list of selectable elements accordingly
|
|
3606
3677
|
* @return {DSElements} all selected elements
|
|
3607
3678
|
*/
|
|
3608
3679
|
}, {
|
|
@@ -3610,15 +3681,16 @@
|
|
|
3610
3681
|
value: function toggleSelection(elements) {
|
|
3611
3682
|
var _this2 = this;
|
|
3612
3683
|
var triggerCallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
3613
|
-
var
|
|
3684
|
+
var removeFromSelectables = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
3614
3685
|
toArray(elements).forEach(function (el) {
|
|
3615
|
-
return _this2.SelectedSet.has(el) ? _this2.removeSelection(elements, triggerCallback,
|
|
3686
|
+
return _this2.SelectedSet.has(el) ? _this2.removeSelection(elements, triggerCallback, removeFromSelectables) : _this2.addSelection(elements, triggerCallback, removeFromSelectables);
|
|
3616
3687
|
});
|
|
3617
3688
|
if (triggerCallback) this.PubSub.publish('callback', {
|
|
3618
3689
|
items: this.getSelection()
|
|
3619
3690
|
});
|
|
3620
3691
|
return this.getSelection();
|
|
3621
3692
|
}
|
|
3693
|
+
|
|
3622
3694
|
/**
|
|
3623
3695
|
* Sets the current selected elements and optionally run the callback
|
|
3624
3696
|
* By default, adds new elements also to the list of selectables
|
|
@@ -3636,6 +3708,7 @@
|
|
|
3636
3708
|
this.addSelection(elements, triggerCallback, dontAddToSelectables);
|
|
3637
3709
|
return this.getSelection();
|
|
3638
3710
|
}
|
|
3711
|
+
|
|
3639
3712
|
/**
|
|
3640
3713
|
* Unselect / Deselect all current selected Nodes
|
|
3641
3714
|
* @param {boolean} [triggerCallback] - if callback should be called
|
|
@@ -3651,6 +3724,7 @@
|
|
|
3651
3724
|
});
|
|
3652
3725
|
return this.getSelection();
|
|
3653
3726
|
}
|
|
3727
|
+
|
|
3654
3728
|
/**
|
|
3655
3729
|
* Add elements that can be selected. No node is added twice
|
|
3656
3730
|
* @param {DSInputElements} elements dom element(s)
|
|
@@ -3669,12 +3743,14 @@
|
|
|
3669
3743
|
});
|
|
3670
3744
|
return elements;
|
|
3671
3745
|
}
|
|
3746
|
+
|
|
3672
3747
|
/**
|
|
3673
3748
|
* Gets all nodes that can potentially be selected
|
|
3674
3749
|
* @return {DSElements} this.selectables
|
|
3675
3750
|
*/
|
|
3676
3751
|
}, {
|
|
3677
3752
|
key: "setSelectables",
|
|
3753
|
+
value:
|
|
3678
3754
|
/**
|
|
3679
3755
|
* Sets all elements that can be selected.
|
|
3680
3756
|
* Removes all current selectables (& their respective classes).
|
|
@@ -3684,13 +3760,14 @@
|
|
|
3684
3760
|
* @param {boolean} [addToSelection] if elements should also be added to current selection
|
|
3685
3761
|
* @return {DSInputElements} elements – the added element(s)
|
|
3686
3762
|
*/
|
|
3687
|
-
|
|
3763
|
+
function setSelectables(elements) {
|
|
3688
3764
|
var removeFromSelection = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
3689
3765
|
var addToSelection = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
3690
3766
|
console.warn('[DragSelect] DEPRECATION ".setSelectables" is deprecated and will be removed soon. Please use "ds.setSettings({ selectables: << new dom elements >> })" instead (see docs)');
|
|
3691
3767
|
this.removeSelectables(elements, removeFromSelection);
|
|
3692
3768
|
return this.addSelectables(elements, addToSelection);
|
|
3693
3769
|
}
|
|
3770
|
+
|
|
3694
3771
|
/**
|
|
3695
3772
|
* Remove elements from the elements that can be selected.
|
|
3696
3773
|
* @param {DSInputElements} elements – dom element(s)
|
|
@@ -3707,11 +3784,13 @@
|
|
|
3707
3784
|
items: this.getSelection()
|
|
3708
3785
|
});
|
|
3709
3786
|
return elements;
|
|
3710
|
-
}
|
|
3787
|
+
}
|
|
3788
|
+
|
|
3789
|
+
/** The starting/initial position of the cursor/selector @return {Vect2} */
|
|
3711
3790
|
}]);
|
|
3712
3791
|
return DragSelect;
|
|
3713
3792
|
}();
|
|
3714
3793
|
|
|
3715
3794
|
return DragSelect;
|
|
3716
3795
|
|
|
3717
|
-
}))
|
|
3796
|
+
}));
|