dragselect 2.1.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 +29 -1
- package/CODE_OF_CONDUCT.md +128 -0
- package/README.md +88 -15
- package/dist/DragSelect.d.ts +17 -4
- package/dist/DragSelect.es6m.js +466 -194
- package/dist/DragSelect.js +466 -194
- package/dist/ds.es6m.min.js +1 -1
- package/dist/ds.min.js +1 -1
- package/dist/methods/index.d.ts +1 -0
- package/dist/methods/subscriberAliases.d.ts +12 -0
- package/dist/modules/Area.d.ts +15 -9
- package/dist/modules/Drag.d.ts +13 -5
- package/dist/modules/Interaction.d.ts +11 -4
- package/dist/modules/PubSub.d.ts +10 -3
- package/dist/modules/SelectorArea.d.ts +9 -1
- package/dist/stores/PointerStore.d.ts +2 -0
- package/dist/types.d.ts +15 -2
- package/package.json +12 -9
- package/src/DragSelect.js +43 -53
- package/src/methods/index.js +1 -0
- package/src/methods/subscriberAliases.js +52 -0
- package/src/modules/Area.js +29 -17
- package/src/modules/Drag.js +37 -15
- package/src/modules/Interaction.js +33 -13
- package/src/modules/PubSub.js +35 -4
- package/src/modules/SelectableSet.js +2 -2
- package/src/modules/SelectedSet.js +12 -8
- package/src/modules/Selection.js +2 -1
- package/src/modules/Selector.js +1 -1
- package/src/modules/SelectorArea.js +30 -8
- package/src/stores/KeyStore.js +2 -0
- package/src/stores/PointerStore.js +9 -8
- package/src/types.js +6 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
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
|
+
|
|
9
|
+
# 2.2.2
|
|
10
|
+
|
|
11
|
+
- Add a check whether the initial click was issued within the area
|
|
12
|
+
- Fixes [#105](https://github.com/ThibaultJanBeyer/DragSelect/issues/105)
|
|
13
|
+
|
|
14
|
+
# 2.2.1
|
|
15
|
+
|
|
16
|
+
- removes dom-nodes when using .stop
|
|
17
|
+
- fixes [#94](https://github.com/ThibaultJanBeyer/DragSelect/issues/94)
|
|
18
|
+
|
|
19
|
+
# 2.2.0
|
|
20
|
+
|
|
21
|
+
- Add new possible callback value: `isDraggingKeyboard`
|
|
22
|
+
- Add new settings prop `keyboardDrag: false`
|
|
23
|
+
- Add `pre` events for all events. i.e. `predragstart`, `predragmove`, etc.
|
|
24
|
+
- Add information on 3rd party integration to the README.
|
|
25
|
+
- Re-add `break` functionality to give maximum flexibility on 3rd party integration
|
|
26
|
+
|
|
27
|
+
All these changes solve [#80](https://github.com/ThibaultJanBeyer/DragSelect/issues/80)
|
|
28
|
+
|
|
1
29
|
# 2.1.2
|
|
2
30
|
|
|
3
31
|
- Fixes build error bug introduced by typings. Solves [#100](https://github.com/ThibaultJanBeyer/DragSelect/issues/100)
|
|
@@ -92,7 +120,7 @@ Based on the changes, some methods did not make sense anymore. So we cleaned the
|
|
|
92
120
|
|
|
93
121
|
Public methods that were removed:
|
|
94
122
|
|
|
95
|
-
- `.break`
|
|
123
|
+
- `.break` (use `.stop` and `.start` instead) (back in v2.2.0)
|
|
96
124
|
- `.getCursorPos`
|
|
97
125
|
- `.getScroll`
|
|
98
126
|
- `.getAreaRect`
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our
|
|
6
|
+
community a harassment-free experience for everyone, regardless of age, body
|
|
7
|
+
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
|
8
|
+
identity and expression, level of experience, education, socio-economic status,
|
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity
|
|
10
|
+
and orientation.
|
|
11
|
+
|
|
12
|
+
We pledge to act and interact in ways that contribute to an open, welcoming,
|
|
13
|
+
diverse, inclusive, and healthy community.
|
|
14
|
+
|
|
15
|
+
## Our Standards
|
|
16
|
+
|
|
17
|
+
Examples of behavior that contributes to a positive environment for our
|
|
18
|
+
community include:
|
|
19
|
+
|
|
20
|
+
* Demonstrating empathy and kindness toward other people
|
|
21
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
|
22
|
+
* Giving and gracefully accepting constructive feedback
|
|
23
|
+
* Accepting responsibility and apologizing to those affected by our mistakes,
|
|
24
|
+
and learning from the experience
|
|
25
|
+
* Focusing on what is best not just for us as individuals, but for the
|
|
26
|
+
overall community
|
|
27
|
+
|
|
28
|
+
Examples of unacceptable behavior include:
|
|
29
|
+
|
|
30
|
+
* The use of sexualized language or imagery, and sexual attention or
|
|
31
|
+
advances of any kind
|
|
32
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
|
33
|
+
* Public or private harassment
|
|
34
|
+
* Publishing others' private information, such as a physical or email
|
|
35
|
+
address, without their explicit permission
|
|
36
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
37
|
+
professional setting
|
|
38
|
+
|
|
39
|
+
## Enforcement Responsibilities
|
|
40
|
+
|
|
41
|
+
Community leaders are responsible for clarifying and enforcing our standards of
|
|
42
|
+
acceptable behavior and will take appropriate and fair corrective action in
|
|
43
|
+
response to any behavior that they deem inappropriate, threatening, offensive,
|
|
44
|
+
or harmful.
|
|
45
|
+
|
|
46
|
+
Community leaders have the right and responsibility to remove, edit, or reject
|
|
47
|
+
comments, commits, code, wiki edits, issues, and other contributions that are
|
|
48
|
+
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
|
49
|
+
decisions when appropriate.
|
|
50
|
+
|
|
51
|
+
## Scope
|
|
52
|
+
|
|
53
|
+
This Code of Conduct applies within all community spaces, and also applies when
|
|
54
|
+
an individual is officially representing the community in public spaces.
|
|
55
|
+
Examples of representing our community include using an official e-mail address,
|
|
56
|
+
posting via an official social media account, or acting as an appointed
|
|
57
|
+
representative at an online or offline event.
|
|
58
|
+
|
|
59
|
+
## Enforcement
|
|
60
|
+
|
|
61
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
62
|
+
reported to the community leaders responsible for enforcement at
|
|
63
|
+
https://github.com/ThibaultJanBeyer/DragSelect/discussions.
|
|
64
|
+
All complaints will be reviewed and investigated promptly and fairly.
|
|
65
|
+
|
|
66
|
+
All community leaders are obligated to respect the privacy and security of the
|
|
67
|
+
reporter of any incident.
|
|
68
|
+
|
|
69
|
+
## Enforcement Guidelines
|
|
70
|
+
|
|
71
|
+
Community leaders will follow these Community Impact Guidelines in determining
|
|
72
|
+
the consequences for any action they deem in violation of this Code of Conduct:
|
|
73
|
+
|
|
74
|
+
### 1. Correction
|
|
75
|
+
|
|
76
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed
|
|
77
|
+
unprofessional or unwelcome in the community.
|
|
78
|
+
|
|
79
|
+
**Consequence**: A private, written warning from community leaders, providing
|
|
80
|
+
clarity around the nature of the violation and an explanation of why the
|
|
81
|
+
behavior was inappropriate. A public apology may be requested.
|
|
82
|
+
|
|
83
|
+
### 2. Warning
|
|
84
|
+
|
|
85
|
+
**Community Impact**: A violation through a single incident or series
|
|
86
|
+
of actions.
|
|
87
|
+
|
|
88
|
+
**Consequence**: A warning with consequences for continued behavior. No
|
|
89
|
+
interaction with the people involved, including unsolicited interaction with
|
|
90
|
+
those enforcing the Code of Conduct, for a specified period of time. This
|
|
91
|
+
includes avoiding interactions in community spaces as well as external channels
|
|
92
|
+
like social media. Violating these terms may lead to a temporary or
|
|
93
|
+
permanent ban.
|
|
94
|
+
|
|
95
|
+
### 3. Temporary Ban
|
|
96
|
+
|
|
97
|
+
**Community Impact**: A serious violation of community standards, including
|
|
98
|
+
sustained inappropriate behavior.
|
|
99
|
+
|
|
100
|
+
**Consequence**: A temporary ban from any sort of interaction or public
|
|
101
|
+
communication with the community for a specified period of time. No public or
|
|
102
|
+
private interaction with the people involved, including unsolicited interaction
|
|
103
|
+
with those enforcing the Code of Conduct, is allowed during this period.
|
|
104
|
+
Violating these terms may lead to a permanent ban.
|
|
105
|
+
|
|
106
|
+
### 4. Permanent Ban
|
|
107
|
+
|
|
108
|
+
**Community Impact**: Demonstrating a pattern of violation of community
|
|
109
|
+
standards, including sustained inappropriate behavior, harassment of an
|
|
110
|
+
individual, or aggression toward or disparagement of classes of individuals.
|
|
111
|
+
|
|
112
|
+
**Consequence**: A permanent ban from any sort of public interaction within
|
|
113
|
+
the community.
|
|
114
|
+
|
|
115
|
+
## Attribution
|
|
116
|
+
|
|
117
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
|
118
|
+
version 2.0, available at
|
|
119
|
+
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
|
120
|
+
|
|
121
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct
|
|
122
|
+
enforcement ladder](https://github.com/mozilla/diversity).
|
|
123
|
+
|
|
124
|
+
[homepage]: https://www.contributor-covenant.org
|
|
125
|
+
|
|
126
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
|
127
|
+
https://www.contributor-covenant.org/faq. Translations are available at
|
|
128
|
+
https://www.contributor-covenant.org/translations.
|
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://david-dm.org/ThibaultJanBeyer/DragSelect)
|
|
13
13
|
|
|
14
14
|
# DragSelect 
|
|
15
15
|
easily add a selection algorithm to your application/website.
|
|
@@ -22,8 +22,15 @@ easily add a selection algorithm to your application/website.
|
|
|
22
22
|
- [Supporters](#supporters)
|
|
23
23
|
- [Installation](#installation)
|
|
24
24
|
- [Usage](#usage)
|
|
25
|
+
- - [Simple](#simple)
|
|
26
|
+
- - [Within a scroll-able Area](#within-a-scroll-able-area)
|
|
27
|
+
- - [Extended](#extended)
|
|
28
|
+
- - [Mobile/Touch usage](#mobile/touch-usage)
|
|
29
|
+
- - [Accessibility (a11y)](#accessibility-a11y)
|
|
30
|
+
- - [Use your own Drag And Drop](#use-your-own-drag-and-drop)
|
|
25
31
|
- [Constructor Properties](#constructor-properties)
|
|
26
32
|
- [Event Callbacks](#event-callbacks)
|
|
33
|
+
- - [Callback Object Keys](#callback-object-keys)
|
|
27
34
|
- [Methods](#methods)
|
|
28
35
|
- [Classes](#classes)
|
|
29
36
|
|
|
@@ -43,7 +50,7 @@ easily add a selection algorithm to your application/website.
|
|
|
43
50
|
- Choose which elements can be selected
|
|
44
51
|
- Supports all major browsers
|
|
45
52
|
- Selected elements can be dragged and dropped
|
|
46
|
-
- Lightweight, only 
|
|
47
54
|
- Popular:  on npm
|
|
48
55
|
- DragSelect was written with Performance in mind (can easily select >15.000 Elements)
|
|
49
56
|
- Supports SVG
|
|
@@ -61,11 +68,16 @@ We use it currently in a professional rich interface application where we have a
|
|
|
61
68
|
|
|
62
69
|
# Supporters
|
|
63
70
|
|
|
71
|
+
Please donate to support the countless hours of hard work & support. Especially if your company makes money. Thank you :)
|
|
72
|
+
|
|
64
73
|
Thanks to:
|
|
65
74
|
|
|
66
75
|
|  | [You?](https://paypal.me/pools/c/8gF2a5szCP) |
|
|
67
76
|
|--- |--- |
|
|
68
|
-
|[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) |
|
|
69
81
|
|
|
70
82
|
# Installation
|
|
71
83
|
## NPM
|
|
@@ -185,6 +197,62 @@ Obviously, keyboard users won’t get the full visual experience but it works si
|
|
|
185
197
|
|
|
186
198
|
<p data-height="350" data-theme-id="0" data-slug-hash="prpwYG" data-default-tab="html,result" data-user="ThibaultJanBeyer" data-embed-version="2" data-pen-title="DragSelect" class="codepen">See the Pen <a href="https://codepen.io/ThibaultJanBeyer/pen/prpwYG/">DragSelect</a> on CodePen.</p>
|
|
187
199
|
|
|
200
|
+
## Use your own Drag And Drop
|
|
201
|
+
|
|
202
|
+
### Using another plugin/tool (3rd party)
|
|
203
|
+
|
|
204
|
+
DragSelect comes with a build-in dragNdrop. Before, `.break` was used for this. But with v2, using your own is now very simple: listen to any DragSelect event to `.stop` it. Then, re-`.start` it after your custom dragNdrop was performed. Check for `isDragging`, which indicates when the users drags (moving the element) and `isDraggingKeyboard` for the keyboard drag events. I.e. use `predragstart`.
|
|
205
|
+
|
|
206
|
+
#### Example
|
|
207
|
+
|
|
208
|
+
```JavaScript
|
|
209
|
+
const ds = new DragSelect({
|
|
210
|
+
keyboardDragSpeed: 0,
|
|
211
|
+
// keyboardDrag: false, // if your library can not handle keyboard dragging
|
|
212
|
+
/* …other settings… */
|
|
213
|
+
})
|
|
214
|
+
const myCustomDrag = new MyCustomDrag({/* …your settings… */})
|
|
215
|
+
|
|
216
|
+
ds.subscribe('predragstart', ({ isDragging, isDraggingKeyboard }) =>
|
|
217
|
+
isDragging && ds.stop(false, false))
|
|
218
|
+
myCustomDrag.subscribe('finished', () => ds.start())
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
Disabling then re-enabling directly can also work (i.e. when your library has no callback):
|
|
222
|
+
|
|
223
|
+
```JavaScript
|
|
224
|
+
ds.subscribe('predragstart', ({ isDragging, isDraggingKeyboard }) => {
|
|
225
|
+
if(isDragging) {
|
|
226
|
+
ds.stop(false, false)
|
|
227
|
+
setTimeout(ds.start)
|
|
228
|
+
}
|
|
229
|
+
})
|
|
230
|
+
```
|
|
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
|
+
|
|
234
|
+
### Writing a fully custom solution
|
|
235
|
+
|
|
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 :)
|
|
237
|
+
|
|
238
|
+
This utility to override DragSelects internal functionality allows you to write it all yourself: You can write your own drag and drop but you can also write your own selection:
|
|
239
|
+
|
|
240
|
+
#### Example
|
|
241
|
+
|
|
242
|
+
> /!\ only use break when you know what you're doing. Support is limited /!\
|
|
243
|
+
|
|
244
|
+
```JavaScript
|
|
245
|
+
ds.subscribe('predragmove', ({ isDragging, isDraggingKeyboard }) => {
|
|
246
|
+
if(isDragging || isDraggingKeyboard) {
|
|
247
|
+
ds.break()
|
|
248
|
+
/* your custom logic for drag handling here. */
|
|
249
|
+
} else {
|
|
250
|
+
ds.break()
|
|
251
|
+
/* your custom logic for selection handling here. */
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
```
|
|
255
|
+
|
|
188
256
|
# Constructor Properties:
|
|
189
257
|
|
|
190
258
|
*DragSelect is hyper customizable*. Note, all properties are optional. See **[the docs](https://dragselect.com/DragSelect.html)** for more info. Here is the full list:
|
|
@@ -203,6 +271,7 @@ Obviously, keyboard users won’t get the full visual experience but it works si
|
|
|
203
271
|
|selector |single DOM element (node) |The square that will be used to draw the selection. | Auto-created HTML Element
|
|
204
272
|
|draggability |boolean |When a user is dragging on an already selected element, the selection is dragged. |`true`
|
|
205
273
|
|immediateDrag |boolean |Whether a selectable element is draggable before being selected or needs to be selected first |`true`
|
|
274
|
+
|keyboardDrag |boolean |Whether or not the user can drag with the keyboard (Accessibility). |`true`
|
|
206
275
|
|dragKeys |{ up:string[], down:string[], left:string[], righ:string[] } |The keys available to drag element using the keyboard. Any key value is possible ([see MDN docs](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key)). |`{ up:['ArrowUp'], down: ['ArrowDown'], left: ['ArrowLeft'], righ: ['ArrowRight'] }`
|
|
207
276
|
|keyboardDragSpeed |number |The speed at which elements are dragged using the keyboard. In pixels per keyDown. |`10`
|
|
208
277
|
|useTransform |boolean |Whether to use the more performant hardware accelerated css transforms when dragging instead of the top/left positions. |`true`
|
|
@@ -223,25 +292,28 @@ ds.subscribe('<event_name>', (callback_object) => {})
|
|
|
223
292
|
|
|
224
293
|
|event_name |callback_object |description |
|
|
225
294
|
|--- |--- |---
|
|
226
|
-
|callback |`{ items, event, isDragging }` |Fired after the selection (i.e. on mouse-up).
|
|
227
|
-
|dragstart |`{ items, event, isDragging }` |Fired when the selection starts (i.e. on mouse-down).
|
|
228
|
-
|dragmove |`{ items, event, isDragging }` |Fired when the mouse moves while dragging (i.e. on mouse-move).
|
|
229
|
-
|autoscroll |`{ items, scroll_directions, scroll_multiplier,
|
|
230
|
-
|elementselect |`{ items, item }` |Fired when an element is added to the selection.
|
|
231
|
-
|elementunselect |`{ items, item }` |Fired when an element is removed from the selection.
|
|
295
|
+
|callback |`{ items, event, isDragging, … }` |Fired after the selection (i.e. on mouse-up).
|
|
296
|
+
|dragstart |`{ items, event, isDragging, isDraggingKeyboard, … }` |Fired when the selection starts (i.e. on mouse-down).
|
|
297
|
+
|dragmove |`{ items, event, isDragging, isDraggingKeyboard, … }` |Fired when the mouse moves while dragging (i.e. on mouse-move).
|
|
298
|
+
|autoscroll |`{ items, isDragging, scroll_directions, scroll_multiplier, … }` |Fired when the area is auto-scrolled (i.e. cursor on a corner of the area).
|
|
299
|
+
|elementselect |`{ items, item, … }` |Fired when an element is added to the selection.
|
|
300
|
+
|elementunselect |`{ items, item, … }` |Fired when an element is removed from the selection.
|
|
301
|
+
|
|
302
|
+
> Note: all your callbacks subscribers will run happen after the internal code ran. If you want to run something before everything else, use the `pre` prefix. I.e. `predragstart` is an event that runs before any internal start logic.
|
|
232
303
|
|
|
233
304
|
### Callback Object Keys
|
|
234
305
|
|
|
235
306
|
|callback_object_keys |type |description |
|
|
236
307
|
|--- |--- |---
|
|
237
|
-
|
|
|
238
|
-
|
|
|
308
|
+
|event |`MouseEvent\|TouchEvent\|KeyboardEvent` |The native HTML Event, depending on the situational context
|
|
309
|
+
|items |`Array.<HTMLElement\|SVGElement\|*>` |Current selected elements
|
|
239
310
|
|isDragging |`boolean` |If true, the user is dragging the selected elements, if false the user is drawing a selection
|
|
240
|
-
|
|
|
311
|
+
|isDraggingKeyboard |`boolean` |If true, the user is dragging the selected elements with the keyboard
|
|
312
|
+
|scroll_directions |`Array.<'top'\|'bottom'\|'left'\|'right'\|undefined>` |The direction in which the event is happening (i.e. scroll direction)
|
|
241
313
|
|scroll_multiplier |`number` |Speed
|
|
242
|
-
|item |`HTMLElement
|
|
314
|
+
|item |`HTMLElement\|SVGElement\|*` |The single element currently being interacted with if any
|
|
243
315
|
|
|
244
|
-
|
|
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
|
|
245
317
|
|
|
246
318
|
# Methods:
|
|
247
319
|
When the function is saved into a variable `var foo = new DragSelect()` you have access to all its inner functions.
|
|
@@ -270,6 +342,7 @@ Also check **[the docs](https://dragselect.com/DragSelect.html)** for more info.
|
|
|
270
342
|
|getCursorPositionDifference |Boolean (usePreviousCursorDifference) |Returns object with the x, y difference between the initial and the last cursor position. If the argument is set to true, it will instead return the x, y difference to the previous coordinates |
|
|
271
343
|
|isMultiSelect |\[event:KeyboardEvent|MouseEvent|TouchEvent\] (optional) |Whether the multi-select key is currently pressed
|
|
272
344
|
|isDragging |/ |Whether the user is currently drag n dropping elements (instead of selection)
|
|
345
|
+
|break |/ |Utility to override DragSelect internal functionality. Read [docs](#writing-a-fully-custom-solution) for more info.
|
|
273
346
|
|
|
274
347
|
# Classes
|
|
275
348
|
| name | trigger |
|
|
@@ -288,7 +361,7 @@ Creating and maintaining useful tools is a lot of work.
|
|
|
288
361
|
So don’t forget to give this repository a star if you find it useful.
|
|
289
362
|
Star this repo, tell all your friends and start contributing and/or [donating 1$](https://paypal.me/pools/c/8gF2a5szCP) to keep it running. Thank you :)
|
|
290
363
|
|
|
291
|
-
[](
|
|
364
|
+
[](https://thibaultjanbeyer.com/)
|
|
292
365
|
|
|
293
366
|
|
|
294
367
|
<script async src="https://production-assets.codepen.io/assets/embed/ei.js"></script>
|
package/dist/DragSelect.d.ts
CHANGED
|
@@ -5,11 +5,16 @@ declare class DragSelect {
|
|
|
5
5
|
* @constructor DragSelect
|
|
6
6
|
* @param {Settings} settings
|
|
7
7
|
*/
|
|
8
|
-
constructor({ area, selectables, autoScrollSpeed, overflowTolerance, zoom, customStyles, multiSelectMode, multiSelectToggling, multiSelectKeys, selector, draggability, immediateDrag, dragKeys, keyboardDragSpeed, useTransform, hoverClass, selectableClass, selectedClass, selectorClass, selectorAreaClass, callback, onDragMove, onDragStartBegin, onDragStart, onElementSelect, onElementUnselect, }: Settings);
|
|
8
|
+
constructor({ area, selectables, autoScrollSpeed, overflowTolerance, zoom, customStyles, multiSelectMode, multiSelectToggling, multiSelectKeys, selector, draggability, immediateDrag, keyboardDrag, dragKeys, keyboardDragSpeed, useTransform, hoverClass, selectableClass, selectedClass, selectorClass, selectorAreaClass, callback, onDragMove, onDragStartBegin, onDragStart, onElementSelect, onElementUnselect, }: Settings);
|
|
9
|
+
/**
|
|
10
|
+
* used to skip all current Selection and dragNdrop functionality
|
|
11
|
+
* @type {boolean}
|
|
12
|
+
*/
|
|
13
|
+
continue: boolean;
|
|
9
14
|
PubSub: PubSub;
|
|
10
15
|
subscribe: (eventName: DSCallbackNames, callback: Function) => number;
|
|
11
16
|
unsubscribe: (eventName: DSCallbackNames, callback?: Function, id?: number) => void;
|
|
12
|
-
publish: (eventName: DSCallbackNames, data:
|
|
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;
|
|
13
18
|
stores: {
|
|
14
19
|
PointerStore: PointerStore;
|
|
15
20
|
ScrollStore: ScrollStore;
|
|
@@ -36,6 +41,7 @@ declare class DragSelect {
|
|
|
36
41
|
* Also, reset the functionality after a teardown
|
|
37
42
|
*/
|
|
38
43
|
start: () => void;
|
|
44
|
+
stopped: boolean;
|
|
39
45
|
/**
|
|
40
46
|
* Complete function teardown
|
|
41
47
|
* Will teardown/stop the whole functionality
|
|
@@ -44,6 +50,12 @@ declare class DragSelect {
|
|
|
44
50
|
* @param {boolean} [withCallback] - if elements should also be added/removed to the selection.
|
|
45
51
|
*/
|
|
46
52
|
stop(remove?: boolean, fromSelection?: boolean, withCallback?: boolean): void;
|
|
53
|
+
/**
|
|
54
|
+
* Utility to override DragSelect internal functionality:
|
|
55
|
+
* Break will skip the selection or dragging functionality (until after the callback) but let everything continue to run.
|
|
56
|
+
* Useful utility to write your own functionality/move/dragNdrop based on DragSelect pointer positions.
|
|
57
|
+
*/
|
|
58
|
+
break: () => boolean;
|
|
47
59
|
/**
|
|
48
60
|
* Returns the current selected nodes
|
|
49
61
|
* @return {DSElements}
|
|
@@ -140,12 +152,13 @@ declare class DragSelect {
|
|
|
140
152
|
*/
|
|
141
153
|
isMultiSelect: (event?: DSEvent | KeyboardEvent) => boolean;
|
|
142
154
|
/**
|
|
143
|
-
*
|
|
155
|
+
* Utility method that returns the cursor position difference between start and now
|
|
144
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
|
|
145
158
|
* @return {Vect2}
|
|
146
159
|
* @deprecated
|
|
147
160
|
*/
|
|
148
|
-
getCursorPositionDifference(usePreviousCursorDifference?: boolean): Vect2;
|
|
161
|
+
getCursorPositionDifference(usePreviousCursorDifference?: boolean, useAreaPositions?: boolean): Vect2;
|
|
149
162
|
/**
|
|
150
163
|
* Whether the user is currently drag n dropping elements (instead of selection)
|
|
151
164
|
* @return {boolean}
|