dragselect 2.2.2 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ # 2.3.0
2
+
3
+ - Fix bug with break not working. (still handling change)
4
+ - Fix bug with `pre` events not working properly.
5
+ - **Caution**:
6
+ - - This upgrade changes the order in which the callbacks are fired. The normal callbacks are fired in a FIFO order, first in, first out. The `pre` callbacks are fired in a LIFO order, last in first out.
7
+ - - Pre Events are now really triggered *before* the whole action.
8
+
1
9
  # 2.2.2
2
10
 
3
11
  - Add a check whether the initial click was issued within the area
package/README.md CHANGED
@@ -30,6 +30,7 @@ easily add a selection algorithm to your application/website.
30
30
  - - [Use your own Drag And Drop](#use-your-own-drag-and-drop)
31
31
  - [Constructor Properties](#constructor-properties)
32
32
  - [Event Callbacks](#event-callbacks)
33
+ - - [Callback Object Keys](#callback-object-keys)
33
34
  - [Methods](#methods)
34
35
  - [Classes](#classes)
35
36
 
@@ -67,11 +68,16 @@ We use it currently in a professional rich interface application where we have a
67
68
 
68
69
  # Supporters
69
70
 
71
+ Please donate to support the countless hours of hard work & support. Especially if your company makes money. Thank you :)
72
+
70
73
  Thanks to:
71
74
 
72
75
  | ![BrowserStack](https://dragselect.com/media/browserstack.jpg) | [You?](https://paypal.me/pools/c/8gF2a5szCP) |
73
76
  |--- |--- |
74
- |[BrowserStack](https://www.browserstack.com/) is an amazing testing service which helps testing the tool on various browsers. They support this open source projects by providing a [free account for open source projects](https://www.browserstack.com/open-source) to use their service! | Thank and support us by making a [Direct Donation](https://paypal.me/pools/c/8gF2a5szCP) (Donations are distributed with all project contributors proportionally. We are grateful for any amount) or [Get in touch](mailto:thibault.beyer@gmail.com) |
77
+ |[BrowserStack](https://www.browserstack.com/) is an amazing testing service which helps testing the tool on various browsers. They support this open source projects by providing a [free account for open source projects](https://www.browserstack.com/open-source) to use their service! | Thank and support us by making a [Direct Donation](https://paypal.me/pools/c/8gF2a5szCP) (Donations are distributed with all project contributors proportionally. We are grateful for any amount) or [Get in touch](mailto:thibault.beyer@gmail.com). We can display your logo here if you want, which will help you recruit great talent and boost your SEO. |
78
+ BTC: [1LdweSpjgSeJC8XxX3swrohBMBLUzg6cmC](https://www.blockchain.com/btc/address/1LdweSpjgSeJC8XxX3swrohBMBLUzg6cmC) |
79
+ Paypal: [https://paypal.me/pools/c/8gF2a5szCP](https://paypal.me/pools/c/8gF2a5szCP) |
80
+ Other: [get in touch](mailto:thibault.beyer@gmail.com) |
75
81
 
76
82
  # Installation
77
83
  ## NPM
@@ -215,14 +221,16 @@ myCustomDrag.subscribe('finished', () => ds.start())
215
221
  Disabling then re-enabling directly can also work (i.e. when your library has no callback):
216
222
 
217
223
  ```JavaScript
218
- ds.subscribe('dragstart', ({ isDragging, isDraggingKeyboard }) => {
224
+ ds.subscribe('predragstart', ({ isDragging, isDraggingKeyboard }) => {
219
225
  if(isDragging) {
220
226
  ds.stop(false, false)
221
- ds.start()
227
+ setTimeout(ds.start)
222
228
  }
223
229
  })
224
230
  ```
225
231
 
232
+ Note: it is important to debounce (i.e. with `setTimeout(ds.start)`) the start function if it's called within a single subscriber so that all the scheduled callbacks finish triggering before we start again.
233
+
226
234
  ### Writing a fully custom solution
227
235
 
228
236
  In case you want to build something completely custom on top of DragSelect, we got you covered! You can use `.break` for this. You heard right, break is back baby :)
@@ -297,13 +305,13 @@ ds.subscribe('<event_name>', (callback_object) => {})
297
305
 
298
306
  |callback_object_keys |type |description |
299
307
  |--- |--- |---
300
- |event |`MouseEvent|TouchEvent|KeyboardEvent` |The native HTML Event, depending on the situational context
301
- |items |`Array.<HTMLElement|SVGElement|*>` |Current selected elements
308
+ |event |`MouseEvent\|TouchEvent\|KeyboardEvent` |The native HTML Event, depending on the situational context
309
+ |items |`Array.<HTMLElement\|SVGElement\|*>` |Current selected elements
302
310
  |isDragging |`boolean` |If true, the user is dragging the selected elements, if false the user is drawing a selection
303
311
  |isDraggingKeyboard |`boolean` |If true, the user is dragging the selected elements with the keyboard
304
- |scroll_directions |`Array.<'top'|'bottom'|'left'|'right'|undefined>` |The direction in which the event is happening (i.e. scroll direction)
312
+ |scroll_directions |`Array.<'top'\|'bottom'\|'left'\|'right'\|undefined>` |The direction in which the event is happening (i.e. scroll direction)
305
313
  |scroll_multiplier |`number` |Speed
306
- |item |`HTMLElement|SVGElement|*` |The single element currently being interacted with if any
314
+ |item |`HTMLElement\|SVGElement\|*` |The single element currently being interacted with if any
307
315
 
308
316
  > Note: all object keys are optional and might not be available, depending on the event type. So make sure to check for availability first
309
317
 
@@ -14,7 +14,7 @@ declare class DragSelect {
14
14
  PubSub: PubSub;
15
15
  subscribe: (eventName: DSCallbackNames, callback: Function) => number;
16
16
  unsubscribe: (eventName: DSCallbackNames, callback?: Function, id?: number) => void;
17
- publish: (eventName: DSCallbackNames, data: CallbackObject) => void;
17
+ publish: (eventName: "dragstart" | "dragmove" | "autoscroll" | "elementselect" | "elementunselect" | "callback" | "Interaction:init" | "Interaction:start" | "Interaction:end" | "Interaction:update" | "Area:modified" | "Area:scroll" | "PointerStore:updated" | "Selected:added" | "Selected:removed" | "Selectable:click" | "Selectable:pointer" | "KeyStore:down" | "KeyStore:up" | "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:pointer:pre" | "KeyStore:down:pre" | "KeyStore:up:pre" | DSCallbackNames[], data: CallbackObject) => void;
18
18
  stores: {
19
19
  PointerStore: PointerStore;
20
20
  ScrollStore: ScrollStore;
@@ -41,6 +41,7 @@ declare class DragSelect {
41
41
  * Also, reset the functionality after a teardown
42
42
  */
43
43
  start: () => void;
44
+ stopped: boolean;
44
45
  /**
45
46
  * Complete function teardown
46
47
  * Will teardown/stop the whole functionality
@@ -1,6 +1,6 @@
1
1
  /***
2
2
 
3
- ~~~ Version 2.2.2 ~~~
3
+ ~~~ Version 2.3.0 ~~~
4
4
 
5
5
  ******************************************
6
6
 
@@ -410,9 +410,9 @@ function _nonIterableRest() {
410
410
 
411
411
  /** @typedef {'Interaction:init'|'Interaction:start'|'Interaction:end'|'Interaction:update'|'Area:modified'|'Area:scroll'|'PointerStore:updated'|'Selected:added'|'Selected:removed'|'Selectable:click'|'Selectable:pointer'|'KeyStore:down'|'KeyStore:up'} DSInternalEventNames */
412
412
 
413
- /** @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:pointer:pre'|'KeyStore:down:pre'|'KeyStore:up:pre'|'Drag:keyboardDrag:pre'} DSInternalEventNamesPre */
413
+ /** @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:pointer:pre'|'KeyStore:down:pre'|'KeyStore:up:pre'} DSInternalEventNamesPre */
414
414
 
415
- /** @typedef {DSEventNames|DSInternalEventNames} DSCallbackNames the name of the callback */
415
+ /** @typedef {DSEventNames|DSInternalEventNames|DSInternalEventNamesPre} DSCallbackNames the name of the callback */
416
416
 
417
417
  /** @typedef {{top:number,left:number,bottom:number,right:number,width:number,height:number}} DSBoundingRect */
418
418
 
@@ -1255,12 +1255,6 @@ var subscriberAliases = (function (_ref) {
1255
1255
  // event, isDraggingKeyboard
1256
1256
  'Interaction:end': [{
1257
1257
  name: 'callback'
1258
- }],
1259
- // event, isDraggingKeyboard
1260
- 'Drag:keyboardDrag': [{
1261
- name: 'dragstart'
1262
- }, {
1263
- name: 'dragmove'
1264
1258
  }] // event, isDraggingKeyboard
1265
1259
 
1266
1260
  };
@@ -1314,6 +1308,13 @@ var updateElementStylePos = (function (element, pos) {
1314
1308
  element.style.height = "".concat(pos.height, "px");
1315
1309
  });
1316
1310
 
1311
+ /**
1312
+ * @typedef {Object} AreaProps
1313
+ * @property {DSArea} area
1314
+ * @property {PubSub} PS
1315
+ * @property {number} zoom
1316
+ */
1317
+
1317
1318
  var Area = /*#__PURE__*/function () {
1318
1319
  /**
1319
1320
  * @type {DSModificationCallback}
@@ -1357,16 +1358,13 @@ var Area = /*#__PURE__*/function () {
1357
1358
 
1358
1359
  /**
1359
1360
  * @constructor Area
1360
- * @param {Object} obj
1361
- * @param {DSArea} obj.area
1362
- * @param {PubSub} obj.PS
1363
- * @param {number} obj.zoom
1361
+ * @param {AreaProps} settings
1364
1362
  * @ignore
1365
1363
  */
1366
1364
  function Area(_ref) {
1367
1365
  var _this = this;
1368
1366
 
1369
- var area = _ref.area,
1367
+ var _area = _ref.area,
1370
1368
  PS = _ref.PS,
1371
1369
  zoom = _ref.zoom;
1372
1370
 
@@ -1388,6 +1386,26 @@ var Area = /*#__PURE__*/function () {
1388
1386
 
1389
1387
  _defineProperty(this, "_rect", void 0);
1390
1388
 
1389
+ _defineProperty(this, "setArea", function (area) {
1390
+ _this._node = area;
1391
+ handleElementPositionAttribute({
1392
+ computedStyle: _this.computedStyle,
1393
+ node: _this._node
1394
+ }); // first immediate debounce to update values after dom-update
1395
+
1396
+ setTimeout(function () {
1397
+ _this.PubSub.publish('Area:modified:pre', {
1398
+ item: _this
1399
+ });
1400
+
1401
+ _this.reset();
1402
+
1403
+ _this.PubSub.publish('Area:modified', {
1404
+ item: _this
1405
+ });
1406
+ });
1407
+ });
1408
+
1391
1409
  _defineProperty(this, "start", function () {
1392
1410
  addModificationObservers(_this.parentNodes, _this._modificationCallback, _this._modificationObserver);
1393
1411
  });
@@ -1406,42 +1424,40 @@ var Area = /*#__PURE__*/function () {
1406
1424
  });
1407
1425
 
1408
1426
  _defineProperty(this, "scroll", function (directions, multiplier) {
1409
- scrollElement(_this._node, directions, multiplier);
1410
-
1411
- _this.PubSub.publish('Area:scroll', {
1427
+ var data = {
1412
1428
  scroll_directions: directions,
1413
1429
  scroll_multiplier: multiplier
1414
- });
1430
+ };
1431
+
1432
+ _this.PubSub.publish('Area:scroll:pre', data);
1433
+
1434
+ scrollElement(_this._node, directions, multiplier);
1435
+
1436
+ _this.PubSub.publish('Area:scroll', data);
1415
1437
  });
1416
1438
 
1417
- this._node = area;
1418
1439
  this._zoom = zoom;
1419
1440
  this.PubSub = PS;
1420
- handleElementPositionAttribute({
1421
- computedStyle: this.computedStyle,
1422
- node: this._node
1423
- });
1441
+ this.setArea(_area);
1424
1442
  this._modificationCallback = debounce(function (event) {
1425
- _this.reset();
1426
-
1427
- _this.PubSub.publish('Area:modified', {
1443
+ _this.PubSub.publish('Area:modified:pre', {
1428
1444
  event: event,
1429
1445
  item: _this
1430
1446
  });
1431
- }, 60);
1432
- this._modificationObserver = new MutationObserver(this._modificationCallback); // first immediate debounce to update values after dom-update
1433
1447
 
1434
- setTimeout(function () {
1435
1448
  _this.reset();
1436
1449
 
1437
1450
  _this.PubSub.publish('Area:modified', {
1438
1451
  event: event,
1439
1452
  item: _this
1440
1453
  });
1441
- });
1454
+ }, 60);
1455
+ this._modificationObserver = new MutationObserver(this._modificationCallback);
1442
1456
  this.PubSub.subscribe('Interaction:init', this.start);
1443
1457
  this.PubSub.subscribe('Interaction:end', this.reset);
1444
1458
  }
1459
+ /** @param {DSArea} area */
1460
+
1445
1461
 
1446
1462
  _createClass(Area, [{
1447
1463
  key: "HTMLNode",
@@ -1618,12 +1634,13 @@ var Drag = /*#__PURE__*/function () {
1618
1634
  var event = _ref2.event,
1619
1635
  key = _ref2.key;
1620
1636
  if (!_this._keyboardDrag || !_this._dragKeysFlat.includes(key) || !_this.DS.SelectedSet.size || !_this._draggability || _this.DS["continue"]) return;
1621
-
1622
- _this.DS.publish('Interaction:start', {
1637
+ var publishData = {
1623
1638
  event: event,
1624
1639
  isDragging: true,
1625
1640
  isDraggingKeyboard: true
1626
- });
1641
+ };
1642
+
1643
+ _this.DS.publish(['Interaction:start:pre', 'Interaction:start'], publishData);
1627
1644
 
1628
1645
  _this._elements = _this.DS.getSelection();
1629
1646
 
@@ -1649,23 +1666,20 @@ var Drag = /*#__PURE__*/function () {
1649
1666
  });
1650
1667
  });
1651
1668
 
1652
- _this.DS.publish('Interaction:update', {
1653
- event: event,
1654
- isDragging: true,
1655
- isDraggingKeyboard: true
1656
- });
1669
+ _this.DS.publish(['Interaction:update:pre', 'Interaction:update'], publishData);
1657
1670
  });
1658
1671
 
1659
1672
  _defineProperty(this, "keyboardEnd", function (_ref3) {
1660
1673
  var event = _ref3.event,
1661
1674
  key = _ref3.key;
1662
1675
  if (!_this._keyboardDrag || !_this._dragKeysFlat.includes(key) || !_this.DS.SelectedSet.size || !_this._draggability) return;
1663
-
1664
- _this.DS.publish('Interaction:end', {
1676
+ var publishData = {
1665
1677
  event: event,
1666
1678
  isDragging: _this._draggability,
1667
1679
  isDraggingKeyboard: true
1668
- });
1680
+ };
1681
+
1682
+ _this.DS.publish(['Interaction:end:pre', 'Interaction:end'], publishData);
1669
1683
  });
1670
1684
 
1671
1685
  _defineProperty(this, "start", function (_ref4) {
@@ -1816,6 +1830,10 @@ var Interaction = /*#__PURE__*/function () {
1816
1830
  _defineProperty(this, "isDragging", void 0);
1817
1831
 
1818
1832
  _defineProperty(this, "init", function () {
1833
+ return _this.DS.publish('Interaction:init:pre', {});
1834
+ });
1835
+
1836
+ _defineProperty(this, "_init", function () {
1819
1837
  _this.stop();
1820
1838
 
1821
1839
  _this._areaElement.addEventListener('mousedown', _this.start);
@@ -1828,6 +1846,13 @@ var Interaction = /*#__PURE__*/function () {
1828
1846
  });
1829
1847
 
1830
1848
  _defineProperty(this, "start", function (event) {
1849
+ return _this.DS.publish('Interaction:start:pre', {
1850
+ event: event,
1851
+ isDragging: _this.isDragging
1852
+ });
1853
+ });
1854
+
1855
+ _defineProperty(this, "_start", function (event) {
1831
1856
  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
1832
1857
 
1833
1858
  if (!_this._canInteract(event)) return;
@@ -1872,8 +1897,7 @@ var Interaction = /*#__PURE__*/function () {
1872
1897
  PointerStore = _this$DS$stores.PointerStore,
1873
1898
  KeyStore = _this$DS$stores.KeyStore,
1874
1899
  SelectableSet = _this$DS.SelectableSet,
1875
- SelectedSet = _this$DS.SelectedSet,
1876
- publish = _this$DS.publish;
1900
+ SelectedSet = _this$DS.SelectedSet;
1877
1901
  PointerStore.start(event);
1878
1902
  var node =
1879
1903
  /** @type {any} */
@@ -1881,10 +1905,9 @@ var Interaction = /*#__PURE__*/function () {
1881
1905
  if (!SelectableSet.has(node)) return;
1882
1906
  if (!KeyStore.isMultiSelectKeyPressed(event)) SelectedSet.clear();
1883
1907
  SelectedSet.toggle(node);
1884
- publish('Interaction:end', {
1885
- event: event,
1886
- isDragging: _this.isDragging
1887
- }); // simulate mouse-up (that does not exist on keyboard)
1908
+
1909
+ _this.reset(); // simulate mouse-up (that does not exist on keyboard)
1910
+
1888
1911
  });
1889
1912
 
1890
1913
  _defineProperty(this, "stop", function () {
@@ -1906,7 +1929,7 @@ var Interaction = /*#__PURE__*/function () {
1906
1929
  var event = _ref3.event,
1907
1930
  scroll_directions = _ref3.scroll_directions,
1908
1931
  scroll_multiplier = _ref3.scroll_multiplier;
1909
- if (_this.isInteracting) _this.DS.publish('Interaction:update', {
1932
+ if (_this.isInteracting) _this.DS.publish(['Interaction:update:pre', 'Interaction:update'], {
1910
1933
  event: event,
1911
1934
  scroll_directions: scroll_directions,
1912
1935
  scroll_multiplier: scroll_multiplier,
@@ -1915,6 +1938,13 @@ var Interaction = /*#__PURE__*/function () {
1915
1938
  });
1916
1939
 
1917
1940
  _defineProperty(this, "reset", function (event) {
1941
+ return _this.DS.publish('Interaction:end:pre', {
1942
+ event: event,
1943
+ isDragging: _this.isDragging
1944
+ });
1945
+ });
1946
+
1947
+ _defineProperty(this, "_reset", function (event) {
1918
1948
  var isDragging = _this.isDragging;
1919
1949
 
1920
1950
  _this.stop();
@@ -1937,6 +1967,15 @@ var Interaction = /*#__PURE__*/function () {
1937
1967
  var event = _ref4.event;
1938
1968
  return _this.start(event);
1939
1969
  });
1970
+ this.DS.subscribe('Interaction:start:pre', function (_ref5) {
1971
+ var event = _ref5.event;
1972
+ return _this._start(event);
1973
+ });
1974
+ this.DS.subscribe('Interaction:init:pre', this._init);
1975
+ this.DS.subscribe('Interaction:end:pre', function (_ref6) {
1976
+ var event = _ref6.event;
1977
+ return _this._reset(event);
1978
+ });
1940
1979
  this.DS.subscribe('Area:scroll', this.update);
1941
1980
  }
1942
1981
 
@@ -1974,9 +2013,11 @@ var Interaction = /*#__PURE__*/function () {
1974
2013
  return Interaction;
1975
2014
  }();
1976
2015
 
1977
- var PubSub = function PubSub() {
2016
+ var PubSub = function PubSub(_ref) {
1978
2017
  var _this = this;
1979
2018
 
2019
+ var DS = _ref.DS;
2020
+
1980
2021
  _classCallCheck(this, PubSub);
1981
2022
 
1982
2023
  _defineProperty(this, "subscribers", {});
@@ -1996,17 +2037,44 @@ var PubSub = function PubSub() {
1996
2037
  });
1997
2038
 
1998
2039
  _defineProperty(this, "publish", function (eventName, data) {
1999
- var _this$subscribers$, _this$subscribers$eve;
2040
+ if (Array.isArray(eventName)) eventName.forEach(function (name) {
2041
+ return _this._publish(name, data);
2042
+ });else _this._publish(eventName, data);
2043
+ });
2000
2044
 
2001
- if (!Array.isArray(_this.subscribers[eventName])) return;
2002
- (_this$subscribers$ = _this.subscribers["".concat(eventName, ":pre")]) === null || _this$subscribers$ === void 0 ? void 0 : _this$subscribers$.forEach(function (callback) {
2003
- return callback(data);
2004
- });
2005
- (_this$subscribers$eve = _this.subscribers[eventName]) === null || _this$subscribers$eve === void 0 ? void 0 : _this$subscribers$eve.forEach(function (callback) {
2006
- return callback(data);
2007
- });
2045
+ _defineProperty(this, "_publish", function (eventName, data) {
2046
+ var subscribers = _this.subscribers[eventName];
2047
+ if (!Array.isArray(subscribers)) return;
2048
+ if (eventName.includes(":pre")) _this._handlePrePublish(subscribers, data);else _this._handlePublish(subscribers, data);
2008
2049
  });
2009
- };
2050
+
2051
+ _defineProperty(this, "_handlePublish", function (subscribers, data) {
2052
+ for (var i = 0, il = subscribers.length; i < il; i++) {
2053
+ if (_this.DS.stopped) return;
2054
+ subscribers[i](data);
2055
+ }
2056
+ });
2057
+
2058
+ _defineProperty(this, "_handlePrePublish", function (subscribers, data) {
2059
+ var i = subscribers.length;
2060
+
2061
+ while (i--) {
2062
+ if (_this.DS.stopped) return;
2063
+ subscribers[i](data);
2064
+ }
2065
+ });
2066
+
2067
+ this.DS = DS;
2068
+ }
2069
+ /**
2070
+ * Subscribe to an event
2071
+ * @memberof DragSelect#
2072
+ * @function subscribe
2073
+ * @param {DSCallbackNames} eventName
2074
+ * @param {DSCallback} callback
2075
+ * @returns {number} event id, can be used to unsubscribe more efficiently
2076
+ */
2077
+ ;
2010
2078
 
2011
2079
  var SelectableSet = /*#__PURE__*/function (_Set) {
2012
2080
  _inherits(SelectableSet, _Set);
@@ -2086,13 +2154,13 @@ var SelectableSet = /*#__PURE__*/function (_Set) {
2086
2154
  });
2087
2155
 
2088
2156
  _defineProperty(_assertThisInitialized(_this), "_onClick", function (event) {
2089
- return _this.DS.publish('Selectable:click', {
2157
+ return _this.DS.publish(['Selectable:click:pre', 'Selectable:click'], {
2090
2158
  event: event
2091
2159
  });
2092
2160
  });
2093
2161
 
2094
2162
  _defineProperty(_assertThisInitialized(_this), "_onPointer", function (event) {
2095
- return _this.DS.publish('Selectable:pointer', {
2163
+ return _this.DS.publish(['Selectable:pointer:pre', 'Selectable:pointer'], {
2096
2164
  event: event
2097
2165
  });
2098
2166
  });
@@ -2224,15 +2292,17 @@ var SelectedSet = /*#__PURE__*/function (_Set) {
2224
2292
  key: "add",
2225
2293
  value: function add(element) {
2226
2294
  if (_get(_getPrototypeOf(SelectedSet.prototype), "has", this).call(this, element)) return;
2295
+ var publishData = {
2296
+ items: this.elements,
2297
+ item: element
2298
+ };
2299
+ this.DS.publish('Selected:added:pre', publishData);
2227
2300
 
2228
2301
  _get(_getPrototypeOf(SelectedSet.prototype), "add", this).call(this, element);
2229
2302
 
2230
2303
  element.classList.add(this._className);
2231
- this.DS.publish('Selected:added', {
2232
- items: this.elements,
2233
- item: element
2234
- });
2235
2304
  element.style.zIndex = "".concat((parseInt(element.style.zIndex) || 0) + 1);
2305
+ this.DS.publish('Selected:added', publishData);
2236
2306
  return this;
2237
2307
  }
2238
2308
  /** @param {DSElement} element */
@@ -2241,15 +2311,17 @@ var SelectedSet = /*#__PURE__*/function (_Set) {
2241
2311
  key: "delete",
2242
2312
  value: function _delete(element) {
2243
2313
  if (!_get(_getPrototypeOf(SelectedSet.prototype), "has", this).call(this, element)) return;
2314
+ var publishData = {
2315
+ items: this.elements,
2316
+ item: element
2317
+ };
2318
+ this.DS.publish('Selected:removed:pre', publishData);
2244
2319
 
2245
2320
  var deleted = _get(_getPrototypeOf(SelectedSet.prototype), "delete", this).call(this, element);
2246
2321
 
2247
2322
  element.classList.remove(this._className);
2248
- this.DS.publish('Selected:removed', {
2249
- items: this.elements,
2250
- item: element
2251
- });
2252
2323
  element.style.zIndex = "".concat((parseInt(element.style.zIndex) || 0) - 1);
2324
+ this.DS.publish('Selected:removed', publishData);
2253
2325
  return deleted;
2254
2326
  }
2255
2327
  }, {
@@ -2351,6 +2423,7 @@ var Selection = /*#__PURE__*/function () {
2351
2423
 
2352
2424
  var multiSelectionToggle = _this.DS.stores.KeyStore.isMultiSelectKeyPressed(event) && _this._multiSelectToggling;
2353
2425
 
2426
+ if (_this.DS["continue"]) return;
2354
2427
  select.forEach(function (element) {
2355
2428
  return handleSelection({
2356
2429
  element: element,
@@ -2693,6 +2766,11 @@ var KeyStore = /*#__PURE__*/function () {
2693
2766
  _defineProperty(this, "keydown", function (event) {
2694
2767
  var key = event.key.toLowerCase();
2695
2768
 
2769
+ _this.DS.publish('KeyStore:down:pre', {
2770
+ event: event,
2771
+ key: key
2772
+ });
2773
+
2696
2774
  _this._currentValues.add(key);
2697
2775
 
2698
2776
  _this.DS.publish('KeyStore:down', {
@@ -2704,6 +2782,11 @@ var KeyStore = /*#__PURE__*/function () {
2704
2782
  _defineProperty(this, "keyup", function (event) {
2705
2783
  var key = event.key.toLowerCase();
2706
2784
 
2785
+ _this.DS.publish('KeyStore:up:pre', {
2786
+ event: event,
2787
+ key: key
2788
+ });
2789
+
2707
2790
  _this._currentValues["delete"](key);
2708
2791
 
2709
2792
  _this.DS.publish('KeyStore:up', {
@@ -2858,6 +2941,11 @@ var PointerStore = /*#__PURE__*/function () {
2858
2941
 
2859
2942
  _defineProperty(this, "update", function (event) {
2860
2943
  if (!event) return;
2944
+
2945
+ _this.DS.publish('PointerStore:updated:pre', {
2946
+ event: event
2947
+ });
2948
+
2861
2949
  _this.currentVal = _this.getPointerPosition(event);
2862
2950
  if (!_this._isMouseInteraction) return;
2863
2951
 
@@ -3200,7 +3288,9 @@ var DragSelect = /*#__PURE__*/function () {
3200
3288
  _defineProperty(this, "continue", false);
3201
3289
 
3202
3290
  _defineProperty(this, "start", function () {
3203
- return _this.Interaction.init();
3291
+ _this.stopped = false;
3292
+
3293
+ _this.Interaction.init();
3204
3294
  });
3205
3295
 
3206
3296
  _defineProperty(this, "break", function () {
@@ -3247,7 +3337,9 @@ var DragSelect = /*#__PURE__*/function () {
3247
3337
  return _this.Interaction.isDragging;
3248
3338
  });
3249
3339
 
3250
- this.PubSub = new PubSub();
3340
+ this.PubSub = new PubSub({
3341
+ DS: this
3342
+ });
3251
3343
  this.subscribe = this.PubSub.subscribe;
3252
3344
  this.unsubscribe = this.PubSub.unsubscribe;
3253
3345
  this.publish = this.PubSub.publish;
@@ -3452,6 +3544,7 @@ var DragSelect = /*#__PURE__*/function () {
3452
3544
  this.stores.ScrollStore.stop();
3453
3545
  if (remove) this.SelectableSet.clear();
3454
3546
  if (fromSelection) this.SelectedSet.clear();
3547
+ this.stopped = true;
3455
3548
  }
3456
3549
  /**
3457
3550
  * Utility to override DragSelect internal functionality: