dragselect 2.5.2 → 2.5.3
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 +4 -0
- package/dist/DragSelect.es6m.js +28 -24
- package/dist/DragSelect.js +28 -24
- package/dist/ds.es6m.min.js +1 -1
- package/dist/ds.min.js +1 -1
- package/dist/methods/subscriberAliases.d.ts +1 -1
- package/package.json +1 -1
- package/src/methods/addModificationObservers.js +2 -5
- package/src/methods/canScroll.js +3 -3
- package/src/methods/getAllParentNodes.js +1 -2
- package/src/methods/getStylePosition.js +10 -11
- package/src/methods/handleElementPositionAttribute.js +1 -1
- package/src/methods/isCollision.js +1 -1
- package/src/methods/subscriberAliases.js +16 -7
- package/src/modules/Area.js +14 -5
- package/src/modules/Drag.js +16 -4
- package/src/modules/DropZones.js +4 -2
- package/src/modules/Interaction.js +8 -5
- package/src/modules/PubSub.js +5 -7
- package/src/modules/SelectedSet.js +2 -0
- package/src/modules/Selection.js +4 -3
- package/src/modules/Selector.js +3 -3
|
@@ -5,6 +5,7 @@ import '../types'
|
|
|
5
5
|
export default class Interaction {
|
|
6
6
|
/** @type {boolean} */
|
|
7
7
|
isInteracting
|
|
8
|
+
|
|
8
9
|
/** @type {boolean} */
|
|
9
10
|
isDragging
|
|
10
11
|
|
|
@@ -30,9 +31,10 @@ export default class Interaction {
|
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
init = () => this.DS.publish('Interaction:init:pre', {})
|
|
34
|
+
|
|
33
35
|
_init = () => {
|
|
34
36
|
this.stop()
|
|
35
|
-
|
|
37
|
+
|
|
36
38
|
// @TODO: fix pointer events mixing issue see [PR](https://github.com/ThibaultJanBeyer/DragSelect/pull/128#issuecomment-1154885289)
|
|
37
39
|
if (this.Settings.usePointerEvents)
|
|
38
40
|
this.DS.Area.HTMLNode.addEventListener('pointerdown', this.start, {
|
|
@@ -62,7 +64,7 @@ export default class Interaction {
|
|
|
62
64
|
(event.target &&
|
|
63
65
|
!this.DS.SelectorArea.isInside(
|
|
64
66
|
/** @type {DSElement} */ (event.target)
|
|
65
|
-
)) || //fix outside elements issue
|
|
67
|
+
)) || // fix outside elements issue
|
|
66
68
|
(!isKeyboardClick && !this.DS.SelectorArea.isClicked(event)) // make sure the mouse click is inside the area
|
|
67
69
|
)
|
|
68
70
|
return false
|
|
@@ -78,6 +80,7 @@ export default class Interaction {
|
|
|
78
80
|
event,
|
|
79
81
|
isDragging: this.isDragging,
|
|
80
82
|
})
|
|
83
|
+
|
|
81
84
|
_start = (event) => {
|
|
82
85
|
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
|
|
83
86
|
if (!this._canInteract(event)) return
|
|
@@ -147,8 +150,7 @@ export default class Interaction {
|
|
|
147
150
|
const node = /** @type {any} */ (event.target)
|
|
148
151
|
if (!SelectableSet.has(node)) return
|
|
149
152
|
|
|
150
|
-
if (!KeyStore.isMultiSelectKeyPressed(event))
|
|
151
|
-
SelectedSet.clear()
|
|
153
|
+
if (!KeyStore.isMultiSelectKeyPressed(event)) SelectedSet.clear()
|
|
152
154
|
SelectedSet.toggle(node)
|
|
153
155
|
|
|
154
156
|
this.reset() // simulate mouse-up (that does not exist on keyboard)
|
|
@@ -193,8 +195,9 @@ export default class Interaction {
|
|
|
193
195
|
event,
|
|
194
196
|
isDragging: this.isDragging,
|
|
195
197
|
})
|
|
198
|
+
|
|
196
199
|
_reset = (event) => {
|
|
197
|
-
const isDragging = this
|
|
200
|
+
const { isDragging } = this
|
|
198
201
|
this.stop()
|
|
199
202
|
this.init()
|
|
200
203
|
this.DS.publish('Interaction:end', { event, isDragging })
|
package/src/modules/PubSub.js
CHANGED
|
@@ -48,17 +48,15 @@ export default class PubSub {
|
|
|
48
48
|
*/
|
|
49
49
|
publish = (eventName, data) => {
|
|
50
50
|
if (Array.isArray(eventName))
|
|
51
|
-
eventName.forEach(name => this._publish(name, data))
|
|
52
|
-
else
|
|
53
|
-
this._publish(eventName, data)
|
|
51
|
+
eventName.forEach((name) => this._publish(name, data))
|
|
52
|
+
else this._publish(eventName, data)
|
|
54
53
|
}
|
|
54
|
+
|
|
55
55
|
_publish = (eventName, data) => {
|
|
56
56
|
const subscribers = this.subscribers[eventName]
|
|
57
57
|
if (!Array.isArray(subscribers)) return
|
|
58
|
-
if (eventName.includes(`:pre`))
|
|
59
|
-
|
|
60
|
-
else
|
|
61
|
-
this._handlePublish(subscribers, data)
|
|
58
|
+
if (eventName.includes(`:pre`)) this._handlePrePublish(subscribers, data)
|
|
59
|
+
else this._handlePublish(subscribers, data)
|
|
62
60
|
}
|
|
63
61
|
|
|
64
62
|
// non-pre events are executed first in first out
|
|
@@ -58,8 +58,10 @@ export default class SelectedSet extends Set {
|
|
|
58
58
|
|
|
59
59
|
/** @param {DSElements} elements */
|
|
60
60
|
addAll = (elements) => elements.forEach((el) => this.add(el))
|
|
61
|
+
|
|
61
62
|
/** @param {DSElements} elements */
|
|
62
63
|
deleteAll = (elements) => elements.forEach((el) => this.delete(el))
|
|
64
|
+
|
|
63
65
|
/** @return {DSElements} */
|
|
64
66
|
get elements() {
|
|
65
67
|
return Array.from(this.values())
|
package/src/modules/Selection.js
CHANGED
|
@@ -66,14 +66,15 @@ export default class Selection {
|
|
|
66
66
|
const select = []
|
|
67
67
|
const unselect = []
|
|
68
68
|
|
|
69
|
-
for(const [element, rect] of elRects) {
|
|
69
|
+
for (const [element, rect] of elRects) {
|
|
70
70
|
if (!SelectorArea.isInside(element, rect)) continue
|
|
71
|
-
if (isCollision(rect, Selector.rect, this.Settings.selectionThreshold))
|
|
71
|
+
if (isCollision(rect, Selector.rect, this.Settings.selectionThreshold))
|
|
72
|
+
select.push(element)
|
|
72
73
|
else unselect.push(element)
|
|
73
74
|
}
|
|
74
75
|
|
|
75
76
|
const multiSelectionToggle =
|
|
76
|
-
|
|
77
|
+
this.DS.stores.KeyStore.isMultiSelectKeyPressed(event) &&
|
|
77
78
|
this.Settings.multiSelectToggling
|
|
78
79
|
|
|
79
80
|
if (this.DS.continue) return
|
package/src/modules/Selector.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
import '../types
|
|
2
|
+
import '../types'
|
|
3
3
|
import DragSelect from '../DragSelect'
|
|
4
4
|
|
|
5
5
|
import {
|
|
@@ -27,7 +27,7 @@ export default class Selector {
|
|
|
27
27
|
// @ts-ignore: @todo: update to typescript
|
|
28
28
|
this.DS.subscribe('Settings:updated:selectorClass', ({ settings }) => {
|
|
29
29
|
this.HTMLNode.classList.remove(settings['selectorClass:pre'])
|
|
30
|
-
this.HTMLNode.classList.add(settings
|
|
30
|
+
this.HTMLNode.classList.add(settings.selectorClass)
|
|
31
31
|
})
|
|
32
32
|
// @ts-ignore: @todo: update to typescript
|
|
33
33
|
this.DS.subscribe('Settings:updated:selector', this.attachSelector)
|
|
@@ -37,7 +37,7 @@ export default class Selector {
|
|
|
37
37
|
this.DS.subscribe('Interaction:update', this.update)
|
|
38
38
|
this.DS.subscribe('Interaction:end', this.stop)
|
|
39
39
|
}
|
|
40
|
-
|
|
40
|
+
|
|
41
41
|
attachSelector = () => {
|
|
42
42
|
if (this.HTMLNode && this.DS.SelectorArea?.HTMLNode)
|
|
43
43
|
this.DS.SelectorArea.HTMLNode.removeChild(this.HTMLNode)
|