gridstack 5.1.0 → 6.0.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/README.md +54 -42
- package/dist/{h5/dd-base-impl.d.ts → dd-base-impl.d.ts} +1 -1
- package/dist/{h5/dd-base-impl.js → dd-base-impl.js} +1 -3
- package/dist/dd-base-impl.js.map +1 -0
- package/dist/{es5/h5/dd-draggable.d.ts → dd-draggable.d.ts} +6 -7
- package/dist/dd-draggable.js +313 -0
- package/dist/dd-draggable.js.map +1 -0
- package/dist/{h5/dd-droppable.d.ts → dd-droppable.d.ts} +3 -2
- package/dist/dd-droppable.js +149 -0
- package/dist/dd-droppable.js.map +1 -0
- package/dist/{h5/dd-element.d.ts → dd-element.d.ts} +2 -2
- package/dist/{h5/dd-element.js → dd-element.js} +1 -1
- package/dist/dd-element.js.map +1 -0
- package/dist/dd-gridstack.d.ts +36 -0
- package/dist/{gridstack-dd.js → dd-gridstack.js} +159 -69
- package/dist/dd-gridstack.js.map +1 -0
- package/dist/dd-manager.d.ts +20 -0
- package/dist/{h5/dd-manager.js → dd-manager.js} +4 -1
- package/dist/dd-manager.js.map +1 -0
- package/dist/{es5/h5/dd-resizable-handle.d.ts → dd-resizable-handle.d.ts} +1 -1
- package/dist/{h5/dd-resizable-handle.js → dd-resizable-handle.js} +32 -8
- package/dist/dd-resizable-handle.js.map +1 -0
- package/dist/{es5/h5/dd-resizable.d.ts → dd-resizable.d.ts} +2 -2
- package/dist/{h5/dd-resizable.js → dd-resizable.js} +41 -28
- package/dist/dd-resizable.js.map +1 -0
- package/dist/dd-touch.d.ts +33 -0
- package/dist/dd-touch.js +179 -0
- package/dist/dd-touch.js.map +1 -0
- package/dist/es5/{h5/dd-base-impl.d.ts → dd-base-impl.d.ts} +1 -1
- package/dist/es5/{h5/dd-base-impl.js → dd-base-impl.js} +1 -3
- package/dist/es5/dd-base-impl.js.map +1 -0
- package/dist/{h5 → es5}/dd-draggable.d.ts +6 -7
- package/dist/es5/dd-draggable.js +335 -0
- package/dist/es5/dd-draggable.js.map +1 -0
- package/dist/es5/{h5/dd-droppable.d.ts → dd-droppable.d.ts} +3 -2
- package/dist/es5/dd-droppable.js +180 -0
- package/dist/es5/dd-droppable.js.map +1 -0
- package/dist/es5/{h5/dd-element.d.ts → dd-element.d.ts} +2 -2
- package/dist/es5/{h5/dd-element.js → dd-element.js} +1 -1
- package/dist/es5/dd-element.js.map +1 -0
- package/dist/es5/dd-gridstack.d.ts +36 -0
- package/dist/es5/{gridstack-dd.js → dd-gridstack.js} +169 -88
- package/dist/es5/dd-gridstack.js.map +1 -0
- package/dist/es5/dd-manager.d.ts +20 -0
- package/dist/es5/{h5/dd-manager.js → dd-manager.js} +4 -1
- package/dist/es5/dd-manager.js.map +1 -0
- package/dist/{h5 → es5}/dd-resizable-handle.d.ts +1 -1
- package/dist/es5/{h5/dd-resizable-handle.js → dd-resizable-handle.js} +32 -8
- package/dist/es5/dd-resizable-handle.js.map +1 -0
- package/dist/{h5 → es5}/dd-resizable.d.ts +2 -2
- package/dist/es5/{h5/dd-resizable.js → dd-resizable.js} +41 -28
- package/dist/es5/dd-resizable.js.map +1 -0
- package/dist/es5/dd-touch.d.ts +33 -0
- package/dist/es5/dd-touch.js +182 -0
- package/dist/es5/dd-touch.js.map +1 -0
- package/dist/es5/gridstack-all.js +3 -0
- package/dist/{gridstack-static.js.LICENSE.txt → es5/gridstack-all.js.LICENSE.txt} +1 -1
- package/dist/es5/gridstack-all.js.map +1 -0
- package/dist/es5/gridstack-engine.d.ts +2 -3
- package/dist/es5/gridstack-engine.js +18 -18
- package/dist/es5/gridstack-engine.js.map +1 -1
- package/dist/es5/gridstack-poly.js +1 -1
- package/dist/es5/gridstack.d.ts +8 -9
- package/dist/es5/gridstack.js +47 -35
- package/dist/es5/gridstack.js.map +1 -1
- package/dist/es5/types.d.ts +12 -16
- package/dist/es5/types.js +1 -1
- package/dist/es5/types.js.map +1 -1
- package/dist/es5/utils.d.ts +11 -1
- package/dist/es5/utils.js +67 -6
- package/dist/es5/utils.js.map +1 -1
- package/dist/gridstack-all.js +3 -0
- package/dist/{es5/gridstack-h5.js.LICENSE.txt → gridstack-all.js.LICENSE.txt} +1 -1
- package/dist/gridstack-all.js.map +1 -0
- package/dist/gridstack-engine.d.ts +2 -3
- package/dist/gridstack-engine.js +17 -18
- package/dist/gridstack-engine.js.map +1 -1
- package/dist/gridstack.css +21 -9
- package/dist/gridstack.d.ts +8 -9
- package/dist/gridstack.js +45 -35
- package/dist/gridstack.js.map +1 -1
- package/dist/gridstack.min.css +1 -1
- package/dist/src/gridstack.scss +19 -12
- package/dist/types.d.ts +12 -16
- package/dist/types.js +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils.d.ts +11 -1
- package/dist/utils.js +64 -6
- package/dist/utils.js.map +1 -1
- package/doc/CHANGES.md +16 -1
- package/doc/README.md +19 -20
- package/package.json +2 -2
- package/dist/es5/gridstack-dd.d.ts +0 -35
- package/dist/es5/gridstack-dd.js.map +0 -1
- package/dist/es5/gridstack-ddi.d.ts +0 -17
- package/dist/es5/gridstack-ddi.js +0 -31
- package/dist/es5/gridstack-ddi.js.map +0 -1
- package/dist/es5/gridstack-h5.d.ts +0 -10
- package/dist/es5/gridstack-h5.js +0 -3
- package/dist/es5/gridstack-h5.js.map +0 -1
- package/dist/es5/gridstack-jq.d.ts +0 -10
- package/dist/es5/gridstack-jq.js +0 -3
- package/dist/es5/gridstack-jq.js.LICENSE.txt +0 -99
- package/dist/es5/gridstack-jq.js.map +0 -1
- package/dist/es5/gridstack-static.d.ts +0 -9
- package/dist/es5/gridstack-static.js +0 -3
- package/dist/es5/gridstack-static.js.LICENSE.txt +0 -7
- package/dist/es5/gridstack-static.js.map +0 -1
- package/dist/es5/h5/dd-base-impl.js.map +0 -1
- package/dist/es5/h5/dd-draggable.js +0 -326
- package/dist/es5/h5/dd-draggable.js.map +0 -1
- package/dist/es5/h5/dd-droppable.js +0 -199
- package/dist/es5/h5/dd-droppable.js.map +0 -1
- package/dist/es5/h5/dd-element.js.map +0 -1
- package/dist/es5/h5/dd-manager.d.ts +0 -8
- package/dist/es5/h5/dd-manager.js.map +0 -1
- package/dist/es5/h5/dd-resizable-handle.js.map +0 -1
- package/dist/es5/h5/dd-resizable.js.map +0 -1
- package/dist/es5/h5/dd-utils.d.ts +0 -19
- package/dist/es5/h5/dd-utils.js +0 -111
- package/dist/es5/h5/dd-utils.js.map +0 -1
- package/dist/es5/h5/gridstack-dd-native.d.ts +0 -26
- package/dist/es5/h5/gridstack-dd-native.js +0 -175
- package/dist/es5/h5/gridstack-dd-native.js.map +0 -1
- package/dist/es5/jq/gridstack-dd-jqueryui.d.ts +0 -22
- package/dist/es5/jq/gridstack-dd-jqueryui.js +0 -162
- package/dist/es5/jq/gridstack-dd-jqueryui.js.map +0 -1
- package/dist/gridstack-dd.d.ts +0 -35
- package/dist/gridstack-dd.js.map +0 -1
- package/dist/gridstack-ddi.d.ts +0 -17
- package/dist/gridstack-ddi.js +0 -28
- package/dist/gridstack-ddi.js.map +0 -1
- package/dist/gridstack-h5.d.ts +0 -10
- package/dist/gridstack-h5.js +0 -3
- package/dist/gridstack-h5.js.LICENSE.txt +0 -7
- package/dist/gridstack-h5.js.map +0 -1
- package/dist/gridstack-jq.d.ts +0 -10
- package/dist/gridstack-jq.js +0 -3
- package/dist/gridstack-jq.js.LICENSE.txt +0 -99
- package/dist/gridstack-jq.js.map +0 -1
- package/dist/gridstack-static.d.ts +0 -9
- package/dist/gridstack-static.js +0 -3
- package/dist/gridstack-static.js.map +0 -1
- package/dist/h5/dd-base-impl.js.map +0 -1
- package/dist/h5/dd-draggable.js +0 -302
- package/dist/h5/dd-draggable.js.map +0 -1
- package/dist/h5/dd-droppable.js +0 -168
- package/dist/h5/dd-droppable.js.map +0 -1
- package/dist/h5/dd-element.js.map +0 -1
- package/dist/h5/dd-manager.d.ts +0 -8
- package/dist/h5/dd-manager.js.map +0 -1
- package/dist/h5/dd-resizable-handle.js.map +0 -1
- package/dist/h5/dd-resizable.js.map +0 -1
- package/dist/h5/dd-utils.d.ts +0 -19
- package/dist/h5/dd-utils.js +0 -94
- package/dist/h5/dd-utils.js.map +0 -1
- package/dist/h5/gridstack-dd-native.d.ts +0 -26
- package/dist/h5/gridstack-dd-native.js +0 -140
- package/dist/h5/gridstack-dd-native.js.map +0 -1
- package/dist/jq/gridstack-dd-jqueryui.d.ts +0 -22
- package/dist/jq/gridstack-dd-jqueryui.js +0 -133
- package/dist/jq/gridstack-dd-jqueryui.js.map +0 -1
- package/dist/jq/jquery-ui.js +0 -2
- package/dist/jq/jquery-ui.js.map +0 -1
- package/dist/jq/jquery.js +0 -2
- package/dist/jq/jquery.js.map +0 -1
- package/dist/jq/jquery.ui.touch-punch.js +0 -2
- package/dist/jq/jquery.ui.touch-punch.js.map +0 -1
package/dist/h5/dd-draggable.js
DELETED
|
@@ -1,302 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* dd-draggable.ts 5.1.0
|
|
4
|
-
* Copyright (c) 2021-2022 Alain Dumesny - see GridStack root license
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.DDDraggable = void 0;
|
|
8
|
-
const dd_manager_1 = require("./dd-manager");
|
|
9
|
-
const dd_utils_1 = require("./dd-utils");
|
|
10
|
-
const dd_base_impl_1 = require("./dd-base-impl");
|
|
11
|
-
class DDDraggable extends dd_base_impl_1.DDBaseImplement {
|
|
12
|
-
constructor(el, option = {}) {
|
|
13
|
-
super();
|
|
14
|
-
/** @internal */
|
|
15
|
-
this.dragging = false;
|
|
16
|
-
/** @internal TODO: set to public as called by DDDroppable! */
|
|
17
|
-
this.ui = () => {
|
|
18
|
-
const containmentEl = this.el.parentElement;
|
|
19
|
-
const containmentRect = containmentEl.getBoundingClientRect();
|
|
20
|
-
const offset = this.helper.getBoundingClientRect();
|
|
21
|
-
return {
|
|
22
|
-
position: {
|
|
23
|
-
top: offset.top - containmentRect.top,
|
|
24
|
-
left: offset.left - containmentRect.left
|
|
25
|
-
}
|
|
26
|
-
/* not used by GridStack for now...
|
|
27
|
-
helper: [this.helper], //The object arr representing the helper that's being dragged.
|
|
28
|
-
offset: { top: offset.top, left: offset.left } // Current offset position of the helper as { top, left } object.
|
|
29
|
-
*/
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
this.el = el;
|
|
33
|
-
this.option = option;
|
|
34
|
-
// get the element that is actually supposed to be dragged by
|
|
35
|
-
let className = option.handle.substring(1);
|
|
36
|
-
this.dragEl = el.classList.contains(className) ? el : el.querySelector(option.handle) || el;
|
|
37
|
-
// create var event binding so we can easily remove and still look like TS methods (unlike anonymous functions)
|
|
38
|
-
this._dragStart = this._dragStart.bind(this);
|
|
39
|
-
this._drag = this._drag.bind(this);
|
|
40
|
-
this._dragEnd = this._dragEnd.bind(this);
|
|
41
|
-
this.enable();
|
|
42
|
-
}
|
|
43
|
-
on(event, callback) {
|
|
44
|
-
super.on(event, callback);
|
|
45
|
-
}
|
|
46
|
-
off(event) {
|
|
47
|
-
super.off(event);
|
|
48
|
-
}
|
|
49
|
-
enable() {
|
|
50
|
-
super.enable();
|
|
51
|
-
this.dragEl.draggable = true;
|
|
52
|
-
this.dragEl.addEventListener('dragstart', this._dragStart);
|
|
53
|
-
this.el.classList.remove('ui-draggable-disabled');
|
|
54
|
-
this.el.classList.add('ui-draggable');
|
|
55
|
-
}
|
|
56
|
-
disable(forDestroy = false) {
|
|
57
|
-
super.disable();
|
|
58
|
-
this.dragEl.removeAttribute('draggable');
|
|
59
|
-
this.dragEl.removeEventListener('dragstart', this._dragStart);
|
|
60
|
-
this.el.classList.remove('ui-draggable');
|
|
61
|
-
if (!forDestroy)
|
|
62
|
-
this.el.classList.add('ui-draggable-disabled');
|
|
63
|
-
}
|
|
64
|
-
destroy() {
|
|
65
|
-
if (this.dragging) {
|
|
66
|
-
// Destroy while dragging should remove dragend listener and manually trigger
|
|
67
|
-
// dragend, otherwise dragEnd can't perform dragstop because eventRegistry is
|
|
68
|
-
// destroyed.
|
|
69
|
-
this._dragEnd({});
|
|
70
|
-
}
|
|
71
|
-
this.disable(true);
|
|
72
|
-
delete this.el;
|
|
73
|
-
delete this.helper;
|
|
74
|
-
delete this.option;
|
|
75
|
-
super.destroy();
|
|
76
|
-
}
|
|
77
|
-
updateOption(opts) {
|
|
78
|
-
Object.keys(opts).forEach(key => this.option[key] = opts[key]);
|
|
79
|
-
return this;
|
|
80
|
-
}
|
|
81
|
-
/** @internal */
|
|
82
|
-
_dragStart(event) {
|
|
83
|
-
dd_manager_1.DDManager.dragElement = this;
|
|
84
|
-
this.helper = this._createHelper(event);
|
|
85
|
-
this._setupHelperContainmentStyle();
|
|
86
|
-
this.dragOffset = this._getDragOffset(event, this.el, this.helperContainment);
|
|
87
|
-
const ev = dd_utils_1.DDUtils.initEvent(event, { target: this.el, type: 'dragstart' });
|
|
88
|
-
if (this.helper !== this.el) {
|
|
89
|
-
this._setupDragFollowNodeNotifyStart(ev);
|
|
90
|
-
// immediately set external helper initial position to avoid flickering behavior and unnecessary looping in `_packNodes()`
|
|
91
|
-
this._dragFollow(event);
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
this.dragFollowTimer = window.setTimeout(() => {
|
|
95
|
-
delete this.dragFollowTimer;
|
|
96
|
-
this._setupDragFollowNodeNotifyStart(ev);
|
|
97
|
-
}, 0);
|
|
98
|
-
}
|
|
99
|
-
this._cancelDragGhost(event);
|
|
100
|
-
}
|
|
101
|
-
/** @internal */
|
|
102
|
-
_setupDragFollowNodeNotifyStart(ev) {
|
|
103
|
-
this._setupHelperStyle();
|
|
104
|
-
document.addEventListener('dragover', this._drag, DDDraggable.dragEventListenerOption);
|
|
105
|
-
this.dragEl.addEventListener('dragend', this._dragEnd);
|
|
106
|
-
if (this.option.start) {
|
|
107
|
-
this.option.start(ev, this.ui());
|
|
108
|
-
}
|
|
109
|
-
this.dragging = true;
|
|
110
|
-
this.helper.classList.add('ui-draggable-dragging');
|
|
111
|
-
this.triggerEvent('dragstart', ev);
|
|
112
|
-
return this;
|
|
113
|
-
}
|
|
114
|
-
/** @internal */
|
|
115
|
-
_drag(event) {
|
|
116
|
-
// Safari: prevent default to allow drop to happen instead of reverting back (with animation) and delaying dragend #1541
|
|
117
|
-
// https://stackoverflow.com/questions/61760755/how-to-fire-dragend-event-immediately
|
|
118
|
-
event.preventDefault();
|
|
119
|
-
this._dragFollow(event);
|
|
120
|
-
const ev = dd_utils_1.DDUtils.initEvent(event, { target: this.el, type: 'drag' });
|
|
121
|
-
if (this.option.drag) {
|
|
122
|
-
this.option.drag(ev, this.ui());
|
|
123
|
-
}
|
|
124
|
-
this.triggerEvent('drag', ev);
|
|
125
|
-
}
|
|
126
|
-
/** @internal */
|
|
127
|
-
_dragEnd(event) {
|
|
128
|
-
if (this.dragFollowTimer) {
|
|
129
|
-
clearTimeout(this.dragFollowTimer);
|
|
130
|
-
delete this.dragFollowTimer;
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
if (this.paintTimer) {
|
|
135
|
-
cancelAnimationFrame(this.paintTimer);
|
|
136
|
-
}
|
|
137
|
-
document.removeEventListener('dragover', this._drag, DDDraggable.dragEventListenerOption);
|
|
138
|
-
this.dragEl.removeEventListener('dragend', this._dragEnd);
|
|
139
|
-
}
|
|
140
|
-
this.dragging = false;
|
|
141
|
-
this.helper.classList.remove('ui-draggable-dragging');
|
|
142
|
-
this.helperContainment.style.position = this.parentOriginStylePosition || null;
|
|
143
|
-
if (this.helper === this.el) {
|
|
144
|
-
this._removeHelperStyle();
|
|
145
|
-
}
|
|
146
|
-
else {
|
|
147
|
-
this.helper.remove();
|
|
148
|
-
}
|
|
149
|
-
const ev = dd_utils_1.DDUtils.initEvent(event, { target: this.el, type: 'dragstop' });
|
|
150
|
-
if (this.option.stop) {
|
|
151
|
-
this.option.stop(ev); // Note: ui() not used by gridstack so don't pass
|
|
152
|
-
}
|
|
153
|
-
this.triggerEvent('dragstop', ev);
|
|
154
|
-
delete dd_manager_1.DDManager.dragElement;
|
|
155
|
-
delete this.helper;
|
|
156
|
-
}
|
|
157
|
-
/** @internal create a clone copy (or user defined method) of the original drag item if set */
|
|
158
|
-
_createHelper(event) {
|
|
159
|
-
let helper = this.el;
|
|
160
|
-
if (typeof this.option.helper === 'function') {
|
|
161
|
-
helper = this.option.helper(event);
|
|
162
|
-
}
|
|
163
|
-
else if (this.option.helper === 'clone') {
|
|
164
|
-
helper = dd_utils_1.DDUtils.clone(this.el);
|
|
165
|
-
}
|
|
166
|
-
if (!document.body.contains(helper)) {
|
|
167
|
-
dd_utils_1.DDUtils.appendTo(helper, this.option.appendTo === 'parent' ? this.el.parentNode : this.option.appendTo);
|
|
168
|
-
}
|
|
169
|
-
if (helper === this.el) {
|
|
170
|
-
this.dragElementOriginStyle = DDDraggable.originStyleProp.map(prop => this.el.style[prop]);
|
|
171
|
-
}
|
|
172
|
-
return helper;
|
|
173
|
-
}
|
|
174
|
-
/** @internal */
|
|
175
|
-
_setupHelperStyle() {
|
|
176
|
-
// TODO: set all at once with style.cssText += ... ? https://stackoverflow.com/questions/3968593
|
|
177
|
-
const rec = this.helper.getBoundingClientRect();
|
|
178
|
-
const style = this.helper.style;
|
|
179
|
-
style.pointerEvents = 'none';
|
|
180
|
-
style['min-width'] = 0; // since we no longer relative to our parent and we don't resize anyway (normally 100/#column %)
|
|
181
|
-
style.width = this.dragOffset.width + 'px';
|
|
182
|
-
style.height = this.dragOffset.height + 'px';
|
|
183
|
-
style.willChange = 'left, top';
|
|
184
|
-
style.position = 'fixed'; // let us drag between grids by not clipping as parent .grid-stack is position: 'relative'
|
|
185
|
-
style.left = rec.left + 'px';
|
|
186
|
-
style.top = rec.top + 'px';
|
|
187
|
-
style.transition = 'none'; // show up instantly
|
|
188
|
-
setTimeout(() => {
|
|
189
|
-
if (this.helper) {
|
|
190
|
-
style.transition = null; // recover animation
|
|
191
|
-
}
|
|
192
|
-
}, 0);
|
|
193
|
-
return this;
|
|
194
|
-
}
|
|
195
|
-
/** @internal */
|
|
196
|
-
_removeHelperStyle() {
|
|
197
|
-
var _a;
|
|
198
|
-
let node = (_a = this.helper) === null || _a === void 0 ? void 0 : _a.gridstackNode;
|
|
199
|
-
// don't bother restoring styles if we're gonna remove anyway...
|
|
200
|
-
if (this.dragElementOriginStyle && (!node || !node._isAboutToRemove)) {
|
|
201
|
-
let helper = this.helper;
|
|
202
|
-
DDDraggable.originStyleProp.forEach(prop => helper.style[prop] = this.dragElementOriginStyle[prop] || null);
|
|
203
|
-
// show up instantly otherwise we animate to off the grid when switching back to 'absolute' from 'fixed'
|
|
204
|
-
helper.style.transition = 'none';
|
|
205
|
-
let transition = this.dragElementOriginStyle['transition'] || null;
|
|
206
|
-
setTimeout(() => helper.style.transition = transition, 0); // recover animation from saved vars
|
|
207
|
-
}
|
|
208
|
-
delete this.dragElementOriginStyle;
|
|
209
|
-
return this;
|
|
210
|
-
}
|
|
211
|
-
/** @internal */
|
|
212
|
-
_dragFollow(event) {
|
|
213
|
-
if (this.paintTimer) {
|
|
214
|
-
cancelAnimationFrame(this.paintTimer);
|
|
215
|
-
}
|
|
216
|
-
this.paintTimer = requestAnimationFrame(() => {
|
|
217
|
-
delete this.paintTimer;
|
|
218
|
-
const offset = this.dragOffset;
|
|
219
|
-
let containmentRect = { left: 0, top: 0 };
|
|
220
|
-
if (this.helper.style.position === 'absolute') {
|
|
221
|
-
const { left, top } = this.helperContainment.getBoundingClientRect();
|
|
222
|
-
containmentRect = { left, top };
|
|
223
|
-
}
|
|
224
|
-
this.helper.style.left = event.clientX + offset.offsetLeft - containmentRect.left + 'px';
|
|
225
|
-
this.helper.style.top = event.clientY + offset.offsetTop - containmentRect.top + 'px';
|
|
226
|
-
});
|
|
227
|
-
}
|
|
228
|
-
/** @internal */
|
|
229
|
-
_setupHelperContainmentStyle() {
|
|
230
|
-
this.helperContainment = this.helper.parentElement;
|
|
231
|
-
if (this.helper.style.position !== 'fixed') {
|
|
232
|
-
this.parentOriginStylePosition = this.helperContainment.style.position;
|
|
233
|
-
if (window.getComputedStyle(this.helperContainment).position.match(/static/)) {
|
|
234
|
-
this.helperContainment.style.position = 'relative';
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
return this;
|
|
238
|
-
}
|
|
239
|
-
/** @internal prevent the default ghost image to be created (which has wrong as we move the helper/element instead
|
|
240
|
-
* (legacy jquery UI code updates the top/left of the item).
|
|
241
|
-
* TODO: maybe use mouse event instead of HTML5 drag as we have to work around it anyway, or change code to not update
|
|
242
|
-
* the actual grid-item but move the ghost image around (and special case jq version) ?
|
|
243
|
-
**/
|
|
244
|
-
_cancelDragGhost(e) {
|
|
245
|
-
/* doesn't seem to do anything...
|
|
246
|
-
let t = e.dataTransfer;
|
|
247
|
-
t.effectAllowed = 'none';
|
|
248
|
-
t.dropEffect = 'none';
|
|
249
|
-
t.setData('text', '');
|
|
250
|
-
*/
|
|
251
|
-
// NOTE: according to spec (and required by Safari see #1540) the image has to be visible in the browser (in dom and not hidden) so make it a 1px div
|
|
252
|
-
let img = document.createElement('div');
|
|
253
|
-
img.style.width = '1px';
|
|
254
|
-
img.style.height = '1px';
|
|
255
|
-
img.style.position = 'fixed'; // prevent unwanted scrollbar
|
|
256
|
-
document.body.appendChild(img);
|
|
257
|
-
e.dataTransfer.setDragImage(img, 0, 0);
|
|
258
|
-
setTimeout(() => document.body.removeChild(img)); // nuke once drag had a chance to grab this 'image'
|
|
259
|
-
e.stopPropagation();
|
|
260
|
-
return this;
|
|
261
|
-
}
|
|
262
|
-
/** @internal */
|
|
263
|
-
_getDragOffset(event, el, parent) {
|
|
264
|
-
// in case ancestor has transform/perspective css properties that change the viewpoint
|
|
265
|
-
let xformOffsetX = 0;
|
|
266
|
-
let xformOffsetY = 0;
|
|
267
|
-
if (parent) {
|
|
268
|
-
const testEl = document.createElement('div');
|
|
269
|
-
dd_utils_1.DDUtils.addElStyles(testEl, {
|
|
270
|
-
opacity: '0',
|
|
271
|
-
position: 'fixed',
|
|
272
|
-
top: 0 + 'px',
|
|
273
|
-
left: 0 + 'px',
|
|
274
|
-
width: '1px',
|
|
275
|
-
height: '1px',
|
|
276
|
-
zIndex: '-999999',
|
|
277
|
-
});
|
|
278
|
-
parent.appendChild(testEl);
|
|
279
|
-
const testElPosition = testEl.getBoundingClientRect();
|
|
280
|
-
parent.removeChild(testEl);
|
|
281
|
-
xformOffsetX = testElPosition.left;
|
|
282
|
-
xformOffsetY = testElPosition.top;
|
|
283
|
-
// TODO: scale ?
|
|
284
|
-
}
|
|
285
|
-
const targetOffset = el.getBoundingClientRect();
|
|
286
|
-
return {
|
|
287
|
-
left: targetOffset.left,
|
|
288
|
-
top: targetOffset.top,
|
|
289
|
-
offsetLeft: -event.clientX + targetOffset.left - xformOffsetX,
|
|
290
|
-
offsetTop: -event.clientY + targetOffset.top - xformOffsetY,
|
|
291
|
-
width: targetOffset.width,
|
|
292
|
-
height: targetOffset.height
|
|
293
|
-
};
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
exports.DDDraggable = DDDraggable;
|
|
297
|
-
/** @internal #1541 can't have {passive: true} on Safari as otherwise it reverts animate back to old location on drop */
|
|
298
|
-
DDDraggable.dragEventListenerOption = true; // DDUtils.isEventSupportPassiveOption ? { capture: true, passive: true } : true;
|
|
299
|
-
/** @internal properties we change during dragging, and restore back */
|
|
300
|
-
DDDraggable.originStyleProp = ['transition', 'pointerEvents', 'position',
|
|
301
|
-
'left', 'top', 'opacity', 'zIndex', 'width', 'height', 'willChange', 'min-width'];
|
|
302
|
-
//# sourceMappingURL=dd-draggable.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dd-draggable.js","sourceRoot":"","sources":["../../src/h5/dd-draggable.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,6CAAyC;AACzC,yCAAqC;AACrC,iDAAuE;AAyBvE,MAAa,WAAY,SAAQ,8BAAe;IA2B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;gBACd,KAAK,EAAE,KAAK;gBACZ,MAAM,EAAE,KAAK;gBACb,MAAM,EAAE,SAAS;aAClB,CAAC,CAAC;YACH,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;YAC3B,MAAM,cAAc,GAAG,MAAM,CAAC,qBAAqB,EAAE,CAAC;YACtD,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;YAC3B,YAAY,GAAG,cAAc,CAAC,IAAI,CAAC;YACnC,YAAY,GAAG,cAAc,CAAC,GAAG,CAAC;YAClC,gBAAgB;SACjB;QAED,MAAM,YAAY,GAAG,EAAE,CAAC,qBAAqB,EAAE,CAAC;QAChD,OAAO;YACL,IAAI,EAAE,YAAY,CAAC,IAAI;YACvB,GAAG,EAAE,YAAY,CAAC,GAAG;YACrB,UAAU,EAAE,CAAE,KAAK,CAAC,OAAO,GAAG,YAAY,CAAC,IAAI,GAAG,YAAY;YAC9D,SAAS,EAAE,CAAE,KAAK,CAAC,OAAO,GAAG,YAAY,CAAC,GAAG,GAAG,YAAY;YAC5D,KAAK,EAAE,YAAY,CAAC,KAAK;YACzB,MAAM,EAAE,YAAY,CAAC,MAAM;SAC5B,CAAC;IACJ,CAAC;;AAlTH,kCAoUC;AA/SC,wHAAwH;AACvG,mCAAuB,GAAG,IAAI,CAAC,CAAC,iFAAiF;AAClI,uEAAuE;AACtD,2BAAe,GAAG,CAAC,YAAY,EAAE,eAAe,EAAE,UAAU;IAC3E,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,WAAW,CAAC,CAAC","sourcesContent":["/**\n * dd-draggable.ts 5.1.0\n * Copyright (c) 2021-2022 Alain Dumesny - see GridStack root license\n */\n\nimport { DDManager } from './dd-manager';\nimport { DDUtils } from './dd-utils';\nimport { DDBaseImplement, HTMLElementExtendOpt } from './dd-base-impl';\nimport { GridItemHTMLElement, DDUIData } from '../types';\n\n// TODO: merge with DDDragOpt ?\nexport interface DDDraggableOpt {\n appendTo?: string | HTMLElement;\n containment?: string | HTMLElement; // TODO: not implemented yet\n handle?: string;\n revert?: string | boolean | unknown; // TODO: not implemented yet\n scroll?: boolean; // nature support by HTML5 drag drop, can't be switch to off actually\n helper?: string | HTMLElement | ((event: Event) => HTMLElement);\n start?: (event: Event, ui: DDUIData) => void;\n stop?: (event: Event) => void;\n drag?: (event: Event, ui: DDUIData) => void;\n}\n\ninterface DragOffset {\n left: number;\n top: number;\n width: number;\n height: number;\n offsetLeft: number;\n offsetTop: number;\n}\n\nexport class DDDraggable extends DDBaseImplement implements HTMLElementExtendOpt<DDDraggableOpt> {\n public el: HTMLElement;\n public option: DDDraggableOpt;\n public helper: HTMLElement; // used by GridStackDDNative\n\n /** @internal */\n protected dragOffset: DragOffset;\n /** @internal */\n protected dragElementOriginStyle: Array<string>;\n /** @internal */\n protected dragFollowTimer: number;\n /** @internal */\n protected dragEl: HTMLElement;\n /** @internal */\n protected dragging = false;\n /** @internal */\n protected paintTimer: number;\n /** @internal */\n protected parentOriginStylePosition: string;\n /** @internal */\n protected helperContainment: HTMLElement;\n /** @internal #1541 can't have {passive: true} on Safari as otherwise it reverts animate back to old location on drop */\n protected static dragEventListenerOption = true; // DDUtils.isEventSupportPassiveOption ? { capture: true, passive: true } : true;\n /** @internal properties we change during dragging, and restore back */\n protected static originStyleProp = ['transition', 'pointerEvents', 'position',\n 'left', 'top', 'opacity', 'zIndex', 'width', 'height', 'willChange', 'min-width'];\n\n constructor(el: HTMLElement, option: DDDraggableOpt = {}) {\n super();\n this.el = el;\n this.option = option;\n // get the element that is actually supposed to be dragged by\n let className = option.handle.substring(1);\n this.dragEl = el.classList.contains(className) ? el : el.querySelector(option.handle) || el;\n // create var event binding so we can easily remove and still look like TS methods (unlike anonymous functions)\n this._dragStart = this._dragStart.bind(this);\n this._drag = this._drag.bind(this);\n this._dragEnd = this._dragEnd.bind(this);\n this.enable();\n }\n\n public on(event: 'drag' | 'dragstart' | 'dragstop', callback: (event: DragEvent) => void): void {\n super.on(event, callback);\n }\n\n public off(event: 'drag' | 'dragstart' | 'dragstop'): void {\n super.off(event);\n }\n\n public enable(): void {\n super.enable();\n this.dragEl.draggable = true;\n this.dragEl.addEventListener('dragstart', this._dragStart);\n this.el.classList.remove('ui-draggable-disabled');\n this.el.classList.add('ui-draggable');\n }\n\n public disable(forDestroy = false): void {\n super.disable();\n this.dragEl.removeAttribute('draggable');\n this.dragEl.removeEventListener('dragstart', this._dragStart);\n this.el.classList.remove('ui-draggable');\n if (!forDestroy) this.el.classList.add('ui-draggable-disabled');\n }\n\n public destroy(): void {\n if (this.dragging) {\n // Destroy while dragging should remove dragend listener and manually trigger\n // dragend, otherwise dragEnd can't perform dragstop because eventRegistry is\n // destroyed.\n this._dragEnd({} as DragEvent);\n }\n this.disable(true);\n delete this.el;\n delete this.helper;\n delete this.option;\n super.destroy();\n }\n\n public updateOption(opts: DDDraggableOpt): DDDraggable {\n Object.keys(opts).forEach(key => this.option[key] = opts[key]);\n return this;\n }\n\n /** @internal */\n protected _dragStart(event: DragEvent): void {\n DDManager.dragElement = this;\n this.helper = this._createHelper(event);\n this._setupHelperContainmentStyle();\n this.dragOffset = this._getDragOffset(event, this.el, this.helperContainment);\n const ev = DDUtils.initEvent<DragEvent>(event, { target: this.el, type: 'dragstart' });\n if (this.helper !== this.el) {\n this._setupDragFollowNodeNotifyStart(ev);\n // immediately set external helper initial position to avoid flickering behavior and unnecessary looping in `_packNodes()`\n this._dragFollow(event);\n } else {\n this.dragFollowTimer = window.setTimeout(() => {\n delete this.dragFollowTimer;\n this._setupDragFollowNodeNotifyStart(ev);\n }, 0);\n }\n this._cancelDragGhost(event);\n }\n\n /** @internal */\n protected _setupDragFollowNodeNotifyStart(ev: Event): DDDraggable {\n this._setupHelperStyle();\n document.addEventListener('dragover', this._drag, DDDraggable.dragEventListenerOption);\n this.dragEl.addEventListener('dragend', this._dragEnd);\n if (this.option.start) {\n this.option.start(ev, this.ui());\n }\n this.dragging = true;\n this.helper.classList.add('ui-draggable-dragging');\n this.triggerEvent('dragstart', ev);\n return this;\n }\n\n /** @internal */\n protected _drag(event: DragEvent): void {\n // Safari: prevent default to allow drop to happen instead of reverting back (with animation) and delaying dragend #1541\n // https://stackoverflow.com/questions/61760755/how-to-fire-dragend-event-immediately\n event.preventDefault();\n this._dragFollow(event);\n const ev = DDUtils.initEvent<DragEvent>(event, { target: this.el, type: 'drag' });\n if (this.option.drag) {\n this.option.drag(ev, this.ui());\n }\n this.triggerEvent('drag', ev);\n }\n\n /** @internal */\n protected _dragEnd(event: DragEvent): void {\n if (this.dragFollowTimer) {\n clearTimeout(this.dragFollowTimer);\n delete this.dragFollowTimer;\n return;\n } else {\n if (this.paintTimer) {\n cancelAnimationFrame(this.paintTimer);\n }\n document.removeEventListener('dragover', this._drag, DDDraggable.dragEventListenerOption);\n this.dragEl.removeEventListener('dragend', this._dragEnd);\n }\n this.dragging = false;\n this.helper.classList.remove('ui-draggable-dragging');\n this.helperContainment.style.position = this.parentOriginStylePosition || null;\n if (this.helper === this.el) {\n this._removeHelperStyle();\n } else {\n this.helper.remove();\n }\n const ev = DDUtils.initEvent<DragEvent>(event, { target: this.el, type: 'dragstop' });\n if (this.option.stop) {\n this.option.stop(ev); // Note: ui() not used by gridstack so don't pass\n }\n this.triggerEvent('dragstop', ev);\n delete DDManager.dragElement;\n delete this.helper;\n }\n\n /** @internal create a clone copy (or user defined method) of the original drag item if set */\n protected _createHelper(event: DragEvent): HTMLElement {\n let helper = this.el;\n if (typeof this.option.helper === 'function') {\n helper = this.option.helper(event);\n } else if (this.option.helper === 'clone') {\n helper = DDUtils.clone(this.el);\n }\n if (!document.body.contains(helper)) {\n DDUtils.appendTo(helper, this.option.appendTo === 'parent' ? this.el.parentNode : this.option.appendTo);\n }\n if (helper === this.el) {\n this.dragElementOriginStyle = DDDraggable.originStyleProp.map(prop => this.el.style[prop]);\n }\n return helper;\n }\n\n /** @internal */\n protected _setupHelperStyle(): DDDraggable {\n // TODO: set all at once with style.cssText += ... ? https://stackoverflow.com/questions/3968593\n const rec = this.helper.getBoundingClientRect();\n const style = this.helper.style;\n style.pointerEvents = 'none';\n style['min-width'] = 0; // since we no longer relative to our parent and we don't resize anyway (normally 100/#column %)\n style.width = this.dragOffset.width + 'px';\n style.height = this.dragOffset.height + 'px';\n style.willChange = 'left, top';\n style.position = 'fixed'; // let us drag between grids by not clipping as parent .grid-stack is position: 'relative'\n style.left = rec.left + 'px';\n style.top = rec.top + 'px';\n style.transition = 'none'; // show up instantly\n setTimeout(() => {\n if (this.helper) {\n style.transition = null; // recover animation\n }\n }, 0);\n return this;\n }\n\n /** @internal */\n protected _removeHelperStyle(): DDDraggable {\n let node = (this.helper as GridItemHTMLElement)?.gridstackNode;\n // don't bother restoring styles if we're gonna remove anyway...\n if (this.dragElementOriginStyle && (!node || !node._isAboutToRemove)) {\n let helper = this.helper;\n DDDraggable.originStyleProp.forEach(prop => helper.style[prop] = this.dragElementOriginStyle[prop] || null);\n // show up instantly otherwise we animate to off the grid when switching back to 'absolute' from 'fixed'\n helper.style.transition = 'none';\n let transition = this.dragElementOriginStyle['transition'] || null;\n setTimeout(() => helper.style.transition = transition, 0); // recover animation from saved vars\n }\n delete this.dragElementOriginStyle;\n return this;\n }\n\n /** @internal */\n protected _dragFollow(event: DragEvent): void {\n if (this.paintTimer) {\n cancelAnimationFrame(this.paintTimer);\n }\n this.paintTimer = requestAnimationFrame(() => {\n delete this.paintTimer;\n const offset = this.dragOffset;\n let containmentRect = { left: 0, top: 0 };\n if (this.helper.style.position === 'absolute') {\n const { left, top } = this.helperContainment.getBoundingClientRect();\n containmentRect = { left, top };\n }\n this.helper.style.left = event.clientX + offset.offsetLeft - containmentRect.left + 'px';\n this.helper.style.top = event.clientY + offset.offsetTop - containmentRect.top + 'px';\n });\n }\n\n /** @internal */\n protected _setupHelperContainmentStyle(): DDDraggable {\n this.helperContainment = this.helper.parentElement;\n if (this.helper.style.position !== 'fixed') {\n this.parentOriginStylePosition = this.helperContainment.style.position;\n if (window.getComputedStyle(this.helperContainment).position.match(/static/)) {\n this.helperContainment.style.position = 'relative';\n }\n }\n return this;\n }\n\n /** @internal prevent the default ghost image to be created (which has wrong as we move the helper/element instead\n * (legacy jquery UI code updates the top/left of the item).\n * TODO: maybe use mouse event instead of HTML5 drag as we have to work around it anyway, or change code to not update\n * the actual grid-item but move the ghost image around (and special case jq version) ?\n **/\n protected _cancelDragGhost(e: DragEvent): DDDraggable {\n /* doesn't seem to do anything...\n let t = e.dataTransfer;\n t.effectAllowed = 'none';\n t.dropEffect = 'none';\n t.setData('text', '');\n */\n\n // NOTE: according to spec (and required by Safari see #1540) the image has to be visible in the browser (in dom and not hidden) so make it a 1px div\n let img = document.createElement('div');\n img.style.width = '1px';\n img.style.height = '1px';\n img.style.position = 'fixed'; // prevent unwanted scrollbar\n document.body.appendChild(img);\n e.dataTransfer.setDragImage(img, 0, 0);\n setTimeout(() => document.body.removeChild(img)); // nuke once drag had a chance to grab this 'image'\n\n e.stopPropagation();\n return this;\n }\n\n /** @internal */\n protected _getDragOffset(event: DragEvent, el: HTMLElement, parent: HTMLElement): DragOffset {\n\n // in case ancestor has transform/perspective css properties that change the viewpoint\n let xformOffsetX = 0;\n let xformOffsetY = 0;\n if (parent) {\n const testEl = document.createElement('div');\n DDUtils.addElStyles(testEl, {\n opacity: '0',\n position: 'fixed',\n top: 0 + 'px',\n left: 0 + 'px',\n width: '1px',\n height: '1px',\n zIndex: '-999999',\n });\n parent.appendChild(testEl);\n const testElPosition = testEl.getBoundingClientRect();\n parent.removeChild(testEl);\n xformOffsetX = testElPosition.left;\n xformOffsetY = testElPosition.top;\n // TODO: scale ?\n }\n\n const targetOffset = el.getBoundingClientRect();\n return {\n left: targetOffset.left,\n top: targetOffset.top,\n offsetLeft: - event.clientX + targetOffset.left - xformOffsetX,\n offsetTop: - event.clientY + targetOffset.top - xformOffsetY,\n width: targetOffset.width,\n height: targetOffset.height\n };\n }\n\n /** @internal TODO: set to public as called by DDDroppable! */\n public ui = (): DDUIData => {\n const containmentEl = this.el.parentElement;\n const containmentRect = containmentEl.getBoundingClientRect();\n const offset = this.helper.getBoundingClientRect();\n return {\n position: { //Current CSS position of the helper as { top, left } object\n top: offset.top - containmentRect.top,\n left: offset.left - containmentRect.left\n }\n /* not used by GridStack for now...\n helper: [this.helper], //The object arr representing the helper that's being dragged.\n offset: { top: offset.top, left: offset.left } // Current offset position of the helper as { top, left } object.\n */\n };\n }\n}\n\n\n"]}
|
package/dist/h5/dd-droppable.js
DELETED
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* dd-droppable.ts 5.1.0
|
|
4
|
-
* Copyright (c) 2021-2022 Alain Dumesny - see GridStack root license
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.DDDroppable = void 0;
|
|
8
|
-
const dd_manager_1 = require("./dd-manager");
|
|
9
|
-
const dd_base_impl_1 = require("./dd-base-impl");
|
|
10
|
-
const dd_utils_1 = require("./dd-utils");
|
|
11
|
-
// TEST let count = 0;
|
|
12
|
-
class DDDroppable extends dd_base_impl_1.DDBaseImplement {
|
|
13
|
-
constructor(el, opts = {}) {
|
|
14
|
-
super();
|
|
15
|
-
this.el = el;
|
|
16
|
-
this.option = opts;
|
|
17
|
-
// create var event binding so we can easily remove and still look like TS methods (unlike anonymous functions)
|
|
18
|
-
this._dragEnter = this._dragEnter.bind(this);
|
|
19
|
-
this._dragOver = this._dragOver.bind(this);
|
|
20
|
-
this._dragLeave = this._dragLeave.bind(this);
|
|
21
|
-
this._drop = this._drop.bind(this);
|
|
22
|
-
this.el.classList.add('ui-droppable');
|
|
23
|
-
this.el.addEventListener('dragenter', this._dragEnter);
|
|
24
|
-
this._setupAccept();
|
|
25
|
-
}
|
|
26
|
-
on(event, callback) {
|
|
27
|
-
super.on(event, callback);
|
|
28
|
-
}
|
|
29
|
-
off(event) {
|
|
30
|
-
super.off(event);
|
|
31
|
-
}
|
|
32
|
-
enable() {
|
|
33
|
-
if (!this.disabled)
|
|
34
|
-
return;
|
|
35
|
-
super.enable();
|
|
36
|
-
this.el.classList.remove('ui-droppable-disabled');
|
|
37
|
-
this.el.addEventListener('dragenter', this._dragEnter);
|
|
38
|
-
}
|
|
39
|
-
disable(forDestroy = false) {
|
|
40
|
-
if (this.disabled)
|
|
41
|
-
return;
|
|
42
|
-
super.disable();
|
|
43
|
-
if (!forDestroy)
|
|
44
|
-
this.el.classList.add('ui-droppable-disabled');
|
|
45
|
-
this.el.removeEventListener('dragenter', this._dragEnter);
|
|
46
|
-
}
|
|
47
|
-
destroy() {
|
|
48
|
-
this._removeLeaveCallbacks();
|
|
49
|
-
this.disable(true);
|
|
50
|
-
this.el.classList.remove('ui-droppable');
|
|
51
|
-
this.el.classList.remove('ui-droppable-disabled');
|
|
52
|
-
super.destroy();
|
|
53
|
-
}
|
|
54
|
-
updateOption(opts) {
|
|
55
|
-
Object.keys(opts).forEach(key => this.option[key] = opts[key]);
|
|
56
|
-
this._setupAccept();
|
|
57
|
-
return this;
|
|
58
|
-
}
|
|
59
|
-
/** @internal called when the cursor enters our area - prepare for a possible drop and track leaving */
|
|
60
|
-
_dragEnter(event) {
|
|
61
|
-
// TEST console.log(`${count++} Enter ${(this.el as GridHTMLElement).gridstack.opts.id}`);
|
|
62
|
-
if (!this._canDrop())
|
|
63
|
-
return;
|
|
64
|
-
event.preventDefault();
|
|
65
|
-
event.stopPropagation();
|
|
66
|
-
// ignore multiple 'dragenter' as we go over existing items
|
|
67
|
-
if (this.moving)
|
|
68
|
-
return;
|
|
69
|
-
this.moving = true;
|
|
70
|
-
const ev = dd_utils_1.DDUtils.initEvent(event, { target: this.el, type: 'dropover' });
|
|
71
|
-
if (this.option.over) {
|
|
72
|
-
this.option.over(ev, this._ui(dd_manager_1.DDManager.dragElement));
|
|
73
|
-
}
|
|
74
|
-
this.triggerEvent('dropover', ev);
|
|
75
|
-
this.el.addEventListener('dragover', this._dragOver);
|
|
76
|
-
this.el.addEventListener('drop', this._drop);
|
|
77
|
-
this.el.addEventListener('dragleave', this._dragLeave);
|
|
78
|
-
// Update: removed that as it causes nested grids to no receive dragenter events when parent drags and sets this for #992. not seeing cursor flicker (chrome).
|
|
79
|
-
// this.el.classList.add('ui-droppable-over');
|
|
80
|
-
// make sure when we enter this, that the last one gets a leave to correctly cleanup as we don't always do
|
|
81
|
-
if (DDDroppable.lastActive && DDDroppable.lastActive !== this) {
|
|
82
|
-
DDDroppable.lastActive._dragLeave(event, true);
|
|
83
|
-
}
|
|
84
|
-
DDDroppable.lastActive = this;
|
|
85
|
-
}
|
|
86
|
-
/** @internal called when an moving to drop item is being dragged over - do nothing but eat the event */
|
|
87
|
-
_dragOver(event) {
|
|
88
|
-
event.preventDefault();
|
|
89
|
-
event.stopPropagation();
|
|
90
|
-
}
|
|
91
|
-
/** @internal called when the item is leaving our area, stop tracking if we had moving item */
|
|
92
|
-
_dragLeave(event, forceLeave) {
|
|
93
|
-
var _a;
|
|
94
|
-
// TEST console.log(`${count++} Leave ${(this.el as GridHTMLElement).gridstack.opts.id}`);
|
|
95
|
-
event.preventDefault();
|
|
96
|
-
event.stopPropagation();
|
|
97
|
-
// ignore leave events on our children (we get them when starting to drag our items)
|
|
98
|
-
// but exclude nested grids since we would still be leaving ourself,
|
|
99
|
-
// but don't handle leave if we're dragging a nested grid around
|
|
100
|
-
if (!forceLeave) {
|
|
101
|
-
let onChild = dd_utils_1.DDUtils.inside(event, this.el);
|
|
102
|
-
let drag = dd_manager_1.DDManager.dragElement.el;
|
|
103
|
-
if (onChild && !((_a = drag.gridstackNode) === null || _a === void 0 ? void 0 : _a.subGrid)) { // dragging a nested grid ?
|
|
104
|
-
let nestedEl = this.el.gridstack.engine.nodes.filter(n => n.subGrid).map(n => n.subGrid.el);
|
|
105
|
-
onChild = !nestedEl.some(el => dd_utils_1.DDUtils.inside(event, el));
|
|
106
|
-
}
|
|
107
|
-
if (onChild)
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
if (this.moving) {
|
|
111
|
-
const ev = dd_utils_1.DDUtils.initEvent(event, { target: this.el, type: 'dropout' });
|
|
112
|
-
if (this.option.out) {
|
|
113
|
-
this.option.out(ev, this._ui(dd_manager_1.DDManager.dragElement));
|
|
114
|
-
}
|
|
115
|
-
this.triggerEvent('dropout', ev);
|
|
116
|
-
}
|
|
117
|
-
this._removeLeaveCallbacks();
|
|
118
|
-
if (DDDroppable.lastActive === this) {
|
|
119
|
-
delete DDDroppable.lastActive;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
/** @internal item is being dropped on us - call the client drop event */
|
|
123
|
-
_drop(event) {
|
|
124
|
-
if (!this.moving)
|
|
125
|
-
return; // should not have received event...
|
|
126
|
-
event.preventDefault();
|
|
127
|
-
const ev = dd_utils_1.DDUtils.initEvent(event, { target: this.el, type: 'drop' });
|
|
128
|
-
if (this.option.drop) {
|
|
129
|
-
this.option.drop(ev, this._ui(dd_manager_1.DDManager.dragElement));
|
|
130
|
-
}
|
|
131
|
-
this.triggerEvent('drop', ev);
|
|
132
|
-
this._removeLeaveCallbacks();
|
|
133
|
-
}
|
|
134
|
-
/** @internal called to remove callbacks when leaving or dropping */
|
|
135
|
-
_removeLeaveCallbacks() {
|
|
136
|
-
if (!this.moving) {
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
delete this.moving;
|
|
140
|
-
this.el.removeEventListener('dragover', this._dragOver);
|
|
141
|
-
this.el.removeEventListener('drop', this._drop);
|
|
142
|
-
this.el.removeEventListener('dragleave', this._dragLeave);
|
|
143
|
-
// Update: removed that as it causes nested grids to no receive dragenter events when parent drags and sets this for #992. not seeing cursor flicker (chrome).
|
|
144
|
-
// this.el.classList.remove('ui-droppable-over');
|
|
145
|
-
}
|
|
146
|
-
/** @internal */
|
|
147
|
-
_canDrop() {
|
|
148
|
-
return dd_manager_1.DDManager.dragElement && (!this.accept || this.accept(dd_manager_1.DDManager.dragElement.el));
|
|
149
|
-
}
|
|
150
|
-
/** @internal */
|
|
151
|
-
_setupAccept() {
|
|
152
|
-
if (this.option.accept && typeof this.option.accept === 'string') {
|
|
153
|
-
this.accept = (el) => {
|
|
154
|
-
return el.matches(this.option.accept);
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
else {
|
|
158
|
-
this.accept = this.option.accept;
|
|
159
|
-
}
|
|
160
|
-
return this;
|
|
161
|
-
}
|
|
162
|
-
/** @internal */
|
|
163
|
-
_ui(drag) {
|
|
164
|
-
return Object.assign({ draggable: drag.el }, drag.ui());
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
exports.DDDroppable = DDDroppable;
|
|
168
|
-
//# sourceMappingURL=dd-droppable.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dd-droppable.js","sourceRoot":"","sources":["../../src/h5/dd-droppable.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,6CAAyC;AACzC,iDAAuE;AACvE,yCAAqC;AAWrC,sBAAsB;AAEtB,MAAa,WAAY,SAAQ,8BAAe;IAU9C,YAAY,EAAe,EAAE,OAAuB,EAAE;QACpD,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,+GAA+G;QAC/G,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7C,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC3C,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7C,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEnC,IAAI,CAAC,EAAE,CAAC,SAAS,C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AAE,CAAC,mBAAmB,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;QACxD,IAAI,CAAC,EAAE,CAAC,mBAAmB,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QAChD,IAAI,CAAC,EAAE,CAAC,mBAAmB,CAAC,WAAW,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QAC1D,8JAA8J;QAC9J,iDAAiD;IACnD,CAAC;IAED,gBAAgB;IACN,QAAQ;QAChB,OAAO,sBAAS,CAAC,WAAW,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,sBAAS,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC;IAC1F,CAAC;IAED,gBAAgB;IACN,YAAY;QACpB,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,IAAI,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,QAAQ,EAAE;YAChE,IAAI,CAAC,MAAM,GAAG,CAAC,EAAe,EAAE,EAAE;gBAChC,OAAO,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,MAAgB,CAAC,CAAA;YACjD,CAAC,CAAA;SACF;aAAM;YACL,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,MAAwC,CAAC;SACpE;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,gBAAgB;IACN,GAAG,CAAC,IAAiB;QAC7B,uBACE,SAAS,EAAE,IAAI,CAAC,EAAE,IACf,IAAI,CAAC,EAAE,EAAE,EACZ;IACJ,CAAC;CACF;AAhLD,kCAgLC","sourcesContent":["/**\n * dd-droppable.ts 5.1.0\n * Copyright (c) 2021-2022 Alain Dumesny - see GridStack root license\n */\n\nimport { DDDraggable } from './dd-draggable';\nimport { DDManager } from './dd-manager';\nimport { DDBaseImplement, HTMLElementExtendOpt } from './dd-base-impl';\nimport { DDUtils } from './dd-utils';\nimport { GridHTMLElement, GridStack } from '../gridstack';\nimport { GridItemHTMLElement } from '../types';\n\nexport interface DDDroppableOpt {\n accept?: string | ((el: HTMLElement) => boolean);\n drop?: (event: DragEvent, ui) => void;\n over?: (event: DragEvent, ui) => void;\n out?: (event: DragEvent, ui) => void;\n}\n\n// TEST let count = 0;\n\nexport class DDDroppable extends DDBaseImplement implements HTMLElementExtendOpt<DDDroppableOpt> {\n\n public accept: (el: HTMLElement) => boolean;\n public el: HTMLElement;\n public option: DDDroppableOpt;\n\n /** @internal */\n protected moving: boolean;\n protected static lastActive: DDDroppable;\n\n constructor(el: HTMLElement, opts: DDDroppableOpt = {}) {\n super();\n this.el = el;\n this.option = opts;\n // create var event binding so we can easily remove and still look like TS methods (unlike anonymous functions)\n this._dragEnter = this._dragEnter.bind(this);\n this._dragOver = this._dragOver.bind(this);\n this._dragLeave = this._dragLeave.bind(this);\n this._drop = this._drop.bind(this);\n\n this.el.classList.add('ui-droppable');\n this.el.addEventListener('dragenter', this._dragEnter);\n this._setupAccept();\n }\n\n public on(event: 'drop' | 'dropover' | 'dropout', callback: (event: DragEvent) => void): void {\n super.on(event, callback);\n }\n\n public off(event: 'drop' | 'dropover' | 'dropout'): void {\n super.off(event);\n }\n\n public enable(): void {\n if (!this.disabled) return;\n super.enable();\n this.el.classList.remove('ui-droppable-disabled');\n this.el.addEventListener('dragenter', this._dragEnter);\n }\n\n public disable(forDestroy=false): void {\n if (this.disabled) return;\n super.disable();\n if (!forDestroy) this.el.classList.add('ui-droppable-disabled');\n this.el.removeEventListener('dragenter', this._dragEnter);\n }\n\n public destroy(): void {\n this._removeLeaveCallbacks();\n this.disable(true);\n this.el.classList.remove('ui-droppable');\n this.el.classList.remove('ui-droppable-disabled');\n super.destroy();\n }\n\n public updateOption(opts: DDDroppableOpt): DDDroppable {\n Object.keys(opts).forEach(key => this.option[key] = opts[key]);\n this._setupAccept();\n return this;\n }\n\n /** @internal called when the cursor enters our area - prepare for a possible drop and track leaving */\n protected _dragEnter(event: DragEvent): void {\n // TEST console.log(`${count++} Enter ${(this.el as GridHTMLElement).gridstack.opts.id}`);\n if (!this._canDrop()) return;\n event.preventDefault();\n event.stopPropagation();\n\n // ignore multiple 'dragenter' as we go over existing items\n if (this.moving) return;\n this.moving = true;\n\n const ev = DDUtils.initEvent<DragEvent>(event, { target: this.el, type: 'dropover' });\n if (this.option.over) {\n this.option.over(ev, this._ui(DDManager.dragElement))\n }\n this.triggerEvent('dropover', ev);\n this.el.addEventListener('dragover', this._dragOver);\n this.el.addEventListener('drop', this._drop);\n this.el.addEventListener('dragleave', this._dragLeave);\n // Update: removed that as it causes nested grids to no receive dragenter events when parent drags and sets this for #992. not seeing cursor flicker (chrome).\n // this.el.classList.add('ui-droppable-over');\n\n // make sure when we enter this, that the last one gets a leave to correctly cleanup as we don't always do\n if (DDDroppable.lastActive && DDDroppable.lastActive !== this) {\n DDDroppable.lastActive._dragLeave(event, true);\n }\n DDDroppable.lastActive = this;\n }\n\n /** @internal called when an moving to drop item is being dragged over - do nothing but eat the event */\n protected _dragOver(event: DragEvent): void {\n event.preventDefault();\n event.stopPropagation();\n }\n\n /** @internal called when the item is leaving our area, stop tracking if we had moving item */\n protected _dragLeave(event: DragEvent, forceLeave?: boolean): void {\n // TEST console.log(`${count++} Leave ${(this.el as GridHTMLElement).gridstack.opts.id}`);\n event.preventDefault();\n event.stopPropagation();\n\n // ignore leave events on our children (we get them when starting to drag our items)\n // but exclude nested grids since we would still be leaving ourself, \n // but don't handle leave if we're dragging a nested grid around\n if (!forceLeave) {\n let onChild = DDUtils.inside(event, this.el);\n let drag: GridItemHTMLElement = DDManager.dragElement.el;\n if (onChild && !drag.gridstackNode?.subGrid) { // dragging a nested grid ?\n let nestedEl = (this.el as GridHTMLElement).gridstack.engine.nodes.filter(n => n.subGrid).map(n => (n.subGrid as GridStack).el);\n onChild = !nestedEl.some(el => DDUtils.inside(event, el));\n }\n if (onChild) return;\n }\n\n if (this.moving) {\n const ev = DDUtils.initEvent<DragEvent>(event, { target: this.el, type: 'dropout' });\n if (this.option.out) {\n this.option.out(ev, this._ui(DDManager.dragElement))\n }\n this.triggerEvent('dropout', ev);\n }\n this._removeLeaveCallbacks();\n\n if (DDDroppable.lastActive === this) {\n delete DDDroppable.lastActive;\n }\n }\n\n /** @internal item is being dropped on us - call the client drop event */\n protected _drop(event: DragEvent): void {\n if (!this.moving) return; // should not have received event...\n event.preventDefault();\n const ev = DDUtils.initEvent<DragEvent>(event, { target: this.el, type: 'drop' });\n if (this.option.drop) {\n this.option.drop(ev, this._ui(DDManager.dragElement))\n }\n this.triggerEvent('drop', ev);\n this._removeLeaveCallbacks();\n }\n\n /** @internal called to remove callbacks when leaving or dropping */\n protected _removeLeaveCallbacks() {\n if (!this.moving) { return; }\n delete this.moving;\n this.el.removeEventListener('dragover', this._dragOver);\n this.el.removeEventListener('drop', this._drop);\n this.el.removeEventListener('dragleave', this._dragLeave);\n // Update: removed that as it causes nested grids to no receive dragenter events when parent drags and sets this for #992. not seeing cursor flicker (chrome).\n // this.el.classList.remove('ui-droppable-over');\n }\n\n /** @internal */\n protected _canDrop(): boolean {\n return DDManager.dragElement && (!this.accept || this.accept(DDManager.dragElement.el));\n }\n\n /** @internal */\n protected _setupAccept(): DDDroppable {\n if (this.option.accept && typeof this.option.accept === 'string') {\n this.accept = (el: HTMLElement) => {\n return el.matches(this.option.accept as string)\n }\n } else {\n this.accept = this.option.accept as ((el: HTMLElement) => boolean);\n }\n return this;\n }\n\n /** @internal */\n protected _ui(drag: DDDraggable) {\n return {\n draggable: drag.el,\n ...drag.ui()\n };\n }\n}\n\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dd-element.js","sourceRoot":"","sources":["../../src/h5/dd-element.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,iDAA6D;AAE7D,iDAA6D;AAC7D,iDAA6D;AAM7D,MAAa,SAAS;IAYpB,YAAY,EAAiB;QAC3B,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACf,C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CAAC;IAEM,cAAc,CAAC,IAAoB;QACxC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;YACrB,IAAI,CAAC,WAAW,GAAG,IAAI,0BAAW,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;SACnD;aAAM;YACL,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;SACrC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,cAAc;QACnB,IAAI,IAAI,CAAC,WAAW,EAAE;YACpB,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;YAC3B,OAAO,IAAI,CAAC,WAAW,CAAC;SACzB;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAxFD,8BAwFC","sourcesContent":["/**\n * dd-elements.ts 5.1.0\n * Copyright (c) 2021 Alain Dumesny - see GridStack root license\n */\n\nimport { DDResizable, DDResizableOpt } from './dd-resizable';\nimport { GridItemHTMLElement } from './../types';\nimport { DDDraggable, DDDraggableOpt } from './dd-draggable';\nimport { DDDroppable, DDDroppableOpt } from './dd-droppable';\n\nexport interface DDElementHost extends GridItemHTMLElement {\n ddElement?: DDElement;\n}\n\nexport class DDElement {\n\n static init(el: DDElementHost): DDElement {\n if (!el.ddElement) { el.ddElement = new DDElement(el); }\n return el.ddElement;\n }\n\n public el: DDElementHost;\n public ddDraggable?: DDDraggable;\n public ddDroppable?: DDDroppable;\n public ddResizable?: DDResizable;\n\n constructor(el: DDElementHost) {\n this.el = el;\n }\n\n public on(eventName: string, callback: (event: MouseEvent) => void): DDElement {\n if (this.ddDraggable && ['drag', 'dragstart', 'dragstop'].indexOf(eventName) > -1) {\n this.ddDraggable.on(eventName as 'drag' | 'dragstart' | 'dragstop', callback);\n } else if (this.ddDroppable && ['drop', 'dropover', 'dropout'].indexOf(eventName) > -1) {\n this.ddDroppable.on(eventName as 'drop' | 'dropover' | 'dropout', callback);\n } else if (this.ddResizable && ['resizestart', 'resize', 'resizestop'].indexOf(eventName) > -1) {\n this.ddResizable.on(eventName as 'resizestart' | 'resize' | 'resizestop', callback);\n }\n return this;\n }\n\n public off(eventName: string): DDElement {\n if (this.ddDraggable && ['drag', 'dragstart', 'dragstop'].indexOf(eventName) > -1) {\n this.ddDraggable.off(eventName as 'drag' | 'dragstart' | 'dragstop');\n } else if (this.ddDroppable && ['drop', 'dropover', 'dropout'].indexOf(eventName) > -1) {\n this.ddDroppable.off(eventName as 'drop' | 'dropover' | 'dropout');\n } else if (this.ddResizable && ['resizestart', 'resize', 'resizestop'].indexOf(eventName) > -1) {\n this.ddResizable.off(eventName as 'resizestart' | 'resize' | 'resizestop');\n }\n return this;\n }\n\n public setupDraggable(opts: DDDraggableOpt): DDElement {\n if (!this.ddDraggable) {\n this.ddDraggable = new DDDraggable(this.el, opts);\n } else {\n this.ddDraggable.updateOption(opts);\n }\n return this;\n }\n\n public cleanDraggable(): DDElement {\n if (this.ddDraggable) {\n this.ddDraggable.destroy();\n delete this.ddDraggable;\n }\n return this;\n }\n\n public setupResizable(opts: DDResizableOpt): DDElement {\n if (!this.ddResizable) {\n this.ddResizable = new DDResizable(this.el, opts);\n } else {\n this.ddResizable.updateOption(opts);\n }\n return this;\n }\n\n public cleanResizable(): DDElement {\n if (this.ddResizable) {\n this.ddResizable.destroy();\n delete this.ddResizable;\n }\n return this;\n }\n\n public setupDroppable(opts: DDDroppableOpt): DDElement {\n if (!this.ddDroppable) {\n this.ddDroppable = new DDDroppable(this.el, opts);\n } else {\n this.ddDroppable.updateOption(opts);\n }\n return this;\n }\n\n public cleanDroppable(): DDElement {\n if (this.ddDroppable) {\n this.ddDroppable.destroy();\n delete this.ddDroppable;\n }\n return this;\n }\n}\n"]}
|
package/dist/h5/dd-manager.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dd-manager.js","sourceRoot":"","sources":["../../src/h5/dd-manager.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,MAAa,SAAS;CAErB;AAFD,8BAEC","sourcesContent":["/**\n * dd-manager.ts 5.1.0\n * Copyright (c) 2021 Alain Dumesny - see GridStack root license\n */\n\nimport { DDDraggable } from './dd-draggable';\n\nexport class DDManager {\n static dragElement: DDDraggable;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dd-resizable-handle.js","sourceRoot":"","sources":["../../src/h5/dd-resizable-handle.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAQH,MAAa,iBAAiB;IAgB5B,YAAY,IAAiB,EAAE,SAAiB,EAAE,MAA4B;QAP9E,uEAAuE;QAC7D,WAAM,GAAG,KAAK,CAAC;QAOvB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,GAAG,GAAG,SAAS,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,+GAA+G;QAC/G,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7C,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7C,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEzC,IAAI,CAAC,KAAK,EAAE,CAAC;IACf,CAAC;IAED,gBAAgB;IACN,KAAK;QACb,MAAM,EAAE,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QACzC,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;QACxC,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,iBAAiB,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;QAC3D,EAAE,CAAC,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC;QACxB,EAAE,CAAC,KAAK,CAAC,UAAU,GAAG,MAAM,CAAC;QAC7B,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;YACjE,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;YACnB,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;SAClD;aAAM,IAAI,IAAI,CAAC,MAAM,EAAE;YACtB,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;SAC/B;IACH,CAAC;IAED,gBAAgB;IACN,QAAQ,CAAC,CAAa;QAC9B,IAAI,IAAI,CAAC,MAAM,EAAE;YACf,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;SAC/B;QACD,QAAQ,CAAC,mBAAmB,CAAC,WAAW,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;QACjE,QAAQ,CAAC,mBAAmB,CAAC,SAAS,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;QACvD,OAAO,IAAI,CAAC,MAAM,CAAC;QACnB,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAED,gBAAgB;IACN,aAAa,CAAC,IAAY,EAAE,KAAiB;QACrD,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;YAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC;QAChD,OAAO,IAAI,CAAC;IACd,CAAC;;AAtFH,8CAuFC;AA1EC,gBAAgB;AACC,wBAAM,GAAG,eAAe,CAAC","sourcesContent":["/**\n * dd-resizable-handle.ts 5.1.0\n * Copyright (c) 2021-2022 Alain Dumesny - see GridStack root license\n */\n\nexport interface DDResizableHandleOpt {\n start?: (event) => void;\n move?: (event) => void;\n stop?: (event) => void;\n}\n\nexport class DDResizableHandle {\n /** @internal */\n protected el: HTMLElement;\n /** @internal */\n protected host: HTMLElement;\n /** @internal */\n protected option: DDResizableHandleOpt;\n /** @internal */\n protected dir: string;\n /** @internal true after we've moved enough pixels to start a resize */\n protected moving = false;\n /** @internal */\n protected mouseDownEvent: MouseEvent;\n /** @internal */\n protected static prefix = 'ui-resizable-';\n\n constructor(host: HTMLElement, direction: string, option: DDResizableHandleOpt) {\n this.host = host;\n this.dir = direction;\n this.option = option;\n // create var event binding so we can easily remove and still look like TS methods (unlike anonymous functions)\n this._mouseDown = this._mouseDown.bind(this);\n this._mouseMove = this._mouseMove.bind(this);\n this._mouseUp = this._mouseUp.bind(this);\n\n this._init();\n }\n\n /** @internal */\n protected _init(): DDResizableHandle {\n const el = document.createElement('div');\n el.classList.add('ui-resizable-handle');\n el.classList.add(`${DDResizableHandle.prefix}${this.dir}`);\n el.style.zIndex = '100';\n el.style.userSelect = 'none';\n this.el = el;\n this.host.appendChild(this.el);\n this.el.addEventListener('mousedown', this._mouseDown);\n return this;\n }\n\n /** call this when resize handle needs to be removed and cleaned up */\n public destroy(): DDResizableHandle {\n if (this.moving) this._mouseUp(this.mouseDownEvent);\n this.el.removeEventListener('mousedown', this._mouseDown);\n this.host.removeChild(this.el);\n delete this.el;\n delete this.host;\n return this;\n }\n\n /** @internal called on mouse down on us: capture move on the entire document (mouse might not stay on us) until we release the mouse */\n protected _mouseDown(e: MouseEvent): void {\n e.preventDefault();\n this.mouseDownEvent = e;\n document.addEventListener('mousemove', this._mouseMove, true); // capture, not bubble\n document.addEventListener('mouseup', this._mouseUp);\n }\n\n /** @internal */\n protected _mouseMove(e: MouseEvent): void {\n let s = this.mouseDownEvent;\n // don't start unless we've moved at least 3 pixels\n if (!this.moving && Math.abs(e.x - s.x) + Math.abs(e.y - s.y) > 2) {\n this.moving = true;\n this._triggerEvent('start', this.mouseDownEvent);\n } else if (this.moving) {\n this._triggerEvent('move', e);\n }\n }\n\n /** @internal */\n protected _mouseUp(e: MouseEvent): void {\n if (this.moving) {\n this._triggerEvent('stop', e);\n }\n document.removeEventListener('mousemove', this._mouseMove, true);\n document.removeEventListener('mouseup', this._mouseUp);\n delete this.moving;\n delete this.mouseDownEvent;\n }\n\n /** @internal */\n protected _triggerEvent(name: string, event: MouseEvent): DDResizableHandle {\n if (this.option[name]) this.option[name](event);\n return this;\n }\n}\n"]}
|