easy-drag-and-drop 1.3.145 → 1.3.146
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/example.js +52 -57
- package/lib/example/div/drop.js +2 -2
- package/lib/example/view.js +4 -4
- package/lib/mixins/drag.js +43 -43
- package/lib/mixins/drop.js +3 -3
- package/package.json +3 -3
- package/src/example/div/drop.js +1 -1
- package/src/example/view.js +3 -3
- package/src/mixins/drag.js +60 -60
- package/src/mixins/drop.js +2 -2
package/src/mixins/drag.js
CHANGED
|
@@ -40,13 +40,55 @@ function disableDrag() {
|
|
|
40
40
|
this.offMouseDown(mouseDownHandler, this);
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
function onCustomDrag(dragCustomHandler, element) {
|
|
44
|
+
const customEventType = DRAG_CUSTOM_EVENT_TYPE,
|
|
45
|
+
customHandler = dragCustomHandler; ///
|
|
46
|
+
|
|
47
|
+
this.onCustomEvent(customEventType, customHandler, element);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function offCustomDrag(dragCustomHandler, element) {
|
|
51
|
+
const customEventType = DRAG_CUSTOM_EVENT_TYPE,
|
|
52
|
+
customHandler = dragCustomHandler; ///
|
|
53
|
+
|
|
54
|
+
this.offCustomEvent(customEventType, customHandler, element);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function onCustomStopDrag(stopDragCustomHandler, element) {
|
|
58
|
+
const customEventType = STOP_DRAG_CUSTOM_EVENT_TYPE,
|
|
59
|
+
customHandler = stopDragCustomHandler; ///
|
|
60
|
+
|
|
61
|
+
this.onCustomEvent(customEventType, customHandler, element);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function offCustomStopDrag(stopDragCustomHandler, element) {
|
|
65
|
+
const customEventType = STOP_DRAG_CUSTOM_EVENT_TYPE,
|
|
66
|
+
customHandler = stopDragCustomHandler; ///
|
|
67
|
+
|
|
68
|
+
this.offCustomEvent(customEventType, customHandler, element);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function onCustomStartDrag(startDragCustomHandler, element) {
|
|
72
|
+
const customEventType = START_DRAG_CUSTOM_EVENT_TYPE,
|
|
73
|
+
customHandler = startDragCustomHandler; ///
|
|
74
|
+
|
|
75
|
+
this.onCustomEvent(customEventType, customHandler, element);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function offCustomStartDrag(startDragCustomHandler, element) {
|
|
79
|
+
const customEventType = START_DRAG_CUSTOM_EVENT_TYPE,
|
|
80
|
+
customHandler = startDragCustomHandler; ///
|
|
81
|
+
|
|
82
|
+
this.offCustomEvent(customEventType, customHandler, element);
|
|
83
|
+
}
|
|
84
|
+
|
|
43
85
|
function isDragging() {
|
|
44
86
|
const dragging = this.hasClass("dragging");
|
|
45
87
|
|
|
46
88
|
return dragging;
|
|
47
89
|
}
|
|
48
90
|
|
|
49
|
-
function startDrag(mouseTop, mouseLeft) {
|
|
91
|
+
function startDrag(event, element, mouseTop, mouseLeft) {
|
|
50
92
|
const bounds = this.getBounds(),
|
|
51
93
|
boundsTop = bounds.getTop(),
|
|
52
94
|
boundsLeft = bounds.getLeft(),
|
|
@@ -79,12 +121,12 @@ function startDrag(mouseTop, mouseLeft) {
|
|
|
79
121
|
|
|
80
122
|
this.setStartMouseLeft(startMouseLeft);
|
|
81
123
|
|
|
82
|
-
this.callCustomHandlers(customEventType);
|
|
124
|
+
this.callCustomHandlers(customEventType, event, element);
|
|
83
125
|
|
|
84
|
-
this.drag(mouseTop, mouseLeft);
|
|
126
|
+
this.drag(event, element, mouseTop, mouseLeft);
|
|
85
127
|
}
|
|
86
128
|
|
|
87
|
-
function stopDrag(aborted) {
|
|
129
|
+
function stopDrag(event, element, aborted) {
|
|
88
130
|
const { dropElement } = globalThis,
|
|
89
131
|
customEventType = STOP_DRAG_CUSTOM_EVENT_TYPE;
|
|
90
132
|
|
|
@@ -93,7 +135,7 @@ function stopDrag(aborted) {
|
|
|
93
135
|
window.offMouseMove(mouseMoveHandler, this);
|
|
94
136
|
|
|
95
137
|
const done = () => {
|
|
96
|
-
this.callCustomHandlersAsync(customEventType, dropElement, aborted, () => {
|
|
138
|
+
this.callCustomHandlersAsync(customEventType, event, element, dropElement, aborted, () => {
|
|
97
139
|
const dragElement = null;
|
|
98
140
|
|
|
99
141
|
Object.assign(globalThis, {
|
|
@@ -113,13 +155,13 @@ function stopDrag(aborted) {
|
|
|
113
155
|
dragElement = null;
|
|
114
156
|
}
|
|
115
157
|
|
|
116
|
-
dropElement.drop(dragElement, aborted, done);
|
|
158
|
+
dropElement.drop(event, element, dragElement, aborted, done);
|
|
117
159
|
} else {
|
|
118
160
|
done();
|
|
119
161
|
}
|
|
120
162
|
}
|
|
121
163
|
|
|
122
|
-
function drag(mouseTop, mouseLeft) {
|
|
164
|
+
function drag(event, element, mouseTop, mouseLeft) {
|
|
123
165
|
const scrollTop = window.getScrollTop(),
|
|
124
166
|
scrollLeft = window.getScrollLeft(),
|
|
125
167
|
topOffset = this.getTopOffset(),
|
|
@@ -143,59 +185,17 @@ function drag(mouseTop, mouseLeft) {
|
|
|
143
185
|
|
|
144
186
|
this.css(css);
|
|
145
187
|
|
|
146
|
-
this.callCustomHandlers(customEventType, relativeMouseTop, relativeMouseLeft);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
function onCustomDrag(dragCustomHandler, element) {
|
|
150
|
-
const customEventType = DRAG_CUSTOM_EVENT_TYPE,
|
|
151
|
-
customHandler = dragCustomHandler; ///
|
|
152
|
-
|
|
153
|
-
this.onCustomEvent(customEventType, customHandler, element);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
function offCustomDrag(dragCustomHandler, element) {
|
|
157
|
-
const customEventType = DRAG_CUSTOM_EVENT_TYPE,
|
|
158
|
-
customHandler = dragCustomHandler; ///
|
|
159
|
-
|
|
160
|
-
this.offCustomEvent(customEventType, customHandler, element);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
function onCustomStopDrag(stopDragCustomHandler, element) {
|
|
164
|
-
const customEventType = STOP_DRAG_CUSTOM_EVENT_TYPE,
|
|
165
|
-
customHandler = stopDragCustomHandler; ///
|
|
166
|
-
|
|
167
|
-
this.onCustomEvent(customEventType, customHandler, element);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
function offCustomStopDrag(stopDragCustomHandler, element) {
|
|
171
|
-
const customEventType = STOP_DRAG_CUSTOM_EVENT_TYPE,
|
|
172
|
-
customHandler = stopDragCustomHandler; ///
|
|
173
|
-
|
|
174
|
-
this.offCustomEvent(customEventType, customHandler, element);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
function onCustomStartDrag(startDragCustomHandler, element) {
|
|
178
|
-
const customEventType = START_DRAG_CUSTOM_EVENT_TYPE,
|
|
179
|
-
customHandler = startDragCustomHandler; ///
|
|
180
|
-
|
|
181
|
-
this.onCustomEvent(customEventType, customHandler, element);
|
|
188
|
+
this.callCustomHandlers(event, element, customEventType, relativeMouseTop, relativeMouseLeft);
|
|
182
189
|
}
|
|
183
190
|
|
|
184
|
-
function
|
|
185
|
-
const customEventType = START_DRAG_CUSTOM_EVENT_TYPE,
|
|
186
|
-
customHandler = startDragCustomHandler; ///
|
|
187
|
-
|
|
188
|
-
this.offCustomEvent(customEventType, customHandler, element);
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
function startWaitingToDrag(mouseTop, mouseLeft) {
|
|
191
|
+
function startWaitingToDrag(event, element, mouseTop, mouseLeft) {
|
|
192
192
|
let timeout = this.getTimeout();
|
|
193
193
|
|
|
194
194
|
if (timeout === null) {
|
|
195
195
|
timeout = setTimeout(() => {
|
|
196
196
|
this.resetTimeout();
|
|
197
197
|
|
|
198
|
-
this.startDrag(mouseTop, mouseLeft);
|
|
198
|
+
this.startDrag(event, element, mouseTop, mouseLeft);
|
|
199
199
|
}, START_DRAGGING_DELAY);
|
|
200
200
|
|
|
201
201
|
this.updateTimeout(timeout);
|
|
@@ -281,16 +281,16 @@ function setStartMouseLeft(startMouseLeft) {
|
|
|
281
281
|
export default {
|
|
282
282
|
enableDrag,
|
|
283
283
|
disableDrag,
|
|
284
|
-
isDragging,
|
|
285
|
-
startDrag,
|
|
286
|
-
stopDrag,
|
|
287
|
-
drag,
|
|
288
284
|
onCustomDrag,
|
|
289
285
|
offCustomDrag,
|
|
290
286
|
onCustomStopDrag,
|
|
291
287
|
offCustomStopDrag,
|
|
292
288
|
onCustomStartDrag,
|
|
293
289
|
offCustomStartDrag,
|
|
290
|
+
isDragging,
|
|
291
|
+
startDrag,
|
|
292
|
+
stopDrag,
|
|
293
|
+
drag,
|
|
294
294
|
startWaitingToDrag,
|
|
295
295
|
stopWaitingToDrag,
|
|
296
296
|
getTimeout,
|
|
@@ -312,7 +312,7 @@ function keyDownHandler(event, element) {
|
|
|
312
312
|
aborted = true;
|
|
313
313
|
|
|
314
314
|
if (escapeKey) {
|
|
315
|
-
this.stopDrag(aborted);
|
|
315
|
+
this.stopDrag(event, element, aborted);
|
|
316
316
|
|
|
317
317
|
event.stopPropagation();
|
|
318
318
|
}
|
|
@@ -323,7 +323,7 @@ function mouseUpHandler(event, element) {
|
|
|
323
323
|
aborted = false;
|
|
324
324
|
|
|
325
325
|
dragging ?
|
|
326
|
-
this.stopDrag(aborted) :
|
|
326
|
+
this.stopDrag(event, element, aborted) :
|
|
327
327
|
this.stopWaitingToDrag();
|
|
328
328
|
|
|
329
329
|
event.stopPropagation();
|
|
@@ -343,7 +343,7 @@ function mouseDownHandler(event, element) {
|
|
|
343
343
|
const mouseTop = mouseTopFromEvent(event),
|
|
344
344
|
mouseLeft = mouseLeftFromEvent(event);
|
|
345
345
|
|
|
346
|
-
this.startWaitingToDrag(mouseTop, mouseLeft);
|
|
346
|
+
this.startWaitingToDrag(event, element, mouseTop, mouseLeft);
|
|
347
347
|
}
|
|
348
348
|
}
|
|
349
349
|
|
|
@@ -361,7 +361,7 @@ function mouseMoveHandler(event, element) {
|
|
|
361
361
|
const mouseTop = mouseTopFromEvent(event),
|
|
362
362
|
mouseLeft = mouseLeftFromEvent(event);
|
|
363
363
|
|
|
364
|
-
this.drag(mouseTop, mouseLeft);
|
|
364
|
+
this.drag(event, element, mouseTop, mouseLeft);
|
|
365
365
|
}
|
|
366
366
|
|
|
367
367
|
event.stopPropagation();
|
package/src/mixins/drop.js
CHANGED
|
@@ -9,10 +9,10 @@ Object.assign(globalThis, {
|
|
|
9
9
|
dropElement
|
|
10
10
|
});
|
|
11
11
|
|
|
12
|
-
function drop(dragElement, aborted, done) {
|
|
12
|
+
function drop(event, element, dragElement, aborted, done) {
|
|
13
13
|
const customEventType = DROP_CUSTOM_EVENT_TYPE;
|
|
14
14
|
|
|
15
|
-
this.callCustomHandlersAsync(customEventType, dragElement, aborted, done);
|
|
15
|
+
this.callCustomHandlersAsync(customEventType, event, element, dragElement, aborted, done);
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
function dragOut(dragElement) {
|