dragselect 2.4.4 → 2.5.1

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.
Files changed (40) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +84 -21
  3. package/dist/DragSelect.d.ts +26 -4
  4. package/dist/DragSelect.es6m.js +830 -782
  5. package/dist/DragSelect.js +830 -782
  6. package/dist/ds.es6m.min.js +1 -1
  7. package/dist/ds.min.js +1 -1
  8. package/dist/methods/addModificationObservers.d.ts +9 -1
  9. package/dist/methods/getAllParentNodes.d.ts +0 -43
  10. package/dist/methods/index.d.ts +1 -0
  11. package/dist/methods/isCollision.d.ts +1 -1
  12. package/dist/methods/subscriberAliases.d.ts +3 -1
  13. package/dist/modules/Area.d.ts +2 -12
  14. package/dist/modules/DropZone.d.ts +0 -43
  15. package/dist/modules/DropZones.d.ts +0 -46
  16. package/dist/modules/SelectableSet.d.ts +11 -0
  17. package/dist/modules/Selection.d.ts +1 -0
  18. package/dist/modules/index.d.ts +1 -0
  19. package/dist/types.d.ts +72 -2
  20. package/jest-puppeteer.config.js +1 -0
  21. package/package.json +5 -4
  22. package/src/DragSelect.js +29 -5
  23. package/src/methods/addModificationObservers.js +26 -5
  24. package/src/methods/canScroll.js +1 -1
  25. package/src/methods/getAllParentNodes.js +18 -0
  26. package/src/methods/handleElementPositionAttribute.js +1 -1
  27. package/src/methods/hydrateSettings.js +16 -0
  28. package/src/methods/index.js +1 -0
  29. package/src/methods/isCollision.js +24 -5
  30. package/src/methods/scrollElement.js +1 -1
  31. package/src/methods/subscriberAliases.js +16 -5
  32. package/src/methods/toArray.js +3 -2
  33. package/src/modules/Area.js +12 -44
  34. package/src/modules/DropZone.js +252 -0
  35. package/src/modules/DropZones.js +159 -0
  36. package/src/modules/SelectableSet.js +22 -0
  37. package/src/modules/Selection.js +9 -11
  38. package/src/modules/index.js +1 -0
  39. package/src/stores/SettingsStore.js +0 -1
  40. package/src/types.js +30 -2
@@ -1,6 +1,6 @@
1
1
  /***
2
2
 
3
- ~~~ Version 2.4.4 ~~~
3
+ ~~~ Version 2.5.1 ~~~
4
4
 
5
5
  ******************************************
6
6
 
@@ -34,7 +34,6 @@ function _classCallCheck(instance, Constructor) {
34
34
  throw new TypeError("Cannot call a class as a function");
35
35
  }
36
36
  }
37
-
38
37
  function _defineProperties(target, props) {
39
38
  for (var i = 0; i < props.length; i++) {
40
39
  var descriptor = props[i];
@@ -44,13 +43,11 @@ function _defineProperties(target, props) {
44
43
  Object.defineProperty(target, descriptor.key, descriptor);
45
44
  }
46
45
  }
47
-
48
46
  function _createClass(Constructor, protoProps, staticProps) {
49
47
  if (protoProps) _defineProperties(Constructor.prototype, protoProps);
50
48
  if (staticProps) _defineProperties(Constructor, staticProps);
51
49
  return Constructor;
52
50
  }
53
-
54
51
  function _defineProperty(obj, key, value) {
55
52
  if (key in obj) {
56
53
  Object.defineProperty(obj, key, {
@@ -62,13 +59,10 @@ function _defineProperty(obj, key, value) {
62
59
  } else {
63
60
  obj[key] = value;
64
61
  }
65
-
66
62
  return obj;
67
63
  }
68
-
69
64
  function ownKeys(object, enumerableOnly) {
70
65
  var keys = Object.keys(object);
71
-
72
66
  if (Object.getOwnPropertySymbols) {
73
67
  var symbols = Object.getOwnPropertySymbols(object);
74
68
  if (enumerableOnly) symbols = symbols.filter(function (sym) {
@@ -76,14 +70,11 @@ function ownKeys(object, enumerableOnly) {
76
70
  });
77
71
  keys.push.apply(keys, symbols);
78
72
  }
79
-
80
73
  return keys;
81
74
  }
82
-
83
75
  function _objectSpread2(target) {
84
76
  for (var i = 1; i < arguments.length; i++) {
85
77
  var source = arguments[i] != null ? arguments[i] : {};
86
-
87
78
  if (i % 2) {
88
79
  ownKeys(Object(source), true).forEach(function (key) {
89
80
  _defineProperty(target, key, source[key]);
@@ -96,15 +87,12 @@ function _objectSpread2(target) {
96
87
  });
97
88
  }
98
89
  }
99
-
100
90
  return target;
101
91
  }
102
-
103
92
  function _inherits(subClass, superClass) {
104
93
  if (typeof superClass !== "function" && superClass !== null) {
105
94
  throw new TypeError("Super expression must either be null or a function");
106
95
  }
107
-
108
96
  subClass.prototype = Object.create(superClass && superClass.prototype, {
109
97
  constructor: {
110
98
  value: subClass,
@@ -114,28 +102,23 @@ function _inherits(subClass, superClass) {
114
102
  });
115
103
  if (superClass) _setPrototypeOf(subClass, superClass);
116
104
  }
117
-
118
105
  function _getPrototypeOf(o) {
119
106
  _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
120
107
  return o.__proto__ || Object.getPrototypeOf(o);
121
108
  };
122
109
  return _getPrototypeOf(o);
123
110
  }
124
-
125
111
  function _setPrototypeOf(o, p) {
126
112
  _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
127
113
  o.__proto__ = p;
128
114
  return o;
129
115
  };
130
-
131
116
  return _setPrototypeOf(o, p);
132
117
  }
133
-
134
118
  function _isNativeReflectConstruct() {
135
119
  if (typeof Reflect === "undefined" || !Reflect.construct) return false;
136
120
  if (Reflect.construct.sham) return false;
137
121
  if (typeof Proxy === "function") return true;
138
-
139
122
  try {
140
123
  Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));
141
124
  return true;
@@ -143,7 +126,6 @@ function _isNativeReflectConstruct() {
143
126
  return false;
144
127
  }
145
128
  }
146
-
147
129
  function _construct(Parent, args, Class) {
148
130
  if (_isNativeReflectConstruct()) {
149
131
  _construct = Reflect.construct;
@@ -157,34 +139,25 @@ function _construct(Parent, args, Class) {
157
139
  return instance;
158
140
  };
159
141
  }
160
-
161
142
  return _construct.apply(null, arguments);
162
143
  }
163
-
164
144
  function _isNativeFunction(fn) {
165
145
  return Function.toString.call(fn).indexOf("[native code]") !== -1;
166
146
  }
167
-
168
147
  function _wrapNativeSuper(Class) {
169
148
  var _cache = typeof Map === "function" ? new Map() : undefined;
170
-
171
149
  _wrapNativeSuper = function _wrapNativeSuper(Class) {
172
150
  if (Class === null || !_isNativeFunction(Class)) return Class;
173
-
174
151
  if (typeof Class !== "function") {
175
152
  throw new TypeError("Super expression must either be null or a function");
176
153
  }
177
-
178
154
  if (typeof _cache !== "undefined") {
179
155
  if (_cache.has(Class)) return _cache.get(Class);
180
-
181
156
  _cache.set(Class, Wrapper);
182
157
  }
183
-
184
158
  function Wrapper() {
185
159
  return _construct(Class, arguments, _getPrototypeOf(this).constructor);
186
160
  }
187
-
188
161
  Wrapper.prototype = Object.create(Class.prototype, {
189
162
  constructor: {
190
163
  value: Wrapper,
@@ -195,106 +168,81 @@ function _wrapNativeSuper(Class) {
195
168
  });
196
169
  return _setPrototypeOf(Wrapper, Class);
197
170
  };
198
-
199
171
  return _wrapNativeSuper(Class);
200
172
  }
201
-
202
173
  function _assertThisInitialized(self) {
203
174
  if (self === void 0) {
204
175
  throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
205
176
  }
206
-
207
177
  return self;
208
178
  }
209
-
210
179
  function _possibleConstructorReturn(self, call) {
211
180
  if (call && (typeof call === "object" || typeof call === "function")) {
212
181
  return call;
213
182
  }
214
-
215
183
  return _assertThisInitialized(self);
216
184
  }
217
-
218
185
  function _createSuper(Derived) {
219
186
  var hasNativeReflectConstruct = _isNativeReflectConstruct();
220
-
221
187
  return function _createSuperInternal() {
222
188
  var Super = _getPrototypeOf(Derived),
223
- result;
224
-
189
+ result;
225
190
  if (hasNativeReflectConstruct) {
226
191
  var NewTarget = _getPrototypeOf(this).constructor;
227
-
228
192
  result = Reflect.construct(Super, arguments, NewTarget);
229
193
  } else {
230
194
  result = Super.apply(this, arguments);
231
195
  }
232
-
233
196
  return _possibleConstructorReturn(this, result);
234
197
  };
235
198
  }
236
-
237
199
  function _superPropBase(object, property) {
238
200
  while (!Object.prototype.hasOwnProperty.call(object, property)) {
239
201
  object = _getPrototypeOf(object);
240
202
  if (object === null) break;
241
203
  }
242
-
243
204
  return object;
244
205
  }
245
-
246
206
  function _get(target, property, receiver) {
247
207
  if (typeof Reflect !== "undefined" && Reflect.get) {
248
208
  _get = Reflect.get;
249
209
  } else {
250
210
  _get = function _get(target, property, receiver) {
251
211
  var base = _superPropBase(target, property);
252
-
253
212
  if (!base) return;
254
213
  var desc = Object.getOwnPropertyDescriptor(base, property);
255
-
256
214
  if (desc.get) {
257
215
  return desc.get.call(receiver);
258
216
  }
259
-
260
217
  return desc.value;
261
218
  };
262
219
  }
263
-
264
220
  return _get(target, property, receiver || target);
265
221
  }
266
-
267
222
  function _slicedToArray(arr, i) {
268
223
  return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
269
224
  }
270
-
271
225
  function _toConsumableArray(arr) {
272
226
  return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
273
227
  }
274
-
275
228
  function _arrayWithoutHoles(arr) {
276
229
  if (Array.isArray(arr)) return _arrayLikeToArray(arr);
277
230
  }
278
-
279
231
  function _arrayWithHoles(arr) {
280
232
  if (Array.isArray(arr)) return arr;
281
233
  }
282
-
283
234
  function _iterableToArray(iter) {
284
235
  if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
285
236
  }
286
-
287
237
  function _iterableToArrayLimit(arr, i) {
288
238
  if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
289
239
  var _arr = [];
290
240
  var _n = true;
291
241
  var _d = false;
292
242
  var _e = undefined;
293
-
294
243
  try {
295
244
  for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
296
245
  _arr.push(_s.value);
297
-
298
246
  if (i && _arr.length === i) break;
299
247
  }
300
248
  } catch (err) {
@@ -307,10 +255,8 @@ function _iterableToArrayLimit(arr, i) {
307
255
  if (_d) throw _e;
308
256
  }
309
257
  }
310
-
311
258
  return _arr;
312
259
  }
313
-
314
260
  function _unsupportedIterableToArray(o, minLen) {
315
261
  if (!o) return;
316
262
  if (typeof o === "string") return _arrayLikeToArray(o, minLen);
@@ -319,27 +265,73 @@ function _unsupportedIterableToArray(o, minLen) {
319
265
  if (n === "Map" || n === "Set") return Array.from(o);
320
266
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
321
267
  }
322
-
323
268
  function _arrayLikeToArray(arr, len) {
324
269
  if (len == null || len > arr.length) len = arr.length;
325
-
326
270
  for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
327
-
328
271
  return arr2;
329
272
  }
330
-
331
273
  function _nonIterableSpread() {
332
274
  throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
333
275
  }
334
-
335
276
  function _nonIterableRest() {
336
277
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
337
278
  }
279
+ function _createForOfIteratorHelper(o, allowArrayLike) {
280
+ var it;
281
+ if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) {
282
+ if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
283
+ if (it) o = it;
284
+ var i = 0;
285
+ var F = function () {};
286
+ return {
287
+ s: F,
288
+ n: function () {
289
+ if (i >= o.length) return {
290
+ done: true
291
+ };
292
+ return {
293
+ done: false,
294
+ value: o[i++]
295
+ };
296
+ },
297
+ e: function (e) {
298
+ throw e;
299
+ },
300
+ f: F
301
+ };
302
+ }
303
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
304
+ }
305
+ var normalCompletion = true,
306
+ didErr = false,
307
+ err;
308
+ return {
309
+ s: function () {
310
+ it = o[Symbol.iterator]();
311
+ },
312
+ n: function () {
313
+ var step = it.next();
314
+ normalCompletion = step.done;
315
+ return step;
316
+ },
317
+ e: function (e) {
318
+ didErr = true;
319
+ err = e;
320
+ },
321
+ f: function () {
322
+ try {
323
+ if (!normalCompletion && it.return != null) it.return();
324
+ } finally {
325
+ if (didErr) throw err;
326
+ }
327
+ }
328
+ };
329
+ }
338
330
 
339
331
  /**
340
332
  * The Settings to be passed to the Class
341
333
  * @typedef {Object} Settings
342
- * @property {HTMLElement|SVGElement|HTMLDocument} [area=document] area in which you can drag. If not provided it will be the whole document
334
+ * @property {HTMLElement|SVGElement|Document} [area=document] area in which you can drag. If not provided it will be the whole document
343
335
  * @property {DSInputElements} [selectables=[]] the elements that can be selected
344
336
  * @property {number} [autoScrollSpeed=5] Speed in which the area scrolls while selecting (if available). Unit is pixel per movement.
345
337
  * @property {Vect2} [overflowTolerance={x:25,y:25}] Tolerance for autoScroll (how close one has to be near an edges for autoScroll to start)
@@ -349,18 +341,30 @@ function _nonIterableRest() {
349
341
  * @property {boolean} [multiSelectToggling=true] Whether or not to toggle already active elements while multi-selecting
350
342
  * @property {DSMultiSelectKeys} [multiSelectKeys=['Control', 'Shift', 'Meta']] Keys that allows switching to the multi-select mode (see the multiSelectMode option). Any key value is possible ([see MDN docs](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key)). Note that the best support is given for <kbd>Control</kbd>, <kbd>Shift</kbd> and <kbd>Meta</kbd>. Provide an empty array `[]` if you want to turn off the functionality.
351
343
  * @property {HTMLElement} [selector=HTMLElement] the square that will draw the selection
344
+ * @property {number} [selectionThreshold=0] how much % of the element has to be selected to be considered selected (0 = just touching, 1 = inside the selection)
352
345
  * @property {boolean} [draggability=true] When a user is dragging on an already selected element, the selection is dragged.
353
346
  * @property {boolean} [immediateDrag=true] Whether an element is draggable from the start or needs to be selected first
354
347
  * @property {boolean} [keyboardDrag=true] Whether or not the user can drag with the keyboard (we don't recommend disabling it)
355
348
  * @property {DSDragKeys} [dragKeys={up:['ArrowUp'],down:['ArrowDown'],left:['ArrowLeft'],righ:['ArrowRight']}] The keys available to drag element using the keyboard.
356
349
  * @property {number} [keyboardDragSpeed=10] The speed at which elements are dragged using the keyboard. In pixels per keydown.
357
350
  * @property {boolean} [useTransform=true] Whether to use hardware accelerated css transforms when dragging or top/left instead
351
+ * @property {number} [refreshMemoryRate=80] Refresh rate on memoization, higher numbers mean better performance but more lag if elements are moving, lower numbers mean less lag but worse performance. If none of your DOMNodes are moving, you can set it to a very high number to increase performance. Value in milliseconds.
352
+ * @property {DSInputDropZone[]} [dropZones=[]] one or more drop-elements: where the selectables can be dropped into
353
+ * @property {number} [dropInsideThreshold=1] how much % of the item has to be inside the dropzone to be considered inside (0 = barely touching, 1 = completely inside)
354
+ * @property {number} [dropTargetThreshold=0] how much % of the zone does the pointer has to be in to be considered a target (0 = anywhere in the zone, max: 0.5 = has to point at the center of the zone)
358
355
  * @property {boolean} [usePointerEvents=false] Whether to use Pointer Events to replace traditional Mouse or Touch Events. Useful for tools like Google Blockly.
359
356
  * @property {string} [hoverClass=ds-hover] the class assigned to the mouse hovered items
360
357
  * @property {string} [selectableClass=ds-selectable] the class assigned to the elements that can be selected
361
358
  * @property {string} [selectedClass=ds-selected] the class assigned to the selected items
362
359
  * @property {string} [selectorClass=ds-selector] the class assigned to the square selector helper
363
360
  * @property {string} [selectorAreaClass=ds-selector-area] the class assigned to the square in which the selector resides. By default it's invisible
361
+ * @property {string} [droppedTargetClass=ds-dropped-target] on an item corresponding the target dropzone. This is also the prefix for ds-dropped-target-${zone.id}
362
+ * @property {string} [droppedInsideClass=ds-dropped-inside] on an item that is within its dropzone bounds after a drop. This is also the prefix for ds-dropped-inside-${zone.id}
363
+ * @property {string} [droppableClass=ds-droppable] on element that can be dropped into at least one container. This is also the prefix for ds-droppable-${zone.id}
364
+ * @property {string} [dropZoneClass=ds-dropzone] on each dropZone
365
+ * @property {string} [dropZoneReadyClass=ds-dropzone-ready] on corresponding dropZone when element is dragged
366
+ * @property {string} [dropZoneTargetClass=ds-dropzone-target] on dropZone that has elements from any successful target drop
367
+ * @property {string} [dropZoneInsideClass=ds-dropzone-inside] on dropZone that has elements inside after any drop
364
368
  */
365
369
 
366
370
  /**
@@ -375,46 +379,48 @@ function _nonIterableRest() {
375
379
  * @property {Settings} [settings] the settings being updates/manipulated/passed, also holds the previous value. i.e. updating selectorClass will publish { settings: { selectorClass: 'newVal', 'selectorClass:pre': 'oldVal' } }
376
380
  * @property {Array.<'top'|'bottom'|'left'|'right'|undefined>} [scroll_directions]
377
381
  * @property {number} [scroll_multiplier]
382
+ * @property {DSDropZone} [dropTarget] The dropZone element that the element was dropped into (or the mouse is currently hovering over)
378
383
  */
379
-
380
384
  /**
381
385
  * @typedef {function} DSCallback
382
386
  * @param {CallbackObject} data
383
387
  */
384
388
 
385
- /** @typedef {{x: number, y: number}} Vect2 */
389
+ /**
390
+ * @typedef {Object} DSInputDropZone
391
+ * @property {string} id
392
+ * @property {DSElement} element
393
+ * @property {DSInputElements} droppables
394
+ */
395
+ /**
396
+ * @typedef {Object} DSDropZone
397
+ * @property {string} id
398
+ * @property {DSElement} element
399
+ * @property {DSElements} droppables
400
+ * @property {DSElements} [itemsDropped] the items related to the target zone
401
+ * @property {DSElements} [itemsInside] the items that are within the targets bounds
402
+ */
386
403
 
404
+ /** @typedef {{x: number, y: number}} Vect2 */
387
405
  /** @typedef {{x:number,y:number,w:number,h:number,r:number,b:number}} DSElementPos */
388
-
389
406
  /** @typedef {Array.<'top'|'bottom'|'left'|'right'|undefined>} DSEdges */
390
407
 
391
- /** @typedef {HTMLElement|SVGElement|HTMLDocument} DSArea area within which you can drag */
392
-
408
+ /** @typedef {HTMLElement|SVGElement|Document} DSArea area within which you can drag */
393
409
  /** @typedef {HTMLElement} DSSelectorArea area in which you can drag */
394
-
395
410
  /** @typedef {Array.<HTMLElement|SVGElement> | HTMLElement | SVGElement} DSInputElements the elements that can be selected */
396
-
397
411
  /** @typedef {Array.<HTMLElement|SVGElement>} DSElements the elements that can be selected */
398
-
399
412
  /** @typedef {HTMLElement|SVGElement} DSElement a single element that can be selected */
400
-
401
413
  /** @typedef {MouseEvent|TouchEvent|PointerEvent} DSEvent en event from a touch or mouse interaction */
402
-
403
414
  /** @typedef {Array.<'Shift'|'Control'|'Meta'|string>} DSMultiSelectKeys An array of keys that allows switching to the multi-select mode */
404
415
 
405
416
  /** @typedef {'dragmove'|'autoscroll'|'dragstart'|'elementselect'|'elementunselect'|'callback'} DSEventNames */
406
-
407
417
  /** @typedef {'Interaction:init'|'Interaction:start'|'Interaction:end'|'Interaction:update'|'Area:modified'|'Area:scroll'|'PointerStore:updated'|'Selected:added'|'Selected:removed'|'Selectable:click'|'Selectable:added'|'Selectable:removed'|'Selectable:pointer'|'KeyStore:down'|'KeyStore:up'} DSInternalEventNames */
408
-
409
418
  /** @typedef {'Interaction:init:pre'|'Interaction:start:pre'|'Interaction:end:pre'|'Interaction:update:pre'|'Area:modified:pre'|'Area:scroll:pre'|'PointerStore:updated:pre'|'Selected:added:pre'|'Selected:removed:pre'|'Selectable:click:pre'|'Selectable:added:pre'|'Selectable:removed:pre'|'Selectable:pointer:pre'|'KeyStore:down:pre'|'KeyStore:up:pre'} DSInternalEventNamesPre */
410
419
  // @todo: update to typescript for complex defs like `Settings:updated:${string}` | `Settings:updated:${string}:pre`
411
-
412
420
  /** @typedef {'Settings:updated'|'Settings:updated:pre'|'Settings:updated:*'|'Settings:updated:*:pre'} DSInternalSettingEvents */
413
-
414
421
  /** @typedef {DSEventNames|DSInternalEventNames|DSInternalEventNamesPre|DSInternalSettingEvents} DSCallbackNames the name of the callback */
415
422
 
416
423
  /** @typedef {{top:number,left:number,bottom:number,right:number,width:number,height:number}} DSBoundingRect */
417
-
418
424
  /** @typedef {{up:string[],down:string[],left:string[],right:string[]}} DSDragKeys */
419
425
 
420
426
  /**
@@ -423,18 +429,18 @@ function _nonIterableRest() {
423
429
  */
424
430
 
425
431
  // @ts-check
432
+
426
433
  /**
427
434
  * @param {Vect2} v1
428
435
  * @param {'+'|'-'|'*'|'/'} operator
429
436
  * @param {Vect2} v2
430
437
  * @return {Vect2}
431
438
  */
432
-
433
439
  var calc = function calc(_ref, operator, _ref2) {
434
440
  var x1 = _ref.x,
435
- y1 = _ref.y;
441
+ y1 = _ref.y;
436
442
  var x2 = _ref2.x,
437
- y2 = _ref2.y;
443
+ y2 = _ref2.y;
438
444
  var calculations = {
439
445
  '+': {
440
446
  x: x1 + x2,
@@ -455,11 +461,11 @@ var calc = function calc(_ref, operator, _ref2) {
455
461
  };
456
462
  return calculations[operator];
457
463
  };
464
+
458
465
  /**
459
466
  * @param {{left:number,top:number}} rect
460
467
  * @returns {Vect2}
461
468
  */
462
-
463
469
  var rect2vect = function rect2vect(rect) {
464
470
  return {
465
471
  x: rect.left,
@@ -471,7 +477,6 @@ var rect2vect = function rect2vect(rect) {
471
477
  * @param {number} dimension
472
478
  * @returns {DSBoundingRect}
473
479
  */
474
-
475
480
  var vect2rect = function vect2rect(vect) {
476
481
  var dimension = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
477
482
  return {
@@ -487,7 +492,6 @@ var vect2rect = function vect2rect(vect) {
487
492
  * @param {number} n
488
493
  * @returns {Vect2}
489
494
  */
490
-
491
495
  var num2vect = function num2vect(n) {
492
496
  return {
493
497
  x: n,
@@ -496,48 +500,65 @@ var num2vect = function num2vect(n) {
496
500
  };
497
501
 
498
502
  // @ts-check
503
+
499
504
  /**
500
- * Adds event-listeners to the selectorArea
501
- * @param {DSArea[]} nodes
502
- * @param {DSModificationCallback} callback
503
- * @param {MutationObserver} modificationObserver
505
+ * Removes event-listeners from the DOMNode
506
+ * @typedef {()=>void} DSCleanup
504
507
  */
505
508
 
506
- var addModificationObservers = (function (nodes, callback, modificationObserver) {
509
+ /**
510
+ * Adds event-listeners to a DOMNode
511
+ * @param {DSArea[]} nodes
512
+ * @param {DSModificationCallback} cb
513
+ * @return {{observer:MutationObserver,callback:DSModificationCallback,cleanup:DSCleanup}}
514
+ */
515
+ var addModificationObservers = (function (nodes, cb) {
516
+ var callback = cb;
507
517
  window.addEventListener('resize', callback);
508
518
  window.addEventListener('scroll', callback);
519
+ var observer = new MutationObserver(callback);
509
520
  nodes.forEach(function (el, i) {
510
- modificationObserver.observe(el, {
521
+ observer.observe(el, {
511
522
  childList: i !== 0,
512
523
  attributes: true
513
524
  });
514
525
  });
526
+
527
+ /**
528
+ * Removes all observers
529
+ */
530
+ var cleanup = function cleanup() {
531
+ return removeModificationObservers(observer, callback);
532
+ };
533
+ return {
534
+ observer: observer,
535
+ callback: callback,
536
+ cleanup: cleanup
537
+ };
515
538
  });
516
539
 
517
540
  // @ts-check
541
+
518
542
  /**
519
543
  * Checks whether the area can scroll or not
520
544
  * @param {DSArea} area
521
545
  * @return {boolean} scroll X/Y
522
546
  */
523
-
524
547
  var canScroll = (function (area) {
525
548
  var scroll = getCurrentScroll(area);
526
549
  if (scroll.x || scroll.y) return true;
527
-
528
- if (area instanceof HTMLDocument) {
550
+ if (area instanceof Document) {
529
551
  if (area.body) return !!(area.body.scrollTop = 1);else return !!(area.documentElement.scrollTop = 1);
530
552
  }
531
-
532
553
  return !!(area.scrollTop = 1);
533
554
  });
534
555
 
535
556
  // @ts-check
557
+
536
558
  /**
537
559
  * Creates the SelectorArea
538
560
  * @return {HTMLDivElement}
539
561
  */
540
-
541
562
  var createSelectorAreaElement = (function () {
542
563
  var node = document.createElement('div');
543
564
  node.style.position = 'fixed';
@@ -548,16 +569,15 @@ var createSelectorAreaElement = (function () {
548
569
  });
549
570
 
550
571
  // @ts-check
572
+
551
573
  /**
552
574
  * Create the selector node
553
575
  * @param {boolean} customStyles
554
576
  * @return {HTMLElement}
555
577
  */
556
-
557
578
  var createSelectorElement = (function (customStyles) {
558
579
  var selector = document.createElement('div');
559
580
  selector.style.position = 'absolute';
560
-
561
581
  if (!customStyles) {
562
582
  selector.style.background = 'rgba(0, 0, 255, 0.1)';
563
583
  selector.style.border = '1px solid rgba(0, 0, 255, 0.45)';
@@ -569,6 +589,7 @@ var createSelectorElement = (function (customStyles) {
569
589
  });
570
590
 
571
591
  // @ts-check
592
+
572
593
  /**
573
594
  * Returns a function, that, as long as it continues to be invoked, will not
574
595
  * be triggered. The function will be called after it stops being called for
@@ -577,32 +598,32 @@ var createSelectorElement = (function (customStyles) {
577
598
  * @param {number} wait
578
599
  * @returns {DSModificationCallback}
579
600
  */
580
-
581
601
  var debounce = (function (func, wait) {
582
- var timeout; // This is the function that is returned and will be executed many times
583
- // We spread (...args) to capture any number of parameters we want to pass
602
+ var timeout;
584
603
 
604
+ // This is the function that is returned and will be executed many times
605
+ // We spread (...args) to capture any number of parameters we want to pass
585
606
  return function () {
586
607
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
587
608
  args[_key] = arguments[_key];
588
609
  }
589
-
590
610
  // The callback function to be executed after
591
611
  // the debounce time has elapsed
592
612
  var later = function later() {
593
613
  // null timeout to indicate the debounce ended
594
- timeout = null; // Execute the callback
614
+ timeout = null;
595
615
 
616
+ // Execute the callback
596
617
  func.apply(void 0, args);
597
- }; // This will reset the waiting every function execution.
618
+ };
619
+ // This will reset the waiting every function execution.
598
620
  // This is the step that prevents the function from
599
621
  // being executed because it will never reach the
600
622
  // inside of the previous setTimeout
623
+ clearTimeout(timeout);
601
624
 
602
-
603
- clearTimeout(timeout); // Restart the debounce waiting period.
625
+ // Restart the debounce waiting period.
604
626
  // setTimeout returns a truthy value (it differs in web vs Node)
605
-
606
627
  timeout = setTimeout(later, wait);
607
628
  };
608
629
  });
@@ -610,13 +631,32 @@ var debounce = (function (func, wait) {
610
631
  // @ts-check
611
632
  var documentScroll = (function () {
612
633
  var _document$body, _document$documentEle, _document$body2, _document$documentEle2;
613
-
614
634
  return {
615
635
  y: ((_document$body = document.body) === null || _document$body === void 0 ? void 0 : _document$body.scrollTop) || ((_document$documentEle = document.documentElement) === null || _document$documentEle === void 0 ? void 0 : _document$documentEle.scrollTop) || 0,
616
636
  x: ((_document$body2 = document.body) === null || _document$body2 === void 0 ? void 0 : _document$body2.scrollLeft) || ((_document$documentEle2 = document.documentElement) === null || _document$documentEle2 === void 0 ? void 0 : _document$documentEle2.scrollLeft) || 0
617
637
  };
618
638
  });
619
639
 
640
+ /**
641
+ * @param {DSElement|DSArea} node
642
+ * @returns {DSElements}
643
+ */
644
+ var getAllParentNodes = (function (node) {
645
+ var traverse = function traverse(toWatch) {
646
+ var _toWatch$index;
647
+ var index = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
648
+ var parent = (_toWatch$index = toWatch[index]) === null || _toWatch$index === void 0 ? void 0 : _toWatch$index.parentNode;
649
+ if (parent) {
650
+ toWatch.push(parent);
651
+ index++;
652
+ return traverse(toWatch, index);
653
+ } else {
654
+ return toWatch;
655
+ }
656
+ };
657
+ return traverse([node]);
658
+ });
659
+
620
660
  // @ts-check
621
661
  /**
622
662
  * Returns the top/left/bottom/right/width/height
@@ -626,7 +666,6 @@ var documentScroll = (function () {
626
666
  * @param {number} zoom
627
667
  * @returns {DSBoundingRect}
628
668
  */
629
-
630
669
  var getAreaRect = (function (area, zoom) {
631
670
  if (area instanceof Document) return {
632
671
  top: 0,
@@ -648,11 +687,11 @@ var getAreaRect = (function (area, zoom) {
648
687
  });
649
688
 
650
689
  // @ts-check
690
+
651
691
  /**
652
692
  * @param {DSArea} [area]
653
693
  * @return {Vect2} scroll X/Y
654
694
  */
655
-
656
695
  var getCurrentScroll = (function (area) {
657
696
  if (!area || area instanceof Document) return documentScroll();
658
697
  return {
@@ -662,6 +701,7 @@ var getCurrentScroll = (function (area) {
662
701
  });
663
702
 
664
703
  // @ts-check
704
+
665
705
  /**
666
706
  * Returns the edges that an element is overflowing
667
707
  * @param {Object} p
@@ -670,34 +710,31 @@ var getCurrentScroll = (function (area) {
670
710
  * @param {Vect2} [p.tolerance]
671
711
  * @returns {DSEdges}
672
712
  */
673
-
674
713
  var getOverflowEdges = (function (_ref) {
675
714
  var elementRect = _ref.elementRect,
676
- containerRect = _ref.containerRect,
677
- _ref$tolerance = _ref.tolerance,
678
- tolerance = _ref$tolerance === void 0 ? {
679
- x: 0,
680
- y: 0
681
- } : _ref$tolerance;
715
+ containerRect = _ref.containerRect,
716
+ _ref$tolerance = _ref.tolerance,
717
+ tolerance = _ref$tolerance === void 0 ? {
718
+ x: 0,
719
+ y: 0
720
+ } : _ref$tolerance;
682
721
  var edges = [];
683
722
  if (elementRect.top - tolerance.y < containerRect.top) edges.push('top');
684
723
  if (elementRect.left - tolerance.x < containerRect.left) edges.push('left');
685
724
  if (elementRect.bottom + tolerance.y > containerRect.bottom) edges.push('bottom');
686
725
  if (elementRect.right + tolerance.y > containerRect.right) edges.push('right');
687
- return (
688
- /** @type {DSEdges} */
689
- edges
726
+ return (/** @type {DSEdges} */edges
690
727
  );
691
728
  });
692
729
 
693
730
  // @ts-check
731
+
694
732
  /**
695
733
  * Returns cursor x, y position based on event object
696
734
  * @param {Object} p
697
735
  * @param {MouseEvent|Touch|PointerEvent} p.event
698
736
  * @return {Vect2} cursor X/Y position
699
737
  */
700
-
701
738
  var getPointerPos = (function (_ref) {
702
739
  var event = _ref.event;
703
740
  return {
@@ -712,12 +749,10 @@ var getPointerPos = (function (_ref) {
712
749
  * @param {{ scrollAmount:Vect2, initialPointerPos:Vect2, pointerPos:Vect2 }} p
713
750
  * @returns {{left:number,top:number,width:number,height:number}}
714
751
  */
715
-
716
752
  var getSelectorPosition = (function (_ref) {
717
753
  var scrollAmount = _ref.scrollAmount,
718
- initialPointerPos = _ref.initialPointerPos,
719
- pointerPos = _ref.pointerPos;
720
-
754
+ initialPointerPos = _ref.initialPointerPos,
755
+ pointerPos = _ref.pointerPos;
721
756
  /** check for direction
722
757
  *
723
758
  * This is quite complicated, so also quite complicated to explain. Lemme’ try:
@@ -756,39 +791,38 @@ var getSelectorPosition = (function (_ref) {
756
791
  *
757
792
  * I hope that makes sense. Try stuff out and play around with variables to get a hang of it.
758
793
  */
759
- var selectorPos = {}; // right
794
+ var selectorPos = {};
760
795
 
796
+ // right
761
797
  if (pointerPos.x > initialPointerPos.x - scrollAmount.x) {
762
798
  // 1.
763
799
  selectorPos.left = initialPointerPos.x - scrollAmount.x; // 2.
764
-
765
800
  selectorPos.width = pointerPos.x - initialPointerPos.x + scrollAmount.x; // 3.
766
801
  // left
767
802
  } else {
768
803
  // 1b.
769
804
  selectorPos.left = pointerPos.x; // 2b.
770
-
771
805
  selectorPos.width = initialPointerPos.x - pointerPos.x - scrollAmount.x; // 3b.
772
- } // bottom
773
-
806
+ }
774
807
 
808
+ // bottom
775
809
  if (pointerPos.y > initialPointerPos.y - scrollAmount.y) {
776
810
  selectorPos.top = initialPointerPos.y - scrollAmount.y;
777
- selectorPos.height = pointerPos.y - initialPointerPos.y + scrollAmount.y; // top
811
+ selectorPos.height = pointerPos.y - initialPointerPos.y + scrollAmount.y;
812
+ // top
778
813
  } else {
779
814
  selectorPos.top = pointerPos.y;
780
815
  selectorPos.height = initialPointerPos.y - pointerPos.y - scrollAmount.y;
781
816
  }
782
-
783
817
  return selectorPos;
784
818
  });
785
819
 
786
820
  // @ts-check
821
+
787
822
  /**
788
823
  * @param {DSElement} element
789
824
  * @return {Vect2}
790
825
  */
791
-
792
826
  var getComputedTranslatePositions = function getComputedTranslatePositions(element) {
793
827
  var position = {
794
828
  x: 0,
@@ -796,40 +830,31 @@ var getComputedTranslatePositions = function getComputedTranslatePositions(eleme
796
830
  };
797
831
  var computed = window.getComputedStyle(element);
798
832
  if (!computed.transform || computed.transform === 'none') return position;
799
-
800
833
  if (computed.transform.indexOf('3d') >= 0) {
801
834
  var match = computed.transform.trim().match(/matrix3d\((.*?)\)/);
802
-
803
835
  if (match && match.length) {
804
836
  var _match$;
805
-
806
837
  var values = (_match$ = match[1]) === null || _match$ === void 0 ? void 0 : _match$.split(',');
807
838
  position.x = parseInt(values[12]) || 0;
808
839
  position.y = parseInt(values[13]) || 0;
809
840
  }
810
-
811
841
  return position;
812
842
  } else {
813
843
  var _match = computed.transform.trim().match(/matrix\((.*?)\)/);
814
-
815
844
  if (_match && _match.length) {
816
845
  var _match$2;
817
-
818
846
  var _values = (_match$2 = _match[1]) === null || _match$2 === void 0 ? void 0 : _match$2.split(',');
819
-
820
847
  position.x = parseInt(_values[4]) || 0;
821
848
  position.y = parseInt(_values[5]) || 0;
822
849
  }
823
-
824
850
  return position;
825
851
  }
826
852
  };
853
+
827
854
  /**
828
855
  * @param {DSElement} element
829
856
  * @return {Vect2}
830
857
  */
831
-
832
-
833
858
  var getTranslatedPositions = function getTranslatedPositions(element) {
834
859
  var transform = element.style.transform;
835
860
  if (!transform || transform.indexOf('translate') < 0) return getComputedTranslatePositions(element);
@@ -838,37 +863,32 @@ var getTranslatedPositions = function getTranslatedPositions(element) {
838
863
  y: 0
839
864
  };
840
865
  var match = transform.trim().match(/translate[3dD]*?\(.*?\)/);
841
-
842
866
  if (match) {
843
867
  var _match$3;
844
-
845
868
  var split = (_match$3 = match[0]) === null || _match$3 === void 0 ? void 0 : _match$3.split('(');
846
-
847
869
  if (split) {
848
870
  var _split$;
849
-
850
871
  var values = (_split$ = split[1]) === null || _split$ === void 0 ? void 0 : _split$.split(',');
851
872
  position.x = parseInt(values[0]) || 0;
852
873
  position.y = parseInt(values[1]) || 0;
853
874
  }
854
875
  }
855
-
856
876
  if (!position.x && !position.x) return getComputedTranslatePositions(element);
857
877
  return position;
858
878
  };
879
+
859
880
  /**
860
881
  * @param {DSElement} element
861
882
  * @return {Vect2}
862
883
  */
863
-
864
-
865
884
  var getTopLeftPosition = function getTopLeftPosition(element) {
866
885
  var style = element.style;
867
886
  var position = {
868
887
  x: parseInt(style.left) || 0,
869
888
  y: parseInt(style.top) || 0
870
- }; // initial positions
889
+ };
871
890
 
891
+ // initial positions
872
892
  if (!position.x && !position.x) {
873
893
  var computed = window.getComputedStyle(element);
874
894
  return {
@@ -876,9 +896,9 @@ var getTopLeftPosition = function getTopLeftPosition(element) {
876
896
  y: parseInt(computed.top) || 0
877
897
  };
878
898
  }
879
-
880
899
  return position;
881
900
  };
901
+
882
902
  /**
883
903
  * Returns the X and Y coordinates based on styles
884
904
  * Can handle translate and top/left
@@ -886,13 +906,12 @@ var getTopLeftPosition = function getTopLeftPosition(element) {
886
906
  * @param {boolean} [useTranslate]
887
907
  * @return {Vect2}
888
908
  */
889
-
890
-
891
909
  var getStylePosition = (function (element, useTranslate) {
892
910
  if (useTranslate) return getTranslatedPositions(element);else return getTopLeftPosition(element);
893
911
  });
894
912
 
895
913
  // @ts-check
914
+
896
915
  /**
897
916
  * pushes element back the overflow amount
898
917
  * (top - top gives overflow, then new position pushed back by overflow)
@@ -904,36 +923,31 @@ var getStylePosition = (function (element, useTranslate) {
904
923
  * @param {Vect2} p.elementPos
905
924
  * @param {boolean} p.useTransform
906
925
  */
907
-
908
926
  var handleElementOverflow = (function (_ref) {
909
927
  var element = _ref.element,
910
- edges = _ref.edges,
911
- elementRect = _ref.elementRect,
912
- containerRect = _ref.containerRect,
913
- elementPos = _ref.elementPos,
914
- useTransform = _ref.useTransform;
915
-
928
+ edges = _ref.edges,
929
+ elementRect = _ref.elementRect,
930
+ containerRect = _ref.containerRect,
931
+ elementPos = _ref.elementPos,
932
+ useTransform = _ref.useTransform;
916
933
  if (edges.includes('top')) {
917
934
  setStylePosition(element, {
918
935
  y: elementPos.y + containerRect.top - elementRect.top,
919
936
  x: elementPos.x
920
937
  }, useTransform);
921
938
  }
922
-
923
939
  if (edges.includes('left')) {
924
940
  setStylePosition(element, {
925
941
  y: elementPos.y,
926
942
  x: elementPos.x + containerRect.left - elementRect.left
927
943
  }, useTransform);
928
944
  }
929
-
930
945
  if (edges.includes('bottom')) {
931
946
  setStylePosition(element, {
932
947
  y: elementPos.y + containerRect.bottom - elementRect.bottom,
933
948
  x: elementPos.x
934
949
  }, useTransform);
935
950
  }
936
-
937
951
  if (edges.includes('right')) {
938
952
  setStylePosition(element, {
939
953
  y: elementPos.y,
@@ -943,28 +957,28 @@ var handleElementOverflow = (function (_ref) {
943
957
  });
944
958
 
945
959
  // @ts-check
960
+
946
961
  /**
947
962
  * Fix: some elements have to have a special position attribute for calculations
948
963
  * @param {Object} p
949
964
  * @param {CSSStyleDeclaration} p.computedStyle
950
965
  * @param {DSArea} p.node
951
966
  */
952
-
953
967
  var handleElementPositionAttribute = (function (_ref) {
954
968
  var computedStyle = _ref.computedStyle,
955
- node = _ref.node;
969
+ node = _ref.node;
956
970
  var position = computedStyle.position;
957
971
  var isPositioned = position === 'absolute' || position === 'relative' || position === 'fixed';
958
- if (!(node instanceof HTMLDocument) && !isPositioned) node.style.position = 'relative';
972
+ if (!(node instanceof Document) && !isPositioned) node.style.position = 'relative';
959
973
  });
960
974
 
961
975
  // @ts-check
976
+
962
977
  /**
963
978
  * @typedef {function} ScrollCallback
964
979
  * @property {Array.<'top'|'bottom'|'left'|'right'|undefined>} directions
965
980
  * @property {number} multiplier
966
981
  */
967
-
968
982
  /**
969
983
  * @param {Object} p
970
984
  * @param {string} p.key the keyboard key that was pressed
@@ -977,46 +991,41 @@ var handleElementPositionAttribute = (function (_ref) {
977
991
  * @param {DSDragKeys} p.dragKeys
978
992
  * @returns {Vect2}
979
993
  */
980
-
981
994
  var handleKeyboardDragPosDifference = (function (_ref) {
982
995
  var shiftKey = _ref.shiftKey,
983
- keyboardDragSpeed = _ref.keyboardDragSpeed,
984
- zoom = _ref.zoom,
985
- key = _ref.key,
986
- dragKeys = _ref.dragKeys,
987
- scrollDiff = _ref.scrollDiff,
988
- canScroll = _ref.canScroll,
989
- scrollCallback = _ref.scrollCallback;
996
+ keyboardDragSpeed = _ref.keyboardDragSpeed,
997
+ zoom = _ref.zoom,
998
+ key = _ref.key,
999
+ dragKeys = _ref.dragKeys,
1000
+ scrollDiff = _ref.scrollDiff,
1001
+ canScroll = _ref.canScroll,
1002
+ scrollCallback = _ref.scrollCallback;
990
1003
  var posDirection = {
991
1004
  x: 0,
992
1005
  y: 0
993
1006
  };
994
1007
  var increase = shiftKey ? keyboardDragSpeed * 4 * zoom : keyboardDragSpeed * zoom;
995
-
996
1008
  if (dragKeys.left.includes(key)) {
997
1009
  posDirection.x = scrollDiff.x || -increase;
998
1010
  if (!shiftKey && !scrollDiff.x && canScroll) scrollCallback(['left'], keyboardDragSpeed);
999
1011
  }
1000
-
1001
1012
  if (dragKeys.right.includes(key)) {
1002
1013
  posDirection.x = scrollDiff.x || increase;
1003
1014
  if (!shiftKey && !scrollDiff.x && canScroll) scrollCallback(['right'], keyboardDragSpeed);
1004
1015
  }
1005
-
1006
1016
  if (dragKeys.up.includes(key)) {
1007
1017
  posDirection.y = scrollDiff.y || -increase;
1008
1018
  if (!shiftKey && !scrollDiff.y && canScroll) scrollCallback(['top'], keyboardDragSpeed);
1009
1019
  }
1010
-
1011
1020
  if (dragKeys.down.includes(key)) {
1012
1021
  posDirection.y = scrollDiff.y || increase;
1013
1022
  if (!shiftKey && !scrollDiff.y && canScroll) scrollCallback(['bottom'], keyboardDragSpeed);
1014
1023
  }
1015
-
1016
1024
  return posDirection;
1017
1025
  });
1018
1026
 
1019
1027
  // @ts-check
1028
+
1020
1029
  /**
1021
1030
  * Logic when an element is selected
1022
1031
  * @param {Object} p
@@ -1026,19 +1035,19 @@ var handleKeyboardDragPosDifference = (function (_ref) {
1026
1035
  * @param {Set} p.SelectedSet
1027
1036
  * @param {string} p.hoverClassName
1028
1037
  */
1029
-
1030
1038
  var handleSelection = (function (_ref) {
1031
1039
  var element = _ref.element,
1032
- force = _ref.force,
1033
- multiSelectionToggle = _ref.multiSelectionToggle,
1034
- SelectedSet = _ref.SelectedSet,
1035
- hoverClassName = _ref.hoverClassName;
1040
+ force = _ref.force,
1041
+ multiSelectionToggle = _ref.multiSelectionToggle,
1042
+ SelectedSet = _ref.SelectedSet,
1043
+ hoverClassName = _ref.hoverClassName;
1036
1044
  if (element.classList.contains(hoverClassName) && !force) return;
1037
1045
  if (!SelectedSet.has(element)) SelectedSet.add(element);else if (multiSelectionToggle) SelectedSet["delete"](element);
1038
1046
  element.classList.add(hoverClassName);
1039
1047
  });
1040
1048
 
1041
1049
  // @ts-check
1050
+
1042
1051
  /**
1043
1052
  * Logic when an element is de-selected
1044
1053
  * @param {Object} p
@@ -1048,16 +1057,16 @@ var handleSelection = (function (_ref) {
1048
1057
  * @param {Set} p.PrevSelectedSet
1049
1058
  * @param {string} p.hoverClassName
1050
1059
  */
1051
-
1052
1060
  var handleUnSelection = (function (_ref) {
1053
1061
  var element = _ref.element,
1054
- force = _ref.force,
1055
- SelectedSet = _ref.SelectedSet,
1056
- PrevSelectedSet = _ref.PrevSelectedSet,
1057
- hoverClassName = _ref.hoverClassName;
1062
+ force = _ref.force,
1063
+ SelectedSet = _ref.SelectedSet,
1064
+ PrevSelectedSet = _ref.PrevSelectedSet,
1065
+ hoverClassName = _ref.hoverClassName;
1058
1066
  if (!element.classList.contains(hoverClassName) && !force) return false;
1059
1067
  var inSelection = SelectedSet.has(element);
1060
1068
  var inPrevSelection = PrevSelectedSet.has(element);
1069
+
1061
1070
  /**
1062
1071
  * Special for issue #9.
1063
1072
  * if a multi-select-key is pressed, ds 'remembers' the last selection and reverts
@@ -1065,7 +1074,6 @@ var handleUnSelection = (function (_ref) {
1065
1074
  * = if item was selected and is not in selection anymore, reselect it
1066
1075
  * = if item was not selected and is not in selection anymore, unselect it
1067
1076
  */
1068
-
1069
1077
  if (inSelection && !inPrevSelection) SelectedSet["delete"](element);else if (!inSelection && inPrevSelection) SelectedSet.add(element);
1070
1078
  element.classList.remove(hoverClassName);
1071
1079
  });
@@ -1079,6 +1087,7 @@ var handleUnSelection = (function (_ref) {
1079
1087
  var wrongTypeWarn = function wrongTypeWarn(key, type, fallback) {
1080
1088
  return console.warn("[DragSelect] TypeIssue: setting \"".concat(key, "\" is not of type \"").concat(type, "\"."));
1081
1089
  };
1090
+
1082
1091
  /**
1083
1092
  * @param {string} key
1084
1093
  * @param {*} value
@@ -1086,67 +1095,67 @@ var wrongTypeWarn = function wrongTypeWarn(key, type, fallback) {
1086
1095
  * @param {*} fallback
1087
1096
  * @returns {object}
1088
1097
  */
1089
-
1090
-
1091
1098
  var hydrateHelper = function hydrateHelper(key, value, withFallback, fallback) {
1092
1099
  // no value available
1093
- if (value === undefined) return withFallback ? _defineProperty({}, key, fallback) : {}; // force unsetting of a value
1094
-
1095
- if (value === null) return _defineProperty({}, key, null); // TypeCheck [GENERIC]
1100
+ if (value === undefined) return withFallback ? _defineProperty({}, key, fallback) : {};
1101
+ // force unsetting of a value
1102
+ if (value === null) return _defineProperty({}, key, null);
1096
1103
 
1104
+ // TypeCheck [GENERIC]
1097
1105
  var isAvailable = true; // if it’s not undefined, it was set voluntarily
1106
+ var forceFallback = false;
1098
1107
 
1099
- var forceFallback = false; // TypeCheck [String]
1100
-
1108
+ // TypeCheck [String]
1101
1109
  var expectedString = typeof fallback === 'string';
1102
1110
  if (expectedString) isAvailable = typeof value === 'string' || value instanceof String;
1103
-
1104
1111
  if (expectedString && !isAvailable) {
1105
1112
  forceFallback = true;
1106
1113
  wrongTypeWarn(key, 'string');
1107
- } // TypeCheck [Number]
1108
-
1114
+ }
1109
1115
 
1116
+ // TypeCheck [Number]
1110
1117
  var expectedNumber = !isNaN(fallback) && typeof fallback === 'number';
1111
1118
  if (expectedNumber) isAvailable = !isNaN(value) && typeof value === 'number';
1112
-
1113
1119
  if (expectedNumber && !isAvailable) {
1114
1120
  forceFallback = true;
1115
1121
  wrongTypeWarn(key, 'number');
1116
- } // TypeCheck [Object]
1117
-
1122
+ }
1118
1123
 
1124
+ // TypeCheck [Object]
1119
1125
  var expectedObject = Object.prototype.toString.call(fallback) === "[object Object]";
1120
1126
  if (expectedObject) isAvailable = Object.prototype.toString.call(value) === "[object Object]";
1121
-
1122
1127
  if (expectedObject && !isAvailable) {
1123
1128
  forceFallback = true;
1124
1129
  wrongTypeWarn(key, 'object');
1125
- } // TypeCheck [Boolean]
1126
-
1130
+ }
1127
1131
 
1132
+ // TypeCheck [Boolean]
1128
1133
  var expectedBoolean = typeof fallback === "boolean";
1129
1134
  if (expectedBoolean) isAvailable = typeof value === "boolean";
1130
-
1131
1135
  if (expectedBoolean && !isAvailable) {
1132
1136
  forceFallback = true;
1133
1137
  wrongTypeWarn(key, 'boolean');
1134
- } // TypeCheck [Array]
1135
-
1138
+ }
1136
1139
 
1140
+ // TypeCheck [Array]
1137
1141
  var expectedArray = Array.isArray(fallback);
1138
1142
  if (expectedArray) isAvailable = Array.isArray(value);
1139
-
1140
1143
  if (expectedArray && !isAvailable) {
1141
1144
  forceFallback = true;
1142
1145
  wrongTypeWarn(key, 'array');
1143
1146
  }
1147
+ var isFallback = forceFallback || withFallback;
1144
1148
 
1145
- var isFallback = forceFallback || withFallback; // Special rule for [dragKeys]
1146
-
1149
+ // Special rule for [dragKeys]
1147
1150
  if (key === 'dragKeys' && isAvailable) return _defineProperty({}, key, Object.assign(fallback, value));else if (key === 'dragKeys' && !isAvailable) return isFallback ? _defineProperty({}, key, fallback) : {};
1151
+
1152
+ // Special rule for [dropZones]
1153
+ if (key === 'dropZones' && isAvailable && new Set(value.map(function (v) {
1154
+ return v.id;
1155
+ })).size !== value.length) console.warn("[DragSelect] UniqueConstraintsIssue: setting \"dropZones\" contains duplicate ids.");
1148
1156
  return isAvailable ? _defineProperty({}, key, value) : isFallback ? _defineProperty({}, key, fallback) : {};
1149
1157
  };
1158
+
1150
1159
  /**
1151
1160
  * This helper method creates the setting object,
1152
1161
  * - if the settings provided are of wrong type, the fallback value will be used
@@ -1157,18 +1166,16 @@ var hydrateHelper = function hydrateHelper(key, value, withFallback, fallback) {
1157
1166
  * @param {Settings} settings
1158
1167
  * @param {boolean} withFallback
1159
1168
  */
1160
-
1161
-
1162
1169
  var hydrateSettings = (function (settings, withFallback) {
1163
- return _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, hydrateHelper('area', settings.area, withFallback, document)), hydrateHelper('selectables', settings.selectables, withFallback, null)), hydrateHelper('autoScrollSpeed', settings.autoScrollSpeed, withFallback, 5)), hydrateHelper('overflowTolerance', settings.overflowTolerance, withFallback, {
1170
+ return _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, hydrateHelper('area', settings.area, withFallback, document)), hydrateHelper('selectables', settings.selectables, withFallback, null)), hydrateHelper('autoScrollSpeed', settings.autoScrollSpeed, withFallback, 5)), hydrateHelper('overflowTolerance', settings.overflowTolerance, withFallback, {
1164
1171
  x: 25,
1165
1172
  y: 25
1166
- })), hydrateHelper('zoom', settings.zoom, withFallback, 1)), hydrateHelper('customStyles', settings.customStyles, withFallback, false)), hydrateHelper('multiSelectMode', settings.multiSelectMode, withFallback, false)), hydrateHelper('multiSelectToggling', settings.multiSelectToggling, withFallback, true)), hydrateHelper('multiSelectKeys', settings.multiSelectKeys, withFallback, ['Control', 'Shift', 'Meta'])), hydrateHelper('selector', settings.selector, withFallback, null)), hydrateHelper('draggability', settings.draggability, withFallback, true)), hydrateHelper('immediateDrag', settings.immediateDrag, withFallback, true)), hydrateHelper('keyboardDrag', settings.keyboardDrag, withFallback, true)), hydrateHelper('dragKeys', settings.dragKeys, withFallback, {
1173
+ })), hydrateHelper('zoom', settings.zoom, withFallback, 1)), hydrateHelper('customStyles', settings.customStyles, withFallback, false)), hydrateHelper('multiSelectMode', settings.multiSelectMode, withFallback, false)), hydrateHelper('multiSelectToggling', settings.multiSelectToggling, withFallback, true)), hydrateHelper('multiSelectKeys', settings.multiSelectKeys, withFallback, ['Control', 'Shift', 'Meta'])), hydrateHelper('selector', settings.selector, withFallback, null)), hydrateHelper('selectionThreshold', settings.selectionThreshold, withFallback, 0)), hydrateHelper('draggability', settings.draggability, withFallback, true)), hydrateHelper('immediateDrag', settings.immediateDrag, withFallback, true)), hydrateHelper('keyboardDrag', settings.keyboardDrag, withFallback, true)), hydrateHelper('dragKeys', settings.dragKeys, withFallback, {
1167
1174
  up: ['ArrowUp'],
1168
1175
  down: ['ArrowDown'],
1169
1176
  left: ['ArrowLeft'],
1170
1177
  right: ['ArrowRight']
1171
- })), hydrateHelper('keyboardDragSpeed', settings.keyboardDragSpeed, withFallback, 10)), hydrateHelper('useTransform', settings.useTransform, withFallback, true)), hydrateHelper('usePointerEvents', settings.usePointerEvents, withFallback, false)), hydrateHelper('hoverClass', settings.hoverClass, withFallback, 'ds-hover')), hydrateHelper('selectableClass', settings.selectableClass, withFallback, 'ds-selectable')), hydrateHelper('selectedClass', settings.selectedClass, withFallback, 'ds-selected')), hydrateHelper('selectorClass', settings.selectorClass, withFallback, 'ds-selector')), hydrateHelper('selectorAreaClass', settings.selectorAreaClass, withFallback, 'ds-selector-area'));
1178
+ })), hydrateHelper('keyboardDragSpeed', settings.keyboardDragSpeed, withFallback, 10)), hydrateHelper('useTransform', settings.useTransform, withFallback, true)), hydrateHelper('refreshMemoryRate', settings.refreshMemoryRate, withFallback, 80)), hydrateHelper('dropZones', settings.dropZones, withFallback, [])), hydrateHelper('dropInsideThreshold', settings.dropInsideThreshold, withFallback, 1)), hydrateHelper('dropTargetThreshold', settings.dropTargetThreshold, withFallback, 0)), hydrateHelper('usePointerEvents', settings.usePointerEvents, withFallback, false)), hydrateHelper('hoverClass', settings.hoverClass, withFallback, 'ds-hover')), hydrateHelper('selectableClass', settings.selectableClass, withFallback, 'ds-selectable')), hydrateHelper('selectedClass', settings.selectedClass, withFallback, 'ds-selected')), hydrateHelper('selectorClass', settings.selectorClass, withFallback, 'ds-selector')), hydrateHelper('selectorAreaClass', settings.selectorAreaClass, withFallback, 'ds-selector-area')), hydrateHelper('droppedTargetClass', settings.droppedTargetClass, withFallback, 'ds-dropped-target')), hydrateHelper('droppedInsideClass', settings.droppedInsideClass, withFallback, 'ds-dropped-inside')), hydrateHelper('droppableClass', settings.droppableClass, withFallback, 'ds-droppable')), hydrateHelper('dropZoneClass', settings.dropZoneClass, withFallback, 'ds-dropzone')), hydrateHelper('dropZoneReadyClass', settings.dropZoneReadyClass, withFallback, 'ds-dropzone-ready')), hydrateHelper('dropZoneTargetClass', settings.dropZoneTargetClass, withFallback, 'ds-dropzone-target')), hydrateHelper('dropZoneInsideClass', settings.dropZoneInsideClass, withFallback, 'ds-dropzone-inside'));
1172
1179
  });
1173
1180
 
1174
1181
  // @ts-check
@@ -1193,19 +1200,41 @@ var hydrateSettings = (function (settings, withFallback) {
1193
1200
  * {@link https://developer.mozilla.org/en-US/docs/Games/Techniques/2D_collision_detection MDN}
1194
1201
  * @param {{left:number,right:number,top:number,bottom:number}} el1
1195
1202
  * @param {{left:number,right:number,top:number,bottom:number}} el2
1203
+ * @param {number} [percent=0]
1204
+ * 1 = the element has to be completely inside the other element
1205
+ * 0.8 = the element has to be 80% inside the other element
1206
+ * 0.5 = the element has to be 50% inside the other element
1207
+ * 0.2 = the element has to be 20% inside the other element
1208
+ * 0 = the element only has to touch the other element
1196
1209
  * @returns {boolean}
1197
1210
  */
1198
-
1199
1211
  var isCollision = (function (el1, el2) {
1200
- if (el1.left < el2.right && // 1.
1201
- el1.right > el2.left && // 2.
1202
- el1.top < el2.bottom && // 3.
1203
- el1.bottom > el2.top // 4.
1204
- ) return true; // collision detected!
1212
+ var percent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
1213
+ var element1 = el1;
1214
+ if (percent > 0) {
1215
+ var widthPoint = (el1.right - el1.left) * percent;
1216
+ var heightPoint = (el1.bottom - el1.top) * percent;
1217
+ element1 = {
1218
+ left: el1.left + widthPoint,
1219
+ right: el1.right - widthPoint,
1220
+ top: el1.top + heightPoint,
1221
+ bottom: el1.bottom - heightPoint
1222
+ };
1223
+ }
1224
+ if (element1.left < el2.right &&
1225
+ // 1.
1226
+ element1.right > el2.left &&
1227
+ // 2.
1228
+ element1.top < el2.bottom &&
1229
+ // 3.
1230
+ element1.bottom > el2.top // 4.
1231
+ ) return true;
1232
+ // collision detected!
1205
1233
  else return false;
1206
1234
  });
1207
1235
 
1208
1236
  // @ts-check
1237
+
1209
1238
  /**
1210
1239
  * Moves the element in a posDirection
1211
1240
  * @param {Object} p
@@ -1214,12 +1243,11 @@ var isCollision = (function (el1, el2) {
1214
1243
  * @param {DSBoundingRect} p.containerRect
1215
1244
  * @param {boolean} p.useTransform
1216
1245
  */
1217
-
1218
1246
  var moveElement = (function (_ref) {
1219
1247
  var element = _ref.element,
1220
- posDirection = _ref.posDirection,
1221
- containerRect = _ref.containerRect,
1222
- useTransform = _ref.useTransform;
1248
+ posDirection = _ref.posDirection,
1249
+ containerRect = _ref.containerRect,
1250
+ useTransform = _ref.useTransform;
1223
1251
  var elementPos = getStylePosition(element, useTransform);
1224
1252
  var newPos = calc(elementPos, '+', posDirection);
1225
1253
  setStylePosition(element, newPos, useTransform);
@@ -1239,12 +1267,12 @@ var moveElement = (function (_ref) {
1239
1267
  });
1240
1268
 
1241
1269
  // @ts-check
1270
+
1242
1271
  /**
1243
1272
  * Removes event-listeners to the selectorArea
1244
1273
  * @param {MutationObserver} modificationObserver
1245
1274
  * @param {DSModificationCallback} callback
1246
1275
  */
1247
-
1248
1276
  var removeModificationObservers = (function (modificationObserver, callback) {
1249
1277
  window.removeEventListener('resize', callback);
1250
1278
  window.removeEventListener('scroll', callback);
@@ -1252,27 +1280,21 @@ var removeModificationObservers = (function (modificationObserver, callback) {
1252
1280
  });
1253
1281
 
1254
1282
  // @ts-check
1283
+
1255
1284
  /**
1256
1285
  * Scroll the element in the specified direction
1257
1286
  * @param {DSArea} element
1258
1287
  * @param {Array.<'top'|'bottom'|'left'|'right'|undefined>} directions
1259
1288
  * @param {number} multiplier
1260
1289
  */
1261
-
1262
1290
  var scrollElement = (function (element, directions, multiplier) {
1263
1291
  if (!directions.length) return;
1264
1292
  var docEl = document && document.documentElement && document.documentElement.scrollTop && document.documentElement;
1265
-
1266
- var _element = element instanceof HTMLDocument ? docEl || document.body : element;
1267
-
1293
+ var _element = element instanceof Document ? docEl || document.body : element;
1268
1294
  var scrollTop = directions.includes('top') && _element.scrollTop > 0;
1269
-
1270
1295
  var scrollBot = directions.includes('bottom') && _element.scrollTop < _element.scrollHeight;
1271
-
1272
1296
  var scrollLeft = directions.includes('left') && _element.scrollLeft > 0;
1273
-
1274
1297
  var scrollRight = directions.includes('right') && _element.scrollLeft < _element.scrollWidth;
1275
-
1276
1298
  if (scrollTop) _element.scrollTop -= 1 * multiplier;
1277
1299
  if (scrollBot) _element.scrollTop += 1 * multiplier;
1278
1300
  if (scrollLeft) _element.scrollLeft -= 1 * multiplier;
@@ -1280,6 +1302,7 @@ var scrollElement = (function (element, directions, multiplier) {
1280
1302
  });
1281
1303
 
1282
1304
  // @ts-check
1305
+
1283
1306
  /**
1284
1307
  * Sets the style position to the X and Y coordinates
1285
1308
  * Can handle translate and top/left
@@ -1288,7 +1311,6 @@ var scrollElement = (function (element, directions, multiplier) {
1288
1311
  * @param {boolean} [useTranslate]
1289
1312
  * @return {DSElement}
1290
1313
  */
1291
-
1292
1314
  var setStylePosition = (function (element, values, useTranslate) {
1293
1315
  if (useTranslate) {
1294
1316
  var prevTransform = element.style.transform;
@@ -1297,7 +1319,6 @@ var setStylePosition = (function (element, values, useTranslate) {
1297
1319
  element.style.left = "".concat(values.x, "px");
1298
1320
  element.style.top = "".concat(values.y, "px");
1299
1321
  }
1300
-
1301
1322
  return element;
1302
1323
  });
1303
1324
 
@@ -1307,7 +1328,6 @@ var setStylePosition = (function (element, values, useTranslate) {
1307
1328
  * @param {DSCallback} callback
1308
1329
  * @returns {number} event id, can be used to unsubscribe more efficiently
1309
1330
  */
1310
-
1311
1331
  /**
1312
1332
  * @typedef {function} DSPublish
1313
1333
  * @param {DSCallbackNames} eventName
@@ -1322,13 +1342,14 @@ var setStylePosition = (function (element, values, useTranslate) {
1322
1342
  * @param {DSPublish} p.publish
1323
1343
  * @param {Interaction} p.Interaction
1324
1344
  * @param {SelectedSet} p.SelectedSet
1345
+ * @param {DropZones} p.DropZones
1325
1346
  */
1326
-
1327
1347
  var subscriberAliases = (function (_ref) {
1328
1348
  var subscribe = _ref.subscribe,
1329
- publish = _ref.publish,
1330
- Interaction = _ref.Interaction,
1331
- SelectedSet = _ref.SelectedSet;
1349
+ publish = _ref.publish,
1350
+ Interaction = _ref.Interaction,
1351
+ SelectedSet = _ref.SelectedSet,
1352
+ DropZones = _ref.DropZones;
1332
1353
  var mapping = {
1333
1354
  'Selected:added': [{
1334
1355
  name: 'elementselect'
@@ -1344,61 +1365,66 @@ var subscriberAliases = (function (_ref) {
1344
1365
  name: 'dragstart'
1345
1366
  }],
1346
1367
  // event, isDraggingKeyboard
1347
- 'Interaction:update': [{
1368
+ 'Interaction:update': [
1369
+ // event, isDraggingKeyboard
1370
+ {
1348
1371
  name: 'dragmove',
1349
1372
  condition: function condition(data) {
1350
1373
  return data.event;
1351
1374
  }
1352
1375
  }],
1376
+ 'Interaction:end': [
1353
1377
  // event, isDraggingKeyboard
1354
- 'Interaction:end': [{
1355
- name: 'callback'
1356
- }] // event, isDraggingKeyboard
1357
-
1378
+ {
1379
+ name: 'callback',
1380
+ extraData: function extraData() {
1381
+ var target = DropZones.getTarget();
1382
+ return _objectSpread2({}, target ? {
1383
+ dropTarget: target.toObject()
1384
+ } : {});
1385
+ }
1386
+ }]
1358
1387
  };
1359
-
1360
1388
  var _loop = function _loop() {
1361
1389
  var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
1362
- sub_name = _Object$entries$_i[0],
1363
- pubs = _Object$entries$_i[1];
1364
-
1390
+ sub_name = _Object$entries$_i[0],
1391
+ pubs = _Object$entries$_i[1];
1365
1392
  ['pre', false].forEach(function (filler) {
1366
1393
  return subscribe(filler ? "".concat(sub_name, ":").concat(filler) : sub_name, function (data) {
1367
1394
  return pubs.forEach(function (pub) {
1368
- return (!pub.condition || pub.condition(data)) && publish(filler ? "".concat(filler).concat(pub.name) : pub.name, _objectSpread2({
1395
+ return (!pub.condition || pub.condition(data)) && publish(filler ? "".concat(filler).concat(pub.name) : pub.name, _objectSpread2(_objectSpread2({
1369
1396
  items: SelectedSet.elements,
1370
1397
  isDragging: Interaction.isDragging
1371
- }, data));
1398
+ }, data), pub.extraData ? pub.extraData(data) : {}));
1372
1399
  });
1373
1400
  });
1374
1401
  });
1375
1402
  };
1376
-
1377
1403
  for (var _i = 0, _Object$entries = Object.entries(mapping); _i < _Object$entries.length; _i++) {
1378
1404
  _loop();
1379
1405
  }
1380
1406
  });
1381
1407
 
1382
1408
  /**
1383
- * Transforms any list or single item to an array so user doesn’t have to care.
1409
+ * Transforms any list or single dom node to an array so user doesn’t have to care. Also removes duplicates.
1384
1410
  * @param {DSInputElements} items a single item, a Node-list or any element group
1385
1411
  * @return {DSElements}
1386
1412
  */
1387
-
1388
1413
  var toArray = (function (items) {
1389
1414
  if (!items) return [];
1390
1415
  if (!Array.isArray(items) && (items instanceof HTMLElement || items instanceof SVGElement)) return [items];
1391
- return _toConsumableArray(items);
1416
+ // @ts-ignore
1417
+ return _toConsumableArray(new Set(_toConsumableArray(items)));
1392
1418
  });
1393
1419
 
1394
1420
  // @ts-check
1421
+
1395
1422
  /**
1396
1423
  * Updates element style left, top, width, height values
1397
1424
  * according to pos input object.
1398
1425
  * @param {HTMLElement} element
1399
1426
  * @param {{left:number,top:number,width:number,height:number}} pos
1400
1427
  */
1401
-
1402
1428
  var updateElementStylePos = (function (element, pos) {
1403
1429
  element.style.left = "".concat(pos.left, "px");
1404
1430
  element.style.top = "".concat(pos.top, "px");
@@ -1413,34 +1439,24 @@ var Area = /*#__PURE__*/function () {
1413
1439
  */
1414
1440
 
1415
1441
  /**
1416
- * @type {DSModificationCallback}
1442
+ * @type {{cleanup:() => void}}
1417
1443
  * @private
1418
1444
  */
1419
1445
 
1420
1446
  /**
1421
- * @type {MutationObserver}
1447
+ * @type {DSArea}
1422
1448
  * @private
1423
1449
  */
1424
1450
 
1425
1451
  /**
1426
- * @type {number}
1452
+ * @type {DSArea[]}
1427
1453
  * @private
1428
1454
  */
1429
1455
 
1430
1456
  /**
1431
- * @type {DSArea}
1457
+ * @type {CSSStyleDeclaration}
1432
1458
  * @private
1433
- */
1434
-
1435
- /**
1436
- * @type {DSArea[]}
1437
- * @private
1438
- */
1439
-
1440
- /**
1441
- * @type {CSSStyleDeclaration}
1442
- * @private
1443
- * */
1459
+ * */
1444
1460
 
1445
1461
  /**
1446
1462
  * @type {{top:number,bottom:number,left:number,right:number}}
@@ -1459,121 +1475,89 @@ var Area = /*#__PURE__*/function () {
1459
1475
  */
1460
1476
  function Area(_ref) {
1461
1477
  var _this = this;
1462
-
1463
1478
  var DS = _ref.DS;
1464
-
1465
1479
  _classCallCheck(this, Area);
1466
-
1467
1480
  _defineProperty(this, "DS", void 0);
1468
-
1469
- _defineProperty(this, "_modificationCallback", void 0);
1470
-
1471
- _defineProperty(this, "_modificationObserver", void 0);
1472
-
1473
- _defineProperty(this, "_zoom", void 0);
1474
-
1481
+ _defineProperty(this, "_observers", void 0);
1475
1482
  _defineProperty(this, "_node", void 0);
1476
-
1477
1483
  _defineProperty(this, "_parentNodes", void 0);
1478
-
1479
1484
  _defineProperty(this, "_computedStyle", void 0);
1480
-
1481
1485
  _defineProperty(this, "_computedBorder", void 0);
1482
-
1483
1486
  _defineProperty(this, "_rect", void 0);
1484
-
1485
1487
  _defineProperty(this, "setArea", function (area) {
1486
1488
  _this._node = area;
1487
1489
  handleElementPositionAttribute({
1488
1490
  computedStyle: _this.computedStyle,
1489
1491
  node: _this._node
1490
- }); // first immediate debounce to update values after dom-update
1492
+ });
1491
1493
 
1494
+ // first immediate debounce to update values after dom-update
1492
1495
  setTimeout(function () {
1493
1496
  _this.DS.PubSub.publish('Area:modified:pre', {
1494
1497
  item: _this
1495
1498
  });
1496
-
1497
1499
  _this.reset();
1498
-
1499
1500
  _this.DS.PubSub.publish('Area:modified', {
1500
1501
  item: _this
1501
1502
  });
1502
1503
  });
1503
1504
  });
1504
-
1505
1505
  _defineProperty(this, "start", function () {
1506
- addModificationObservers(_this.parentNodes, _this._modificationCallback, _this._modificationObserver);
1506
+ _this._observers = addModificationObservers(_this.parentNodes, debounce(function (event) {
1507
+ _this.DS.PubSub.publish('Area:modified:pre', {
1508
+ event: event,
1509
+ item: _this
1510
+ });
1511
+ _this.reset();
1512
+ _this.DS.PubSub.publish('Area:modified', {
1513
+ event: event,
1514
+ item: _this
1515
+ });
1516
+ }, 60));
1507
1517
  });
1508
-
1509
1518
  _defineProperty(this, "reset", function () {
1510
1519
  _this._computedStyle = undefined;
1511
1520
  _this._rect = undefined;
1512
1521
  _this._computedBorder = undefined;
1513
1522
  _this._parentNodes = undefined;
1514
1523
  });
1515
-
1516
1524
  _defineProperty(this, "stop", function () {
1517
- removeModificationObservers(_this._modificationObserver, _this._modificationCallback);
1518
-
1525
+ _this._observers.cleanup();
1519
1526
  _this.reset();
1520
1527
  });
1521
-
1522
1528
  _defineProperty(this, "scroll", function (directions, multiplier) {
1523
1529
  var data = {
1524
1530
  scroll_directions: directions,
1525
1531
  scroll_multiplier: multiplier
1526
1532
  };
1527
-
1528
1533
  _this.DS.PubSub.publish('Area:scroll:pre', data);
1529
-
1530
1534
  scrollElement(_this._node, directions, multiplier);
1531
-
1532
1535
  _this.DS.PubSub.publish('Area:scroll', data);
1533
1536
  });
1534
-
1535
1537
  this.DS = DS;
1536
- this.setArea(this.DS.stores.SettingsStore.s.area); // @ts-ignore: @todo: update to typescript
1537
-
1538
+ this.setArea(this.DS.stores.SettingsStore.s.area);
1539
+ // @ts-ignore: @todo: update to typescript
1538
1540
  this.DS.PubSub.subscribe('Settings:updated:area', function (_ref2) {
1539
1541
  var settings = _ref2.settings;
1540
1542
  return _this.setArea(settings.area);
1541
1543
  });
1542
- this._modificationCallback = debounce(function (event) {
1543
- _this.DS.PubSub.publish('Area:modified:pre', {
1544
- event: event,
1545
- item: _this
1546
- });
1547
-
1548
- _this.reset();
1549
-
1550
- _this.DS.PubSub.publish('Area:modified', {
1551
- event: event,
1552
- item: _this
1553
- });
1554
- }, 60);
1555
- this._modificationObserver = new MutationObserver(this._modificationCallback);
1556
1544
  this.DS.PubSub.subscribe('Interaction:init', this.start);
1557
1545
  this.DS.PubSub.subscribe('Interaction:end', this.reset);
1558
1546
  }
1559
- /** @param {DSArea} area */
1560
-
1561
1547
 
1548
+ /** @param {DSArea} area */
1562
1549
  _createClass(Area, [{
1563
1550
  key: "HTMLNode",
1564
1551
  //////////////////////////////////////////////////////////////////////////////////////
1565
1552
  // Node Getters
1566
1553
  get: function get() {
1567
- return (
1568
- /** @type {DSArea} */
1569
- this._node
1554
+ return (/** @type {DSArea} */this._node
1570
1555
  );
1571
1556
  }
1572
1557
  /**
1573
1558
  * The computed border from the element (caches result)
1574
1559
  * @type {{top:number,bottom:number,left:number,right:number}}
1575
1560
  */
1576
-
1577
1561
  }, {
1578
1562
  key: "computedBorder",
1579
1563
  get: function get() {
@@ -1589,18 +1573,16 @@ var Area = /*#__PURE__*/function () {
1589
1573
  * The computed styles from the element (caches result)
1590
1574
  * @type {CSSStyleDeclaration}
1591
1575
  */
1592
-
1593
1576
  }, {
1594
1577
  key: "computedStyle",
1595
1578
  get: function get() {
1596
1579
  if (this._computedStyle) return this._computedStyle;
1597
- if (this.HTMLNode instanceof HTMLDocument) return this._computedStyle = window.getComputedStyle(this.HTMLNode.body || this.HTMLNode.documentElement);else return this._computedStyle = window.getComputedStyle(this.HTMLNode);
1580
+ if (this.HTMLNode instanceof Document) return this._computedStyle = window.getComputedStyle(this.HTMLNode.body || this.HTMLNode.documentElement);else return this._computedStyle = window.getComputedStyle(this.HTMLNode);
1598
1581
  }
1599
1582
  /**
1600
1583
  * The element rect (caches result) (without scrollbar or borders)
1601
1584
  * @type {DSBoundingRect}
1602
1585
  */
1603
-
1604
1586
  }, {
1605
1587
  key: "rect",
1606
1588
  get: function get() {
@@ -1611,27 +1593,9 @@ var Area = /*#__PURE__*/function () {
1611
1593
  key: "parentNodes",
1612
1594
  get: function get() {
1613
1595
  if (this._parentNodes) return this._parentNodes;
1614
-
1615
- var traverse = function traverse(toWatch) {
1616
- var _toWatch$index;
1617
-
1618
- var index = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
1619
- var parent = (_toWatch$index = toWatch[index]) === null || _toWatch$index === void 0 ? void 0 : _toWatch$index.parentNode;
1620
-
1621
- if (parent) {
1622
- toWatch.push(parent);
1623
- index++;
1624
- return traverse(toWatch, index);
1625
- } else {
1626
- return toWatch;
1627
- }
1628
- };
1629
-
1630
- this._parentNodes = traverse([this.HTMLNode]);
1631
- return this._parentNodes;
1596
+ return this._parentNodes = getAllParentNodes(this.HTMLNode);
1632
1597
  }
1633
1598
  }]);
1634
-
1635
1599
  return Area;
1636
1600
  }();
1637
1601
 
@@ -1668,21 +1632,13 @@ var Drag = /*#__PURE__*/function () {
1668
1632
  */
1669
1633
  function Drag(_ref) {
1670
1634
  var _this = this;
1671
-
1672
1635
  var DS = _ref.DS;
1673
-
1674
1636
  _classCallCheck(this, Drag);
1675
-
1676
1637
  _defineProperty(this, "_prevCursorPos", void 0);
1677
-
1678
1638
  _defineProperty(this, "_prevScrollPos", void 0);
1679
-
1680
1639
  _defineProperty(this, "_elements", []);
1681
-
1682
1640
  _defineProperty(this, "_dragKeys", void 0);
1683
-
1684
1641
  _defineProperty(this, "_dragKeysFlat", []);
1685
-
1686
1642
  _defineProperty(this, "assignDragkeys", function () {
1687
1643
  _this._dragKeys = {
1688
1644
  up: _this.DS.stores.SettingsStore.s.dragKeys.up.map(function (k) {
@@ -1700,26 +1656,19 @@ var Drag = /*#__PURE__*/function () {
1700
1656
  };
1701
1657
  _this._dragKeysFlat = [].concat(_toConsumableArray(_this._dragKeys.up), _toConsumableArray(_this._dragKeys.down), _toConsumableArray(_this._dragKeys.left), _toConsumableArray(_this._dragKeys.right));
1702
1658
  });
1703
-
1704
1659
  _defineProperty(this, "keyboardDrag", function (_ref2) {
1705
1660
  var event = _ref2.event,
1706
- key = _ref2.key;
1707
-
1661
+ key = _ref2.key;
1708
1662
  var _key = key.toLowerCase();
1709
-
1710
1663
  if (!_this.DS.stores.SettingsStore.s.keyboardDrag || !_this._dragKeysFlat.includes(_key) || !_this.DS.SelectedSet.size || !_this.DS.stores.SettingsStore.s.draggability || _this.DS["continue"]) return;
1711
1664
  var publishData = {
1712
1665
  event: event,
1713
1666
  isDragging: true,
1714
1667
  isDraggingKeyboard: true
1715
1668
  };
1716
-
1717
1669
  _this.DS.publish(['Interaction:start:pre', 'Interaction:start'], publishData);
1718
-
1719
1670
  _this._elements = _this.DS.getSelection();
1720
-
1721
1671
  _this.handleZIndex(true);
1722
-
1723
1672
  var posDirection = handleKeyboardDragPosDifference({
1724
1673
  shiftKey: _this.DS.stores.KeyStore.currentValues.includes('shift'),
1725
1674
  keyboardDragSpeed: _this.DS.stores.SettingsStore.s.keyboardDragSpeed,
@@ -1730,7 +1679,6 @@ var Drag = /*#__PURE__*/function () {
1730
1679
  canScroll: _this.DS.stores.ScrollStore.canScroll,
1731
1680
  dragKeys: _this._dragKeys
1732
1681
  });
1733
-
1734
1682
  _this._elements.forEach(function (element) {
1735
1683
  return moveElement({
1736
1684
  element: element,
@@ -1739,53 +1687,41 @@ var Drag = /*#__PURE__*/function () {
1739
1687
  useTransform: _this.DS.stores.SettingsStore.s.useTransform
1740
1688
  });
1741
1689
  });
1742
-
1743
1690
  _this.DS.publish(['Interaction:update:pre', 'Interaction:update'], publishData);
1744
1691
  });
1745
-
1746
1692
  _defineProperty(this, "keyboardEnd", function (_ref3) {
1747
1693
  var event = _ref3.event,
1748
- key = _ref3.key;
1749
-
1694
+ key = _ref3.key;
1750
1695
  var _key = key.toLowerCase();
1751
-
1752
1696
  if (!_this.DS.stores.SettingsStore.s.keyboardDrag || !_this._dragKeysFlat.includes(_key) || !_this.DS.SelectedSet.size || !_this.DS.stores.SettingsStore.s.draggability) return;
1753
1697
  var publishData = {
1754
1698
  event: event,
1755
1699
  isDragging: _this.DS.stores.SettingsStore.s.draggability,
1756
1700
  isDraggingKeyboard: true
1757
1701
  };
1758
-
1759
1702
  _this.DS.publish(['Interaction:end:pre', 'Interaction:end'], publishData);
1760
1703
  });
1761
-
1762
1704
  _defineProperty(this, "start", function (_ref4) {
1763
1705
  var isDragging = _ref4.isDragging,
1764
- isDraggingKeyboard = _ref4.isDraggingKeyboard;
1706
+ isDraggingKeyboard = _ref4.isDraggingKeyboard;
1765
1707
  if (!isDragging || isDraggingKeyboard) return;
1766
1708
  _this._prevCursorPos = null;
1767
1709
  _this._prevScrollPos = null;
1768
1710
  _this._elements = _this.DS.getSelection();
1769
-
1770
1711
  _this.handleZIndex(true);
1771
1712
  });
1772
-
1773
1713
  _defineProperty(this, "stop", function (evt) {
1774
1714
  if (evt !== null && evt !== void 0 && evt.isKeyboard) return;
1775
1715
  _this._prevCursorPos = null;
1776
1716
  _this._prevScrollPos = null;
1777
-
1778
1717
  _this.handleZIndex(false);
1779
-
1780
1718
  _this._elements = [];
1781
1719
  });
1782
-
1783
1720
  _defineProperty(this, "update", function (_ref5) {
1784
1721
  var isDragging = _ref5.isDragging,
1785
- isDraggingKeyboard = _ref5.isDraggingKeyboard;
1722
+ isDraggingKeyboard = _ref5.isDraggingKeyboard;
1786
1723
  if (!isDragging || !_this._elements.length || isDraggingKeyboard || _this.DS["continue"]) return;
1787
1724
  var posDirection = calc(_this._cursorDiff, '+', _this._scrollDiff);
1788
-
1789
1725
  _this._elements.forEach(function (element) {
1790
1726
  return moveElement({
1791
1727
  element: element,
@@ -1795,15 +1731,14 @@ var Drag = /*#__PURE__*/function () {
1795
1731
  });
1796
1732
  });
1797
1733
  });
1798
-
1799
1734
  _defineProperty(this, "handleZIndex", function (add) {
1800
1735
  _this._elements.forEach(function (element) {
1801
1736
  return element.style.zIndex = "".concat((parseInt(element.style.zIndex) || 0) + add ? 9999 : -9998);
1802
1737
  });
1803
1738
  });
1739
+ this.DS = DS;
1804
1740
 
1805
- this.DS = DS; // @ts-ignore: @todo: update to typescript
1806
-
1741
+ // @ts-ignore: @todo: update to typescript
1807
1742
  this.DS.subscribe('Settings:updated:dragKeys', this.assignDragkeys);
1808
1743
  this.assignDragkeys();
1809
1744
  this.DS.subscribe('Interaction:start', this.start);
@@ -1812,7 +1747,6 @@ var Drag = /*#__PURE__*/function () {
1812
1747
  this.DS.subscribe('KeyStore:down', this.keyboardDrag);
1813
1748
  this.DS.subscribe('KeyStore:up', this.keyboardEnd);
1814
1749
  }
1815
-
1816
1750
  _createClass(Drag, [{
1817
1751
  key: "_cursorDiff",
1818
1752
  get: function get() {
@@ -1836,10 +1770,364 @@ var Drag = /*#__PURE__*/function () {
1836
1770
  return scrollDiff;
1837
1771
  }
1838
1772
  }]);
1839
-
1840
1773
  return Drag;
1841
1774
  }();
1842
1775
 
1776
+ var DropZone = /*#__PURE__*/function () {
1777
+ /**
1778
+ * @type {string}
1779
+ */
1780
+
1781
+ /**
1782
+ * @type {DSElement}
1783
+ */
1784
+
1785
+ /**
1786
+ * @type {DSElements}
1787
+ */
1788
+
1789
+ /**
1790
+ * @type {DOMRect}
1791
+ * @private
1792
+ */
1793
+
1794
+ /**
1795
+ * @type {{cleanup:()=>void}}
1796
+ * @private
1797
+ */
1798
+
1799
+ /**
1800
+ * @type {NodeJS.Timeout}
1801
+ * @private
1802
+ */
1803
+
1804
+ /**
1805
+ * @type {DSElements}
1806
+ * @private
1807
+ */
1808
+
1809
+ /**
1810
+ * @type {DSElements}
1811
+ * @private
1812
+ */
1813
+
1814
+ /**
1815
+ * @constructor Drag
1816
+ * @param {Object} obj
1817
+ * @param {DragSelect} obj.DS
1818
+ * @param {string} obj.id
1819
+ * @param {DSElement} obj.element
1820
+ * @param {DSInputElements} obj.droppables
1821
+ * @ignore
1822
+ */
1823
+ function DropZone(_ref) {
1824
+ var _this = this;
1825
+ var DS = _ref.DS,
1826
+ id = _ref.id,
1827
+ element = _ref.element,
1828
+ droppables = _ref.droppables;
1829
+ _classCallCheck(this, DropZone);
1830
+ _defineProperty(this, "id", void 0);
1831
+ _defineProperty(this, "element", void 0);
1832
+ _defineProperty(this, "droppables", void 0);
1833
+ _defineProperty(this, "_rect", void 0);
1834
+ _defineProperty(this, "_observers", void 0);
1835
+ _defineProperty(this, "_timeout", void 0);
1836
+ _defineProperty(this, "_itemsDropped", []);
1837
+ _defineProperty(this, "_itemsInside", void 0);
1838
+ _defineProperty(this, "setReadyClasses", function (action) {
1839
+ if (_this.isDestroyed) return;
1840
+ var selectedEls = _this.droppables.filter(function (el) {
1841
+ return _this.DS.SelectedSet.has(el);
1842
+ });
1843
+ if (!selectedEls.length) return;
1844
+ selectedEls.forEach(function (item) {
1845
+ item.classList[action]("".concat(_this.Settings.droppableClass));
1846
+ item.classList[action]("".concat(_this.Settings.droppableClass, "-").concat(_this.id));
1847
+ });
1848
+ _this.element.classList[action]("".concat(_this.Settings.dropZoneReadyClass));
1849
+ });
1850
+ _defineProperty(this, "handleNoDrop", function () {
1851
+ var _this$_itemsDropped;
1852
+ if (_this.isDestroyed) return;
1853
+ // for each selected element that is not part of the target zone, remove the classes
1854
+ _this.DS.SelectedSet.forEach(function (item) {
1855
+ item.classList.remove(_this.Settings.droppedTargetClass);
1856
+ item.classList.remove("".concat(_this.Settings.droppedTargetClass, "-").concat(_this.id));
1857
+ });
1858
+ // and remove them from the zones dropped items
1859
+ _this._itemsDropped = _this._itemsDropped.filter(function (item) {
1860
+ return !_this.DS.SelectedSet.has(item);
1861
+ });
1862
+ // if the zone has no dropped left, also remove the zones class
1863
+ if (!((_this$_itemsDropped = _this._itemsDropped) !== null && _this$_itemsDropped !== void 0 && _this$_itemsDropped.length)) _this.element.classList.remove("".concat(_this.Settings.dropZoneTargetClass));
1864
+ });
1865
+ _defineProperty(this, "handleDrop", function () {
1866
+ var _this$droppables, _this$_itemsDropped2, _this$_itemsDropped3;
1867
+ if (_this.isDestroyed) return;
1868
+ _this._itemsDropped = _toConsumableArray(new Set([].concat(_toConsumableArray(_this._itemsDropped), _toConsumableArray((_this$droppables = _this.droppables) === null || _this$droppables === void 0 ? void 0 : _this$droppables.filter(function (item) {
1869
+ return _this.DS.SelectedSet.has(item);
1870
+ })))));
1871
+ // add the target class to the zones dropped items
1872
+ (_this$_itemsDropped2 = _this._itemsDropped) === null || _this$_itemsDropped2 === void 0 ? void 0 : _this$_itemsDropped2.forEach(function (item) {
1873
+ item.classList.add("".concat(_this.Settings.droppedTargetClass));
1874
+ item.classList.add("".concat(_this.Settings.droppedTargetClass, "-").concat(_this.id));
1875
+ });
1876
+ // if the zone has dropped, add the zones class
1877
+ if ((_this$_itemsDropped3 = _this._itemsDropped) !== null && _this$_itemsDropped3 !== void 0 && _this$_itemsDropped3.length) _this.element.classList.add("".concat(_this.Settings.dropZoneTargetClass));
1878
+ });
1879
+ _defineProperty(this, "handleItemsInsideClasses", function () {
1880
+ var isAnyInside = false;
1881
+ _this.droppables.forEach(function (item) {
1882
+ if (_this.itemsInside.includes(item)) {
1883
+ item.classList.add("".concat(_this.Settings.droppedInsideClass));
1884
+ item.classList.add("".concat(_this.Settings.droppedInsideClass, "-").concat(_this.id));
1885
+ isAnyInside = true;
1886
+ } else {
1887
+ item.classList.remove("".concat(_this.Settings.droppedInsideClass, "-").concat(_this.id));
1888
+ if (!item.className.includes("".concat(_this.Settings.droppedInsideClass, "-"))) item.classList.remove("".concat(_this.Settings.droppedInsideClass));
1889
+ }
1890
+ });
1891
+ if (isAnyInside) _this.element.classList.add("".concat(_this.Settings.dropZoneInsideClass));else _this.element.classList.remove("".concat(_this.Settings.dropZoneInsideClass));
1892
+ });
1893
+ _defineProperty(this, "start", function (_ref2) {
1894
+ var isDragging = _ref2.isDragging;
1895
+ if (!isDragging || _this.isDestroyed) return;
1896
+ _this.setReadyClasses('add');
1897
+ });
1898
+ _defineProperty(this, "stop", function (_ref3) {
1899
+ var isDragging = _ref3.isDragging;
1900
+ if (!isDragging || _this.isDestroyed) return;
1901
+ _this.setReadyClasses('remove');
1902
+ _this.handleItemsInsideClasses();
1903
+ });
1904
+ _defineProperty(this, "toObject", function () {
1905
+ return {
1906
+ id: _this.id,
1907
+ element: _this.element,
1908
+ droppables: _this.droppables,
1909
+ itemsDropped: _this.itemsDropped,
1910
+ itemsInside: _this.itemsInside
1911
+ };
1912
+ });
1913
+ this.DS = DS;
1914
+ this.Settings = DS.stores.SettingsStore.s;
1915
+ this.id = id;
1916
+ this.element = element;
1917
+ this.droppables = toArray(droppables);
1918
+ this.element.classList.add("".concat(this.Settings.dropZoneClass));
1919
+
1920
+ // @ts-ignore: @todo: update to typescript
1921
+ this.DS.subscribe('Settings:updated:dropZoneClass', function (_ref4) {
1922
+ var settings = _ref4.settings;
1923
+ _this.element.classList.remove(settings['dropZoneClass:pre']);
1924
+ _this.element.classList.add(settings.dropZoneClass);
1925
+ });
1926
+ this._observers = addModificationObservers(this.parentNodes, debounce(function () {
1927
+ return _this._rect = null;
1928
+ }, this.Settings.refreshMemoryRate));
1929
+ this.DS.subscribe('Interaction:start', this.start);
1930
+ this.DS.subscribe('Interaction:end', this.stop);
1931
+ }
1932
+
1933
+ /**
1934
+ * @param {'add'|'remove'} action
1935
+ */
1936
+ _createClass(DropZone, [{
1937
+ key: "destroy",
1938
+ value: function destroy() {
1939
+ var _this2 = this;
1940
+ this._observers.cleanup();
1941
+ this.element.classList.remove("".concat(this.Settings.dropZoneClass));
1942
+ this.element.classList.remove("".concat(this.Settings.dropZoneTargetClass));
1943
+ this.element.classList.remove("".concat(this.Settings.dropZoneReadyClass));
1944
+ this.droppables.forEach(function (item) {
1945
+ item.classList.remove("".concat(_this2.Settings.droppedTargetClass));
1946
+ item.classList.remove("".concat(_this2.Settings.droppedTargetClass, "-").concat(_this2.id));
1947
+ item.classList.remove("".concat(_this2.Settings.droppableClass));
1948
+ item.classList.remove("".concat(_this2.Settings.droppableClass, "-").concat(_this2.id));
1949
+ });
1950
+ this.DS.unsubscribe('Interaction:start', this.start);
1951
+ this.DS.unsubscribe('Interaction:end', this.stop);
1952
+ this.element = null;
1953
+ this.droppables = null;
1954
+ this.id = null;
1955
+ this._itemsDropped = null;
1956
+ this._itemsInside = null;
1957
+ this.isDestroyed = true;
1958
+ }
1959
+ /**
1960
+ * @returns {DSDropZone}
1961
+ */
1962
+ }, {
1963
+ key: "rect",
1964
+ get: function get() {
1965
+ if (this.isDestroyed) return null;
1966
+ if (this._rect) return this._rect;
1967
+ return this._rect = this.element.getBoundingClientRect();
1968
+ }
1969
+ }, {
1970
+ key: "itemsDropped",
1971
+ get: function get() {
1972
+ if (this.isDestroyed) return null;
1973
+ return this._itemsDropped;
1974
+ }
1975
+ }, {
1976
+ key: "itemsInside",
1977
+ get: function get() {
1978
+ var _this3 = this;
1979
+ if (this.isDestroyed) return null;
1980
+ if (this._itemsInside) return this._itemsInside;
1981
+ this._itemsInside = this.droppables.flatMap(function (item) {
1982
+ if (isCollision(_this3.DS.SelectableSet.rects.get(item), _this3.rect, _this3.Settings.dropInsideThreshold)) return [item];
1983
+ return [];
1984
+ });
1985
+
1986
+ // since elements can be moved while this getter is called, we need to update the values every X seconds
1987
+ if (this._timeout) clearTimeout(this._timeout);
1988
+ this._timeout = setTimeout(function () {
1989
+ return _this3._itemsInside = null;
1990
+ }, this.Settings.refreshMemoryRate);
1991
+ return this._itemsInside;
1992
+ }
1993
+ }, {
1994
+ key: "parentNodes",
1995
+ get: function get() {
1996
+ if (this._parentNodes) return this._parentNodes;
1997
+ return this._parentNodes = getAllParentNodes(this.element);
1998
+ }
1999
+ }]);
2000
+ return DropZone;
2001
+ }();
2002
+
2003
+ var DropZones =
2004
+ /**
2005
+ * Get the drop zone by the zone element
2006
+ * @type {Map<DSElement, DropZone>}
2007
+ * @private
2008
+ */
2009
+
2010
+ /**
2011
+ * Get the drop zone by the zone id
2012
+ * @type {Map<string, DropZone>}
2013
+ * @private
2014
+ */
2015
+
2016
+ /**
2017
+ * Get the drop zones by one zone item
2018
+ * @type {Map<DSElement,DropZone[]>}
2019
+ * @private
2020
+ */
2021
+
2022
+ /**
2023
+ * Get the drop zones by one zone item
2024
+ * @type {DropZone[]}
2025
+ * @private
2026
+ */
2027
+
2028
+ /**
2029
+ * @constructor Drag
2030
+ * @param {{DS:DragSelect}} obj
2031
+ * @ignore
2032
+ */
2033
+ function DropZones(_ref) {
2034
+ var _this = this;
2035
+ var DS = _ref.DS;
2036
+ _classCallCheck(this, DropZones);
2037
+ _defineProperty(this, "_zoneByElement", new Map());
2038
+ _defineProperty(this, "_zoneById", new Map());
2039
+ _defineProperty(this, "_zonesByDroppable", new Map());
2040
+ _defineProperty(this, "_zones", void 0);
2041
+ _defineProperty(this, "setDropZones", function (_ref2) {
2042
+ var dropZones = _ref2.dropZones;
2043
+ if (!dropZones) return;
2044
+ if (_this._zones) _this._zones.forEach(function (zone) {
2045
+ return zone.destroy();
2046
+ });
2047
+ _this._zones = dropZones.map(function (zone) {
2048
+ return new DropZone(_objectSpread2({
2049
+ DS: _this.DS
2050
+ }, zone));
2051
+ });
2052
+ _this._zones.forEach(function (zone) {
2053
+ _this._zoneByElement.set(zone.element, zone);
2054
+ _this._zoneById.set(zone.id, zone);
2055
+ zone.droppables.forEach(function (droppable) {
2056
+ var zones = _this._zonesByDroppable.get(droppable);
2057
+ if (!(zones !== null && zones !== void 0 && zones.length)) return _this._zonesByDroppable.set(droppable, [zone]);
2058
+ // @ts-ignore
2059
+ _this._zonesByDroppable.set(droppable, _toConsumableArray(new Set([].concat(_toConsumableArray(zones), [zone]))));
2060
+ });
2061
+ });
2062
+ });
2063
+ _defineProperty(this, "_handleDrop", function (target) {
2064
+ _this._zones.forEach(function (zone) {
2065
+ if (zone === target) return;
2066
+ zone.handleNoDrop();
2067
+ });
2068
+ if (!target) return;
2069
+ target.handleDrop();
2070
+ });
2071
+ _defineProperty(this, "_getZoneByElementsFromPoint", function (elements, _ref3) {
2072
+ var x = _ref3.x,
2073
+ y = _ref3.y;
2074
+ for (var i = 0, il = elements.length; i < il; i++) {
2075
+ var zone = _this._zoneByElement.get(elements[i]);
2076
+ if (zone && isCollision(zone.rect, {
2077
+ left: x,
2078
+ right: x,
2079
+ top: y,
2080
+ bottom: y
2081
+ }, Math.min(_this.Settings.dropTargetThreshold, 0.5))) {
2082
+ return zone;
2083
+ }
2084
+ }
2085
+ });
2086
+ _defineProperty(this, "stop", function (_ref4) {
2087
+ var isDragging = _ref4.isDragging;
2088
+ if (!isDragging) return;
2089
+ var target = _this.getTarget();
2090
+ _this._handleDrop(target);
2091
+ });
2092
+ _defineProperty(this, "getItemsDroppedById", function (zoneId) {
2093
+ var zone = _this._zoneById.get(zoneId);
2094
+ if (!zone) return console.warn("[DragSelect] No zone found (id: ".concat(zoneId, ")"));
2095
+ return zone.itemsDropped;
2096
+ });
2097
+ _defineProperty(this, "getItemsInsideById", function (zoneId, addClasses) {
2098
+ var zone = _this._zoneById.get(zoneId);
2099
+ if (!zone) return console.warn("[DragSelect] No zone found (id: ".concat(zoneId, ")"));
2100
+ var itemsInside = zone.itemsInside;
2101
+ if (addClasses) zone.handleItemsInsideClasses();
2102
+ return itemsInside;
2103
+ });
2104
+ _defineProperty(this, "getTarget", function (coordinates) {
2105
+ var _this$_zones;
2106
+ if (!((_this$_zones = _this._zones) !== null && _this$_zones !== void 0 && _this$_zones.length)) return;
2107
+ var x = (coordinates === null || coordinates === void 0 ? void 0 : coordinates.x) || _this.DS.stores.PointerStore.currentVal.x;
2108
+ var y = (coordinates === null || coordinates === void 0 ? void 0 : coordinates.y) || _this.DS.stores.PointerStore.currentVal.y;
2109
+ var elements = document.elementsFromPoint(x, y);
2110
+ return _this._getZoneByElementsFromPoint( /** @type {DSElements} */elements, {
2111
+ x: x,
2112
+ y: y
2113
+ });
2114
+ });
2115
+ this.DS = DS;
2116
+ this.Settings = DS.stores.SettingsStore.s;
2117
+
2118
+ // @ts-ignore: @todo: update to typescript
2119
+ this.DS.subscribe('Settings:updated:dropZones', this.setDropZones);
2120
+ this.setDropZones({
2121
+ dropZones: /** @type {DSDropZone[]} */this.DS.stores.SettingsStore.s.dropZones
2122
+ });
2123
+ this.DS.subscribe('Interaction:end', this.stop);
2124
+ }
2125
+
2126
+ /**
2127
+ * @param {Object} obj
2128
+ * @param {DSDropZone[]} [obj.dropZones]
2129
+ */;
2130
+
1843
2131
  var Interaction = /*#__PURE__*/function () {
1844
2132
  /** @type {boolean} */
1845
2133
 
@@ -1852,137 +2140,103 @@ var Interaction = /*#__PURE__*/function () {
1852
2140
  */
1853
2141
  function Interaction(_ref) {
1854
2142
  var _this = this;
1855
-
1856
2143
  var DS = _ref.DS;
1857
-
1858
2144
  _classCallCheck(this, Interaction);
1859
-
1860
2145
  _defineProperty(this, "isInteracting", void 0);
1861
-
1862
2146
  _defineProperty(this, "isDragging", void 0);
1863
-
1864
2147
  _defineProperty(this, "init", function () {
1865
2148
  return _this.DS.publish('Interaction:init:pre', {});
1866
2149
  });
1867
-
1868
2150
  _defineProperty(this, "_init", function () {
1869
- _this.stop(); // @TODO: fix pointer events mixing issue see [PR](https://github.com/ThibaultJanBeyer/DragSelect/pull/128#issuecomment-1154885289)
1870
-
2151
+ _this.stop();
1871
2152
 
2153
+ // @TODO: fix pointer events mixing issue see [PR](https://github.com/ThibaultJanBeyer/DragSelect/pull/128#issuecomment-1154885289)
1872
2154
  if (_this.Settings.usePointerEvents) _this.DS.Area.HTMLNode.addEventListener('pointerdown', _this.start, {
1873
2155
  passive: false
1874
2156
  });else _this.DS.Area.HTMLNode.addEventListener('mousedown', _this.start);
1875
-
1876
2157
  _this.DS.Area.HTMLNode.addEventListener('touchstart', _this.start, {
1877
2158
  passive: false
1878
2159
  });
1879
-
1880
2160
  _this.DS.publish('Interaction:init', {});
1881
2161
  });
1882
-
1883
2162
  _defineProperty(this, "start", function (event) {
1884
2163
  return _this.DS.publish('Interaction:start:pre', {
1885
2164
  event: event,
1886
2165
  isDragging: _this.isDragging
1887
2166
  });
1888
2167
  });
1889
-
1890
2168
  _defineProperty(this, "_start", function (event) {
1891
2169
  if (event.type === 'touchstart') event.preventDefault(); // Call preventDefault() to prevent double click issue, see https://github.com/ThibaultJanBeyer/DragSelect/pull/29 & https://developer.mozilla.org/vi/docs/Web/API/Touch_events/Supporting_both_TouchEvent_and_MouseEvent
1892
-
1893
2170
  if (!_this._canInteract(event)) return;
1894
2171
  _this.isInteracting = true;
1895
2172
  _this.isDragging = _this.isDragEvent(event);
1896
-
1897
2173
  _this.DS.publish('Interaction:start', {
1898
2174
  event: event,
1899
2175
  isDragging: _this.isDragging
1900
- }); // @TODO: fix pointer events mixing issue see [PR](https://github.com/ThibaultJanBeyer/DragSelect/pull/128#issuecomment-1154885289)
1901
-
2176
+ });
1902
2177
 
2178
+ // @TODO: fix pointer events mixing issue see [PR](https://github.com/ThibaultJanBeyer/DragSelect/pull/128#issuecomment-1154885289)
1903
2179
  if (_this.Settings.usePointerEvents) {
1904
2180
  document.addEventListener('pointerup', _this.reset);
1905
2181
  document.addEventListener('pointercancel', _this.reset);
1906
2182
  } else document.addEventListener('mouseup', _this.reset);
1907
-
1908
2183
  document.addEventListener('touchend', _this.reset);
1909
2184
  });
1910
-
1911
2185
  _defineProperty(this, "isDragEvent", function (event) {
1912
- var clickedElement =
1913
- /** @type {Element} */
1914
- event.target.closest(".".concat(_this.Settings.selectableClass));
2186
+ var clickedElement = /** @type {Element} */event.target.closest(".".concat(_this.Settings.selectableClass));
1915
2187
  if (!_this.Settings.draggability || _this.DS.stores.KeyStore.isMultiSelectKeyPressed(event) || !clickedElement) return false;
1916
-
1917
2188
  if (_this.Settings.immediateDrag) {
1918
- if (!_this.DS.SelectedSet.size) _this.DS.SelectedSet.add(
1919
- /** @type {DSElement} */
1920
- clickedElement);else if (!_this.DS.SelectedSet.has(clickedElement)) {
2189
+ if (!_this.DS.SelectedSet.size) _this.DS.SelectedSet.add( /** @type {DSElement} */clickedElement);else if (!_this.DS.SelectedSet.has(clickedElement)) {
1921
2190
  _this.DS.SelectedSet.clear();
1922
-
1923
- _this.DS.SelectedSet.add(
1924
- /** @type {DSElement} */
1925
- clickedElement);
2191
+ _this.DS.SelectedSet.add( /** @type {DSElement} */clickedElement);
1926
2192
  }
1927
2193
  }
1928
-
1929
2194
  if (_this.DS.SelectedSet.has(clickedElement)) return true;
1930
2195
  return false;
1931
2196
  });
1932
-
1933
2197
  _defineProperty(this, "onClick", function (_ref2) {
1934
2198
  var event = _ref2.event;
1935
2199
  if (!_this._canInteract(event)) return;
1936
2200
  if (event.detail > 0) return; // mouse interaction
1937
-
1938
2201
  var _this$DS = _this.DS,
1939
- _this$DS$stores = _this$DS.stores,
1940
- PointerStore = _this$DS$stores.PointerStore,
1941
- KeyStore = _this$DS$stores.KeyStore,
1942
- SelectableSet = _this$DS.SelectableSet,
1943
- SelectedSet = _this$DS.SelectedSet;
2202
+ _this$DS$stores = _this$DS.stores,
2203
+ PointerStore = _this$DS$stores.PointerStore,
2204
+ KeyStore = _this$DS$stores.KeyStore,
2205
+ SelectableSet = _this$DS.SelectableSet,
2206
+ SelectedSet = _this$DS.SelectedSet;
1944
2207
  PointerStore.start(event);
1945
- var node =
1946
- /** @type {any} */
1947
- event.target;
2208
+ var node = /** @type {any} */event.target;
1948
2209
  if (!SelectableSet.has(node)) return;
1949
2210
  if (!KeyStore.isMultiSelectKeyPressed(event)) SelectedSet.clear();
1950
2211
  SelectedSet.toggle(node);
1951
-
1952
2212
  _this.reset(); // simulate mouse-up (that does not exist on keyboard)
1953
-
1954
2213
  });
1955
-
1956
2214
  _defineProperty(this, "stop", function () {
1957
2215
  _this.isInteracting = false;
1958
- _this.isDragging = false; // @TODO: fix pointer events mixing issue see [PR](https://github.com/ThibaultJanBeyer/DragSelect/pull/128#issuecomment-1154885289)
2216
+ _this.isDragging = false;
1959
2217
 
2218
+ // @TODO: fix pointer events mixing issue see [PR](https://github.com/ThibaultJanBeyer/DragSelect/pull/128#issuecomment-1154885289)
1960
2219
  if (_this.Settings.usePointerEvents) {
1961
2220
  _this.DS.Area.HTMLNode.removeEventListener('pointerdown', _this.start, {
1962
2221
  // @ts-ignore
1963
2222
  passive: false
1964
2223
  });
1965
-
1966
2224
  document.removeEventListener('pointerup', _this.reset);
1967
2225
  document.removeEventListener('pointercancel', _this.reset);
1968
2226
  } else {
1969
2227
  _this.DS.Area.HTMLNode.removeEventListener('mousedown', _this.start);
1970
-
1971
2228
  document.removeEventListener('mouseup', _this.reset);
1972
2229
  }
1973
-
1974
2230
  _this.DS.Area.HTMLNode.removeEventListener('touchstart', _this.start, {
1975
2231
  // @ts-ignore
1976
2232
  passive: false
1977
2233
  });
1978
-
1979
2234
  document.removeEventListener('touchend', _this.reset);
1980
2235
  });
1981
-
1982
2236
  _defineProperty(this, "update", function (_ref3) {
1983
2237
  var event = _ref3.event,
1984
- scroll_directions = _ref3.scroll_directions,
1985
- scroll_multiplier = _ref3.scroll_multiplier;
2238
+ scroll_directions = _ref3.scroll_directions,
2239
+ scroll_multiplier = _ref3.scroll_multiplier;
1986
2240
  if (_this.isInteracting) _this.DS.publish(['Interaction:update:pre', 'Interaction:update'], {
1987
2241
  event: event,
1988
2242
  scroll_directions: scroll_directions,
@@ -1990,30 +2244,24 @@ var Interaction = /*#__PURE__*/function () {
1990
2244
  isDragging: _this.isDragging
1991
2245
  });
1992
2246
  });
1993
-
1994
2247
  _defineProperty(this, "reset", function (event) {
1995
2248
  return _this.DS.publish('Interaction:end:pre', {
1996
2249
  event: event,
1997
2250
  isDragging: _this.isDragging
1998
2251
  });
1999
2252
  });
2000
-
2001
2253
  _defineProperty(this, "_reset", function (event) {
2002
2254
  var isDragging = _this.isDragging;
2003
-
2004
2255
  _this.stop();
2005
-
2006
2256
  _this.init();
2007
-
2008
2257
  _this.DS.publish('Interaction:end', {
2009
2258
  event: event,
2010
2259
  isDragging: isDragging
2011
2260
  });
2012
2261
  });
2013
-
2014
2262
  this.DS = DS;
2015
- this.Settings = DS.stores.SettingsStore.s; // @ts-ignore: @todo: update to typescript
2016
-
2263
+ this.Settings = DS.stores.SettingsStore.s;
2264
+ // @ts-ignore: @todo: update to typescript
2017
2265
  this.DS.subscribe('Settings:updated:area', this.init);
2018
2266
  this.DS.subscribe('PointerStore:updated', this.update);
2019
2267
  this.DS.subscribe('Selectable:click', this.onClick);
@@ -2032,28 +2280,19 @@ var Interaction = /*#__PURE__*/function () {
2032
2280
  });
2033
2281
  this.DS.subscribe('Area:scroll', this.update);
2034
2282
  }
2035
-
2036
2283
  _createClass(Interaction, [{
2037
2284
  key: "_canInteract",
2038
-
2039
2285
  /**
2040
2286
  * @param {DSEvent} event
2041
2287
  */
2042
2288
  value: function _canInteract(event) {
2043
- var isKeyboardClick =
2044
- /** @type {MouseEvent} */
2045
- event.clientX === 0 &&
2046
- /** @type {MouseEvent} */
2047
- event.clientY === 0 &&
2048
- /** @type {MouseEvent} */
2049
- event.detail === 0 && event.target;
2050
- if (
2051
- /** @type {MouseEvent} */
2052
- event.button === 2 || // right-clicks
2053
- this.isInteracting || // fix double-click issues
2054
- event.target && !this.DS.SelectorArea.isInside(
2055
- /** @type {DSElement} */
2056
- event.target) || //fix outside elements issue
2289
+ var isKeyboardClick = /** @type {MouseEvent} */event.clientX === 0 && /** @type {MouseEvent} */event.clientY === 0 && /** @type {MouseEvent} */event.detail === 0 && event.target;
2290
+ if ( /** @type {MouseEvent} */event.button === 2 ||
2291
+ // right-clicks
2292
+ this.isInteracting ||
2293
+ // fix double-click issues
2294
+ event.target && !this.DS.SelectorArea.isInside( /** @type {DSElement} */event.target) ||
2295
+ //fix outside elements issue
2057
2296
  !isKeyboardClick && !this.DS.SelectorArea.isClicked(event) // make sure the mouse click is inside the area
2058
2297
  ) return false;
2059
2298
  return true;
@@ -2061,65 +2300,51 @@ var Interaction = /*#__PURE__*/function () {
2061
2300
  /**
2062
2301
  * @param {DSEvent} event
2063
2302
  */
2064
-
2065
2303
  }]);
2066
-
2067
2304
  return Interaction;
2068
2305
  }();
2069
2306
 
2070
2307
  var PubSub = function PubSub(_ref) {
2071
2308
  var _this = this;
2072
-
2073
2309
  var DS = _ref.DS;
2074
-
2075
2310
  _classCallCheck(this, PubSub);
2076
-
2077
2311
  _defineProperty(this, "subscribers", {});
2078
-
2079
2312
  _defineProperty(this, "subscribe", function (eventName, callback) {
2080
2313
  if (!Array.isArray(_this.subscribers[eventName])) _this.subscribers[eventName] = [];
2081
-
2082
2314
  _this.subscribers[eventName].push(callback);
2083
-
2084
2315
  return _this.subscribers[eventName].length - 1;
2085
2316
  });
2086
-
2087
2317
  _defineProperty(this, "unsubscribe", function (eventName, callback, id) {
2088
2318
  if (id >= 0) _this.subscribers[eventName].splice(id, 1);else if (callback) _this.subscribers[eventName] = _this.subscribers[eventName].filter(function (cb) {
2089
2319
  return cb !== callback;
2090
2320
  });
2091
2321
  });
2092
-
2093
2322
  _defineProperty(this, "publish", function (eventName, data) {
2094
2323
  if (Array.isArray(eventName)) eventName.forEach(function (name) {
2095
2324
  return _this._publish(name, data);
2096
2325
  });else _this._publish(eventName, data);
2097
2326
  });
2098
-
2099
2327
  _defineProperty(this, "_publish", function (eventName, data) {
2100
2328
  var subscribers = _this.subscribers[eventName];
2101
2329
  if (!Array.isArray(subscribers)) return;
2102
2330
  if (eventName.includes(":pre")) _this._handlePrePublish(subscribers, data);else _this._handlePublish(subscribers, data);
2103
2331
  });
2104
-
2105
2332
  _defineProperty(this, "_handlePublish", function (subscribers, data) {
2106
2333
  for (var i = 0, il = subscribers.length; i < il; i++) {
2107
2334
  if (_this.DS.stopped) return;
2108
2335
  subscribers[i](data);
2109
2336
  }
2110
2337
  });
2111
-
2112
2338
  _defineProperty(this, "_handlePrePublish", function (subscribers, data) {
2113
2339
  var i = subscribers.length;
2114
-
2115
2340
  while (i--) {
2116
2341
  if (_this.DS.stopped) return;
2117
2342
  subscribers[i](data);
2118
2343
  }
2119
2344
  });
2120
-
2121
2345
  this.DS = DS;
2122
2346
  }
2347
+
2123
2348
  /**
2124
2349
  * Subscribe to an event
2125
2350
  * @memberof DragSelect#
@@ -2127,13 +2352,20 @@ var PubSub = function PubSub(_ref) {
2127
2352
  * @param {DSCallbackNames} eventName
2128
2353
  * @param {DSCallback} callback
2129
2354
  * @returns {number} event id, can be used to unsubscribe more efficiently
2130
- */
2131
- ;
2355
+ */;
2132
2356
 
2133
2357
  var SelectableSet = /*#__PURE__*/function (_Set) {
2134
2358
  _inherits(SelectableSet, _Set);
2135
-
2136
2359
  var _super = _createSuper(SelectableSet);
2360
+ /**
2361
+ * @type {Map<DSElement,DSBoundingRect>}
2362
+ * @private
2363
+ */
2364
+
2365
+ /**
2366
+ * @type {NodeJS.Timeout}
2367
+ * @private
2368
+ */
2137
2369
 
2138
2370
  /**
2139
2371
  * @constructor SelectableSet
@@ -2142,79 +2374,62 @@ var SelectableSet = /*#__PURE__*/function (_Set) {
2142
2374
  */
2143
2375
  function SelectableSet(_ref) {
2144
2376
  var _this;
2145
-
2146
2377
  var DS = _ref.DS;
2147
-
2148
2378
  _classCallCheck(this, SelectableSet);
2149
-
2150
2379
  _this = _super.call(this);
2151
-
2380
+ _defineProperty(_assertThisInitialized(_this), "_rects", void 0);
2381
+ _defineProperty(_assertThisInitialized(_this), "_timeout", void 0);
2152
2382
  _defineProperty(_assertThisInitialized(_this), "init", function () {
2153
2383
  return toArray(_this.Settings.selectables).forEach(function (el) {
2154
2384
  return _this.add(el);
2155
2385
  });
2156
2386
  });
2157
-
2158
2387
  _defineProperty(_assertThisInitialized(_this), "clear", function () {
2159
2388
  return _this.forEach(function (el) {
2160
2389
  return _this["delete"](el);
2161
2390
  });
2162
2391
  });
2163
-
2164
2392
  _defineProperty(_assertThisInitialized(_this), "_onClick", function (event) {
2165
2393
  return _this.DS.publish(['Selectable:click:pre', 'Selectable:click'], {
2166
2394
  event: event
2167
2395
  });
2168
2396
  });
2169
-
2170
2397
  _defineProperty(_assertThisInitialized(_this), "_onPointer", function (event) {
2171
2398
  return _this.DS.publish(['Selectable:pointer:pre', 'Selectable:pointer'], {
2172
2399
  event: event
2173
2400
  });
2174
2401
  });
2175
-
2176
2402
  _defineProperty(_assertThisInitialized(_this), "addAll", function (elements) {
2177
2403
  return elements.forEach(function (el) {
2178
2404
  return _this.add(el);
2179
2405
  });
2180
2406
  });
2181
-
2182
2407
  _defineProperty(_assertThisInitialized(_this), "deleteAll", function (elements) {
2183
2408
  return elements.forEach(function (el) {
2184
2409
  return _this["delete"](el);
2185
2410
  });
2186
2411
  });
2187
-
2188
2412
  _this.DS = DS;
2189
2413
  _this.Settings = DS.stores.SettingsStore.s;
2190
-
2191
- _this.DS.subscribe('Interaction:init', _this.init); // @ts-ignore: @todo: update to typescript
2192
-
2193
-
2414
+ _this.DS.subscribe('Interaction:init', _this.init);
2415
+ // @ts-ignore: @todo: update to typescript
2194
2416
  _this.DS.PubSub.subscribe('Settings:updated:selectables', function () {
2195
2417
  _this.clear();
2196
-
2197
- _this.init();
2198
- }); // @ts-ignore: @todo: update to typescript
2199
-
2200
-
2418
+ _this.init();
2419
+ });
2420
+ // @ts-ignore: @todo: update to typescript
2201
2421
  _this.DS.subscribe('Settings:updated:selectableClass', function (_ref2) {
2202
2422
  var settings = _ref2.settings;
2203
-
2204
2423
  _this.forEach(function (el) {
2205
2424
  el.classList.remove(settings['selectableClass:pre']);
2206
2425
  el.classList.add(settings['selectableClass']);
2207
2426
  });
2208
2427
  });
2209
-
2210
2428
  return _this;
2211
2429
  }
2212
-
2213
2430
  _createClass(SelectableSet, [{
2214
2431
  key: "add",
2215
-
2216
- /** @param {DSElement} element */
2217
- value: function add(element) {
2432
+ /** @param {DSElement} element */value: function add(element) {
2218
2433
  if (_get(_getPrototypeOf(SelectableSet.prototype), "has", this).call(this, element)) return;
2219
2434
  var publishData = {
2220
2435
  items: this.elements,
@@ -2237,9 +2452,7 @@ var SelectableSet = /*#__PURE__*/function (_Set) {
2237
2452
  });
2238
2453
  this.DS.publish('Selectable:added', publishData);
2239
2454
  return _get(_getPrototypeOf(SelectableSet.prototype), "add", this).call(this, element);
2240
- }
2241
- /** @param {DSElement} element */
2242
-
2455
+ } /** @param {DSElement} element */
2243
2456
  }, {
2244
2457
  key: "delete",
2245
2458
  value: function _delete(element) {
@@ -2265,21 +2478,33 @@ var SelectableSet = /*#__PURE__*/function (_Set) {
2265
2478
  }
2266
2479
  }, {
2267
2480
  key: "elements",
2268
-
2269
- /** @return {DSElements} */
2270
- get: function get() {
2481
+ /** @return {DSElements} */get: function get() {
2271
2482
  return Array.from(this.values());
2272
2483
  }
2273
- }]);
2484
+ }, {
2485
+ key: "rects",
2486
+ get: function get() {
2487
+ var _this2 = this;
2488
+ if (this._rects) return this._rects;
2489
+ this._rects = new Map();
2490
+ this.forEach(function (element) {
2491
+ return _this2._rects.set(element, element.getBoundingClientRect());
2492
+ });
2274
2493
 
2494
+ // since elements can be moved, we need to update the rects every X ms
2495
+ if (this._timeout) clearTimeout(this._timeout);
2496
+ this._timeout = setTimeout(function () {
2497
+ return _this2._rects = null;
2498
+ }, this.Settings.refreshMemoryRate);
2499
+ return this._rects;
2500
+ }
2501
+ }]);
2275
2502
  return SelectableSet;
2276
2503
  }( /*#__PURE__*/_wrapNativeSuper(Set));
2277
2504
 
2278
2505
  var SelectedSet = /*#__PURE__*/function (_Set) {
2279
2506
  _inherits(SelectedSet, _Set);
2280
-
2281
2507
  var _super = _createSuper(SelectedSet);
2282
-
2283
2508
  /**
2284
2509
  * @constructor SelectableSet
2285
2510
  * @param {{DS:DragSelect}} obj
@@ -2287,37 +2512,29 @@ var SelectedSet = /*#__PURE__*/function (_Set) {
2287
2512
  */
2288
2513
  function SelectedSet(_ref) {
2289
2514
  var _this;
2290
-
2291
2515
  var DS = _ref.DS;
2292
-
2293
2516
  _classCallCheck(this, SelectedSet);
2294
-
2295
2517
  _this = _super.call(this);
2296
-
2297
2518
  _defineProperty(_assertThisInitialized(_this), "clear", function () {
2298
2519
  return _this.forEach(function (el) {
2299
2520
  return _this["delete"](el);
2300
2521
  });
2301
2522
  });
2302
-
2303
2523
  _defineProperty(_assertThisInitialized(_this), "addAll", function (elements) {
2304
2524
  return elements.forEach(function (el) {
2305
2525
  return _this.add(el);
2306
2526
  });
2307
2527
  });
2308
-
2309
2528
  _defineProperty(_assertThisInitialized(_this), "deleteAll", function (elements) {
2310
2529
  return elements.forEach(function (el) {
2311
2530
  return _this["delete"](el);
2312
2531
  });
2313
2532
  });
2314
-
2315
2533
  _this.DS = DS;
2316
2534
  return _this;
2317
2535
  }
2318
- /** @param {DSElement} element */
2319
-
2320
2536
 
2537
+ /** @param {DSElement} element */
2321
2538
  _createClass(SelectedSet, [{
2322
2539
  key: "add",
2323
2540
  value: function add(element) {
@@ -2327,16 +2544,12 @@ var SelectedSet = /*#__PURE__*/function (_Set) {
2327
2544
  item: element
2328
2545
  };
2329
2546
  this.DS.publish('Selected:added:pre', publishData);
2330
-
2331
2547
  _get(_getPrototypeOf(SelectedSet.prototype), "add", this).call(this, element);
2332
-
2333
2548
  element.classList.add(this.DS.stores.SettingsStore.s.selectedClass);
2334
2549
  element.style.zIndex = "".concat((parseInt(element.style.zIndex) || 0) + 1);
2335
2550
  this.DS.publish('Selected:added', publishData);
2336
2551
  return this;
2337
- }
2338
- /** @param {DSElement} element */
2339
-
2552
+ } /** @param {DSElement} element */
2340
2553
  }, {
2341
2554
  key: "delete",
2342
2555
  value: function _delete(element) {
@@ -2346,9 +2559,7 @@ var SelectedSet = /*#__PURE__*/function (_Set) {
2346
2559
  item: element
2347
2560
  };
2348
2561
  this.DS.publish('Selected:removed:pre', publishData);
2349
-
2350
2562
  var deleted = _get(_getPrototypeOf(SelectedSet.prototype), "delete", this).call(this, element);
2351
-
2352
2563
  element.classList.remove(this.DS.stores.SettingsStore.s.selectedClass);
2353
2564
  element.style.zIndex = "".concat((parseInt(element.style.zIndex) || 0) - 1);
2354
2565
  this.DS.publish('Selected:removed', publishData);
@@ -2356,7 +2567,6 @@ var SelectedSet = /*#__PURE__*/function (_Set) {
2356
2567
  }
2357
2568
  }, {
2358
2569
  key: "toggle",
2359
-
2360
2570
  /**
2361
2571
  * Adds/Removes an element. If it is already selected = remove, if not = add.
2362
2572
  * @param {DSElement} element
@@ -2365,18 +2575,13 @@ var SelectedSet = /*#__PURE__*/function (_Set) {
2365
2575
  value: function toggle(element) {
2366
2576
  if (this.has(element)) this["delete"](element);else this.add(element);
2367
2577
  return element;
2368
- }
2369
- /** @param {DSElements} elements */
2370
-
2578
+ } /** @param {DSElements} elements */
2371
2579
  }, {
2372
2580
  key: "elements",
2373
-
2374
- /** @return {DSElements} */
2375
- get: function get() {
2581
+ /** @return {DSElements} */get: function get() {
2376
2582
  return Array.from(this.values());
2377
2583
  }
2378
2584
  }]);
2379
-
2380
2585
  return SelectedSet;
2381
2586
  }( /*#__PURE__*/_wrapNativeSuper(Set));
2382
2587
 
@@ -2393,50 +2598,46 @@ var Selection = /*#__PURE__*/function () {
2393
2598
  */
2394
2599
  function Selection(_ref) {
2395
2600
  var _this = this;
2396
-
2397
2601
  var DS = _ref.DS;
2398
-
2399
2602
  _classCallCheck(this, Selection);
2400
-
2401
2603
  _defineProperty(this, "_prevSelectedSet", void 0);
2402
-
2403
2604
  _defineProperty(this, "start", function (_ref2) {
2404
2605
  var event = _ref2.event,
2405
- isDragging = _ref2.isDragging;
2606
+ isDragging = _ref2.isDragging;
2406
2607
  if (isDragging) return;
2407
-
2408
2608
  _this._storePrevious(event);
2409
-
2410
2609
  _this._handleInsideSelection(true, event);
2411
2610
  });
2412
-
2413
2611
  _defineProperty(this, "update", function (_ref3) {
2414
2612
  var isDragging = _ref3.isDragging;
2415
2613
  if (isDragging || _this.DS["continue"]) return;
2416
-
2417
2614
  _this._handleInsideSelection();
2418
2615
  });
2419
-
2420
2616
  _defineProperty(this, "_handleInsideSelection", function (force, event) {
2421
2617
  var _this$DS = _this.DS,
2422
- SelectableSet = _this$DS.SelectableSet,
2423
- SelectorArea = _this$DS.SelectorArea,
2424
- Selector = _this$DS.Selector;
2618
+ SelectableSet = _this$DS.SelectableSet,
2619
+ SelectorArea = _this$DS.SelectorArea,
2620
+ Selector = _this$DS.Selector;
2425
2621
  /** @type {any} */
2426
-
2427
- var elPosCombo = SelectableSet.elements.map(function (element) {
2428
- return [element, element.getBoundingClientRect()];
2429
- });
2622
+ var elRects = SelectableSet.rects;
2430
2623
  var select = [];
2431
2624
  var unselect = [];
2432
-
2433
- for (var i = 0, il = elPosCombo.length; i < il; i++) {
2434
- if (!SelectorArea.isInside(elPosCombo[i][0], elPosCombo[i][1])) continue;
2435
- if (isCollision(elPosCombo[i][1], Selector.rect)) select.push(elPosCombo[i][0]);else unselect.push(elPosCombo[i][0]);
2625
+ var _iterator = _createForOfIteratorHelper(elRects),
2626
+ _step;
2627
+ try {
2628
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
2629
+ var _step$value = _slicedToArray(_step.value, 2),
2630
+ element = _step$value[0],
2631
+ rect = _step$value[1];
2632
+ if (!SelectorArea.isInside(element, rect)) continue;
2633
+ if (isCollision(rect, Selector.rect, _this.Settings.selectionThreshold)) select.push(element);else unselect.push(element);
2634
+ }
2635
+ } catch (err) {
2636
+ _iterator.e(err);
2637
+ } finally {
2638
+ _iterator.f();
2436
2639
  }
2437
-
2438
- var multiSelectionToggle = _this.DS.stores.KeyStore.isMultiSelectKeyPressed(event) && _this.DS.stores.SettingsStore.s.multiSelectToggling;
2439
-
2640
+ var multiSelectionToggle = _this.DS.stores.KeyStore.isMultiSelectKeyPressed(event) && _this.Settings.multiSelectToggling;
2440
2641
  if (_this.DS["continue"]) return;
2441
2642
  select.forEach(function (element) {
2442
2643
  return handleSelection({
@@ -2444,7 +2645,7 @@ var Selection = /*#__PURE__*/function () {
2444
2645
  force: force,
2445
2646
  multiSelectionToggle: multiSelectionToggle,
2446
2647
  SelectedSet: _this.DS.SelectedSet,
2447
- hoverClassName: _this.DS.stores.SettingsStore.s.hoverClass
2648
+ hoverClassName: _this.Settings.hoverClass
2448
2649
  });
2449
2650
  });
2450
2651
  unselect.forEach(function (element) {
@@ -2452,35 +2653,31 @@ var Selection = /*#__PURE__*/function () {
2452
2653
  element: element,
2453
2654
  force: force,
2454
2655
  SelectedSet: _this.DS.SelectedSet,
2455
- hoverClassName: _this.DS.stores.SettingsStore.s.hoverClass,
2656
+ hoverClassName: _this.Settings.hoverClass,
2456
2657
  PrevSelectedSet: _this._prevSelectedSet
2457
2658
  });
2458
2659
  });
2459
2660
  });
2460
-
2461
2661
  this.DS = DS;
2662
+ this.Settings = this.DS.stores.SettingsStore.s;
2462
2663
  this.DS.subscribe('Interaction:start', this.start);
2463
2664
  this.DS.subscribe('Interaction:update', this.update);
2464
2665
  }
2666
+
2465
2667
  /**
2466
2668
  * Stores the previous selection (solves #9)
2467
2669
  * @param {DSEvent} event
2468
2670
  * @private
2469
2671
  * */
2470
-
2471
-
2472
2672
  _createClass(Selection, [{
2473
2673
  key: "_storePrevious",
2474
2674
  value: function _storePrevious(event) {
2475
2675
  var _this$DS2 = this.DS,
2476
- KeyStore = _this$DS2.stores.KeyStore,
2477
- SelectedSet = _this$DS2.SelectedSet;
2676
+ KeyStore = _this$DS2.stores.KeyStore,
2677
+ SelectedSet = _this$DS2.SelectedSet;
2478
2678
  if (KeyStore.isMultiSelectKeyPressed(event)) this._prevSelectedSet = new Set(SelectedSet);else this._prevSelectedSet = new Set();
2479
- }
2480
- /** @param {{event:DSEvent,isDragging:boolean}} event */
2481
-
2679
+ } /** @param {{event:DSEvent,isDragging:boolean}} event */
2482
2680
  }]);
2483
-
2484
2681
  return Selection;
2485
2682
  }();
2486
2683
 
@@ -2497,24 +2694,16 @@ var Selector = /*#__PURE__*/function () {
2497
2694
  */
2498
2695
  function Selector(_ref) {
2499
2696
  var _this = this;
2500
-
2501
2697
  var DS = _ref.DS;
2502
-
2503
2698
  _classCallCheck(this, Selector);
2504
-
2505
2699
  _defineProperty(this, "_rect", void 0);
2506
-
2507
2700
  _defineProperty(this, "attachSelector", function () {
2508
2701
  var _this$DS$SelectorArea, _this$DS$SelectorArea2;
2509
-
2510
2702
  if (_this.HTMLNode && (_this$DS$SelectorArea = _this.DS.SelectorArea) !== null && _this$DS$SelectorArea !== void 0 && _this$DS$SelectorArea.HTMLNode) _this.DS.SelectorArea.HTMLNode.removeChild(_this.HTMLNode);
2511
2703
  _this.HTMLNode = _this.DS.stores.SettingsStore.s.selector || createSelectorElement(_this.DS.stores.SettingsStore.s.customStyles);
2512
-
2513
2704
  _this.HTMLNode.classList.add(_this.DS.stores.SettingsStore.s.selectorClass);
2514
-
2515
2705
  if (_this.HTMLNode && (_this$DS$SelectorArea2 = _this.DS.SelectorArea) !== null && _this$DS$SelectorArea2 !== void 0 && _this$DS$SelectorArea2.HTMLNode) _this.DS.SelectorArea.HTMLNode.appendChild(_this.HTMLNode);
2516
2706
  });
2517
-
2518
2707
  _defineProperty(this, "start", function (_ref2) {
2519
2708
  var isDragging = _ref2.isDragging;
2520
2709
  if (isDragging) return;
@@ -2524,19 +2713,17 @@ var Selector = /*#__PURE__*/function () {
2524
2713
  _this.HTMLNode.style.display = 'block';
2525
2714
  _this._rect = null;
2526
2715
  });
2527
-
2528
2716
  _defineProperty(this, "stop", function () {
2529
2717
  _this.HTMLNode.style.width = '0';
2530
2718
  _this.HTMLNode.style.height = '0';
2531
2719
  _this.HTMLNode.style.display = 'none';
2532
2720
  });
2533
-
2534
2721
  _defineProperty(this, "update", function (_ref3) {
2535
2722
  var isDragging = _ref3.isDragging;
2536
2723
  if (isDragging || _this.DS["continue"]) return;
2537
2724
  var _this$DS$stores = _this.DS.stores,
2538
- ScrollStore = _this$DS$stores.ScrollStore,
2539
- PointerStore = _this$DS$stores.PointerStore;
2725
+ ScrollStore = _this$DS$stores.ScrollStore,
2726
+ PointerStore = _this$DS$stores.PointerStore;
2540
2727
  var pos = getSelectorPosition({
2541
2728
  scrollAmount: ScrollStore.scrollAmount,
2542
2729
  initialPointerPos: PointerStore.initialValArea,
@@ -2545,24 +2732,21 @@ var Selector = /*#__PURE__*/function () {
2545
2732
  updateElementStylePos(_this.HTMLNode, pos);
2546
2733
  _this._rect = null;
2547
2734
  });
2735
+ this.DS = DS;
2548
2736
 
2549
- this.DS = DS; // @ts-ignore: @todo: update to typescript
2550
-
2737
+ // @ts-ignore: @todo: update to typescript
2551
2738
  this.DS.subscribe('Settings:updated:selectorClass', function (_ref4) {
2552
2739
  var settings = _ref4.settings;
2553
-
2554
2740
  _this.HTMLNode.classList.remove(settings['selectorClass:pre']);
2555
-
2556
2741
  _this.HTMLNode.classList.add(settings['selectorClass']);
2557
- }); // @ts-ignore: @todo: update to typescript
2558
-
2742
+ });
2743
+ // @ts-ignore: @todo: update to typescript
2559
2744
  this.DS.subscribe('Settings:updated:selector', this.attachSelector);
2560
2745
  this.attachSelector();
2561
2746
  this.DS.subscribe('Interaction:start', this.start);
2562
2747
  this.DS.subscribe('Interaction:update', this.update);
2563
2748
  this.DS.subscribe('Interaction:end', this.stop);
2564
2749
  }
2565
-
2566
2750
  _createClass(Selector, [{
2567
2751
  key: "rect",
2568
2752
  get: function get() {
@@ -2570,7 +2754,6 @@ var Selector = /*#__PURE__*/function () {
2570
2754
  return this._rect = this.HTMLNode.getBoundingClientRect();
2571
2755
  }
2572
2756
  }]);
2573
-
2574
2757
  return Selector;
2575
2758
  }();
2576
2759
 
@@ -2598,31 +2781,21 @@ var SelectorArea = /*#__PURE__*/function () {
2598
2781
  */
2599
2782
  function SelectorArea(_ref) {
2600
2783
  var _this = this;
2601
-
2602
2784
  var DS = _ref.DS;
2603
-
2604
2785
  _classCallCheck(this, SelectorArea);
2605
-
2606
2786
  _defineProperty(this, "_scrollInterval", void 0);
2607
-
2608
2787
  _defineProperty(this, "_rect", void 0);
2609
-
2610
2788
  _defineProperty(this, "currentEdges", []);
2611
-
2612
2789
  _defineProperty(this, "start", function () {
2613
2790
  return _this.applyElements('append');
2614
2791
  });
2615
-
2616
2792
  _defineProperty(this, "applyElements", function () {
2617
2793
  var method = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'append';
2618
2794
  var docEl = document.body ? 'body' : 'documentElement';
2619
2795
  var methodName = "".concat(method, "Child");
2620
-
2621
2796
  _this.HTMLNode[methodName](_this.DS.Selector.HTMLNode);
2622
-
2623
2797
  document[docEl][methodName](_this.HTMLNode);
2624
2798
  });
2625
-
2626
2799
  _defineProperty(this, "updatePos", function () {
2627
2800
  _this._rect = null;
2628
2801
  var rect = _this.DS.Area.rect;
@@ -2637,25 +2810,21 @@ var SelectorArea = /*#__PURE__*/function () {
2637
2810
  if (style.width !== width) style.width = width;
2638
2811
  if (style.height !== height) style.height = height;
2639
2812
  });
2640
-
2641
2813
  _defineProperty(this, "stop", function (remove) {
2642
2814
  _this.stopAutoScroll();
2643
-
2644
2815
  if (remove) _this.applyElements('remove');
2645
2816
  });
2646
-
2647
2817
  _defineProperty(this, "startAutoScroll", function () {
2648
2818
  _this.currentEdges = [];
2649
2819
  _this._scrollInterval = setInterval(function () {
2650
2820
  return _this.handleAutoScroll();
2651
2821
  }, 16);
2652
2822
  });
2653
-
2654
2823
  _defineProperty(this, "handleAutoScroll", function () {
2655
2824
  if (_this.DS["continue"]) return;
2656
2825
  var _this$DS = _this.DS,
2657
- PointerStore = _this$DS.stores.PointerStore,
2658
- Area = _this$DS.Area;
2826
+ PointerStore = _this$DS.stores.PointerStore,
2827
+ Area = _this$DS.Area;
2659
2828
  _this.currentEdges = getOverflowEdges({
2660
2829
  elementRect: vect2rect(PointerStore.currentVal),
2661
2830
  containerRect: _this.rect,
@@ -2663,25 +2832,20 @@ var SelectorArea = /*#__PURE__*/function () {
2663
2832
  });
2664
2833
  if (_this.currentEdges.length) Area.scroll(_this.currentEdges, _this.DS.stores.SettingsStore.s.autoScrollSpeed);
2665
2834
  });
2666
-
2667
2835
  _defineProperty(this, "stopAutoScroll", function () {
2668
2836
  _this.currentEdges = [];
2669
2837
  clearInterval(_this._scrollInterval);
2670
2838
  });
2671
-
2672
2839
  _defineProperty(this, "isInside", function (element, elementRect) {
2673
2840
  if (_this.DS.Area.HTMLNode.contains(element) && _this.DS.stores.ScrollStore.canScroll) return true;
2674
2841
  return isCollision(_this.rect, elementRect || element.getBoundingClientRect());
2675
2842
  });
2676
-
2677
2843
  this.DS = DS;
2678
- this.HTMLNode = createSelectorAreaElement(); // @ts-ignore: @todo: update to typescript
2679
-
2844
+ this.HTMLNode = createSelectorAreaElement();
2845
+ // @ts-ignore: @todo: update to typescript
2680
2846
  this.DS.subscribe('Settings:updated:selectorAreaClass', function (_ref2) {
2681
2847
  var settings = _ref2.settings;
2682
-
2683
2848
  _this.HTMLNode.classList.remove(settings['selectorAreaClass:pre']);
2684
-
2685
2849
  _this.HTMLNode.classList.add(settings['selectorAreaClass']);
2686
2850
  });
2687
2851
  this.HTMLNode.classList.add(this.DS.stores.SettingsStore.s.selectorAreaClass);
@@ -2691,14 +2855,11 @@ var SelectorArea = /*#__PURE__*/function () {
2691
2855
  this.DS.subscribe('Interaction:start', this.startAutoScroll);
2692
2856
  this.DS.subscribe('Interaction:end', function () {
2693
2857
  _this.updatePos();
2694
-
2695
2858
  _this.stopAutoScroll();
2696
2859
  });
2697
2860
  }
2698
-
2699
2861
  _createClass(SelectorArea, [{
2700
2862
  key: "isClicked",
2701
-
2702
2863
  /**
2703
2864
  * checks if the click was triggered on the area.
2704
2865
  * @param {DSEvent} [event]
@@ -2721,7 +2882,6 @@ var SelectorArea = /*#__PURE__*/function () {
2721
2882
  return this._rect = this.HTMLNode.getBoundingClientRect();
2722
2883
  }
2723
2884
  }]);
2724
-
2725
2885
  return SelectorArea;
2726
2886
  }();
2727
2887
 
@@ -2744,80 +2904,59 @@ var KeyStore = /*#__PURE__*/function () {
2744
2904
  */
2745
2905
  function KeyStore(_ref) {
2746
2906
  var _this = this;
2747
-
2748
2907
  var DS = _ref.DS;
2749
-
2750
2908
  _classCallCheck(this, KeyStore);
2751
-
2752
2909
  _defineProperty(this, "_currentValues", new Set());
2753
-
2754
2910
  _defineProperty(this, "_keyMapping", {
2755
2911
  control: 'ctrlKey',
2756
2912
  shift: 'shiftKey',
2757
2913
  meta: 'metaKey'
2758
2914
  });
2759
-
2760
2915
  _defineProperty(this, "init", function () {
2761
2916
  document.addEventListener('keydown', _this.keydown);
2762
2917
  document.addEventListener('keyup', _this.keyup);
2763
2918
  window.addEventListener('blur', _this.reset);
2764
2919
  });
2765
-
2766
2920
  _defineProperty(this, "keydown", function (event) {
2767
2921
  var key = event.key.toLowerCase();
2768
-
2769
2922
  _this.DS.publish('KeyStore:down:pre', {
2770
2923
  event: event,
2771
2924
  key: key
2772
2925
  });
2773
-
2774
2926
  _this._currentValues.add(key);
2775
-
2776
2927
  _this.DS.publish('KeyStore:down', {
2777
2928
  event: event,
2778
2929
  key: key
2779
2930
  });
2780
2931
  });
2781
-
2782
2932
  _defineProperty(this, "keyup", function (event) {
2783
2933
  var key = event.key.toLowerCase();
2784
-
2785
2934
  _this.DS.publish('KeyStore:up:pre', {
2786
2935
  event: event,
2787
2936
  key: key
2788
2937
  });
2789
-
2790
2938
  _this._currentValues["delete"](key);
2791
-
2792
2939
  _this.DS.publish('KeyStore:up', {
2793
2940
  event: event,
2794
2941
  key: key
2795
2942
  });
2796
2943
  });
2797
-
2798
2944
  _defineProperty(this, "stop", function () {
2799
2945
  document.removeEventListener('keydown', _this.keydown);
2800
2946
  document.removeEventListener('keyup', _this.reset);
2801
2947
  window.removeEventListener('blur', _this.reset);
2802
-
2803
2948
  _this.reset();
2804
2949
  });
2805
-
2806
2950
  _defineProperty(this, "reset", function () {
2807
2951
  return _this._currentValues.clear();
2808
2952
  });
2809
-
2810
2953
  this.DS = DS;
2811
2954
  this.DS.subscribe('Interaction:init', this.init);
2812
2955
  }
2813
-
2814
2956
  _createClass(KeyStore, [{
2815
2957
  key: "isMultiSelectKeyPressed",
2816
-
2817
- /** @param {KeyboardEvent|MouseEvent|PointerEvent|TouchEvent} [event] */
2818
- value: function isMultiSelectKeyPressed(event) {
2958
+ /** @param {KeyboardEvent|MouseEvent|PointerEvent|TouchEvent} [event] */value: function isMultiSelectKeyPressed(event) {
2819
2959
  var _this2 = this;
2820
-
2821
2960
  if (this.DS.stores.SettingsStore.s.multiSelectMode) return true;
2822
2961
  var multiSelectKeys = this.DS.stores.SettingsStore.s.multiSelectKeys.map(function (key) {
2823
2962
  return key.toLocaleLowerCase();
@@ -2836,14 +2975,13 @@ var KeyStore = /*#__PURE__*/function () {
2836
2975
  return Array.from(this._currentValues.values());
2837
2976
  }
2838
2977
  }]);
2839
-
2840
2978
  return KeyStore;
2841
2979
  }();
2842
2980
 
2843
2981
  var PointerStore = /*#__PURE__*/function () {
2844
2982
  /** @type {boolean} */
2845
- // Pointer Positions within Area
2846
2983
 
2984
+ // Pointer Positions within Area
2847
2985
  /**
2848
2986
  * @type {Vect2}
2849
2987
  * @private
@@ -2858,8 +2996,8 @@ var PointerStore = /*#__PURE__*/function () {
2858
2996
  * @type {Vect2}
2859
2997
  * @private
2860
2998
  * */
2861
- // General Pointer Position
2862
2999
 
3000
+ // General Pointer Position
2863
3001
  /**
2864
3002
  * @type {Vect2}
2865
3003
  * @private
@@ -2888,27 +3026,16 @@ var PointerStore = /*#__PURE__*/function () {
2888
3026
  */
2889
3027
  function PointerStore(_ref) {
2890
3028
  var _this = this;
2891
-
2892
3029
  var DS = _ref.DS;
2893
-
2894
3030
  _classCallCheck(this, PointerStore);
2895
-
2896
3031
  _defineProperty(this, "_isMouseInteraction", false);
2897
-
2898
3032
  _defineProperty(this, "_initialValArea", void 0);
2899
-
2900
3033
  _defineProperty(this, "_currentValArea", void 0);
2901
-
2902
3034
  _defineProperty(this, "_lastValArea", void 0);
2903
-
2904
3035
  _defineProperty(this, "_initialVal", void 0);
2905
-
2906
3036
  _defineProperty(this, "_currentVal", void 0);
2907
-
2908
3037
  _defineProperty(this, "_lastVal", void 0);
2909
-
2910
3038
  _defineProperty(this, "_lastTouch", void 0);
2911
-
2912
3039
  _defineProperty(this, "init", function () {
2913
3040
  if (_this.Settings.usePointerEvents) document.addEventListener('pointermove', _this.update, {
2914
3041
  // @ts-ignore
@@ -2919,28 +3046,22 @@ var PointerStore = /*#__PURE__*/function () {
2919
3046
  passive: false
2920
3047
  });
2921
3048
  });
2922
-
2923
3049
  _defineProperty(this, "getPointerPosition", function (event) {
2924
3050
  return getPointerPos({
2925
3051
  event: _this._normalizedEvent(event)
2926
3052
  });
2927
3053
  });
2928
-
2929
3054
  _defineProperty(this, "update", function (event) {
2930
3055
  if (!event) return;
2931
-
2932
3056
  _this.DS.publish('PointerStore:updated:pre', {
2933
3057
  event: event
2934
3058
  });
2935
-
2936
3059
  _this.currentVal = _this.getPointerPosition(event);
2937
3060
  if (!_this._isMouseInteraction) return;
2938
-
2939
3061
  _this.DS.publish('PointerStore:updated', {
2940
3062
  event: event
2941
3063
  });
2942
3064
  });
2943
-
2944
3065
  _defineProperty(this, "stop", function () {
2945
3066
  // @TODO: fix pointer events mixing issue see [PR](https://github.com/ThibaultJanBeyer/DragSelect/pull/128#issuecomment-1154885289)
2946
3067
  if (_this.Settings.usePointerEvents) document.removeEventListener('pointermove', _this.update, {
@@ -2950,22 +3071,18 @@ var PointerStore = /*#__PURE__*/function () {
2950
3071
  document.removeEventListener('touchmove', _this.update, {
2951
3072
  // @ts-ignore
2952
3073
  passive: false
2953
- }); // debounce in order "onClick" to work
2954
-
3074
+ });
3075
+ // debounce in order "onClick" to work
2955
3076
  setTimeout(function () {
2956
3077
  return _this._isMouseInteraction = false;
2957
3078
  }, 100);
2958
3079
  });
2959
-
2960
3080
  _defineProperty(this, "reset", function (event) {
2961
3081
  if (!event) return;
2962
3082
  _this.currentVal = _this.lastVal = _this.getPointerPosition(event);
2963
-
2964
3083
  _this.stop();
2965
-
2966
3084
  _this.init();
2967
3085
  });
2968
-
2969
3086
  this.DS = DS;
2970
3087
  this.Settings = DS.stores.SettingsStore.s;
2971
3088
  this.DS.subscribe('Interaction:init', this.init);
@@ -2978,21 +3095,15 @@ var PointerStore = /*#__PURE__*/function () {
2978
3095
  return _this.reset(event);
2979
3096
  });
2980
3097
  }
2981
-
2982
3098
  _createClass(PointerStore, [{
2983
3099
  key: "start",
2984
-
2985
- /** @param {DSEvent} [event] */
2986
- value: function start(event) {
3100
+ /** @param {DSEvent} [event] */value: function start(event) {
2987
3101
  if (!event) return;
2988
3102
  this._isMouseInteraction = true;
2989
3103
  this.currentVal = this.initialVal = this.getPointerPosition(event);
2990
- }
2991
- /** @param {DSEvent} event */
2992
-
3104
+ } /** @param {DSEvent} event */
2993
3105
  }, {
2994
3106
  key: "_normalizedEvent",
2995
-
2996
3107
  /**
2997
3108
  * @param {DSEvent} event
2998
3109
  * @return {MouseEvent|PointerEvent|Touch}
@@ -3000,13 +3111,11 @@ var PointerStore = /*#__PURE__*/function () {
3000
3111
  */
3001
3112
  value: function _normalizedEvent(event) {
3002
3113
  // touchend has not touches. so we take the last touch if a touchevent, we need to store the positions
3003
- if ('touches' in event && event.type !== 'touchend') this._lastTouch = event; // if a touchevent, return the last touch rather than the regular event
3114
+ if ('touches' in event && event.type !== 'touchend') this._lastTouch = event;
3115
+ // if a touchevent, return the last touch rather than the regular event
3004
3116
  // we need .touches[0] from that event instead
3005
-
3006
3117
  return 'touches' in event ? this._lastTouch.touches[0] : event;
3007
- }
3008
- /** First recorded pointer position within the area */
3009
-
3118
+ } /** First recorded pointer position within the area */
3010
3119
  }, {
3011
3120
  key: "initialValArea",
3012
3121
  get: function get() {
@@ -3015,9 +3124,7 @@ var PointerStore = /*#__PURE__*/function () {
3015
3124
  y: 0
3016
3125
  };
3017
3126
  return this._initialValArea;
3018
- }
3019
- /** Current pointer position within the area */
3020
-
3127
+ } /** Current pointer position within the area */
3021
3128
  }, {
3022
3129
  key: "currentValArea",
3023
3130
  get: function get() {
@@ -3026,9 +3133,7 @@ var PointerStore = /*#__PURE__*/function () {
3026
3133
  y: 0
3027
3134
  };
3028
3135
  return this._currentValArea;
3029
- }
3030
- /** Last recorded pointer position within the area */
3031
-
3136
+ } /** Last recorded pointer position within the area */
3032
3137
  }, {
3033
3138
  key: "lastValArea",
3034
3139
  get: function get() {
@@ -3037,9 +3142,7 @@ var PointerStore = /*#__PURE__*/function () {
3037
3142
  y: 0
3038
3143
  };
3039
3144
  return this._lastValArea;
3040
- }
3041
- /** First recorded pointer position */
3042
-
3145
+ } /** First recorded pointer position */
3043
3146
  }, {
3044
3147
  key: "initialVal",
3045
3148
  get: function get() {
@@ -3048,9 +3151,7 @@ var PointerStore = /*#__PURE__*/function () {
3048
3151
  y: 0
3049
3152
  };
3050
3153
  return this._initialVal;
3051
- }
3052
- /** Current pointer position */
3053
- ,
3154
+ } /** Current pointer position */,
3054
3155
  set: function set(value) {
3055
3156
  this._initialVal = value;
3056
3157
  this._initialValArea = value && calc(value, '-', calc(rect2vect(this.DS.Area.rect), '+', rect2vect(this.DS.Area.computedBorder)));
@@ -3063,9 +3164,7 @@ var PointerStore = /*#__PURE__*/function () {
3063
3164
  y: 0
3064
3165
  };
3065
3166
  return this._currentVal;
3066
- }
3067
- /** Last recorded pointer position */
3068
- ,
3167
+ } /** Last recorded pointer position */,
3069
3168
  set: function set(value) {
3070
3169
  this._currentVal = value;
3071
3170
  this._currentValArea = value && calc(value, '-', calc(rect2vect(this.DS.Area.rect), '+', rect2vect(this.DS.Area.computedBorder)));
@@ -3084,7 +3183,6 @@ var PointerStore = /*#__PURE__*/function () {
3084
3183
  this._lastValArea = value && calc(value, '-', calc(rect2vect(this.DS.Area.rect), '+', rect2vect(this.DS.Area.computedBorder)));
3085
3184
  }
3086
3185
  }]);
3087
-
3088
3186
  return PointerStore;
3089
3187
  }();
3090
3188
 
@@ -3109,47 +3207,33 @@ var ScrollStore = /*#__PURE__*/function () {
3109
3207
  */
3110
3208
  function ScrollStore(_ref) {
3111
3209
  var _this = this;
3112
-
3113
3210
  var DS = _ref.DS;
3114
-
3115
3211
  _classCallCheck(this, ScrollStore);
3116
-
3117
3212
  _defineProperty(this, "_initialVal", void 0);
3118
-
3119
3213
  _defineProperty(this, "_currentVal", void 0);
3120
-
3121
3214
  _defineProperty(this, "_canScroll", void 0);
3122
-
3123
3215
  _defineProperty(this, "init", function () {
3124
3216
  return _this.DS.stores.SettingsStore.s.area.addEventListener('scroll', _this.update);
3125
3217
  });
3126
-
3127
3218
  _defineProperty(this, "start", function () {
3128
3219
  _this._currentVal = _this._initialVal = getCurrentScroll(_this.DS.stores.SettingsStore.s.area);
3129
-
3130
3220
  _this.DS.stores.SettingsStore.s.area.addEventListener('scroll', _this.update);
3131
3221
  });
3132
-
3133
3222
  _defineProperty(this, "update", function () {
3134
3223
  return _this._currentVal = getCurrentScroll(_this.DS.stores.SettingsStore.s.area);
3135
3224
  });
3136
-
3137
3225
  _defineProperty(this, "stop", function () {
3138
3226
  _this.DS.stores.SettingsStore.s.area.removeEventListener('scroll', _this.update);
3139
-
3140
3227
  _this._initialVal = {
3141
3228
  x: 0,
3142
3229
  y: 0
3143
3230
  };
3144
3231
  _this._canScroll = null;
3145
3232
  });
3146
-
3147
3233
  _defineProperty(this, "reset", function () {
3148
3234
  _this.stop();
3149
-
3150
3235
  _this.start();
3151
3236
  });
3152
-
3153
3237
  this.DS = DS;
3154
3238
  this.DS.subscribe('Interaction:init', this.init);
3155
3239
  this.DS.subscribe('Interaction:start', function () {
@@ -3159,7 +3243,6 @@ var ScrollStore = /*#__PURE__*/function () {
3159
3243
  return _this.reset();
3160
3244
  });
3161
3245
  }
3162
-
3163
3246
  _createClass(ScrollStore, [{
3164
3247
  key: "canScroll",
3165
3248
  get: function get() {
@@ -3169,8 +3252,9 @@ var ScrollStore = /*#__PURE__*/function () {
3169
3252
  }, {
3170
3253
  key: "scrollAmount",
3171
3254
  get: function get() {
3172
- var scrollDiff = calc(this.currentVal, '-', this.initialVal); // if area is zoomed, the scroll values are skewed, we need to fix that manually :(
3255
+ var scrollDiff = calc(this.currentVal, '-', this.initialVal);
3173
3256
 
3257
+ // if area is zoomed, the scroll values are skewed, we need to fix that manually :(
3174
3258
  var zoom = num2vect(this.DS.stores.SettingsStore.s.zoom);
3175
3259
  var zoomScroll = calc(calc(scrollDiff, '*', zoom), '-', scrollDiff);
3176
3260
  return {
@@ -3194,7 +3278,6 @@ var ScrollStore = /*#__PURE__*/function () {
3194
3278
  return this._currentVal;
3195
3279
  }
3196
3280
  }]);
3197
-
3198
3281
  return ScrollStore;
3199
3282
  }();
3200
3283
 
@@ -3221,39 +3304,29 @@ var SettingsStore =
3221
3304
  */
3222
3305
  function SettingsStore(_ref) {
3223
3306
  var _this = this;
3224
-
3225
3307
  var DS = _ref.DS,
3226
- _settings2 = _ref.settings;
3227
-
3308
+ _settings2 = _ref.settings;
3228
3309
  _classCallCheck(this, SettingsStore);
3229
-
3230
3310
  _defineProperty(this, "_settings", {});
3231
-
3232
3311
  _defineProperty(this, "s", {});
3233
-
3234
3312
  _defineProperty(this, "update", function (_ref2) {
3235
3313
  var settings = _ref2.settings,
3236
- init = _ref2.init;
3314
+ init = _ref2.init;
3237
3315
  return _this.DS.publish('Settings:updated:pre', _objectSpread2({
3238
3316
  settings: settings
3239
3317
  }, init ? {
3240
3318
  init: init
3241
3319
  } : {}));
3242
3320
  });
3243
-
3244
3321
  _defineProperty(this, "_update", function (_ref3) {
3245
3322
  var settings = _ref3.settings,
3246
- init = _ref3.init;
3247
-
3323
+ init = _ref3.init;
3248
3324
  var _settings = hydrateSettings(settings, init);
3249
-
3250
3325
  var _loop = function _loop() {
3251
3326
  var _settings4;
3252
-
3253
3327
  var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
3254
- key = _Object$entries$_i[0],
3255
- value = _Object$entries$_i[1];
3256
-
3328
+ key = _Object$entries$_i[0],
3329
+ value = _Object$entries$_i[1];
3257
3330
  if (!(key in _this._settings)) {
3258
3331
  Object.defineProperty(_this.s, key, {
3259
3332
  get: function get() {
@@ -3266,24 +3339,19 @@ function SettingsStore(_ref) {
3266
3339
  }
3267
3340
  });
3268
3341
  }
3269
-
3270
3342
  _this._settings["".concat(key, ":pre")] = _this._settings[key];
3271
3343
  _this._settings[key] = value;
3272
3344
  var update = {
3273
3345
  settings: (_settings4 = {}, _defineProperty(_settings4, key, _this._settings[key]), _defineProperty(_settings4, "".concat(key, ":pre"), _this._settings["".concat(key, ":pre")]), _settings4)
3274
3346
  };
3275
-
3276
- _this.DS.publish('Settings:updated', update); // @ts-ignore: @todo: update to typescript
3277
-
3278
-
3347
+ _this.DS.publish('Settings:updated', update);
3348
+ // @ts-ignore: @todo: update to typescript
3279
3349
  _this.DS.publish("Settings:updated:".concat(key), update);
3280
3350
  };
3281
-
3282
3351
  for (var _i = 0, _Object$entries = Object.entries(_settings); _i < _Object$entries.length; _i++) {
3283
3352
  _loop();
3284
3353
  }
3285
3354
  });
3286
-
3287
3355
  this.DS = DS;
3288
3356
  this.DS.subscribe('Settings:updated:pre', this._update);
3289
3357
  this.update({
@@ -3291,11 +3359,11 @@ function SettingsStore(_ref) {
3291
3359
  init: true
3292
3360
  });
3293
3361
  }
3294
- /** @param {{settings: Settings, init?: boolean}} props */
3295
- ;
3296
3362
 
3297
- //////////////////////////////////////////////////////////////////////////////////////
3363
+ /** @param {{settings: Settings, init?: boolean}} props */;
3298
3364
 
3365
+ // Setup
3366
+ //////////////////////////////////////////////////////////////////////////////////////
3299
3367
  var DragSelect = /*#__PURE__*/function () {
3300
3368
  /**
3301
3369
  * used to skip all current Selection and dragNdrop functionality
@@ -3309,76 +3377,67 @@ var DragSelect = /*#__PURE__*/function () {
3309
3377
  */
3310
3378
  function DragSelect(_settings) {
3311
3379
  var _this = this;
3312
-
3313
3380
  _classCallCheck(this, DragSelect);
3314
-
3315
3381
  _defineProperty(this, "continue", false);
3316
-
3317
3382
  _defineProperty(this, "start", function () {
3318
3383
  _this.stopped = false;
3319
-
3320
3384
  _this.Interaction.init();
3321
3385
  });
3322
-
3323
3386
  _defineProperty(this, "break", function () {
3324
3387
  return _this["continue"] = true;
3325
3388
  });
3326
-
3389
+ _defineProperty(this, "setSettings", function (settings) {
3390
+ return _this.stores.SettingsStore.update({
3391
+ settings: settings
3392
+ });
3393
+ });
3327
3394
  _defineProperty(this, "getSelection", function () {
3328
3395
  return _this.SelectedSet.elements;
3329
3396
  });
3330
-
3331
3397
  _defineProperty(this, "getSelectables", function () {
3332
3398
  return _this.SelectableSet.elements;
3333
3399
  });
3334
-
3335
3400
  _defineProperty(this, "getInitialCursorPosition", function () {
3336
3401
  return _this.stores.PointerStore.initialVal;
3337
3402
  });
3338
-
3339
3403
  _defineProperty(this, "getCurrentCursorPosition", function () {
3340
3404
  return _this.stores.PointerStore.currentVal;
3341
3405
  });
3342
-
3343
3406
  _defineProperty(this, "getPreviousCursorPosition", function () {
3344
3407
  return _this.stores.PointerStore.lastVal;
3345
3408
  });
3346
-
3347
3409
  _defineProperty(this, "getInitialCursorPositionArea", function () {
3348
3410
  return _this.stores.PointerStore.initialValArea;
3349
3411
  });
3350
-
3351
3412
  _defineProperty(this, "getCurrentCursorPositionArea", function () {
3352
3413
  return _this.stores.PointerStore.currentValArea;
3353
3414
  });
3354
-
3355
3415
  _defineProperty(this, "getPreviousCursorPositionArea", function () {
3356
3416
  return _this.stores.PointerStore.lastValArea;
3357
3417
  });
3358
-
3359
3418
  _defineProperty(this, "isMultiSelect", function (event) {
3360
3419
  return _this.stores.KeyStore.isMultiSelectKeyPressed(event);
3361
3420
  });
3362
-
3363
3421
  _defineProperty(this, "isDragging", function () {
3364
3422
  return _this.Interaction.isDragging;
3365
3423
  });
3366
-
3367
- _defineProperty(this, "setSettings", function (settings) {
3368
- return _this.stores.SettingsStore.update({
3369
- settings: settings
3370
- });
3424
+ _defineProperty(this, "getZoneByCoordinates", function (coordinates) {
3425
+ var _this$DropZones$getTa;
3426
+ return (_this$DropZones$getTa = _this.DropZones.getTarget(coordinates)) === null || _this$DropZones$getTa === void 0 ? void 0 : _this$DropZones$getTa.toObject();
3427
+ });
3428
+ _defineProperty(this, "getItemsDroppedByZoneId", function (zoneId) {
3429
+ return _this.DropZones.getItemsDroppedById(zoneId);
3430
+ });
3431
+ _defineProperty(this, "getItemsInsideByZoneId", function (zoneId, addClasses) {
3432
+ return _this.DropZones.getItemsInsideById(zoneId, addClasses);
3371
3433
  });
3372
-
3373
3434
  this.PubSub = new PubSub({
3374
3435
  DS: this
3375
3436
  });
3376
3437
  this.subscribe = this.PubSub.subscribe;
3377
3438
  this.unsubscribe = this.PubSub.unsubscribe;
3378
3439
  this.publish = this.PubSub.publish;
3379
- this.stores =
3380
- /** @type {{ SettingsStore:SettingsStore, PointerStore:PointerStore, ScrollStore:ScrollStore, KeyStore:KeyStore }} */
3381
- {};
3440
+ this.stores = /** @type {{ SettingsStore:SettingsStore, PointerStore:PointerStore, ScrollStore:ScrollStore, KeyStore:KeyStore }} */{};
3382
3441
  this.stores.SettingsStore = new SettingsStore({
3383
3442
  DS: this,
3384
3443
  settings: _settings
@@ -3413,32 +3472,35 @@ var DragSelect = /*#__PURE__*/function () {
3413
3472
  this.Drag = new Drag({
3414
3473
  DS: this
3415
3474
  });
3475
+ this.DropZones = new DropZones({
3476
+ DS: this
3477
+ });
3416
3478
  this.Interaction = new Interaction({
3417
3479
  DS: this
3418
- }); // Subscriber Aliases
3480
+ });
3419
3481
 
3482
+ // Subscriber Aliases
3420
3483
  subscriberAliases({
3421
3484
  subscribe: this.subscribe,
3422
3485
  publish: this.publish,
3423
3486
  SelectedSet: this.SelectedSet,
3424
- Interaction: this.Interaction
3487
+ Interaction: this.Interaction,
3488
+ DropZones: this.DropZones
3425
3489
  });
3426
3490
  this.subscribe('Interaction:end', function () {
3427
3491
  return _this["continue"] = false;
3428
3492
  });
3429
3493
  this.start();
3430
- } // Useful methods for the user
3431
- //////////////////////////////////////////////////////////////////////////////////////
3494
+ }
3432
3495
 
3496
+ // Useful methods for the user
3497
+ //////////////////////////////////////////////////////////////////////////////////////
3433
3498
  /**
3434
3499
  * Initializes the functionality. Automatically triggered when created.
3435
3500
  * Also, reset the functionality after a teardown
3436
3501
  */
3437
-
3438
-
3439
3502
  _createClass(DragSelect, [{
3440
3503
  key: "stop",
3441
-
3442
3504
  /**
3443
3505
  * Complete function teardown
3444
3506
  * Will teardown/stop the whole functionality
@@ -3470,10 +3532,8 @@ var DragSelect = /*#__PURE__*/function () {
3470
3532
  * Break will skip the selection or dragging functionality (until after the callback) but let everything continue to run.
3471
3533
  * Useful utility to write your own functionality/move/dragNdrop based on DragSelect pointer positions.
3472
3534
  */
3473
-
3474
3535
  }, {
3475
3536
  key: "addSelection",
3476
-
3477
3537
  /**
3478
3538
  * Adds several elements to the selection list also adds the specific classes and take into account all calculations.
3479
3539
  * Does not clear the selection, in contrary to .setSelection. Can add multiple elements at once
@@ -3500,7 +3560,6 @@ var DragSelect = /*#__PURE__*/function () {
3500
3560
  * @param {boolean} [removeFromSelectables] - if element should be removed from the list of selectable elements
3501
3561
  * @return {DSElements} all selected elements
3502
3562
  */
3503
-
3504
3563
  }, {
3505
3564
  key: "removeSelection",
3506
3565
  value: function removeSelection(elements) {
@@ -3522,12 +3581,10 @@ var DragSelect = /*#__PURE__*/function () {
3522
3581
  * @param {boolean} [alsoSelectables] - if element should not be added/removed to the list of selectable elements accordingly
3523
3582
  * @return {DSElements} all selected elements
3524
3583
  */
3525
-
3526
3584
  }, {
3527
3585
  key: "toggleSelection",
3528
3586
  value: function toggleSelection(elements) {
3529
3587
  var _this2 = this;
3530
-
3531
3588
  var triggerCallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
3532
3589
  var alsoSelectables = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
3533
3590
  toArray(elements).forEach(function (el) {
@@ -3546,7 +3603,6 @@ var DragSelect = /*#__PURE__*/function () {
3546
3603
  * @param {boolean} [dontAddToSelectables] - if element should not be added to the list of selectable elements
3547
3604
  * @return {DSElements}
3548
3605
  */
3549
-
3550
3606
  }, {
3551
3607
  key: "setSelection",
3552
3608
  value: function setSelection(elements) {
@@ -3561,7 +3617,6 @@ var DragSelect = /*#__PURE__*/function () {
3561
3617
  * @param {boolean} [triggerCallback] - if callback should be called
3562
3618
  * @return {DSElements} this.selected, should be empty
3563
3619
  */
3564
-
3565
3620
  }, {
3566
3621
  key: "clearSelection",
3567
3622
  value: function clearSelection() {
@@ -3579,7 +3634,6 @@ var DragSelect = /*#__PURE__*/function () {
3579
3634
  * @param {boolean} [triggerCallback] - if callback should be called
3580
3635
  * @return {DSInputElements} the added element(s)
3581
3636
  */
3582
-
3583
3637
  }, {
3584
3638
  key: "addSelectables",
3585
3639
  value: function addSelectables(elements, addToSelection, triggerCallback) {
@@ -3595,10 +3649,8 @@ var DragSelect = /*#__PURE__*/function () {
3595
3649
  * Gets all nodes that can potentially be selected
3596
3650
  * @return {DSElements} this.selectables
3597
3651
  */
3598
-
3599
3652
  }, {
3600
3653
  key: "setSelectables",
3601
-
3602
3654
  /**
3603
3655
  * Sets all elements that can be selected.
3604
3656
  * Removes all current selectables (& their respective classes).
@@ -3622,7 +3674,6 @@ var DragSelect = /*#__PURE__*/function () {
3622
3674
  * @param {boolean} [triggerCallback] - if callback should be called
3623
3675
  * @return {DSInputElements} the removed element(s)
3624
3676
  */
3625
-
3626
3677
  }, {
3627
3678
  key: "removeSelectables",
3628
3679
  value: function removeSelectables(elements, removeFromSelection, triggerCallback) {
@@ -3632,11 +3683,8 @@ var DragSelect = /*#__PURE__*/function () {
3632
3683
  items: this.getSelection()
3633
3684
  });
3634
3685
  return elements;
3635
- }
3636
- /** The starting/initial position of the cursor/selector @return {Vect2} */
3637
-
3686
+ } /** The starting/initial position of the cursor/selector @return {Vect2} */
3638
3687
  }]);
3639
-
3640
3688
  return DragSelect;
3641
3689
  }();
3642
3690