dragselect 2.7.3 → 3.0.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 +100 -22
- package/LICENSE +690 -0
- package/README.md +2 -1
- package/jest-puppeteer.config.js +13 -3
- package/jest.config.js +5 -0
- package/package.json +40 -46
- package/rollup.config.mjs +82 -0
- package/src/DragSelect.ts +425 -0
- package/src/methods/addModificationObservers.ts +51 -0
- package/src/methods/canScroll.ts +19 -0
- package/src/methods/{createSelectorAreaElement.js → createSelectorAreaElement.ts} +1 -8
- package/src/methods/{createSelectorElement.js → createSelectorElement.ts} +1 -9
- package/src/methods/{debounce.js → debounce.ts} +5 -11
- package/src/methods/ensureArray.ts +13 -0
- package/src/methods/getAllParentNodes.ts +15 -0
- package/src/methods/{getAreaRect.js → getAreaRect.ts} +2 -6
- package/src/methods/getCurrentScroll.ts +14 -0
- package/src/methods/{documentScroll.js → getDocumentScroll.ts} +2 -2
- package/src/methods/{getOverflowEdges.js → getOverflowEdges.ts} +11 -11
- package/src/methods/getPointerPos.ts +9 -0
- package/src/methods/getSelectionRect.ts +29 -0
- package/src/methods/{getSelectorPosition.js → getSelectorPosition.ts} +11 -9
- package/src/methods/{getStylePosition.spec.js → getStylePosition.spec.ts} +9 -9
- package/src/methods/{getStylePosition.js → getStylePosition.ts} +5 -21
- package/src/methods/handleElementPositionAttribute.ts +15 -0
- package/src/methods/handleKeyboardDragPosDifference.ts +35 -0
- package/src/methods/handleSelection.ts +26 -0
- package/src/methods/{handleUnSelection.js → handleUnSelection.ts} +14 -14
- package/src/methods/{hydrateSettings.js → hydrateSettings.ts} +15 -26
- package/src/methods/isCollision.ts +66 -0
- package/src/methods/limitDirection.ts +36 -0
- package/src/methods/moveElement.ts +18 -0
- package/src/methods/{scrollElement.js → scrollElement.ts} +4 -10
- package/src/methods/{setStylePosition.js → setStylePosition.ts} +3 -11
- package/src/methods/subscriberAliases.ts +240 -0
- package/src/methods/updateElementStylePos.ts +7 -0
- package/src/methods/vect2.ts +34 -0
- package/src/modules/Area.ts +169 -0
- package/src/modules/Drag.ts +236 -0
- package/src/modules/{DropZone.js → DropZone.ts} +80 -119
- package/src/modules/DropZones.ts +151 -0
- package/src/modules/Interaction.ts +251 -0
- package/src/modules/PubSub.ts +111 -0
- package/src/modules/SelectableSet.ts +146 -0
- package/src/modules/SelectedSet.ts +92 -0
- package/src/modules/{Selection.js → Selection.ts} +59 -44
- package/src/modules/Selector.ts +81 -0
- package/src/modules/{SelectorArea.js → SelectorArea.ts} +58 -71
- package/src/stores/KeyStore.ts +92 -0
- package/src/stores/PointerStore.ts +194 -0
- package/src/stores/ScrollStore.ts +87 -0
- package/src/stores/SettingsStore.ts +88 -0
- package/src/types.ts +158 -0
- package/tsconfig.json +105 -0
- package/bower.json +0 -24
- package/dist/DragSelect.d.ts +0 -200
- package/dist/DragSelect.es6m.js +0 -3877
- package/dist/DragSelect.js +0 -3885
- package/dist/ds.es6m.min.js +0 -1
- package/dist/ds.min.js +0 -1
- package/dist/methods/addModificationObservers.d.ts +0 -11
- package/dist/methods/canScroll.d.ts +0 -3
- package/dist/methods/createSelectorAreaElement.d.ts +0 -3
- package/dist/methods/createSelectorElement.d.ts +0 -3
- package/dist/methods/debounce.d.ts +0 -3
- package/dist/methods/documentScroll.d.ts +0 -6
- package/dist/methods/getAllParentNodes.d.ts +0 -3
- package/dist/methods/getAreaRect.d.ts +0 -3
- package/dist/methods/getBoundingClientRect.d.ts +0 -4
- package/dist/methods/getCurrentScroll.d.ts +0 -3
- package/dist/methods/getOverflowEdges.d.ts +0 -7
- package/dist/methods/getPointerPos.d.ts +0 -5
- package/dist/methods/getSelectorPosition.d.ts +0 -12
- package/dist/methods/getStylePosition.d.ts +0 -3
- package/dist/methods/handleElementOverflow.d.ts +0 -10
- package/dist/methods/handleElementPositionAttribute.d.ts +0 -6
- package/dist/methods/handleKeyboardDragPosDifference.d.ts +0 -13
- package/dist/methods/handleSelection.d.ts +0 -9
- package/dist/methods/handleUnSelection.d.ts +0 -9
- package/dist/methods/hydrateSettings.d.ts +0 -3
- package/dist/methods/index.d.ts +0 -30
- package/dist/methods/isCollision.d.ts +0 -13
- package/dist/methods/moveElement.d.ts +0 -8
- package/dist/methods/removeModificationObservers.d.ts +0 -3
- package/dist/methods/scrollElement.d.ts +0 -3
- package/dist/methods/setStylePosition.d.ts +0 -3
- package/dist/methods/subscriberAliases.d.ts +0 -14
- package/dist/methods/toArray.d.ts +0 -3
- package/dist/methods/updateElementStylePos.d.ts +0 -8
- package/dist/methods/vect2.d.ts +0 -8
- package/dist/modules/Area.d.ts +0 -80
- package/dist/modules/Drag.d.ts +0 -71
- package/dist/modules/DropZone.d.ts +0 -90
- package/dist/modules/DropZones.d.ts +0 -73
- package/dist/modules/Interaction.d.ts +0 -51
- package/dist/modules/PubSub.d.ts +0 -37
- package/dist/modules/SelectableSet.d.ts +0 -40
- package/dist/modules/SelectedSet.d.ts +0 -29
- package/dist/modules/Selection.d.ts +0 -54
- package/dist/modules/Selector.d.ts +0 -29
- package/dist/modules/SelectorArea.d.ts +0 -58
- package/dist/modules/index.d.ts +0 -11
- package/dist/stores/KeyStore.d.ts +0 -34
- package/dist/stores/PointerStore.d.ts +0 -83
- package/dist/stores/ScrollStore.d.ts +0 -38
- package/dist/stores/SettingsStore.d.ts +0 -39
- package/dist/stores/index.d.ts +0 -5
- package/dist/types.d.ts +0 -276
- package/jsconfig.json +0 -13
- package/rollup.config.js +0 -101
- package/src/DragSelect.js +0 -384
- package/src/methods/addModificationObservers.js +0 -38
- package/src/methods/canScroll.js +0 -20
- package/src/methods/getAllParentNodes.js +0 -17
- package/src/methods/getBoundingClientRect.js +0 -33
- package/src/methods/getCurrentScroll.js +0 -15
- package/src/methods/getPointerPos.js +0 -13
- package/src/methods/handleElementOverflow.js +0 -65
- package/src/methods/handleElementPositionAttribute.js +0 -16
- package/src/methods/handleKeyboardDragPosDifference.js +0 -57
- package/src/methods/handleSelection.js +0 -26
- package/src/methods/index.js +0 -29
- package/src/methods/isCollision.js +0 -58
- package/src/methods/moveElement.js +0 -39
- package/src/methods/removeModificationObservers.js +0 -13
- package/src/methods/subscriberAliases.js +0 -72
- package/src/methods/toArray.js +0 -18
- package/src/methods/updateElementStylePos.js +0 -15
- package/src/methods/vect2.js +0 -54
- package/src/modules/Area.js +0 -183
- package/src/modules/Drag.js +0 -257
- package/src/modules/DropZones.js +0 -161
- package/src/modules/Interaction.js +0 -208
- package/src/modules/PubSub.js +0 -78
- package/src/modules/SelectableSet.js +0 -144
- package/src/modules/SelectedSet.js +0 -69
- package/src/modules/Selector.js +0 -90
- package/src/modules/index.js +0 -10
- package/src/stores/KeyStore.js +0 -83
- package/src/stores/PointerStore.js +0 -218
- package/src/stores/ScrollStore.js +0 -92
- package/src/stores/SettingsStore.js +0 -66
- package/src/stores/index.js +0 -4
- package/src/types.js +0 -100
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,66 @@
|
|
|
1
|
+
# 3.0.0
|
|
2
|
+
|
|
3
|
+
## Breaking Updates
|
|
4
|
+
|
|
5
|
+
### Moving the project to typescript
|
|
6
|
+
|
|
7
|
+
- Enable complex typings
|
|
8
|
+
- Removes typing issues from the past
|
|
9
|
+
|
|
10
|
+
### New license model
|
|
11
|
+
|
|
12
|
+
- Free to everything for non-commercial, paid for commercial projects
|
|
13
|
+
- Fees will be split with contributors
|
|
14
|
+
- Enables faster development cycles
|
|
15
|
+
- Keeps the lights on
|
|
16
|
+
- Attract talent to collaborate
|
|
17
|
+
|
|
18
|
+
### Callbacks Refactor
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
"elementselect" => "DS:select",
|
|
22
|
+
"elementunselect" => "DS:unselect",
|
|
23
|
+
"autoscroll" => "DS:scroll",
|
|
24
|
+
"dragstart" => "DS:start",
|
|
25
|
+
"dragmove" => "DS:update",
|
|
26
|
+
"callback" => "DS:end",
|
|
27
|
+
"preelementselect" => "DS:select:pre",
|
|
28
|
+
"preelementunselect" => "DS:unselect:pre",
|
|
29
|
+
"preautoscroll" => "DS:scroll:pre",
|
|
30
|
+
"predragstart" => "DS:start:pre",
|
|
31
|
+
"predragmove" => "DS:update:pre",
|
|
32
|
+
"precallback" => "DS:end:pre",
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
- New callbacks:
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
"DS:added:pre"
|
|
39
|
+
"DS:added"
|
|
40
|
+
"DS:removed:pre"
|
|
41
|
+
"DS:removed"
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Box-Dragging as new default
|
|
45
|
+
|
|
46
|
+
- This is the default expected behaviour, hence if should be the default
|
|
47
|
+
|
|
48
|
+
### Removing self-hosted versions
|
|
49
|
+
|
|
50
|
+
- This was just bad practice from ancient times
|
|
51
|
+
|
|
52
|
+
## Extras (non-breaking)
|
|
53
|
+
|
|
54
|
+
- Previous setting `dragAsBlock` is the default behavior.
|
|
55
|
+
- Add an over-writeable method to filter the elements that are supposed to be dragged `.filterDragElements` [Override](https://www.DragSelect.com/docs/API/Overrides) inspired by [#158](https://github.com/ThibaultJanBeyer/DragSelect/pull/158)
|
|
56
|
+
- Fix persistance of `removeSelectables` as of [148](https://github.com/ThibaultJanBeyer/DragSelect/issues/148) note however, that the items are still in the settings, thus will be re-added when manually running `.start()`
|
|
57
|
+
- Add keyboard drop-zoning solving [149](https://github.com/ThibaultJanBeyer/DragSelect/issues/149)
|
|
58
|
+
- Fix key stroke bug [#181](https://github.com/ThibaultJanBeyer/DragSelect/issues/181)
|
|
59
|
+
|
|
60
|
+
# 2.7.4
|
|
61
|
+
|
|
62
|
+
- Fix typing issues [#175](https://github.com/ThibaultJanBeyer/DragSelect/issues/175) thanks [@Ruslan207](https://github.com/Ruslan207)
|
|
63
|
+
|
|
1
64
|
# 2.7.2
|
|
2
65
|
|
|
3
66
|
- Add readme to npmjs
|
|
@@ -5,9 +68,9 @@
|
|
|
5
68
|
|
|
6
69
|
# 2.7.0
|
|
7
70
|
|
|
8
|
-
- Introduce blog-drag as alpha. It is supposed to fix dragging of multiple elements: dragging them as one block keeping aspect ratio positions on drag-scroll. Instead of moving elements individually. This was considered a bug. However as it is not fully tested it comes under a flag, please turn it on by setting `dragAsBlock: true`
|
|
71
|
+
- Introduce blog-drag as alpha. It is supposed to fix dragging of multiple elements: dragging them as one block keeping aspect ratio positions on drag-scroll. Instead of moving elements individually. This was considered a bug. However as it is not fully tested it comes under a flag, please turn it on by setting `dragAsBlock: true` and [report any issue you find here](https://github.com/ThibaultJanBeyer/DragSelect/issues). Thanks to [@rendertom](https://github.com/rendertom) for the addition [#162](https://github.com/ThibaultJanBeyer/DragSelect/pull/162).
|
|
9
72
|
|
|
10
|
-
|
|
73
|
+
_Note: this feature will be turned on by default in a future release once proper testing and all bugs are fixed_
|
|
11
74
|
|
|
12
75
|
# 2.6.1
|
|
13
76
|
|
|
@@ -17,7 +80,7 @@
|
|
|
17
80
|
|
|
18
81
|
- Introducing Overrides as a new concept to help advanced modification use-cases like [#150](https://github.com/ThibaultJanBeyer/DragSelect/issues/150) in collaboration with [@HollowMan6](https://github.com/HollowMan6)
|
|
19
82
|
- - See [Example use-case](https://dragselect.com/docs/guided-examples/Custom-Selection-Filter-Override) & [API for overrides](https://dragselect.com/docs/API/Overrides)
|
|
20
|
-
- Expose `filterSelected` in
|
|
83
|
+
- Expose `filterSelected` in `Selection` module
|
|
21
84
|
- Expose `isCollision` helper method
|
|
22
85
|
|
|
23
86
|
# 2.5.6
|
|
@@ -65,7 +128,7 @@
|
|
|
65
128
|
|
|
66
129
|
# 2.4.0-1
|
|
67
130
|
|
|
68
|
-
- Change all Properties dynamically
|
|
131
|
+
- Change all Properties dynamically _anytime_. Solves #111 and #95. Very helpful for async libraries like react. You can do so using the `setSettings` method, you can pass any settings in the object and they will be updated. Example: update the drag area at any time by running: `ds.setSettings({ area: document.getElementById("new-area") })`.
|
|
69
132
|
- Remove deprecated keys `ctrlKey`, `shiftKey` and `metaKey`. Use `Control`, `Shift` and `Meta` respectively instead.
|
|
70
133
|
- Remove deprecated method `getCursorPositionDifference`. Calculate the difference on your own instead.
|
|
71
134
|
- Remove deprecated setting property callbacks. Use `DragSelect.subscribe("callback", (callbackObject) => {})` instead.
|
|
@@ -80,7 +143,7 @@
|
|
|
80
143
|
- Fix bug with `pre` events not working properly.
|
|
81
144
|
- **Caution**:
|
|
82
145
|
- - 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.
|
|
83
|
-
- - Pre Events are now really triggered
|
|
146
|
+
- - Pre Events are now really triggered _before_ the whole action.
|
|
84
147
|
- Fixes issue [#110](https://github.com/ThibaultJanBeyer/DragSelect/issues/110) where teardown did not work properly
|
|
85
148
|
|
|
86
149
|
# 2.2.2
|
|
@@ -106,7 +169,7 @@ All these changes solve [#80](https://github.com/ThibaultJanBeyer/DragSelect/iss
|
|
|
106
169
|
# 2.1.2
|
|
107
170
|
|
|
108
171
|
- Fixes build error bug introduced by typings. Solves [#100](https://github.com/ThibaultJanBeyer/DragSelect/issues/100)
|
|
109
|
-
Issue: the JS-Docs files types.js was not included in d.ts files. Now rollup builds are force-including it.
|
|
172
|
+
Issue: the JS-Docs files types.js was not included in d.ts files. Now rollup builds are force-including it.
|
|
110
173
|
|
|
111
174
|
# 2.1.0-1
|
|
112
175
|
|
|
@@ -169,26 +232,38 @@ Changed the callbacks to follow a pub/sub pattern. They're not events you can su
|
|
|
169
232
|
Here is an example on what you'll have to change:
|
|
170
233
|
|
|
171
234
|
### Before
|
|
235
|
+
|
|
172
236
|
```javascript
|
|
173
237
|
const ds = new DragSelect({
|
|
174
|
-
callback: (items, event) => console.log(
|
|
175
|
-
onDragMove: (event) => console.log(
|
|
176
|
-
onDragStartBegin: (event) => console.log(
|
|
177
|
-
onDragStart: (event) => console.log(
|
|
178
|
-
onElementSelect: (item) => console.log(
|
|
179
|
-
onElementUnselect:
|
|
238
|
+
callback: (items, event) => console.log('my callback', items, event),
|
|
239
|
+
onDragMove: (event) => console.log('my callback', event),
|
|
240
|
+
onDragStartBegin: (event) => console.log('my callback', event),
|
|
241
|
+
onDragStart: (event) => console.log('my callback', event),
|
|
242
|
+
onElementSelect: (item) => console.log('my callback', item),
|
|
243
|
+
onElementUnselect: (item) => console.log('my callback', item),
|
|
180
244
|
})
|
|
181
245
|
```
|
|
182
246
|
|
|
183
247
|
### Now
|
|
248
|
+
|
|
184
249
|
```javascript
|
|
185
250
|
const ds = new DragSelect({})
|
|
186
|
-
ds.subscribe('callback', ({ items, item, event }) =>
|
|
187
|
-
|
|
251
|
+
ds.subscribe('callback', ({ items, item, event }) =>
|
|
252
|
+
console.log('my callback', items, event)
|
|
253
|
+
)
|
|
254
|
+
ds.subscribe('dragmove', ({ items, item, event }) =>
|
|
255
|
+
console.log('my callback', event)
|
|
256
|
+
)
|
|
188
257
|
// dragstartbegin was removed use dragstart instead
|
|
189
|
-
ds.subscribe('dragstart', ({ items, item, event }) =>
|
|
190
|
-
|
|
191
|
-
|
|
258
|
+
ds.subscribe('dragstart', ({ items, item, event }) =>
|
|
259
|
+
console.log('my callback', event)
|
|
260
|
+
)
|
|
261
|
+
ds.subscribe('elementselect', ({ items, item, event }) =>
|
|
262
|
+
console.log('my callback', item)
|
|
263
|
+
)
|
|
264
|
+
ds.subscribe('elementunselect', ({ items, item, event }) =>
|
|
265
|
+
console.log('my callback', item)
|
|
266
|
+
)
|
|
192
267
|
```
|
|
193
268
|
|
|
194
269
|
## Removed private and public methods (Breaking Change)
|
|
@@ -221,7 +296,7 @@ However, that means that the key names have changes. Following keys should be re
|
|
|
221
296
|
## Dropped IE Support
|
|
222
297
|
|
|
223
298
|
- Internet explorer is no longer supported. Following other big libraries. Dropping IE Support drastically reduces bundle size and improves maintainability of the project. Also following Microsoft itself, which [stopped support for IE all together](https://www.independent.co.uk/life-style/gadgets-and-tech/news/microsoft-internet-explorer-out-use-11-edge-a9676176.html). If you need IE support, please use a build tool that gives you IE Support with necessary polyfills for now and write support request stating your use-case. You can also consider using any versions prior 2.
|
|
224
|
-
We do support Edge and all other major browsers.
|
|
299
|
+
We do support Edge and all other major browsers.
|
|
225
300
|
|
|
226
301
|
## Impressive performance improvements
|
|
227
302
|
|
|
@@ -234,14 +309,16 @@ We compared the accumulated average execution times before and after the changes
|
|
|
234
309
|
- 11.36% faster by using an interaction pub/sub mechanism
|
|
235
310
|
- 15.86% faster by caching element positions (each update) & using more performant css class manipulations
|
|
236
311
|
- 28.36% faster by caching by bundling reflows and repaints
|
|
312
|
+
|
|
237
313
|
---
|
|
314
|
+
|
|
238
315
|
= 59,67% performance increase
|
|
239
316
|
|
|
240
317
|
# 1.15.1
|
|
241
318
|
|
|
242
319
|
- This is a preparation to some code-refactoring and bigger changes aimed for v2
|
|
243
320
|
- Preparation to deprecate `getScroll` and `getAreaRect`. They will both become internal methods. Unless you've valid reasons to keep exposing them.
|
|
244
|
-
- We will soon also prevent you from using most internal methods (those marked with `_` at the start). You'll not be able to extend them, nor override, nor use directly. Also here, unless you've valid reasons to keep them exposed.
|
|
321
|
+
- We will soon also prevent you from using most internal methods (those marked with `_` at the start). You'll not be able to extend them, nor override, nor use directly. Also here, unless you've valid reasons to keep them exposed.
|
|
245
322
|
|
|
246
323
|
# 1.15.0
|
|
247
324
|
|
|
@@ -302,6 +379,7 @@ We compared the accumulated average execution times before and after the changes
|
|
|
302
379
|
# 1.11.1
|
|
303
380
|
|
|
304
381
|
- Add em6 moduled files that have native `module export DragSelect` that can be used in for example:
|
|
382
|
+
|
|
305
383
|
```html
|
|
306
384
|
<script type="module">
|
|
307
385
|
import DragSelect from "path/to/DragSelect.es6m.js"
|
|
@@ -312,16 +390,16 @@ We compared the accumulated average execution times before and after the changes
|
|
|
312
390
|
# 1.11.0
|
|
313
391
|
|
|
314
392
|
- Moved the files from the `dist` folder to the `docs` folder to adhere to github pages standart
|
|
315
|
-
- Improve code stability by enforcing typechecks via JS-Docs, inspired by [truckjs](https://medium.com/@trukrs/type-safe-javascript-with-jsdoc-7a2a63209b76)
|
|
393
|
+
- Improve code stability by enforcing typechecks via JS-Docs, inspired by [truckjs](https://medium.com/@trukrs/type-safe-javascript-with-jsdoc-7a2a63209b76)
|
|
316
394
|
- Partial rewrite using native ES6 classes transpiling down to ES5 using babel.
|
|
317
|
-
|
|
395
|
+
_Note: first I refactored the code to TypeScript but then rolled back because it might limit the ability of external people to contribute due to the new language_
|
|
318
396
|
- Improve documentation by autogenerating it with JS-Docs
|
|
319
397
|
|
|
320
398
|
# 1.10.0
|
|
321
399
|
|
|
322
400
|
- Add touch device support (i.e. Mobile Phones)
|
|
323
401
|
- Preparations for modern code. I.e. ES6:
|
|
324
|
-
Usind Babel to transpile downwards to ES5. This should not result in any changes on your side.
|
|
402
|
+
Usind Babel to transpile downwards to ES5. This should not result in any changes on your side.
|
|
325
403
|
|
|
326
404
|
# 1.9.1
|
|
327
405
|
|