dragselect 2.3.1 → 2.4.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.
- package/CHANGELOG.md +7 -0
- package/README.md +45 -23
- package/deploying.md +9 -4
- package/dist/DragSelect.d.ts +10 -18
- package/dist/DragSelect.es6m.js +412 -579
- package/dist/DragSelect.js +412 -579
- package/dist/ds.es6m.min.js +1 -1
- package/dist/ds.min.js +1 -1
- package/dist/methods/createSelectorAreaElement.d.ts +1 -1
- package/dist/methods/getOverflowEdges.d.ts +1 -1
- package/dist/methods/hydrateSettings.d.ts +3 -0
- package/dist/methods/index.d.ts +1 -0
- package/dist/modules/Area.d.ts +10 -15
- package/dist/modules/Drag.d.ts +4 -40
- package/dist/modules/Interaction.d.ts +2 -31
- package/dist/modules/SelectableSet.d.ts +6 -38
- package/dist/modules/SelectedSet.d.ts +6 -10
- package/dist/modules/Selection.d.ts +2 -14
- package/dist/modules/Selector.d.ts +5 -11
- package/dist/modules/SelectorArea.d.ts +4 -17
- package/dist/stores/KeyStore.d.ts +2 -14
- package/dist/stores/ScrollStore.d.ts +2 -9
- package/dist/stores/SettingsStore.d.ts +39 -0
- package/dist/stores/index.d.ts +1 -0
- package/dist/types.d.ts +13 -32
- package/package.json +3 -3
- package/src/DragSelect.js +22 -175
- package/src/methods/createSelectorAreaElement.js +1 -3
- package/src/methods/hydrateSettings.js +109 -0
- package/src/methods/index.js +1 -0
- package/src/modules/Area.js +24 -22
- package/src/modules/Drag.js +37 -71
- package/src/modules/Interaction.js +14 -45
- package/src/modules/SelectableSet.js +29 -54
- package/src/modules/SelectedSet.js +4 -13
- package/src/modules/Selection.js +6 -19
- package/src/modules/Selector.js +21 -8
- package/src/modules/SelectorArea.js +12 -17
- package/src/stores/KeyStore.js +11 -37
- package/src/stores/ScrollStore.js +17 -17
- package/src/stores/SettingsStore.js +67 -0
- package/src/stores/index.js +1 -0
- package/src/types.js +4 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# 2.4.0-1
|
|
2
|
+
|
|
3
|
+
- 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") })`.
|
|
4
|
+
- Remove deprecated keys `ctrlKey`, `shiftKey` and `metaKey`. Use `Control`, `Shift` and `Meta` respectively instead.
|
|
5
|
+
- Remove deprecated method `getCursorPositionDifference`. Calculate the difference on your own instead.
|
|
6
|
+
- Remove deprecated setting property callbacks. Use `DragSelect.subscribe("callback", (callbackObject) => {})` instead.
|
|
7
|
+
|
|
1
8
|
# 2.3.1
|
|
2
9
|
|
|
3
10
|
- Fix bug [#109](https://github.com/ThibaultJanBeyer/DragSelect/issues/109) where inner elements are ignored from normal drag behavior
|
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
[GitHub](https://github.com/ThibaultJanBeyer/DragSelect/) | [NPM](https://www.npmjs.com/package/dragselect) | [Project-Page](https://dragselect.com/)
|
|
11
11
|
|
|
12
|
-
[](https://travis-ci.com/ThibaultJanBeyer/DragSelect)   [](https://travis-ci.com/ThibaultJanBeyer/DragSelect)   [](https://github.com/ThibaultJanBeyer/DragSelect/blob/master/package.json) [](https://github.com/ThibaultJanBeyer/DragSelect/blob/master/CONTRIBUTING.md) [](https://github.com/sponsors/ThibaultJanBeyer)
|
|
13
13
|
|
|
14
14
|
# DragSelect 
|
|
15
15
|
easily add a selection algorithm to your application/website.
|
|
@@ -25,10 +25,11 @@ easily add a selection algorithm to your application/website.
|
|
|
25
25
|
- - [Simple](#simple)
|
|
26
26
|
- - [Within a scroll-able Area](#within-a-scroll-able-area)
|
|
27
27
|
- - [Extended](#extended)
|
|
28
|
-
- - [Mobile
|
|
28
|
+
- - [Mobile Touch usage](#mobiletouch-usage)
|
|
29
29
|
- - [Accessibility (a11y)](#accessibility-a11y)
|
|
30
30
|
- - [Use your own Drag And Drop](#use-your-own-drag-and-drop)
|
|
31
|
-
- [Constructor Properties](#constructor-properties)
|
|
31
|
+
- [Constructor Properties (Settings)](#constructor-properties-settings)
|
|
32
|
+
- - [Post initialization setting updates](#post-initialization-setting-updates)
|
|
32
33
|
- [Event Callbacks](#event-callbacks)
|
|
33
34
|
- - [Callback Object Keys](#callback-object-keys)
|
|
34
35
|
- [Methods](#methods)
|
|
@@ -40,7 +41,7 @@ easily add a selection algorithm to your application/website.
|
|
|
40
41
|
|
|
41
42
|
# Key-Features
|
|
42
43
|
|
|
43
|
-
- **No dependencies** [](https://github.com/ThibaultJanBeyer/DragSelect/blob/master/package.json)
|
|
44
45
|
- Hyper customizable
|
|
45
46
|
- Replicates operating system drag-selection in the browser
|
|
46
47
|
- Accessibility (a11y)
|
|
@@ -68,16 +69,23 @@ We use it currently in a professional rich interface application where we have a
|
|
|
68
69
|
|
|
69
70
|
# Supporters
|
|
70
71
|
|
|
71
|
-
Please donate to support the countless hours of hard work & support. Especially if your company makes money. Thank you :)
|
|
72
|
+
Please donate to support the countless hours of hard work & support. Especially if your company makes money, then there is no excuse. Thank you :)
|
|
72
73
|
|
|
73
|
-
|
|
74
|
+
If you're too poor or broke you can still support us with your time instead by [contributing to the code](https://github.com/ThibaultJanBeyer/DragSelect/blob/master/CONTRIBUTING.md)!
|
|
75
|
+
|
|
76
|
+
## Thanks to:
|
|
74
77
|
|
|
75
78
|
|  | [You?](https://github.com/sponsors/ThibaultJanBeyer) |
|
|
76
79
|
|--- |--- |
|
|
77
|
-
|[BrowserStack](https://www.browserstack.com/) is
|
|
78
|
-
BTC: [1LdweSpjgSeJC8XxX3swrohBMBLUzg6cmC](https://www.blockchain.com/btc/address/1LdweSpjgSeJC8XxX3swrohBMBLUzg6cmC) |
|
|
79
|
-
|
|
80
|
-
Other: [get in touch](mailto:thibault.beyer@gmail.com) |
|
|
80
|
+
|[BrowserStack](https://www.browserstack.com/) is a testing service which helps testing the tool on various browsers. They support this open source projects by providing us with a [free account](https://www.browserstack.com/open-source)! | Thank and support us by making a [Direct Donation to DragSelect](https://www.blockchain.com/btc/address/1LdweSpjgSeJC8XxX3swrohBMBLUzg6cmC) (via Bitcoin: `1LdweSpjgSeJC8XxX3swrohBMBLUzg6cmC`). Or sponsor via [GitHub Sponsors](https://github.com/sponsors/ThibaultJanBeyer) or [Get in touch](mailto:thibault.beyer@gmail.com). |
|
|
81
|
+
| Via BTC: | [1LdweSpjgSeJC8XxX3swrohBMBLUzg6cmC](https://www.blockchain.com/btc/address/1LdweSpjgSeJC8XxX3swrohBMBLUzg6cmC) (direct) |
|
|
82
|
+
| Via GitHub: | [GitHub Sponsors](https://github.com/sponsors/ThibaultJanBeyer) (monthly & one-time) |
|
|
83
|
+
| Other: | [get in touch](mailto:thibault.beyer@gmail.com) |
|
|
84
|
+
|
|
85
|
+
All donations are distributed with all project contributors proportionally to their involvement. We are grateful for any amount:
|
|
86
|
+
We have more than , imagine how much we'd have if everyone would have had donated only 1$ 🤩 (unfortunately this did not happen)
|
|
87
|
+
|
|
88
|
+
If you donate, we can display your logo here if you want, which will give you fame, fortune and help you recruit great talent and boosting your SEO.
|
|
81
89
|
|
|
82
90
|
# Installation
|
|
83
91
|
## NPM
|
|
@@ -146,26 +154,24 @@ All options are optional. You could also just initiate the Dragselect by `new Dr
|
|
|
146
154
|
Find all possible properties and methods in **[the docs](https://dragselect.com/DragSelect.html)**
|
|
147
155
|
|
|
148
156
|
```javascript
|
|
157
|
+
// if you add the function to a variable like this, you have access to all its functions
|
|
149
158
|
const ds = new DragSelect({
|
|
150
|
-
//
|
|
151
|
-
|
|
159
|
+
// all settings are optional and can be added later
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
// this is how you add/update settings after initialization
|
|
163
|
+
ds.setSettings({
|
|
164
|
+
// node/nodes that can be selected. By default will never add elements twice:
|
|
152
165
|
selectables: document.querySelectorAll('.selectable-nodes'),
|
|
153
166
|
// area in which you can drag. If not provided it will be the whole document & body/documentElement.
|
|
154
167
|
area: document.getElementById('area'),
|
|
155
168
|
// and many more, see "properties" section in the docs
|
|
156
|
-
})
|
|
157
|
-
|
|
158
|
-
// if you add the function to a variable like we did, you have access to all its functions:
|
|
169
|
+
})
|
|
159
170
|
|
|
160
171
|
// fired once the user releases the mouse. (items) = selected nodes:
|
|
161
172
|
ds.subscribe('callback', ({ items, event }) => {})
|
|
162
|
-
|
|
163
173
|
// returns all currently selected nodes:
|
|
164
174
|
ds.getSelection();
|
|
165
|
-
|
|
166
|
-
// adds elements that can be selected. Won't add elements twice:
|
|
167
|
-
ds.addSelectables(document.getElementsByClassName('selectable-node'));
|
|
168
|
-
|
|
169
175
|
// Teardown/stop the whole functionality:
|
|
170
176
|
ds.stop();
|
|
171
177
|
// Reset the functionality after a teardown:
|
|
@@ -253,9 +259,13 @@ ds.subscribe('predragmove', ({ isDragging, isDraggingKeyboard }) => {
|
|
|
253
259
|
}
|
|
254
260
|
```
|
|
255
261
|
|
|
256
|
-
# Constructor Properties:
|
|
262
|
+
# Constructor Properties (Settings):
|
|
257
263
|
|
|
258
|
-
*DragSelect is hyper customizable*. Note, all properties are optional. See **[the docs](https://dragselect.com/DragSelect.html)** for more info.
|
|
264
|
+
*DragSelect is hyper customizable*. Note, all properties are optional. See **[the docs](https://dragselect.com/DragSelect.html)** for more info.
|
|
265
|
+
|
|
266
|
+
Moreover any setting can also be updated or added after the initialization, see [post-initialization setting updates](#post-initialization-setting-updates).
|
|
267
|
+
|
|
268
|
+
Here is the full list:
|
|
259
269
|
|
|
260
270
|
| property | type | usage | default |
|
|
261
271
|
|--- |--- |--- |--- |
|
|
@@ -280,6 +290,18 @@ ds.subscribe('predragmove', ({ isDragging, isDraggingKeyboard }) => {
|
|
|
280
290
|
|selectorClass |string |The class name assigned to the square selector helper. |[see classes](#classes)
|
|
281
291
|
|selectableClass |string |The class name assigned to the elements that can be selected. |[see classes](#classes)
|
|
282
292
|
|
|
293
|
+
## Post-Initialization Setting-Updates
|
|
294
|
+
|
|
295
|
+
Any setting can be updated/added after initialization by using the `setSettings` method. Here is an example updating the `area` and the `selectables`:
|
|
296
|
+
|
|
297
|
+
```JavaScript
|
|
298
|
+
const ds = new DragSelect({})
|
|
299
|
+
ds.setSettings({
|
|
300
|
+
selectables: document.getElementsByClassName('selectable-nodes'),
|
|
301
|
+
area: document.getElementById('area')
|
|
302
|
+
})
|
|
303
|
+
```
|
|
304
|
+
|
|
283
305
|
# Event Callbacks
|
|
284
306
|
|
|
285
307
|
Event Callbacks are used like this:
|
|
@@ -359,7 +381,7 @@ Also check **[the docs](https://dragselect.com/DragSelect.html)** for more info.
|
|
|
359
381
|
|
|
360
382
|
Creating and maintaining useful tools is a lot of work.
|
|
361
383
|
So don’t forget to give this repository a star if you find it useful.
|
|
362
|
-
Star this repo, tell all your friends and start contributing and/or [donating 1$](https://
|
|
384
|
+
Star this repo, tell all your friends and start contributing and/or [donating 1$](https://github.com/sponsors/ThibaultJanBeyer) to keep it running. Thank you :)
|
|
363
385
|
|
|
364
386
|
[](https://thibaultjanbeyer.com/)
|
|
365
387
|
|
package/deploying.md
CHANGED
|
@@ -11,21 +11,26 @@ if you are a regular contributor, see [contibuting](CONTRIBUTING.md) and make a
|
|
|
11
11
|
|
|
12
12
|
## Deploying
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
Typically you don’t have to do this, since you most likely are not the project owner.
|
|
15
15
|
But if you are the project owner:
|
|
16
16
|
|
|
17
|
-
- Travis will take care of deployment to gh-pages when you push/merge to github (gh-pages will be build by
|
|
17
|
+
- Travis will take care of deployment to gh-pages when you push/merge to github (gh-pages will be build by Travis)
|
|
18
18
|
|
|
19
19
|
If this was successful, the next step is to publish the new version on `npm`:
|
|
20
20
|
|
|
21
21
|
```
|
|
22
22
|
npm version patch
|
|
23
23
|
npm run rollup
|
|
24
|
-
npm publish
|
|
25
24
|
```
|
|
26
25
|
Rollup is necessary for npm packages (since `dist` will be deployed to npm but is ignored in repo)
|
|
27
26
|
|
|
28
27
|
versions are either `patch` wich changes 0.0.x, `minor` wich changes 0.x.0 or `major` for x.0.0.
|
|
29
28
|
See [npm docs](https://docs.npmjs.com/getting-started/publishing-npm-packages)
|
|
30
29
|
|
|
31
|
-
|
|
30
|
+
Check if the `changelog` reflects the latest version
|
|
31
|
+
|
|
32
|
+
After that push again, just to make sure and then publish
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
npm publish
|
|
36
|
+
```
|
package/dist/DragSelect.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ declare class DragSelect {
|
|
|
5
5
|
* @constructor DragSelect
|
|
6
6
|
* @param {Settings} settings
|
|
7
7
|
*/
|
|
8
|
-
constructor(
|
|
8
|
+
constructor(settings: Settings);
|
|
9
9
|
/**
|
|
10
10
|
* used to skip all current Selection and dragNdrop functionality
|
|
11
11
|
* @type {boolean}
|
|
@@ -14,8 +14,9 @@ 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:
|
|
17
|
+
publish: (eventName: DSCallbackNames | DSCallbackNames[], data: CallbackObject) => void;
|
|
18
18
|
stores: {
|
|
19
|
+
SettingsStore: SettingsStore;
|
|
19
20
|
PointerStore: PointerStore;
|
|
20
21
|
ScrollStore: ScrollStore;
|
|
21
22
|
KeyStore: KeyStore;
|
|
@@ -28,14 +29,6 @@ declare class DragSelect {
|
|
|
28
29
|
Selection: Selection;
|
|
29
30
|
Drag: Drag;
|
|
30
31
|
Interaction: Interaction;
|
|
31
|
-
_callbacksTemp({ callback, onDragMove, onDragStart, onDragStartBegin, onElementSelect, onElementUnselect, }: {
|
|
32
|
-
callback: any;
|
|
33
|
-
onDragMove: any;
|
|
34
|
-
onDragStart: any;
|
|
35
|
-
onDragStartBegin: any;
|
|
36
|
-
onElementSelect: any;
|
|
37
|
-
onElementUnselect: any;
|
|
38
|
-
}): void;
|
|
39
32
|
/**
|
|
40
33
|
* Initializes the functionality. Automatically triggered when created.
|
|
41
34
|
* Also, reset the functionality after a teardown
|
|
@@ -151,21 +144,20 @@ declare class DragSelect {
|
|
|
151
144
|
* @return {boolean}
|
|
152
145
|
*/
|
|
153
146
|
isMultiSelect: (event?: DSEvent | KeyboardEvent) => boolean;
|
|
154
|
-
/**
|
|
155
|
-
* Utility method that returns the cursor position difference between start and now
|
|
156
|
-
* @param {boolean} [usePreviousCursorDifference] if true, it will output the cursor position difference between the previous selection and now
|
|
157
|
-
* @param {boolean} [useAreaPositions] if true, it will use cursor positions relative to the area
|
|
158
|
-
* @return {Vect2}
|
|
159
|
-
* @deprecated
|
|
160
|
-
*/
|
|
161
|
-
getCursorPositionDifference(usePreviousCursorDifference?: boolean, useAreaPositions?: boolean): Vect2;
|
|
162
147
|
/**
|
|
163
148
|
* Whether the user is currently drag n dropping elements (instead of selection)
|
|
164
149
|
* @return {boolean}
|
|
165
150
|
*/
|
|
166
151
|
isDragging: () => boolean;
|
|
152
|
+
/**
|
|
153
|
+
* Update any setting dynamically
|
|
154
|
+
* @param {Settings} settings
|
|
155
|
+
* @return {void}
|
|
156
|
+
*/
|
|
157
|
+
setSettings: (settings: Settings) => void;
|
|
167
158
|
}
|
|
168
159
|
import { PubSub } from "./modules";
|
|
160
|
+
import { SettingsStore } from "./stores";
|
|
169
161
|
import { PointerStore } from "./stores";
|
|
170
162
|
import { ScrollStore } from "./stores";
|
|
171
163
|
import { KeyStore } from "./stores";
|