dragselect 2.2.1 → 2.3.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 +18 -0
- package/CODE_OF_CONDUCT.md +128 -0
- package/README.md +17 -9
- package/dist/DragSelect.d.ts +2 -1
- package/dist/DragSelect.es6m.js +221 -99
- package/dist/DragSelect.js +221 -99
- package/dist/ds.es6m.min.js +1 -1
- package/dist/ds.min.js +1 -1
- package/dist/modules/Area.d.ts +15 -9
- package/dist/modules/Interaction.d.ts +18 -5
- package/dist/modules/PubSub.d.ts +9 -2
- package/dist/modules/SelectorArea.d.ts +2 -1
- package/dist/stores/PointerStore.d.ts +2 -0
- package/dist/types.d.ts +2 -2
- package/package.json +2 -1
- package/src/DragSelect.js +8 -2
- package/src/methods/subscriberAliases.js +0 -1
- package/src/modules/Area.js +29 -17
- package/src/modules/Drag.js +7 -9
- package/src/modules/Interaction.js +61 -18
- package/src/modules/PubSub.js +34 -4
- package/src/modules/SelectableSet.js +2 -2
- package/src/modules/SelectedSet.js +12 -8
- package/src/modules/Selection.js +1 -0
- package/src/modules/SelectorArea.js +10 -5
- package/src/stores/KeyStore.js +2 -0
- package/src/stores/PointerStore.js +9 -8
- package/src/types.js +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
# 2.3.1
|
|
2
|
+
|
|
3
|
+
- Fix bug [#109](https://github.com/ThibaultJanBeyer/DragSelect/issues/109) where inner elements are ignored from normal drag behavior
|
|
4
|
+
|
|
5
|
+
# 2.3.0
|
|
6
|
+
|
|
7
|
+
- Fix bug with break not working. (still handling change)
|
|
8
|
+
- Fix bug with `pre` events not working properly.
|
|
9
|
+
- **Caution**:
|
|
10
|
+
- - 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.
|
|
11
|
+
- - Pre Events are now really triggered *before* the whole action.
|
|
12
|
+
- Fixes issue [#110](https://github.com/ThibaultJanBeyer/DragSelect/issues/110) where teardown did not work properly
|
|
13
|
+
|
|
14
|
+
# 2.2.2
|
|
15
|
+
|
|
16
|
+
- Add a check whether the initial click was issued within the area
|
|
17
|
+
- Fixes [#105](https://github.com/ThibaultJanBeyer/DragSelect/issues/105)
|
|
18
|
+
|
|
1
19
|
# 2.2.1
|
|
2
20
|
|
|
3
21
|
- removes dom-nodes when using .stop
|
|
@@ -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
|
@@ -30,6 +30,7 @@ easily add a selection algorithm to your application/website.
|
|
|
30
30
|
- - [Use your own Drag And Drop](#use-your-own-drag-and-drop)
|
|
31
31
|
- [Constructor Properties](#constructor-properties)
|
|
32
32
|
- [Event Callbacks](#event-callbacks)
|
|
33
|
+
- - [Callback Object Keys](#callback-object-keys)
|
|
33
34
|
- [Methods](#methods)
|
|
34
35
|
- [Classes](#classes)
|
|
35
36
|
|
|
@@ -67,11 +68,16 @@ We use it currently in a professional rich interface application where we have a
|
|
|
67
68
|
|
|
68
69
|
# Supporters
|
|
69
70
|
|
|
71
|
+
Please donate to support the countless hours of hard work & support. Especially if your company makes money. Thank you :)
|
|
72
|
+
|
|
70
73
|
Thanks to:
|
|
71
74
|
|
|
72
|
-
|  | [You?](https://
|
|
75
|
+
|  | [You?](https://github.com/sponsors/ThibaultJanBeyer) |
|
|
73
76
|
|--- |--- |
|
|
74
|
-
|[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 to DragSelect](https://paypal.me/pools/c/8gF2a5szCP) (Donations are distributed with all project contributors proportionally. We are grateful for any amount) or sponsor me via [GitHub Sponsors](https://github.com/sponsors/ThibaultJanBeyer) 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) |
|
|
75
81
|
|
|
76
82
|
# Installation
|
|
77
83
|
## NPM
|
|
@@ -215,14 +221,16 @@ myCustomDrag.subscribe('finished', () => ds.start())
|
|
|
215
221
|
Disabling then re-enabling directly can also work (i.e. when your library has no callback):
|
|
216
222
|
|
|
217
223
|
```JavaScript
|
|
218
|
-
ds.subscribe('
|
|
224
|
+
ds.subscribe('predragstart', ({ isDragging, isDraggingKeyboard }) => {
|
|
219
225
|
if(isDragging) {
|
|
220
226
|
ds.stop(false, false)
|
|
221
|
-
ds.start
|
|
227
|
+
setTimeout(ds.start)
|
|
222
228
|
}
|
|
223
229
|
})
|
|
224
230
|
```
|
|
225
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
|
+
|
|
226
234
|
### Writing a fully custom solution
|
|
227
235
|
|
|
228
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 :)
|
|
@@ -297,13 +305,13 @@ ds.subscribe('<event_name>', (callback_object) => {})
|
|
|
297
305
|
|
|
298
306
|
|callback_object_keys |type |description |
|
|
299
307
|
|--- |--- |---
|
|
300
|
-
|event |`MouseEvent
|
|
301
|
-
|items |`Array.<HTMLElement
|
|
308
|
+
|event |`MouseEvent\|TouchEvent\|KeyboardEvent` |The native HTML Event, depending on the situational context
|
|
309
|
+
|items |`Array.<HTMLElement\|SVGElement\|*>` |Current selected elements
|
|
302
310
|
|isDragging |`boolean` |If true, the user is dragging the selected elements, if false the user is drawing a selection
|
|
303
311
|
|isDraggingKeyboard |`boolean` |If true, the user is dragging the selected elements with the keyboard
|
|
304
|
-
|scroll_directions |`Array.<'top'
|
|
312
|
+
|scroll_directions |`Array.<'top'\|'bottom'\|'left'\|'right'\|undefined>` |The direction in which the event is happening (i.e. scroll direction)
|
|
305
313
|
|scroll_multiplier |`number` |Speed
|
|
306
|
-
|item |`HTMLElement
|
|
314
|
+
|item |`HTMLElement\|SVGElement\|*` |The single element currently being interacted with if any
|
|
307
315
|
|
|
308
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
|
|
309
317
|
|
|
@@ -334,7 +342,7 @@ Also check **[the docs](https://dragselect.com/DragSelect.html)** for more info.
|
|
|
334
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 |
|
|
335
343
|
|isMultiSelect |\[event:KeyboardEvent|MouseEvent|TouchEvent\] (optional) |Whether the multi-select key is currently pressed
|
|
336
344
|
|isDragging |/ |Whether the user is currently drag n dropping elements (instead of selection)
|
|
337
|
-
|break |/ |Utility to override DragSelect internal functionality. Read [docs](#writing-a-fully-custom-solution) for more info.
|
|
345
|
+
|break |/ |Utility to override DragSelect internal functionality. Breaks out of current flow. Read [docs](#writing-a-fully-custom-solution) for more info.
|
|
338
346
|
|
|
339
347
|
# Classes
|
|
340
348
|
| name | trigger |
|
package/dist/DragSelect.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ 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: DSCallbackNames, data: CallbackObject) => void;
|
|
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;
|
|
18
18
|
stores: {
|
|
19
19
|
PointerStore: PointerStore;
|
|
20
20
|
ScrollStore: ScrollStore;
|
|
@@ -41,6 +41,7 @@ declare class DragSelect {
|
|
|
41
41
|
* Also, reset the functionality after a teardown
|
|
42
42
|
*/
|
|
43
43
|
start: () => void;
|
|
44
|
+
stopped: boolean;
|
|
44
45
|
/**
|
|
45
46
|
* Complete function teardown
|
|
46
47
|
* Will teardown/stop the whole functionality
|