dragselect 2.5.1 → 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 +8 -0
- package/README.md +3 -3
- package/dist/DragSelect.es6m.js +63 -47
- package/dist/DragSelect.js +63 -47
- package/dist/ds.es6m.min.js +1 -1
- package/dist/ds.min.js +1 -1
- package/dist/methods/subscriberAliases.d.ts +1 -1
- package/dist/modules/DropZone.d.ts +5 -3
- package/dist/types.d.ts +10 -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/hydrateSettings.js +176 -47
- 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/DropZone.js +12 -3
- package/src/modules/DropZones.js +4 -2
- package/src/modules/Interaction.js +8 -5
- package/src/modules/PubSub.js +5 -7
- package/src/modules/SelectableSet.js +17 -13
- package/src/modules/SelectedSet.js +2 -0
- package/src/modules/Selection.js +4 -3
- package/src/modules/Selector.js +3 -3
- package/src/types.js +3 -3
|
@@ -5,14 +5,14 @@ export default class DropZone {
|
|
|
5
5
|
* @param {DragSelect} obj.DS
|
|
6
6
|
* @param {string} obj.id
|
|
7
7
|
* @param {DSElement} obj.element
|
|
8
|
-
* @param {DSInputElements} obj.droppables
|
|
8
|
+
* @param {DSInputElements} [obj.droppables]
|
|
9
9
|
* @ignore
|
|
10
10
|
*/
|
|
11
11
|
constructor({ DS, id, element, droppables }: {
|
|
12
12
|
DS: DragSelect;
|
|
13
13
|
id: string;
|
|
14
14
|
element: DSElement;
|
|
15
|
-
droppables
|
|
15
|
+
droppables?: DSInputElements;
|
|
16
16
|
});
|
|
17
17
|
/**
|
|
18
18
|
* @type {string}
|
|
@@ -25,7 +25,7 @@ export default class DropZone {
|
|
|
25
25
|
/**
|
|
26
26
|
* @type {DSElements}
|
|
27
27
|
*/
|
|
28
|
-
|
|
28
|
+
_droppables: DSElements;
|
|
29
29
|
/**
|
|
30
30
|
* @type {DOMRect}
|
|
31
31
|
* @private
|
|
@@ -53,6 +53,8 @@ export default class DropZone {
|
|
|
53
53
|
private _itemsInside;
|
|
54
54
|
DS: DragSelect;
|
|
55
55
|
Settings: Settings;
|
|
56
|
+
set droppables(arg: DSElements);
|
|
57
|
+
get droppables(): DSElements;
|
|
56
58
|
/**
|
|
57
59
|
* @param {'add'|'remove'} action
|
|
58
60
|
*/
|
package/dist/types.d.ts
CHANGED
|
@@ -180,9 +180,18 @@ type CallbackObject = {
|
|
|
180
180
|
};
|
|
181
181
|
type DSCallback = Function;
|
|
182
182
|
type DSInputDropZone = {
|
|
183
|
+
/**
|
|
184
|
+
* can be any unique identifier of type string
|
|
185
|
+
*/
|
|
183
186
|
id: string;
|
|
187
|
+
/**
|
|
188
|
+
* is the dropzone itself
|
|
189
|
+
*/
|
|
184
190
|
element: DSElement;
|
|
185
|
-
|
|
191
|
+
/**
|
|
192
|
+
* the elements that can be dropped into that zone. This is optional, by default it will be all selectables
|
|
193
|
+
*/
|
|
194
|
+
droppables?: DSInputElements;
|
|
186
195
|
};
|
|
187
196
|
type DSDropZone = {
|
|
188
197
|
id: string;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
import '../types'
|
|
3
3
|
|
|
4
|
-
import { removeModificationObservers } from '
|
|
4
|
+
import { removeModificationObservers } from '.'
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Removes event-listeners from the DOMNode
|
|
@@ -32,10 +32,7 @@ export default (nodes, cb) => {
|
|
|
32
32
|
/**
|
|
33
33
|
* Removes all observers
|
|
34
34
|
*/
|
|
35
|
-
const cleanup = () => removeModificationObservers(
|
|
36
|
-
observer,
|
|
37
|
-
callback,
|
|
38
|
-
)
|
|
35
|
+
const cleanup = () => removeModificationObservers(observer, callback)
|
|
39
36
|
|
|
40
37
|
return { observer, callback, cleanup }
|
|
41
38
|
}
|
package/src/methods/canScroll.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
import '../types'
|
|
3
|
-
import { getCurrentScroll } from '
|
|
3
|
+
import { getCurrentScroll } from '.'
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Checks whether the area can scroll or not
|
|
@@ -8,12 +8,12 @@ import { getCurrentScroll } from './'
|
|
|
8
8
|
* @return {boolean} scroll X/Y
|
|
9
9
|
*/
|
|
10
10
|
export default (area) => {
|
|
11
|
-
|
|
11
|
+
const scroll = getCurrentScroll(area)
|
|
12
12
|
if (scroll.x || scroll.y) return true
|
|
13
13
|
|
|
14
14
|
if (area instanceof Document) {
|
|
15
15
|
if (area.body) return !!(area.body.scrollTop = 1)
|
|
16
|
-
|
|
16
|
+
return !!(area.documentElement.scrollTop = 1)
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
return !!(area.scrollTop = 1)
|
|
@@ -22,15 +22,14 @@ const getComputedTranslatePositions = (element) => {
|
|
|
22
22
|
position.y = parseInt(values[13]) || 0
|
|
23
23
|
}
|
|
24
24
|
return position
|
|
25
|
-
} else {
|
|
26
|
-
const match = computed.transform.trim().match(/matrix\((.*?)\)/)
|
|
27
|
-
if (match && match.length) {
|
|
28
|
-
const values = match[1]?.split(',')
|
|
29
|
-
position.x = parseInt(values[4]) || 0
|
|
30
|
-
position.y = parseInt(values[5]) || 0
|
|
31
|
-
}
|
|
32
|
-
return position
|
|
33
25
|
}
|
|
26
|
+
const match = computed.transform.trim().match(/matrix\((.*?)\)/)
|
|
27
|
+
if (match && match.length) {
|
|
28
|
+
const values = match[1]?.split(',')
|
|
29
|
+
position.x = parseInt(values[4]) || 0
|
|
30
|
+
position.y = parseInt(values[5]) || 0
|
|
31
|
+
}
|
|
32
|
+
return position
|
|
34
33
|
}
|
|
35
34
|
|
|
36
35
|
/**
|
|
@@ -38,7 +37,7 @@ const getComputedTranslatePositions = (element) => {
|
|
|
38
37
|
* @return {Vect2}
|
|
39
38
|
*/
|
|
40
39
|
const getTranslatedPositions = (element) => {
|
|
41
|
-
const transform = element.style
|
|
40
|
+
const { transform } = element.style
|
|
42
41
|
|
|
43
42
|
if (!transform || transform.indexOf('translate') < 0)
|
|
44
43
|
return getComputedTranslatePositions(element)
|
|
@@ -68,7 +67,7 @@ const getTranslatedPositions = (element) => {
|
|
|
68
67
|
* @return {Vect2}
|
|
69
68
|
*/
|
|
70
69
|
const getTopLeftPosition = (element) => {
|
|
71
|
-
const style = element
|
|
70
|
+
const { style } = element
|
|
72
71
|
|
|
73
72
|
const position = {
|
|
74
73
|
x: parseInt(style.left) || 0,
|
|
@@ -96,5 +95,5 @@ const getTopLeftPosition = (element) => {
|
|
|
96
95
|
*/
|
|
97
96
|
export default (element, useTranslate) => {
|
|
98
97
|
if (useTranslate) return getTranslatedPositions(element)
|
|
99
|
-
|
|
98
|
+
return getTopLeftPosition(element)
|
|
100
99
|
}
|
|
@@ -8,7 +8,7 @@ import '../types'
|
|
|
8
8
|
* @param {DSArea} p.node
|
|
9
9
|
*/
|
|
10
10
|
export default ({ computedStyle, node }) => {
|
|
11
|
-
const position = computedStyle
|
|
11
|
+
const { position } = computedStyle
|
|
12
12
|
const isPositioned =
|
|
13
13
|
position === 'absolute' || position === 'relative' || position === 'fixed'
|
|
14
14
|
if (!(node instanceof Document) && !isPositioned)
|
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @param {string} key
|
|
3
|
-
* @param {string} type
|
|
2
|
+
* @param {string} key
|
|
3
|
+
* @param {string} type
|
|
4
4
|
* @param {*} fallback
|
|
5
5
|
* @returns {void}
|
|
6
6
|
*/
|
|
7
|
-
const wrongTypeWarn = (key, type, fallback) =>
|
|
8
|
-
console.warn(
|
|
7
|
+
const wrongTypeWarn = (key, type, fallback) =>
|
|
8
|
+
console.warn(
|
|
9
|
+
`[DragSelect] TypeIssue: setting "${key}" is not of type "${type}".`
|
|
10
|
+
)
|
|
9
11
|
|
|
10
12
|
/**
|
|
11
|
-
* @param {string} key
|
|
13
|
+
* @param {string} key
|
|
12
14
|
* @param {*} value
|
|
13
|
-
* @param {boolean} withFallback
|
|
14
|
-
* @param {*} fallback
|
|
15
|
+
* @param {boolean} withFallback
|
|
16
|
+
* @param {*} fallback
|
|
15
17
|
* @returns {object}
|
|
16
18
|
*/
|
|
17
19
|
const hydrateHelper = (key, value, withFallback, fallback) => {
|
|
18
20
|
// no value available
|
|
19
|
-
if (value === undefined)
|
|
20
|
-
return withFallback ? { [key]: fallback } : {}
|
|
21
|
+
if (value === undefined) return withFallback ? { [key]: fallback } : {}
|
|
21
22
|
// force unsetting of a value
|
|
22
23
|
if (value === null) return { [key]: null }
|
|
23
24
|
|
|
@@ -27,31 +28,35 @@ const hydrateHelper = (key, value, withFallback, fallback) => {
|
|
|
27
28
|
|
|
28
29
|
// TypeCheck [String]
|
|
29
30
|
const expectedString = typeof fallback === 'string'
|
|
30
|
-
if (expectedString)
|
|
31
|
+
if (expectedString)
|
|
32
|
+
isAvailable = typeof value === 'string' || value instanceof String
|
|
31
33
|
if (expectedString && !isAvailable) {
|
|
32
34
|
forceFallback = true
|
|
33
35
|
wrongTypeWarn(key, 'string', fallback)
|
|
34
36
|
}
|
|
35
37
|
|
|
36
38
|
// TypeCheck [Number]
|
|
37
|
-
const expectedNumber = !isNaN(fallback) && typeof fallback === 'number'
|
|
38
|
-
if (expectedNumber)
|
|
39
|
+
const expectedNumber = !Number.isNaN(fallback) && typeof fallback === 'number'
|
|
40
|
+
if (expectedNumber)
|
|
41
|
+
isAvailable = !Number.isNaN(value) && typeof value === 'number'
|
|
39
42
|
if (expectedNumber && !isAvailable) {
|
|
40
43
|
forceFallback = true
|
|
41
44
|
wrongTypeWarn(key, 'number', fallback)
|
|
42
45
|
}
|
|
43
46
|
|
|
44
47
|
// TypeCheck [Object]
|
|
45
|
-
const expectedObject =
|
|
46
|
-
|
|
48
|
+
const expectedObject =
|
|
49
|
+
Object.prototype.toString.call(fallback) === '[object Object]'
|
|
50
|
+
if (expectedObject)
|
|
51
|
+
isAvailable = Object.prototype.toString.call(value) === '[object Object]'
|
|
47
52
|
if (expectedObject && !isAvailable) {
|
|
48
53
|
forceFallback = true
|
|
49
54
|
wrongTypeWarn(key, 'object', fallback)
|
|
50
55
|
}
|
|
51
56
|
|
|
52
57
|
// TypeCheck [Boolean]
|
|
53
|
-
const expectedBoolean = typeof fallback ===
|
|
54
|
-
if (expectedBoolean) isAvailable = typeof value ===
|
|
58
|
+
const expectedBoolean = typeof fallback === 'boolean'
|
|
59
|
+
if (expectedBoolean) isAvailable = typeof value === 'boolean'
|
|
55
60
|
if (expectedBoolean && !isAvailable) {
|
|
56
61
|
forceFallback = true
|
|
57
62
|
wrongTypeWarn(key, 'boolean', fallback)
|
|
@@ -68,59 +73,183 @@ const hydrateHelper = (key, value, withFallback, fallback) => {
|
|
|
68
73
|
const isFallback = forceFallback || withFallback
|
|
69
74
|
|
|
70
75
|
// Special rule for [dragKeys]
|
|
71
|
-
if (key === 'dragKeys' && isAvailable)
|
|
72
|
-
|
|
76
|
+
if (key === 'dragKeys' && isAvailable)
|
|
77
|
+
return { [key]: Object.assign(fallback, value) }
|
|
78
|
+
if (key === 'dragKeys' && !isAvailable)
|
|
79
|
+
return isFallback ? { [key]: fallback } : {}
|
|
73
80
|
|
|
74
81
|
// Special rule for [dropZones]
|
|
75
|
-
if (
|
|
76
|
-
|
|
82
|
+
if (
|
|
83
|
+
key === 'dropZones' &&
|
|
84
|
+
isAvailable &&
|
|
85
|
+
new Set(value.map((v) => v.id)).size !== value.length
|
|
86
|
+
)
|
|
87
|
+
console.warn(
|
|
88
|
+
`[DragSelect] UniqueConstraintsIssue: setting "dropZones" contains duplicate ids.`
|
|
89
|
+
)
|
|
77
90
|
|
|
78
|
-
|
|
91
|
+
if (isAvailable) return { [key]: value }
|
|
92
|
+
if (isFallback) return { [key]: fallback }
|
|
93
|
+
return {}
|
|
79
94
|
}
|
|
80
95
|
|
|
81
96
|
/**
|
|
82
97
|
* This helper method creates the setting object,
|
|
83
98
|
* - if the settings provided are of wrong type, the fallback value will be used
|
|
84
99
|
* - - except for if settings are undefined or explicitly marked as "null"
|
|
85
|
-
* - if "withfallback" is true, it will return the object with all settings:
|
|
100
|
+
* - if "withfallback" is true, it will return the object with all settings:
|
|
86
101
|
* - - if not provided from the settings object (or wrong type), the fallback will be used
|
|
87
102
|
* (the fallback value for each setting is the last prop of the hydrateHelper)
|
|
88
|
-
* @param {Settings} settings
|
|
89
|
-
* @param {boolean} withFallback
|
|
103
|
+
* @param {Settings} settings
|
|
104
|
+
* @param {boolean} withFallback
|
|
90
105
|
*/
|
|
91
106
|
export default (settings, withFallback) => ({
|
|
92
107
|
...hydrateHelper('area', settings.area, withFallback, document),
|
|
93
108
|
...hydrateHelper('selectables', settings.selectables, withFallback, null),
|
|
94
|
-
...hydrateHelper(
|
|
95
|
-
|
|
109
|
+
...hydrateHelper(
|
|
110
|
+
'autoScrollSpeed',
|
|
111
|
+
settings.autoScrollSpeed,
|
|
112
|
+
withFallback,
|
|
113
|
+
5
|
|
114
|
+
),
|
|
115
|
+
...hydrateHelper(
|
|
116
|
+
'overflowTolerance',
|
|
117
|
+
settings.overflowTolerance,
|
|
118
|
+
withFallback,
|
|
119
|
+
{ x: 25, y: 25 }
|
|
120
|
+
),
|
|
96
121
|
...hydrateHelper('zoom', settings.zoom, withFallback, 1),
|
|
97
122
|
...hydrateHelper('customStyles', settings.customStyles, withFallback, false),
|
|
98
|
-
...hydrateHelper(
|
|
99
|
-
|
|
100
|
-
|
|
123
|
+
...hydrateHelper(
|
|
124
|
+
'multiSelectMode',
|
|
125
|
+
settings.multiSelectMode,
|
|
126
|
+
withFallback,
|
|
127
|
+
false
|
|
128
|
+
),
|
|
129
|
+
...hydrateHelper(
|
|
130
|
+
'multiSelectToggling',
|
|
131
|
+
settings.multiSelectToggling,
|
|
132
|
+
withFallback,
|
|
133
|
+
true
|
|
134
|
+
),
|
|
135
|
+
...hydrateHelper('multiSelectKeys', settings.multiSelectKeys, withFallback, [
|
|
136
|
+
'Control',
|
|
137
|
+
'Shift',
|
|
138
|
+
'Meta',
|
|
139
|
+
]),
|
|
101
140
|
...hydrateHelper('selector', settings.selector, withFallback, null),
|
|
102
|
-
...hydrateHelper(
|
|
141
|
+
...hydrateHelper(
|
|
142
|
+
'selectionThreshold',
|
|
143
|
+
settings.selectionThreshold,
|
|
144
|
+
withFallback,
|
|
145
|
+
0
|
|
146
|
+
),
|
|
103
147
|
...hydrateHelper('draggability', settings.draggability, withFallback, true),
|
|
104
148
|
...hydrateHelper('immediateDrag', settings.immediateDrag, withFallback, true),
|
|
105
149
|
...hydrateHelper('keyboardDrag', settings.keyboardDrag, withFallback, true),
|
|
106
|
-
...hydrateHelper('dragKeys', settings.dragKeys, withFallback, {
|
|
107
|
-
|
|
150
|
+
...hydrateHelper('dragKeys', settings.dragKeys, withFallback, {
|
|
151
|
+
up: ['ArrowUp'],
|
|
152
|
+
down: ['ArrowDown'],
|
|
153
|
+
left: ['ArrowLeft'],
|
|
154
|
+
right: ['ArrowRight'],
|
|
155
|
+
}),
|
|
156
|
+
...hydrateHelper(
|
|
157
|
+
'keyboardDragSpeed',
|
|
158
|
+
settings.keyboardDragSpeed,
|
|
159
|
+
withFallback,
|
|
160
|
+
10
|
|
161
|
+
),
|
|
108
162
|
...hydrateHelper('useTransform', settings.useTransform, withFallback, true),
|
|
109
|
-
...hydrateHelper(
|
|
163
|
+
...hydrateHelper(
|
|
164
|
+
'refreshMemoryRate',
|
|
165
|
+
settings.refreshMemoryRate,
|
|
166
|
+
withFallback,
|
|
167
|
+
80
|
|
168
|
+
),
|
|
110
169
|
...hydrateHelper('dropZones', settings.dropZones, withFallback, []),
|
|
111
|
-
...hydrateHelper(
|
|
112
|
-
|
|
113
|
-
|
|
170
|
+
...hydrateHelper(
|
|
171
|
+
'dropInsideThreshold',
|
|
172
|
+
settings.dropInsideThreshold,
|
|
173
|
+
withFallback,
|
|
174
|
+
1
|
|
175
|
+
),
|
|
176
|
+
...hydrateHelper(
|
|
177
|
+
'dropTargetThreshold',
|
|
178
|
+
settings.dropTargetThreshold,
|
|
179
|
+
withFallback,
|
|
180
|
+
0
|
|
181
|
+
),
|
|
182
|
+
...hydrateHelper(
|
|
183
|
+
'usePointerEvents',
|
|
184
|
+
settings.usePointerEvents,
|
|
185
|
+
withFallback,
|
|
186
|
+
false
|
|
187
|
+
),
|
|
114
188
|
...hydrateHelper('hoverClass', settings.hoverClass, withFallback, 'ds-hover'),
|
|
115
|
-
...hydrateHelper(
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
...hydrateHelper(
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
189
|
+
...hydrateHelper(
|
|
190
|
+
'selectableClass',
|
|
191
|
+
settings.selectableClass,
|
|
192
|
+
withFallback,
|
|
193
|
+
'ds-selectable'
|
|
194
|
+
),
|
|
195
|
+
...hydrateHelper(
|
|
196
|
+
'selectedClass',
|
|
197
|
+
settings.selectedClass,
|
|
198
|
+
withFallback,
|
|
199
|
+
'ds-selected'
|
|
200
|
+
),
|
|
201
|
+
...hydrateHelper(
|
|
202
|
+
'selectorClass',
|
|
203
|
+
settings.selectorClass,
|
|
204
|
+
withFallback,
|
|
205
|
+
'ds-selector'
|
|
206
|
+
),
|
|
207
|
+
...hydrateHelper(
|
|
208
|
+
'selectorAreaClass',
|
|
209
|
+
settings.selectorAreaClass,
|
|
210
|
+
withFallback,
|
|
211
|
+
'ds-selector-area'
|
|
212
|
+
),
|
|
213
|
+
...hydrateHelper(
|
|
214
|
+
'droppedTargetClass',
|
|
215
|
+
settings.droppedTargetClass,
|
|
216
|
+
withFallback,
|
|
217
|
+
'ds-dropped-target'
|
|
218
|
+
),
|
|
219
|
+
...hydrateHelper(
|
|
220
|
+
'droppedInsideClass',
|
|
221
|
+
settings.droppedInsideClass,
|
|
222
|
+
withFallback,
|
|
223
|
+
'ds-dropped-inside'
|
|
224
|
+
),
|
|
225
|
+
...hydrateHelper(
|
|
226
|
+
'droppableClass',
|
|
227
|
+
settings.droppableClass,
|
|
228
|
+
withFallback,
|
|
229
|
+
'ds-droppable'
|
|
230
|
+
),
|
|
231
|
+
...hydrateHelper(
|
|
232
|
+
'dropZoneClass',
|
|
233
|
+
settings.dropZoneClass,
|
|
234
|
+
withFallback,
|
|
235
|
+
'ds-dropzone'
|
|
236
|
+
),
|
|
237
|
+
...hydrateHelper(
|
|
238
|
+
'dropZoneReadyClass',
|
|
239
|
+
settings.dropZoneReadyClass,
|
|
240
|
+
withFallback,
|
|
241
|
+
'ds-dropzone-ready'
|
|
242
|
+
),
|
|
243
|
+
...hydrateHelper(
|
|
244
|
+
'dropZoneTargetClass',
|
|
245
|
+
settings.dropZoneTargetClass,
|
|
246
|
+
withFallback,
|
|
247
|
+
'ds-dropzone-target'
|
|
248
|
+
),
|
|
249
|
+
...hydrateHelper(
|
|
250
|
+
'dropZoneInsideClass',
|
|
251
|
+
settings.dropZoneInsideClass,
|
|
252
|
+
withFallback,
|
|
253
|
+
'ds-dropzone-inside'
|
|
254
|
+
),
|
|
126
255
|
})
|
|
@@ -24,24 +24,33 @@ import { DropZones, Interaction, SelectedSet } from '../modules'
|
|
|
24
24
|
* @param {SelectedSet} p.SelectedSet
|
|
25
25
|
* @param {DropZones} p.DropZones
|
|
26
26
|
*/
|
|
27
|
-
export default ({
|
|
27
|
+
export default ({
|
|
28
|
+
subscribe,
|
|
29
|
+
publish,
|
|
30
|
+
Interaction,
|
|
31
|
+
SelectedSet,
|
|
32
|
+
DropZones,
|
|
33
|
+
}) => {
|
|
28
34
|
const mapping = {
|
|
29
35
|
'Selected:added': [{ name: 'elementselect' }],
|
|
30
36
|
'Selected:removed': [{ name: 'elementunselect' }],
|
|
31
37
|
'Area:scroll': [{ name: 'autoscroll' }], // scroll_directions, scroll_multiplier
|
|
32
38
|
'Interaction:start': [{ name: 'dragstart' }], // event, isDraggingKeyboard
|
|
33
|
-
'Interaction:update': [
|
|
39
|
+
'Interaction:update': [
|
|
40
|
+
// event, isDraggingKeyboard
|
|
34
41
|
{ name: 'dragmove', condition: (data) => data.event },
|
|
35
|
-
],
|
|
36
|
-
'Interaction:end': [
|
|
42
|
+
],
|
|
43
|
+
'Interaction:end': [
|
|
44
|
+
// event, isDraggingKeyboard
|
|
37
45
|
{
|
|
38
|
-
name: 'callback',
|
|
46
|
+
name: 'callback',
|
|
47
|
+
extraData: () => {
|
|
39
48
|
const target = DropZones.getTarget()
|
|
40
49
|
return {
|
|
41
50
|
...(target ? { dropTarget: target.toObject() } : {}),
|
|
42
51
|
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
52
|
+
},
|
|
53
|
+
},
|
|
45
54
|
],
|
|
46
55
|
}
|
|
47
56
|
|
package/src/modules/Area.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 {
|
|
@@ -17,31 +17,37 @@ export default class Area {
|
|
|
17
17
|
* @private
|
|
18
18
|
*/
|
|
19
19
|
DS
|
|
20
|
+
|
|
20
21
|
/**
|
|
21
22
|
* @type {{cleanup:() => void}}
|
|
22
23
|
* @private
|
|
23
24
|
*/
|
|
24
25
|
_observers
|
|
26
|
+
|
|
25
27
|
/**
|
|
26
28
|
* @type {DSArea}
|
|
27
29
|
* @private
|
|
28
30
|
*/
|
|
29
31
|
_node
|
|
32
|
+
|
|
30
33
|
/**
|
|
31
34
|
* @type {DSArea[]}
|
|
32
35
|
* @private
|
|
33
36
|
*/
|
|
34
37
|
_parentNodes
|
|
38
|
+
|
|
35
39
|
/**
|
|
36
40
|
* @type {CSSStyleDeclaration}
|
|
37
41
|
* @private
|
|
38
42
|
* */
|
|
39
43
|
_computedStyle
|
|
44
|
+
|
|
40
45
|
/**
|
|
41
46
|
* @type {{top:number,bottom:number,left:number,right:number}}
|
|
42
47
|
* @private
|
|
43
48
|
* */
|
|
44
49
|
_computedBorder
|
|
50
|
+
|
|
45
51
|
/**
|
|
46
52
|
* @type {DSBoundingRect}
|
|
47
53
|
* @private
|
|
@@ -105,7 +111,7 @@ export default class Area {
|
|
|
105
111
|
this.reset()
|
|
106
112
|
}
|
|
107
113
|
|
|
108
|
-
|
|
114
|
+
/// ///////////////////////////////////////////////////////////////////////////////////
|
|
109
115
|
// Scroll
|
|
110
116
|
|
|
111
117
|
/**
|
|
@@ -123,7 +129,7 @@ export default class Area {
|
|
|
123
129
|
this.DS.PubSub.publish('Area:scroll', data)
|
|
124
130
|
}
|
|
125
131
|
|
|
126
|
-
|
|
132
|
+
/// ///////////////////////////////////////////////////////////////////////////////////
|
|
127
133
|
// Node Getters
|
|
128
134
|
|
|
129
135
|
get HTMLNode() {
|
|
@@ -154,7 +160,7 @@ export default class Area {
|
|
|
154
160
|
return (this._computedStyle = window.getComputedStyle(
|
|
155
161
|
this.HTMLNode.body || this.HTMLNode.documentElement
|
|
156
162
|
))
|
|
157
|
-
|
|
163
|
+
return (this._computedStyle = window.getComputedStyle(this.HTMLNode))
|
|
158
164
|
}
|
|
159
165
|
|
|
160
166
|
/**
|
|
@@ -163,7 +169,10 @@ export default class Area {
|
|
|
163
169
|
*/
|
|
164
170
|
get rect() {
|
|
165
171
|
if (this._rect) return this._rect
|
|
166
|
-
return (this._rect = getAreaRect(
|
|
172
|
+
return (this._rect = getAreaRect(
|
|
173
|
+
this.HTMLNode,
|
|
174
|
+
this.DS.stores.SettingsStore.s.zoom
|
|
175
|
+
))
|
|
167
176
|
}
|
|
168
177
|
|
|
169
178
|
get parentNodes() {
|
package/src/modules/Drag.js
CHANGED
|
@@ -10,21 +10,25 @@ export default class Drag {
|
|
|
10
10
|
* @private
|
|
11
11
|
*/
|
|
12
12
|
_prevCursorPos
|
|
13
|
+
|
|
13
14
|
/**
|
|
14
15
|
* @type {Vect2}
|
|
15
16
|
* @private
|
|
16
17
|
*/
|
|
17
18
|
_prevScrollPos
|
|
19
|
+
|
|
18
20
|
/**
|
|
19
21
|
* @type {DSElements}
|
|
20
22
|
* @private
|
|
21
23
|
*/
|
|
22
24
|
_elements = []
|
|
25
|
+
|
|
23
26
|
/**
|
|
24
27
|
* @type {DSDragKeys}
|
|
25
28
|
* @private
|
|
26
29
|
*/
|
|
27
30
|
_dragKeys
|
|
31
|
+
|
|
28
32
|
/**
|
|
29
33
|
* @type {string[]}
|
|
30
34
|
* @private
|
|
@@ -51,10 +55,18 @@ export default class Drag {
|
|
|
51
55
|
|
|
52
56
|
assignDragkeys = () => {
|
|
53
57
|
this._dragKeys = {
|
|
54
|
-
up: this.DS.stores.SettingsStore.s.dragKeys.up.map((k) =>
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
+
up: this.DS.stores.SettingsStore.s.dragKeys.up.map((k) =>
|
|
59
|
+
k.toLowerCase()
|
|
60
|
+
),
|
|
61
|
+
down: this.DS.stores.SettingsStore.s.dragKeys.down.map((k) =>
|
|
62
|
+
k.toLowerCase()
|
|
63
|
+
),
|
|
64
|
+
left: this.DS.stores.SettingsStore.s.dragKeys.left.map((k) =>
|
|
65
|
+
k.toLowerCase()
|
|
66
|
+
),
|
|
67
|
+
right: this.DS.stores.SettingsStore.s.dragKeys.right.map((k) =>
|
|
68
|
+
k.toLowerCase()
|
|
69
|
+
),
|
|
58
70
|
}
|
|
59
71
|
this._dragKeysFlat = [
|
|
60
72
|
...this._dragKeys.up,
|