gridstack 7.3.0 → 8.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 +9 -2
- package/dist/dd-base-impl.d.ts +20 -20
- package/dist/dd-base-impl.js +31 -35
- package/dist/dd-base-impl.js.map +1 -1
- package/dist/dd-draggable.d.ts +28 -28
- package/dist/dd-draggable.js +336 -344
- package/dist/dd-draggable.js.map +1 -1
- package/dist/dd-droppable.d.ts +26 -26
- package/dist/dd-droppable.js +146 -148
- package/dist/dd-droppable.js.map +1 -1
- package/dist/dd-element.d.ts +27 -27
- package/dist/dd-element.js +90 -94
- package/dist/dd-element.js.map +1 -1
- package/dist/dd-gridstack.d.ts +34 -34
- package/dist/dd-gridstack.js +127 -124
- package/dist/dd-gridstack.js.map +1 -1
- package/dist/dd-manager.d.ts +22 -22
- package/dist/dd-manager.js +9 -13
- package/dist/dd-manager.js.map +1 -1
- package/dist/dd-resizable-handle.d.ts +14 -14
- package/dist/dd-resizable-handle.js +102 -105
- package/dist/dd-resizable-handle.js.map +1 -1
- package/dist/dd-resizable.d.ts +28 -28
- package/dist/dd-resizable.js +290 -296
- package/dist/dd-resizable.js.map +1 -1
- package/dist/dd-touch.d.ts +33 -33
- package/dist/dd-touch.js +173 -182
- package/dist/dd-touch.js.map +1 -1
- package/dist/es5/dd-base-impl.d.ts +20 -20
- package/dist/es5/dd-base-impl.js +40 -40
- package/dist/es5/dd-base-impl.js.map +1 -1
- package/dist/es5/dd-draggable.d.ts +28 -28
- package/dist/es5/dd-draggable.js +366 -367
- package/dist/es5/dd-draggable.js.map +1 -1
- package/dist/es5/dd-droppable.d.ts +26 -26
- package/dist/es5/dd-droppable.js +181 -179
- package/dist/es5/dd-droppable.js.map +1 -1
- package/dist/es5/dd-element.d.ts +27 -27
- package/dist/es5/dd-element.js +95 -95
- package/dist/es5/dd-element.js.map +1 -1
- package/dist/es5/dd-gridstack.d.ts +34 -34
- package/dist/es5/dd-gridstack.js +144 -144
- package/dist/es5/dd-gridstack.js.map +1 -1
- package/dist/es5/dd-manager.d.ts +22 -22
- package/dist/es5/dd-manager.js +16 -16
- package/dist/es5/dd-manager.js.map +1 -1
- package/dist/es5/dd-resizable-handle.d.ts +14 -14
- package/dist/es5/dd-resizable-handle.js +105 -106
- package/dist/es5/dd-resizable-handle.js.map +1 -1
- package/dist/es5/dd-resizable.d.ts +28 -28
- package/dist/es5/dd-resizable.js +317 -318
- package/dist/es5/dd-resizable.js.map +1 -1
- package/dist/es5/dd-touch.d.ts +33 -33
- package/dist/es5/dd-touch.js +185 -185
- package/dist/es5/dd-touch.js.map +1 -1
- package/dist/es5/gridstack-all.js +1 -1
- package/dist/es5/gridstack-all.js.LICENSE.txt +1 -1
- package/dist/es5/gridstack-all.js.map +1 -1
- package/dist/es5/gridstack-engine.d.ts +102 -102
- package/dist/es5/gridstack-engine.js +1000 -995
- package/dist/es5/gridstack-engine.js.map +1 -1
- package/dist/es5/gridstack-poly.js +1 -1
- package/dist/es5/gridstack.d.ts +392 -376
- package/dist/es5/gridstack.js +2254 -2233
- package/dist/es5/gridstack.js.map +1 -1
- package/dist/es5/types.d.ts +279 -284
- package/dist/es5/types.js +47 -35
- package/dist/es5/types.js.map +1 -1
- package/dist/es5/utils.d.ts +95 -93
- package/dist/es5/utils.js +600 -569
- package/dist/es5/utils.js.map +1 -1
- package/dist/gridstack-all.js +1 -1
- package/dist/gridstack-all.js.LICENSE.txt +1 -1
- package/dist/gridstack-all.js.map +1 -1
- package/dist/gridstack-engine.d.ts +102 -102
- package/dist/gridstack-engine.js +950 -954
- package/dist/gridstack-engine.js.map +1 -1
- package/dist/gridstack-extra.css +0 -390
- package/dist/gridstack-extra.min.css +1 -1
- package/dist/gridstack.css +19 -97
- package/dist/gridstack.d.ts +392 -376
- package/dist/gridstack.js +2155 -2157
- package/dist/gridstack.js.map +1 -1
- package/dist/gridstack.min.css +1 -1
- package/dist/ng/README.md +154 -0
- package/dist/ng/gridstack-item.component.d.ts +29 -0
- package/dist/ng/gridstack-item.component.js +65 -0
- package/dist/ng/gridstack-item.component.js.map +1 -0
- package/dist/ng/gridstack.component.d.ts +118 -0
- package/dist/ng/gridstack.component.js +245 -0
- package/dist/ng/gridstack.component.js.map +1 -0
- package/dist/src/gridstack-extra.scss +0 -2
- package/dist/src/gridstack.scss +14 -9
- package/dist/types.d.ts +279 -284
- package/dist/types.js +44 -35
- package/dist/types.js.map +1 -1
- package/dist/utils.d.ts +95 -93
- package/dist/utils.js +546 -527
- package/dist/utils.js.map +1 -1
- package/{dist → dist_save}/angular/gridstack-item.component.ts +5 -3
- package/{dist → dist_save}/angular/gridstack.component.ts +32 -18
- package/dist_save/dd-base-impl.d.ts +20 -0
- package/dist_save/dd-base-impl.js +36 -0
- package/dist_save/dd-base-impl.js.map +1 -0
- package/dist_save/dd-draggable.d.ts +28 -0
- package/dist_save/dd-draggable.js +343 -0
- package/dist_save/dd-draggable.js.map +1 -0
- package/dist_save/dd-droppable.d.ts +26 -0
- package/dist_save/dd-droppable.js +149 -0
- package/dist_save/dd-droppable.js.map +1 -0
- package/dist_save/dd-element.d.ts +27 -0
- package/dist_save/dd-element.js +95 -0
- package/dist_save/dd-element.js.map +1 -0
- package/dist_save/dd-gridstack.d.ts +34 -0
- package/dist_save/dd-gridstack.js +125 -0
- package/dist_save/dd-gridstack.js.map +1 -0
- package/dist_save/dd-manager.d.ts +22 -0
- package/dist_save/dd-manager.js +14 -0
- package/dist_save/dd-manager.js.map +1 -0
- package/dist_save/dd-resizable-handle.d.ts +14 -0
- package/dist_save/dd-resizable-handle.js +106 -0
- package/dist_save/dd-resizable-handle.js.map +1 -0
- package/dist_save/dd-resizable.d.ts +28 -0
- package/dist_save/dd-resizable.js +294 -0
- package/dist_save/dd-resizable.js.map +1 -0
- package/dist_save/dd-touch.d.ts +33 -0
- package/dist_save/dd-touch.js +183 -0
- package/dist_save/dd-touch.js.map +1 -0
- package/dist_save/es5/dd-base-impl.d.ts +20 -0
- package/dist_save/es5/dd-base-impl.js +41 -0
- package/dist_save/es5/dd-base-impl.js.map +1 -0
- package/dist_save/es5/dd-draggable.d.ts +28 -0
- package/dist_save/es5/dd-draggable.js +366 -0
- package/dist_save/es5/dd-draggable.js.map +1 -0
- package/dist_save/es5/dd-droppable.d.ts +26 -0
- package/dist_save/es5/dd-droppable.js +180 -0
- package/dist_save/es5/dd-droppable.js.map +1 -0
- package/dist_save/es5/dd-element.d.ts +27 -0
- package/dist_save/es5/dd-element.js +96 -0
- package/dist_save/es5/dd-element.js.map +1 -0
- package/dist_save/es5/dd-gridstack.d.ts +34 -0
- package/dist_save/es5/dd-gridstack.js +145 -0
- package/dist_save/es5/dd-gridstack.js.map +1 -0
- package/dist_save/es5/dd-manager.d.ts +22 -0
- package/dist_save/es5/dd-manager.js +17 -0
- package/dist_save/es5/dd-manager.js.map +1 -0
- package/dist_save/es5/dd-resizable-handle.d.ts +14 -0
- package/dist_save/es5/dd-resizable-handle.js +107 -0
- package/dist_save/es5/dd-resizable-handle.js.map +1 -0
- package/dist_save/es5/dd-resizable.d.ts +28 -0
- package/dist_save/es5/dd-resizable.js +316 -0
- package/dist_save/es5/dd-resizable.js.map +1 -0
- package/dist_save/es5/dd-touch.d.ts +33 -0
- package/dist_save/es5/dd-touch.js +186 -0
- package/dist_save/es5/dd-touch.js.map +1 -0
- package/dist_save/es5/gridstack-all.js +3 -0
- package/dist_save/es5/gridstack-all.js.LICENSE.txt +7 -0
- package/dist_save/es5/gridstack-all.js.map +1 -0
- package/dist_save/es5/gridstack-engine.d.ts +102 -0
- package/dist_save/es5/gridstack-engine.js +997 -0
- package/dist_save/es5/gridstack-engine.js.map +1 -0
- package/dist_save/es5/gridstack-poly.js +356 -0
- package/dist_save/es5/gridstack.d.ts +376 -0
- package/dist_save/es5/gridstack.js +2238 -0
- package/dist_save/es5/gridstack.js.map +1 -0
- package/dist_save/es5/types.d.ts +284 -0
- package/dist_save/es5/types.js +36 -0
- package/dist_save/es5/types.js.map +1 -0
- package/dist_save/es5/utils.d.ts +95 -0
- package/dist_save/es5/utils.js +590 -0
- package/dist_save/es5/utils.js.map +1 -0
- package/dist_save/gridstack-all.js +3 -0
- package/dist_save/gridstack-all.js.LICENSE.txt +7 -0
- package/dist_save/gridstack-all.js.map +1 -0
- package/dist_save/gridstack-engine.d.ts +102 -0
- package/dist_save/gridstack-engine.js +956 -0
- package/dist_save/gridstack-engine.js.map +1 -0
- package/dist_save/gridstack-extra.css +433 -0
- package/dist_save/gridstack-extra.min.css +1 -0
- package/dist_save/gridstack.css +226 -0
- package/dist_save/gridstack.d.ts +376 -0
- package/dist_save/gridstack.js +2162 -0
- package/dist_save/gridstack.js.map +1 -0
- package/dist_save/gridstack.min.css +1 -0
- package/dist_save/src/gridstack-extra.scss +27 -0
- package/dist_save/src/gridstack.scss +131 -0
- package/dist_save/types.d.ts +284 -0
- package/dist_save/types.js +36 -0
- package/dist_save/types.js.map +1 -0
- package/dist_save/utils.d.ts +95 -0
- package/dist_save/utils.js +548 -0
- package/dist_save/utils.js.map +1 -0
- package/doc/CHANGES.md +20 -0
- package/doc/README.md +21 -14
- package/package.json +25 -24
- /package/{dist → dist_save}/angular/README.md +0 -0
package/dist/es5/dd-resizable.js
CHANGED
|
@@ -1,319 +1,318 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* dd-resizable.ts
|
|
4
|
-
* Copyright (c) 2021-2022 Alain Dumesny - see GridStack root license
|
|
5
|
-
*/
|
|
6
|
-
var __extends = (this && this.__extends) || (function () {
|
|
7
|
-
var extendStatics = function (d, b) {
|
|
8
|
-
extendStatics = Object.setPrototypeOf ||
|
|
9
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
10
|
-
function (d, b) { for (var p in b) if (
|
|
11
|
-
return extendStatics(d, b);
|
|
12
|
-
};
|
|
13
|
-
return function (d, b) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
d
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
var
|
|
24
|
-
var
|
|
25
|
-
var
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
_this
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
var
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
_this.
|
|
69
|
-
|
|
70
|
-
_this.
|
|
71
|
-
_this.
|
|
72
|
-
_this.
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
this.
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
this.el.classList.
|
|
91
|
-
this._setupAutoHide(false);
|
|
92
|
-
};
|
|
93
|
-
DDResizable.prototype.destroy = function () {
|
|
94
|
-
this._removeHandlers();
|
|
95
|
-
this._setupAutoHide(false);
|
|
96
|
-
this.el
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
var
|
|
102
|
-
var
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
this.
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
this.el.addEventListener('
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
this.el.
|
|
124
|
-
this.el.removeEventListener('
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
//
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
var
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
.map(function (dir) { return
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
this.
|
|
178
|
-
this.
|
|
179
|
-
this.
|
|
180
|
-
this.
|
|
181
|
-
this.
|
|
182
|
-
this.
|
|
183
|
-
this.
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
this.
|
|
189
|
-
this
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
this.
|
|
195
|
-
this.
|
|
196
|
-
this.
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
this
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
this.
|
|
211
|
-
this.
|
|
212
|
-
this.
|
|
213
|
-
delete this.
|
|
214
|
-
delete this.
|
|
215
|
-
delete this.
|
|
216
|
-
delete this.
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
this.
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
this.el.style.
|
|
229
|
-
this
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
var
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
var
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
newRect.
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
newRect.
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
var
|
|
284
|
-
var
|
|
285
|
-
var
|
|
286
|
-
var
|
|
287
|
-
var
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
var _this = this;
|
|
294
|
-
var containmentRect = { left: 0, top: 0, width: 0, height: 0 };
|
|
295
|
-
if (this.el.style.position === 'absolute') {
|
|
296
|
-
var containmentEl = this.el.parentElement;
|
|
297
|
-
var _a = containmentEl.getBoundingClientRect(),
|
|
298
|
-
containmentRect = { left: left, top: top_1, width: 0, height: 0 };
|
|
299
|
-
}
|
|
300
|
-
if (!this.temporalRect)
|
|
301
|
-
return this;
|
|
302
|
-
Object.keys(this.temporalRect).forEach(function (key) {
|
|
303
|
-
var value = _this.temporalRect[key];
|
|
304
|
-
_this.el.style[key] = value - containmentRect[key] + 'px';
|
|
305
|
-
});
|
|
306
|
-
return this;
|
|
307
|
-
};
|
|
308
|
-
/** @internal */
|
|
309
|
-
DDResizable.prototype._removeHandlers = function () {
|
|
310
|
-
this.handlers.forEach(function (handle) { return handle.destroy(); });
|
|
311
|
-
delete this.handlers;
|
|
312
|
-
return this;
|
|
313
|
-
};
|
|
314
|
-
/** @internal */
|
|
315
|
-
DDResizable._originStyleProp = ['width', 'height', 'position', 'left', 'top', 'opacity', 'zIndex'];
|
|
316
|
-
return DDResizable;
|
|
317
|
-
}(dd_base_impl_1.DDBaseImplement));
|
|
318
|
-
exports.DDResizable = DDResizable;
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* dd-resizable.ts 8.0.1
|
|
4
|
+
* Copyright (c) 2021-2022 Alain Dumesny - see GridStack root license
|
|
5
|
+
*/
|
|
6
|
+
var __extends = (this && this.__extends) || (function () {
|
|
7
|
+
var extendStatics = function (d, b) {
|
|
8
|
+
extendStatics = Object.setPrototypeOf ||
|
|
9
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
10
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
11
|
+
return extendStatics(d, b);
|
|
12
|
+
};
|
|
13
|
+
return function (d, b) {
|
|
14
|
+
if (typeof b !== "function" && b !== null)
|
|
15
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
16
|
+
extendStatics(d, b);
|
|
17
|
+
function __() { this.constructor = d; }
|
|
18
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
19
|
+
};
|
|
20
|
+
})();
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.DDResizable = void 0;
|
|
23
|
+
var dd_resizable_handle_1 = require("./dd-resizable-handle");
|
|
24
|
+
var dd_base_impl_1 = require("./dd-base-impl");
|
|
25
|
+
var utils_1 = require("./utils");
|
|
26
|
+
var dd_manager_1 = require("./dd-manager");
|
|
27
|
+
var DDResizable = exports.DDResizable = /** @class */ (function (_super) {
|
|
28
|
+
__extends(DDResizable, _super);
|
|
29
|
+
function DDResizable(el, opts) {
|
|
30
|
+
if (opts === void 0) { opts = {}; }
|
|
31
|
+
var _this = _super.call(this) || this;
|
|
32
|
+
/** @internal */
|
|
33
|
+
_this._ui = function () {
|
|
34
|
+
var containmentEl = _this.el.parentElement;
|
|
35
|
+
var containmentRect = containmentEl.getBoundingClientRect();
|
|
36
|
+
var newRect = {
|
|
37
|
+
width: _this.originalRect.width,
|
|
38
|
+
height: _this.originalRect.height + _this.scrolled,
|
|
39
|
+
left: _this.originalRect.left,
|
|
40
|
+
top: _this.originalRect.top - _this.scrolled
|
|
41
|
+
};
|
|
42
|
+
var rect = _this.temporalRect || newRect;
|
|
43
|
+
return {
|
|
44
|
+
position: {
|
|
45
|
+
left: rect.left - containmentRect.left,
|
|
46
|
+
top: rect.top - containmentRect.top
|
|
47
|
+
},
|
|
48
|
+
size: {
|
|
49
|
+
width: rect.width,
|
|
50
|
+
height: rect.height
|
|
51
|
+
}
|
|
52
|
+
/* Gridstack ONLY needs position set above... keep around in case.
|
|
53
|
+
element: [this.el], // The object representing the element to be resized
|
|
54
|
+
helper: [], // TODO: not support yet - The object representing the helper that's being resized
|
|
55
|
+
originalElement: [this.el],// we don't wrap here, so simplify as this.el //The object representing the original element before it is wrapped
|
|
56
|
+
originalPosition: { // The position represented as { left, top } before the resizable is resized
|
|
57
|
+
left: this.originalRect.left - containmentRect.left,
|
|
58
|
+
top: this.originalRect.top - containmentRect.top
|
|
59
|
+
},
|
|
60
|
+
originalSize: { // The size represented as { width, height } before the resizable is resized
|
|
61
|
+
width: this.originalRect.width,
|
|
62
|
+
height: this.originalRect.height
|
|
63
|
+
}
|
|
64
|
+
*/
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
_this.el = el;
|
|
68
|
+
_this.option = opts;
|
|
69
|
+
// create var event binding so we can easily remove and still look like TS methods (unlike anonymous functions)
|
|
70
|
+
_this._mouseOver = _this._mouseOver.bind(_this);
|
|
71
|
+
_this._mouseOut = _this._mouseOut.bind(_this);
|
|
72
|
+
_this.enable();
|
|
73
|
+
_this._setupAutoHide(_this.option.autoHide);
|
|
74
|
+
_this._setupHandlers();
|
|
75
|
+
return _this;
|
|
76
|
+
}
|
|
77
|
+
DDResizable.prototype.on = function (event, callback) {
|
|
78
|
+
_super.prototype.on.call(this, event, callback);
|
|
79
|
+
};
|
|
80
|
+
DDResizable.prototype.off = function (event) {
|
|
81
|
+
_super.prototype.off.call(this, event);
|
|
82
|
+
};
|
|
83
|
+
DDResizable.prototype.enable = function () {
|
|
84
|
+
_super.prototype.enable.call(this);
|
|
85
|
+
this.el.classList.remove('ui-resizable-disabled');
|
|
86
|
+
this._setupAutoHide(this.option.autoHide);
|
|
87
|
+
};
|
|
88
|
+
DDResizable.prototype.disable = function () {
|
|
89
|
+
_super.prototype.disable.call(this);
|
|
90
|
+
this.el.classList.add('ui-resizable-disabled');
|
|
91
|
+
this._setupAutoHide(false);
|
|
92
|
+
};
|
|
93
|
+
DDResizable.prototype.destroy = function () {
|
|
94
|
+
this._removeHandlers();
|
|
95
|
+
this._setupAutoHide(false);
|
|
96
|
+
delete this.el;
|
|
97
|
+
_super.prototype.destroy.call(this);
|
|
98
|
+
};
|
|
99
|
+
DDResizable.prototype.updateOption = function (opts) {
|
|
100
|
+
var _this = this;
|
|
101
|
+
var updateHandles = (opts.handles && opts.handles !== this.option.handles);
|
|
102
|
+
var updateAutoHide = (opts.autoHide && opts.autoHide !== this.option.autoHide);
|
|
103
|
+
Object.keys(opts).forEach(function (key) { return _this.option[key] = opts[key]; });
|
|
104
|
+
if (updateHandles) {
|
|
105
|
+
this._removeHandlers();
|
|
106
|
+
this._setupHandlers();
|
|
107
|
+
}
|
|
108
|
+
if (updateAutoHide) {
|
|
109
|
+
this._setupAutoHide(this.option.autoHide);
|
|
110
|
+
}
|
|
111
|
+
return this;
|
|
112
|
+
};
|
|
113
|
+
/** @internal turns auto hide on/off */
|
|
114
|
+
DDResizable.prototype._setupAutoHide = function (auto) {
|
|
115
|
+
if (auto) {
|
|
116
|
+
this.el.classList.add('ui-resizable-autohide');
|
|
117
|
+
// use mouseover and not mouseenter to get better performance and track for nested cases
|
|
118
|
+
this.el.addEventListener('mouseover', this._mouseOver);
|
|
119
|
+
this.el.addEventListener('mouseout', this._mouseOut);
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
this.el.classList.remove('ui-resizable-autohide');
|
|
123
|
+
this.el.removeEventListener('mouseover', this._mouseOver);
|
|
124
|
+
this.el.removeEventListener('mouseout', this._mouseOut);
|
|
125
|
+
if (dd_manager_1.DDManager.overResizeElement === this) {
|
|
126
|
+
delete dd_manager_1.DDManager.overResizeElement;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return this;
|
|
130
|
+
};
|
|
131
|
+
/** @internal */
|
|
132
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
133
|
+
DDResizable.prototype._mouseOver = function (e) {
|
|
134
|
+
// console.log(`${count++} pre-enter ${(this.el as GridItemHTMLElement).gridstackNode._id}`)
|
|
135
|
+
// already over a child, ignore. Ideally we just call e.stopPropagation() but see https://github.com/gridstack/gridstack.js/issues/2018
|
|
136
|
+
if (dd_manager_1.DDManager.overResizeElement || dd_manager_1.DDManager.dragElement)
|
|
137
|
+
return;
|
|
138
|
+
dd_manager_1.DDManager.overResizeElement = this;
|
|
139
|
+
// console.log(`${count++} enter ${(this.el as GridItemHTMLElement).gridstackNode._id}`)
|
|
140
|
+
this.el.classList.remove('ui-resizable-autohide');
|
|
141
|
+
};
|
|
142
|
+
/** @internal */
|
|
143
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
144
|
+
DDResizable.prototype._mouseOut = function (e) {
|
|
145
|
+
// console.log(`${count++} pre-leave ${(this.el as GridItemHTMLElement).gridstackNode._id}`)
|
|
146
|
+
if (dd_manager_1.DDManager.overResizeElement !== this)
|
|
147
|
+
return;
|
|
148
|
+
delete dd_manager_1.DDManager.overResizeElement;
|
|
149
|
+
// console.log(`${count++} leave ${(this.el as GridItemHTMLElement).gridstackNode._id}`)
|
|
150
|
+
this.el.classList.add('ui-resizable-autohide');
|
|
151
|
+
};
|
|
152
|
+
/** @internal */
|
|
153
|
+
DDResizable.prototype._setupHandlers = function () {
|
|
154
|
+
var _this = this;
|
|
155
|
+
var handlerDirection = this.option.handles || 'e,s,se';
|
|
156
|
+
if (handlerDirection === 'all') {
|
|
157
|
+
handlerDirection = 'n,e,s,w,se,sw,ne,nw';
|
|
158
|
+
}
|
|
159
|
+
this.handlers = handlerDirection.split(',')
|
|
160
|
+
.map(function (dir) { return dir.trim(); })
|
|
161
|
+
.map(function (dir) { return new dd_resizable_handle_1.DDResizableHandle(_this.el, dir, {
|
|
162
|
+
start: function (event) {
|
|
163
|
+
_this._resizeStart(event);
|
|
164
|
+
},
|
|
165
|
+
stop: function (event) {
|
|
166
|
+
_this._resizeStop(event);
|
|
167
|
+
},
|
|
168
|
+
move: function (event) {
|
|
169
|
+
_this._resizing(event, dir);
|
|
170
|
+
}
|
|
171
|
+
}); });
|
|
172
|
+
return this;
|
|
173
|
+
};
|
|
174
|
+
/** @internal */
|
|
175
|
+
DDResizable.prototype._resizeStart = function (event) {
|
|
176
|
+
this.originalRect = this.el.getBoundingClientRect();
|
|
177
|
+
this.scrollEl = utils_1.Utils.getScrollElement(this.el);
|
|
178
|
+
this.scrollY = this.scrollEl.scrollTop;
|
|
179
|
+
this.scrolled = 0;
|
|
180
|
+
this.startEvent = event;
|
|
181
|
+
this._setupHelper();
|
|
182
|
+
this._applyChange();
|
|
183
|
+
var ev = utils_1.Utils.initEvent(event, { type: 'resizestart', target: this.el });
|
|
184
|
+
if (this.option.start) {
|
|
185
|
+
this.option.start(ev, this._ui());
|
|
186
|
+
}
|
|
187
|
+
this.el.classList.add('ui-resizable-resizing');
|
|
188
|
+
this.triggerEvent('resizestart', ev);
|
|
189
|
+
return this;
|
|
190
|
+
};
|
|
191
|
+
/** @internal */
|
|
192
|
+
DDResizable.prototype._resizing = function (event, dir) {
|
|
193
|
+
this.scrolled = this.scrollEl.scrollTop - this.scrollY;
|
|
194
|
+
this.temporalRect = this._getChange(event, dir);
|
|
195
|
+
this._applyChange();
|
|
196
|
+
var ev = utils_1.Utils.initEvent(event, { type: 'resize', target: this.el });
|
|
197
|
+
if (this.option.resize) {
|
|
198
|
+
this.option.resize(ev, this._ui());
|
|
199
|
+
}
|
|
200
|
+
this.triggerEvent('resize', ev);
|
|
201
|
+
return this;
|
|
202
|
+
};
|
|
203
|
+
/** @internal */
|
|
204
|
+
DDResizable.prototype._resizeStop = function (event) {
|
|
205
|
+
var ev = utils_1.Utils.initEvent(event, { type: 'resizestop', target: this.el });
|
|
206
|
+
if (this.option.stop) {
|
|
207
|
+
this.option.stop(ev); // Note: ui() not used by gridstack so don't pass
|
|
208
|
+
}
|
|
209
|
+
this.el.classList.remove('ui-resizable-resizing');
|
|
210
|
+
this.triggerEvent('resizestop', ev);
|
|
211
|
+
this._cleanHelper();
|
|
212
|
+
delete this.startEvent;
|
|
213
|
+
delete this.originalRect;
|
|
214
|
+
delete this.temporalRect;
|
|
215
|
+
delete this.scrollY;
|
|
216
|
+
delete this.scrolled;
|
|
217
|
+
return this;
|
|
218
|
+
};
|
|
219
|
+
/** @internal */
|
|
220
|
+
DDResizable.prototype._setupHelper = function () {
|
|
221
|
+
var _this = this;
|
|
222
|
+
this.elOriginStyleVal = DDResizable._originStyleProp.map(function (prop) { return _this.el.style[prop]; });
|
|
223
|
+
this.parentOriginStylePosition = this.el.parentElement.style.position;
|
|
224
|
+
if (window.getComputedStyle(this.el.parentElement).position.match(/static/)) {
|
|
225
|
+
this.el.parentElement.style.position = 'relative';
|
|
226
|
+
}
|
|
227
|
+
this.el.style.position = 'absolute';
|
|
228
|
+
this.el.style.opacity = '0.8';
|
|
229
|
+
return this;
|
|
230
|
+
};
|
|
231
|
+
/** @internal */
|
|
232
|
+
DDResizable.prototype._cleanHelper = function () {
|
|
233
|
+
var _this = this;
|
|
234
|
+
DDResizable._originStyleProp.forEach(function (prop, i) {
|
|
235
|
+
_this.el.style[prop] = _this.elOriginStyleVal[i] || null;
|
|
236
|
+
});
|
|
237
|
+
this.el.parentElement.style.position = this.parentOriginStylePosition || null;
|
|
238
|
+
return this;
|
|
239
|
+
};
|
|
240
|
+
/** @internal */
|
|
241
|
+
DDResizable.prototype._getChange = function (event, dir) {
|
|
242
|
+
var oEvent = this.startEvent;
|
|
243
|
+
var newRect = {
|
|
244
|
+
width: this.originalRect.width,
|
|
245
|
+
height: this.originalRect.height + this.scrolled,
|
|
246
|
+
left: this.originalRect.left,
|
|
247
|
+
top: this.originalRect.top - this.scrolled
|
|
248
|
+
};
|
|
249
|
+
var offsetX = event.clientX - oEvent.clientX;
|
|
250
|
+
var offsetY = event.clientY - oEvent.clientY;
|
|
251
|
+
if (dir.indexOf('e') > -1) {
|
|
252
|
+
newRect.width += offsetX;
|
|
253
|
+
}
|
|
254
|
+
else if (dir.indexOf('w') > -1) {
|
|
255
|
+
newRect.width -= offsetX;
|
|
256
|
+
newRect.left += offsetX;
|
|
257
|
+
}
|
|
258
|
+
if (dir.indexOf('s') > -1) {
|
|
259
|
+
newRect.height += offsetY;
|
|
260
|
+
}
|
|
261
|
+
else if (dir.indexOf('n') > -1) {
|
|
262
|
+
newRect.height -= offsetY;
|
|
263
|
+
newRect.top += offsetY;
|
|
264
|
+
}
|
|
265
|
+
var constrain = this._constrainSize(newRect.width, newRect.height);
|
|
266
|
+
if (Math.round(newRect.width) !== Math.round(constrain.width)) { // round to ignore slight round-off errors
|
|
267
|
+
if (dir.indexOf('w') > -1) {
|
|
268
|
+
newRect.left += newRect.width - constrain.width;
|
|
269
|
+
}
|
|
270
|
+
newRect.width = constrain.width;
|
|
271
|
+
}
|
|
272
|
+
if (Math.round(newRect.height) !== Math.round(constrain.height)) {
|
|
273
|
+
if (dir.indexOf('n') > -1) {
|
|
274
|
+
newRect.top += newRect.height - constrain.height;
|
|
275
|
+
}
|
|
276
|
+
newRect.height = constrain.height;
|
|
277
|
+
}
|
|
278
|
+
return newRect;
|
|
279
|
+
};
|
|
280
|
+
/** @internal constrain the size to the set min/max values */
|
|
281
|
+
DDResizable.prototype._constrainSize = function (oWidth, oHeight) {
|
|
282
|
+
var maxWidth = this.option.maxWidth || Number.MAX_SAFE_INTEGER;
|
|
283
|
+
var minWidth = this.option.minWidth || oWidth;
|
|
284
|
+
var maxHeight = this.option.maxHeight || Number.MAX_SAFE_INTEGER;
|
|
285
|
+
var minHeight = this.option.minHeight || oHeight;
|
|
286
|
+
var width = Math.min(maxWidth, Math.max(minWidth, oWidth));
|
|
287
|
+
var height = Math.min(maxHeight, Math.max(minHeight, oHeight));
|
|
288
|
+
return { width: width, height: height };
|
|
289
|
+
};
|
|
290
|
+
/** @internal */
|
|
291
|
+
DDResizable.prototype._applyChange = function () {
|
|
292
|
+
var _a;
|
|
293
|
+
var _this = this;
|
|
294
|
+
var containmentRect = { left: 0, top: 0, width: 0, height: 0 };
|
|
295
|
+
if (this.el.style.position === 'absolute') {
|
|
296
|
+
var containmentEl = this.el.parentElement;
|
|
297
|
+
var left = (_a = containmentEl.getBoundingClientRect(), _a.left), top_1 = _a.top;
|
|
298
|
+
containmentRect = { left: left, top: top_1, width: 0, height: 0 };
|
|
299
|
+
}
|
|
300
|
+
if (!this.temporalRect)
|
|
301
|
+
return this;
|
|
302
|
+
Object.keys(this.temporalRect).forEach(function (key) {
|
|
303
|
+
var value = _this.temporalRect[key];
|
|
304
|
+
_this.el.style[key] = value - containmentRect[key] + 'px';
|
|
305
|
+
});
|
|
306
|
+
return this;
|
|
307
|
+
};
|
|
308
|
+
/** @internal */
|
|
309
|
+
DDResizable.prototype._removeHandlers = function () {
|
|
310
|
+
this.handlers.forEach(function (handle) { return handle.destroy(); });
|
|
311
|
+
delete this.handlers;
|
|
312
|
+
return this;
|
|
313
|
+
};
|
|
314
|
+
/** @internal */
|
|
315
|
+
DDResizable._originStyleProp = ['width', 'height', 'position', 'left', 'top', 'opacity', 'zIndex'];
|
|
316
|
+
return DDResizable;
|
|
317
|
+
}(dd_base_impl_1.DDBaseImplement));
|
|
319
318
|
//# sourceMappingURL=dd-resizable.js.map
|