uiik 1.0.9 → 1.3.0-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/README.md +7 -0
- package/{types/detector.d.ts → detector.d.ts} +0 -19
- package/draggable.d.ts +8 -0
- package/droppable.d.ts +9 -0
- package/{types/index.d.ts → index.d.ts} +5 -0
- package/index.esm.js +1852 -1253
- package/index.js +1914 -1296
- package/package.json +5 -5
- package/resizable.d.ts +7 -0
- package/rotatable.d.ts +6 -0
- package/selectable.d.ts +8 -0
- package/sortable.d.ts +9 -0
- package/splittable.d.ts +6 -0
- package/transform.d.ts +19 -0
- package/types.d.ts +286 -0
- package/utils.d.ts +51 -0
- package/types/draggable.d.ts +0 -25
- package/types/droppable.d.ts +0 -30
- package/types/resizable.d.ts +0 -19
- package/types/rotatable.d.ts +0 -23
- package/types/selectable.d.ts +0 -32
- package/types/splittable.d.ts +0 -23
- package/types/types.d.ts +0 -320
- package/types/utils.d.ts +0 -22
package/index.esm.js
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* uiik v1.0
|
|
2
|
+
* uiik v1.3.0-alpha
|
|
3
3
|
* A UI interactions kit includes draggable, splittable, rotatable, selectable, etc.
|
|
4
4
|
* https://github.com/holyhigh2/uiik
|
|
5
5
|
* c) 2021-2023 @holyhigh2 may be freely distributed under the MIT license
|
|
6
6
|
*/
|
|
7
|
-
import { isArrayLike, isString,
|
|
7
|
+
import { isDefined, isArrayLike, isString, isElement, isEmpty, isArray, isNumber, isFunction, isBoolean, isUndefined } from 'myfx/is';
|
|
8
|
+
import { find, map, toArray, each, reject, includes, some, flatMap, size } from 'myfx/collection';
|
|
9
|
+
import { get, assign, merge } from 'myfx/object';
|
|
10
|
+
import { split, test } from 'myfx/string';
|
|
11
|
+
import { compact, findIndex } from 'myfx/array';
|
|
12
|
+
import 'myfx';
|
|
13
|
+
import { alphaId } from 'myfx/utils';
|
|
8
14
|
|
|
9
15
|
/******************************************************************************
|
|
10
16
|
Copyright (c) Microsoft Corporation.
|
|
@@ -32,12 +38,337 @@ function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
|
|
32
38
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
33
39
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
34
40
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
44
|
+
var e = new Error(message);
|
|
45
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const UtMap = new WeakMap();
|
|
49
|
+
const EXP_MATRIX$1 = /matrix\((?<a>[\d-.]+)\s*,\s*(?<b>[\d-.]+)\s*,\s*(?<c>[\d-.]+)\s*,\s*(?<d>[\d-.]+)\s*,\s*(?<x>[\d-.]+)\s*,\s*(?<y>[\d-.]+)\)/gim;
|
|
50
|
+
class UiiTransformer {
|
|
51
|
+
constructor(el) {
|
|
52
|
+
this.angle = 0;
|
|
53
|
+
this.el = el;
|
|
54
|
+
this.normalize(el);
|
|
55
|
+
UtMap.set(el, this);
|
|
56
|
+
}
|
|
57
|
+
normalize(el) {
|
|
58
|
+
let { x, y } = normalize(el);
|
|
59
|
+
this.x = x;
|
|
60
|
+
this.y = y;
|
|
61
|
+
return this;
|
|
62
|
+
}
|
|
63
|
+
moveTo(x, y) {
|
|
64
|
+
this.x = x;
|
|
65
|
+
this.y = y;
|
|
66
|
+
moveTo(this.el, this.x, this.y);
|
|
67
|
+
}
|
|
68
|
+
moveToX(x) {
|
|
69
|
+
this.x = x;
|
|
70
|
+
moveTo(this.el, this.x, this.y);
|
|
71
|
+
}
|
|
72
|
+
moveToY(y) {
|
|
73
|
+
this.y = y;
|
|
74
|
+
moveTo(this.el, this.x, this.y);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function normalize(el) {
|
|
78
|
+
const style = window.getComputedStyle(el);
|
|
79
|
+
let x = 0, y = 0;
|
|
80
|
+
if (el instanceof HTMLElement) {
|
|
81
|
+
x = (parseFloat(style.left) || 0) + (parseFloat(style.marginLeft) || 0);
|
|
82
|
+
y = (parseFloat(style.top) || 0) + (parseFloat(style.marginTop) || 0);
|
|
83
|
+
el.style.setProperty("left", "0", "important");
|
|
84
|
+
el.style.setProperty("top", "0", "important");
|
|
85
|
+
el.style.setProperty("margin", "0", "important");
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
x = parseFloat(style.x || style.cx) || 0;
|
|
89
|
+
y = parseFloat(style.y || style.cy) || 0;
|
|
90
|
+
el.removeAttribute("x");
|
|
91
|
+
el.removeAttribute("y");
|
|
92
|
+
el.removeAttribute("cx");
|
|
93
|
+
el.removeAttribute("cy");
|
|
94
|
+
}
|
|
95
|
+
EXP_MATRIX$1.lastIndex = 0;
|
|
96
|
+
const rs = EXP_MATRIX$1.exec(window.getComputedStyle(el).transform);
|
|
97
|
+
if (rs && rs.groups) {
|
|
98
|
+
x += parseFloat(rs.groups.x) || 0;
|
|
99
|
+
y += parseFloat(rs.groups.y) || 0;
|
|
100
|
+
}
|
|
101
|
+
moveTo(el, x, y);
|
|
102
|
+
return { x, y };
|
|
103
|
+
}
|
|
104
|
+
function wrapper(el) {
|
|
105
|
+
let ut = UtMap.get(el);
|
|
106
|
+
if (ut)
|
|
107
|
+
return ut.normalize(el);
|
|
108
|
+
return new UiiTransformer(el);
|
|
109
|
+
}
|
|
110
|
+
function transformMove(transofrmStr, x, y, unit = false) {
|
|
111
|
+
return (`translate(${x}${unit ? "px" : ""},${y}${unit ? "px" : ""})` +
|
|
112
|
+
transofrmStr.replace(/translate\([^)]+?\)/, ""));
|
|
113
|
+
}
|
|
114
|
+
function getTranslate(el) {
|
|
115
|
+
let xVal = NaN, yVal = NaN;
|
|
116
|
+
let transformStr = "";
|
|
117
|
+
if (el instanceof SVGGraphicsElement) {
|
|
118
|
+
transformStr = el.getAttribute("transform") || "";
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
let style = el.style;
|
|
122
|
+
transformStr = style.transform || "";
|
|
123
|
+
}
|
|
124
|
+
EXP_GET_TRANSLATE.lastIndex = 0;
|
|
125
|
+
const xy = EXP_GET_TRANSLATE.exec(transformStr);
|
|
126
|
+
if (xy && xy.groups) {
|
|
127
|
+
xVal = parseFloat(xy.groups.x);
|
|
128
|
+
yVal = parseFloat(xy.groups.y);
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
EXP_GET_TRANSLATE_XY.lastIndex = 0;
|
|
132
|
+
const xy = EXP_GET_TRANSLATE_XY.exec(transformStr);
|
|
133
|
+
if (xy && xy.groups) {
|
|
134
|
+
if (xy.groups.dir == "X") {
|
|
135
|
+
xVal = parseFloat(xy.groups.v);
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
yVal = parseFloat(xy.groups.v);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return { x: xVal, y: yVal };
|
|
143
|
+
}
|
|
144
|
+
function moveTo(el, x, y) {
|
|
145
|
+
if (el instanceof SVGGraphicsElement) {
|
|
146
|
+
el.setAttribute("transform", transformMove(el.getAttribute("transform") || "", x, y));
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
let style = el.style;
|
|
150
|
+
style.transform = transformMove(style.transform || "", x, y, true);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
const EXP_GET_TRANSLATE = /translate\(\s*(?<x>[\d.-]+)\D*,\s*(?<y>[\d.-]+)\D*\)/gim;
|
|
154
|
+
const EXP_GET_TRANSLATE_XY = /translate(?<dir>X|Y)\(\s*(?<v>[\d.-]+)\D*\)/gim;
|
|
155
|
+
function moveBy(el, x, y) {
|
|
156
|
+
const xy = getTranslate(el);
|
|
157
|
+
if (el instanceof SVGGraphicsElement) {
|
|
158
|
+
el.setAttribute("transform", transformMove(el.getAttribute("transform") || "", xy.x + x, xy.y + y));
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
let style = el.style;
|
|
162
|
+
style.transform = transformMove(style.transform || "", xy.x + x, xy.y + y, true);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
function rotateTo(el, deg, cx, cy) {
|
|
166
|
+
if (el instanceof SVGGraphicsElement) {
|
|
167
|
+
let transformStr = el.getAttribute("transform") || "";
|
|
168
|
+
let originPos = isDefined(cx) && isDefined(cy);
|
|
169
|
+
let origin = "";
|
|
170
|
+
if (originPos) {
|
|
171
|
+
if (el.x instanceof SVGAnimatedLength) {
|
|
172
|
+
cx += el.x.animVal.value;
|
|
173
|
+
cy += el.y.animVal.value;
|
|
174
|
+
}
|
|
175
|
+
else if (el.cx instanceof SVGAnimatedLength) {
|
|
176
|
+
cx += el.cx.animVal.value;
|
|
177
|
+
cy += el.cy.animVal.value;
|
|
178
|
+
}
|
|
179
|
+
origin = `,${cx},${cy}`;
|
|
180
|
+
}
|
|
181
|
+
transformStr =
|
|
182
|
+
transformStr.replace(/rotate\([^)]+?\)/, "") + ` rotate(${deg}${origin})`;
|
|
183
|
+
el.setAttribute("transform", transformStr);
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
let style = el.style;
|
|
187
|
+
style.transform =
|
|
188
|
+
style.transform.replace(/rotate\([^)]+?\)/, "").replace(/rotateZ\([^)]+?\)/, "") +
|
|
189
|
+
" rotateZ(" +
|
|
190
|
+
deg +
|
|
191
|
+
"deg)";
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
const ONE_ANG = Math.PI / 180;
|
|
196
|
+
const ONE_RAD = 180 / Math.PI;
|
|
197
|
+
function getBox(child, parent) {
|
|
198
|
+
const rect = child.getBoundingClientRect();
|
|
199
|
+
const rs = { x: 0, y: 0, w: rect.width, h: rect.height };
|
|
200
|
+
parent =
|
|
201
|
+
parent ||
|
|
202
|
+
child.offsetParent ||
|
|
203
|
+
child.ownerSVGElement ||
|
|
204
|
+
child.parentElement ||
|
|
205
|
+
document.body;
|
|
206
|
+
const parentRect = parent.getBoundingClientRect();
|
|
207
|
+
const parentStyle = window.getComputedStyle(parent);
|
|
208
|
+
const parentBorderLeft = parseFloat(parentStyle.borderLeftWidth);
|
|
209
|
+
const parentBorderTop = parseFloat(parentStyle.borderTopWidth);
|
|
210
|
+
rs.x = rect.x - parentRect.x + parent.scrollLeft;
|
|
211
|
+
rs.y = rect.y - parentRect.y + parent.scrollTop;
|
|
212
|
+
if (child instanceof SVGElement) ;
|
|
213
|
+
else {
|
|
214
|
+
rs.x -= parentBorderLeft;
|
|
215
|
+
rs.y -= parentBorderTop;
|
|
216
|
+
}
|
|
217
|
+
return rs;
|
|
218
|
+
}
|
|
219
|
+
function getPointOffset(e, pos) {
|
|
220
|
+
let ox = e.offsetX || 0, oy = e.offsetY || 0;
|
|
221
|
+
if (e.target instanceof SVGElement) {
|
|
222
|
+
ox -= pos.x;
|
|
223
|
+
oy -= pos.y;
|
|
224
|
+
}
|
|
225
|
+
return [ox, oy];
|
|
226
|
+
}
|
|
227
|
+
function isSVGEl(el) {
|
|
228
|
+
return el instanceof SVGElement;
|
|
229
|
+
}
|
|
230
|
+
const EDGE_THRESHOLD = 5;
|
|
231
|
+
const DRAGGING_RULE = "body * { pointer-events: none; }";
|
|
232
|
+
let lockSheet;
|
|
233
|
+
function lockPage() {
|
|
234
|
+
lockSheet = getFirstSS();
|
|
235
|
+
lockSheet === null || lockSheet === void 0 ? void 0 : lockSheet.insertRule(DRAGGING_RULE, 0);
|
|
236
|
+
}
|
|
237
|
+
function unlockPage() {
|
|
238
|
+
lockSheet === null || lockSheet === void 0 ? void 0 : lockSheet.deleteRule(0);
|
|
239
|
+
}
|
|
240
|
+
function getFirstSS() {
|
|
241
|
+
if (document.styleSheets.length < 1) {
|
|
242
|
+
document.head.appendChild(document.createElement("style"));
|
|
243
|
+
}
|
|
244
|
+
const sheet = find(document.styleSheets, (ss) => !ss.href);
|
|
245
|
+
if (!sheet) {
|
|
246
|
+
document.head.appendChild(document.createElement("style"));
|
|
247
|
+
}
|
|
248
|
+
return sheet || find(document.styleSheets, (ss) => !ss.href);
|
|
249
|
+
}
|
|
250
|
+
let cursor = { html: "", body: "" };
|
|
251
|
+
function saveCursor() {
|
|
252
|
+
cursor.body = document.body.style.cursor;
|
|
253
|
+
cursor.html = document.documentElement.style.cursor;
|
|
254
|
+
}
|
|
255
|
+
function setCursor(cursor) {
|
|
256
|
+
document.body.style.cursor = document.documentElement.style.cursor = cursor;
|
|
257
|
+
}
|
|
258
|
+
function restoreCursor() {
|
|
259
|
+
document.body.style.cursor = cursor.body;
|
|
260
|
+
document.documentElement.style.cursor = cursor.html;
|
|
261
|
+
}
|
|
262
|
+
function getStyleXy(el) {
|
|
263
|
+
const style = window.getComputedStyle(el);
|
|
264
|
+
let x = 0, y = 0;
|
|
265
|
+
if (el instanceof SVGGraphicsElement) {
|
|
266
|
+
x = parseFloat(style.x || style.cx) || 0;
|
|
267
|
+
y = parseFloat(style.y || style.cy) || 0;
|
|
268
|
+
}
|
|
269
|
+
else {
|
|
270
|
+
x = parseFloat(style.left) || 0;
|
|
271
|
+
y = parseFloat(style.top) || 0;
|
|
272
|
+
}
|
|
273
|
+
return { x, y };
|
|
274
|
+
}
|
|
275
|
+
const EXP_MATRIX = /matrix\((?<a>[\d.-]+)\s*,\s*(?<b>[\d.-]+)\s*,\s*(?<c>[\d.-]+)\s*,\s*(?<d>[\d.-]+)\s*,\s*(?<x>[\d.-]+)\s*,\s*(?<y>[\d.-]+)\s*\)/;
|
|
276
|
+
function getMatrixInfo(elCStyle) {
|
|
277
|
+
let a = 1, b = 0, x = 0, y = 0;
|
|
278
|
+
let e = undefined, f = undefined;
|
|
279
|
+
if (elCStyle instanceof SVGGraphicsElement) {
|
|
280
|
+
const transMatrix = elCStyle.transform.animVal[0];
|
|
281
|
+
if (transMatrix) {
|
|
282
|
+
e = transMatrix.matrix.e;
|
|
283
|
+
f = transMatrix.matrix.f;
|
|
284
|
+
}
|
|
285
|
+
elCStyle = window.getComputedStyle(elCStyle);
|
|
286
|
+
}
|
|
287
|
+
else {
|
|
288
|
+
if (elCStyle instanceof HTMLElement) {
|
|
289
|
+
elCStyle = window.getComputedStyle(elCStyle);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
const matched = elCStyle.transform.match(EXP_MATRIX);
|
|
293
|
+
if (matched && matched.groups) {
|
|
294
|
+
a = parseFloat(matched.groups.a);
|
|
295
|
+
b = parseFloat(matched.groups.b);
|
|
296
|
+
parseFloat(matched.groups.c);
|
|
297
|
+
parseFloat(matched.groups.d);
|
|
298
|
+
x = parseFloat(matched.groups.x);
|
|
299
|
+
y = parseFloat(matched.groups.y);
|
|
300
|
+
}
|
|
301
|
+
if (e && f) {
|
|
302
|
+
x = e;
|
|
303
|
+
y = f;
|
|
304
|
+
}
|
|
305
|
+
const rs = { scale: 1, angle: 0, x, y };
|
|
306
|
+
rs.scale = Math.sqrt(a * a + b * b);
|
|
307
|
+
rs.angle = Math.round(Math.atan2(b, a) * (180 / Math.PI));
|
|
308
|
+
return rs;
|
|
309
|
+
}
|
|
310
|
+
function getPointInContainer(event, el, elRect, elCStyle, matrixInfo) {
|
|
311
|
+
if (!elRect) {
|
|
312
|
+
elRect = el.getBoundingClientRect();
|
|
313
|
+
}
|
|
314
|
+
if (!elCStyle) {
|
|
315
|
+
elCStyle = window.getComputedStyle(el);
|
|
316
|
+
}
|
|
317
|
+
if (!matrixInfo) {
|
|
318
|
+
matrixInfo = getMatrixInfo(elCStyle);
|
|
319
|
+
}
|
|
320
|
+
const scale = matrixInfo.scale;
|
|
321
|
+
let x = event.clientX -
|
|
322
|
+
elRect.x -
|
|
323
|
+
(parseFloat(elCStyle.borderLeftWidth) || 0) * scale +
|
|
324
|
+
el.scrollLeft * scale;
|
|
325
|
+
let y = event.clientY -
|
|
326
|
+
elRect.y -
|
|
327
|
+
(parseFloat(elCStyle.borderTopWidth) || 0) * scale +
|
|
328
|
+
el.scrollTop * scale;
|
|
329
|
+
return { x: x / scale, y: y / scale };
|
|
330
|
+
}
|
|
331
|
+
function getRectInContainer(el, container) {
|
|
332
|
+
const elRect = el.getBoundingClientRect();
|
|
333
|
+
const containerRect = container.getBoundingClientRect();
|
|
334
|
+
const elCStyle = window.getComputedStyle(container);
|
|
335
|
+
const matrixInfo = getMatrixInfo(elCStyle);
|
|
336
|
+
const scale = matrixInfo.scale;
|
|
337
|
+
let x = elRect.x -
|
|
338
|
+
containerRect.x -
|
|
339
|
+
(parseFloat(elCStyle.borderLeftWidth) || 0) * scale +
|
|
340
|
+
container.scrollLeft * scale;
|
|
341
|
+
let y = elRect.y -
|
|
342
|
+
containerRect.y -
|
|
343
|
+
(parseFloat(elCStyle.borderTopWidth) || 0) * scale +
|
|
344
|
+
container.scrollTop * scale;
|
|
345
|
+
return {
|
|
346
|
+
x: x / scale,
|
|
347
|
+
y: y / scale,
|
|
348
|
+
w: elRect.width / scale,
|
|
349
|
+
h: elRect.height / scale,
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
function getCenterXy(el) {
|
|
353
|
+
const cStyle = window.getComputedStyle(el);
|
|
354
|
+
const center = cStyle.transformOrigin;
|
|
355
|
+
const centerPair = center.split(" ");
|
|
356
|
+
const ox = parseFloat(centerPair[0]);
|
|
357
|
+
const oy = parseFloat(centerPair[1]);
|
|
358
|
+
const shadowDom = el.cloneNode();
|
|
359
|
+
rotateTo(shadowDom, 0);
|
|
360
|
+
const parentEl = el.parentElement;
|
|
361
|
+
let startX = 0, startY = 0;
|
|
362
|
+
if (parentEl) {
|
|
363
|
+
parentEl.appendChild(shadowDom);
|
|
364
|
+
const offsetXY = getRectInContainer(shadowDom, parentEl);
|
|
365
|
+
(startX = offsetXY.x), (startY = offsetXY.y);
|
|
366
|
+
parentEl.removeChild(shadowDom);
|
|
367
|
+
}
|
|
368
|
+
return { sx: startX, sy: startY, x: startX + ox, y: startY + oy, ox, oy };
|
|
35
369
|
}
|
|
36
370
|
|
|
37
371
|
var _Uii_listeners;
|
|
38
|
-
/**
|
|
39
|
-
* A Base class for all Uii classes
|
|
40
|
-
*/
|
|
41
372
|
class Uii {
|
|
42
373
|
constructor(ele, opts) {
|
|
43
374
|
this.enabled = true;
|
|
@@ -54,6 +385,9 @@ class Uii {
|
|
|
54
385
|
});
|
|
55
386
|
}
|
|
56
387
|
else {
|
|
388
|
+
if (isString(ele)) {
|
|
389
|
+
this.eleString = ele;
|
|
390
|
+
}
|
|
57
391
|
const el = isString(ele) ? document.querySelectorAll(ele) : ele;
|
|
58
392
|
if (!isElement(el) && !isArrayLike(el)) {
|
|
59
393
|
console.error('Invalid element "' + ele + '"');
|
|
@@ -62,22 +396,84 @@ class Uii {
|
|
|
62
396
|
this.ele = isArrayLike(el) ? toArray(el) : [el];
|
|
63
397
|
}
|
|
64
398
|
}
|
|
65
|
-
/**
|
|
66
|
-
* 销毁uii对象,包括卸载事件、清空元素等
|
|
67
|
-
*/
|
|
68
399
|
destroy() {
|
|
69
|
-
each(__classPrivateFieldGet(this, _Uii_listeners, "f"), ev => {
|
|
400
|
+
each(__classPrivateFieldGet(this, _Uii_listeners, "f"), (ev) => {
|
|
70
401
|
ev[0].removeEventListener(ev[1], ev[2], ev[3]);
|
|
71
402
|
});
|
|
72
403
|
__classPrivateFieldSet(this, _Uii_listeners, [], "f");
|
|
73
404
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
405
|
+
addPointerDown(el, pointerDown, opts) {
|
|
406
|
+
const onPointerDown = pointerDown;
|
|
407
|
+
const threshold = opts.threshold || 0;
|
|
408
|
+
const toLockPage = opts.lockPage || false;
|
|
409
|
+
const uiiOptions = this.opts;
|
|
410
|
+
this.registerEvent(el, 'mousedown', (e) => {
|
|
411
|
+
let t = e.target;
|
|
412
|
+
if (!t)
|
|
413
|
+
return;
|
|
414
|
+
const hasCursor = !isEmpty(get(uiiOptions, 'cursor.active'));
|
|
415
|
+
const currentStyle = el.style;
|
|
416
|
+
const currentCStyle = window.getComputedStyle(el);
|
|
417
|
+
const currentRect = el.getBoundingClientRect();
|
|
418
|
+
let dragging = false;
|
|
419
|
+
const originPosX = e.clientX;
|
|
420
|
+
const originPosY = e.clientY;
|
|
421
|
+
if (hasCursor) {
|
|
422
|
+
saveCursor();
|
|
423
|
+
}
|
|
424
|
+
let onPointerStart;
|
|
425
|
+
let onPointerMove;
|
|
426
|
+
let onPointerEnd;
|
|
427
|
+
onPointerDown({
|
|
428
|
+
onPointerMove: (pm) => { onPointerMove = pm; },
|
|
429
|
+
onPointerStart: (ps) => { onPointerStart = ps; },
|
|
430
|
+
onPointerEnd: (pe) => { onPointerEnd = pe; },
|
|
431
|
+
ev: e,
|
|
432
|
+
pointX: e.clientX, pointY: e.clientY, target: t,
|
|
433
|
+
currentTarget: el, currentStyle, currentCStyle, currentRect
|
|
434
|
+
});
|
|
435
|
+
const pointerMove = (ev) => {
|
|
436
|
+
const offX = ev.clientX - originPosX;
|
|
437
|
+
const offY = ev.clientY - originPosY;
|
|
438
|
+
if (!dragging) {
|
|
439
|
+
if (Math.abs(offX) > threshold || Math.abs(offY) > threshold) {
|
|
440
|
+
dragging = true;
|
|
441
|
+
if (toLockPage) {
|
|
442
|
+
lockPage();
|
|
443
|
+
}
|
|
444
|
+
if (hasCursor) {
|
|
445
|
+
setCursor(uiiOptions.cursor.active);
|
|
446
|
+
}
|
|
447
|
+
onPointerMove && onPointerStart({ ev });
|
|
448
|
+
}
|
|
449
|
+
else {
|
|
450
|
+
ev.preventDefault();
|
|
451
|
+
return false;
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
onPointerMove && onPointerMove({ ev, pointX: ev.clientX, pointY: ev.clientY, offX, offY, currentStyle, currentCStyle });
|
|
455
|
+
};
|
|
456
|
+
const pointerEnd = (ev) => {
|
|
457
|
+
document.removeEventListener('mousemove', pointerMove, false);
|
|
458
|
+
document.removeEventListener('mouseup', pointerEnd, false);
|
|
459
|
+
window.removeEventListener('blur', pointerEnd, false);
|
|
460
|
+
if (dragging) {
|
|
461
|
+
if (toLockPage) {
|
|
462
|
+
unlockPage();
|
|
463
|
+
}
|
|
464
|
+
if (hasCursor) {
|
|
465
|
+
restoreCursor();
|
|
466
|
+
}
|
|
467
|
+
onPointerEnd && onPointerEnd({ ev, currentStyle });
|
|
468
|
+
}
|
|
469
|
+
};
|
|
470
|
+
document.addEventListener("mousemove", pointerMove);
|
|
471
|
+
document.addEventListener("mouseup", pointerEnd);
|
|
472
|
+
window.addEventListener("blur", pointerEnd);
|
|
473
|
+
e.preventDefault();
|
|
474
|
+
return false;
|
|
475
|
+
}, true);
|
|
476
|
+
}
|
|
81
477
|
registerEvent(el, event, hook, useCapture = false) {
|
|
82
478
|
const wrapper = ((ev) => {
|
|
83
479
|
if (!this.enabled)
|
|
@@ -87,107 +483,32 @@ class Uii {
|
|
|
87
483
|
el.addEventListener(event, wrapper, useCapture);
|
|
88
484
|
__classPrivateFieldGet(this, _Uii_listeners, "f").push([el, event, wrapper, useCapture]);
|
|
89
485
|
}
|
|
90
|
-
/**
|
|
91
|
-
* 禁用uii实例,禁用后的dom不会响应事件
|
|
92
|
-
*/
|
|
93
486
|
disable() {
|
|
94
487
|
this.enabled = false;
|
|
95
488
|
}
|
|
96
|
-
/**
|
|
97
|
-
* 启用uii实例
|
|
98
|
-
*/
|
|
99
489
|
enable() {
|
|
100
490
|
this.enabled = true;
|
|
101
491
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
* @returns
|
|
106
|
-
*/
|
|
492
|
+
getOptions() {
|
|
493
|
+
return this.opts;
|
|
494
|
+
}
|
|
107
495
|
getOption(name) {
|
|
108
|
-
return
|
|
496
|
+
return this.opts[name];
|
|
109
497
|
}
|
|
110
|
-
/**
|
|
111
|
-
* 一次设置多个选项值。触发`onOptionChanged`
|
|
112
|
-
* @param options
|
|
113
|
-
*/
|
|
114
498
|
setOptions(options) {
|
|
115
499
|
assign(this.opts, options);
|
|
116
500
|
this.onOptionChanged(this.opts);
|
|
117
501
|
}
|
|
118
|
-
/**
|
|
119
|
-
* 设置指定name的选项值。触发`onOptionChanged`
|
|
120
|
-
* @param name
|
|
121
|
-
* @param value
|
|
122
|
-
*/
|
|
123
502
|
setOption(name, value) {
|
|
124
503
|
this.opts[name] = value;
|
|
125
504
|
this.onOptionChanged(this.opts);
|
|
126
505
|
}
|
|
127
|
-
|
|
128
|
-
* @internal
|
|
129
|
-
*/
|
|
130
|
-
onOptionChanged(opts) {
|
|
131
|
-
}
|
|
506
|
+
onOptionChanged(opts) { }
|
|
132
507
|
}
|
|
133
508
|
_Uii_listeners = new WeakMap();
|
|
134
509
|
|
|
135
|
-
/* eslint-disable max-len */
|
|
136
|
-
/**
|
|
137
|
-
* 获取child相对于parent的offset信息。含border宽度
|
|
138
|
-
* @returns
|
|
139
|
-
*/
|
|
140
|
-
function getOffset(child, parent) {
|
|
141
|
-
const rs = { x: 0, y: 0 };
|
|
142
|
-
let op = child.offsetParent;
|
|
143
|
-
while (op && parent && op !== parent) {
|
|
144
|
-
const style = window.getComputedStyle(op);
|
|
145
|
-
rs.x += op.offsetLeft + parseFloat(style.borderLeftWidth);
|
|
146
|
-
rs.y += op.offsetTop + parseFloat(style.borderTopWidth);
|
|
147
|
-
op = op.offsetParent;
|
|
148
|
-
}
|
|
149
|
-
rs.x += child.offsetLeft;
|
|
150
|
-
rs.y += child.offsetTop;
|
|
151
|
-
return rs;
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* 边缘检测最小内部边距
|
|
155
|
-
*/
|
|
156
|
-
const EDGE_THRESHOLD = 5;
|
|
157
|
-
const DRAGGING_RULE = "body * { pointer-events: none; }";
|
|
158
|
-
let lockSheet;
|
|
159
|
-
function lockPage() {
|
|
160
|
-
lockSheet = getFirstSS();
|
|
161
|
-
lockSheet === null || lockSheet === void 0 ? void 0 : lockSheet.insertRule(DRAGGING_RULE, 0);
|
|
162
|
-
}
|
|
163
|
-
function unlockPage() {
|
|
164
|
-
lockSheet === null || lockSheet === void 0 ? void 0 : lockSheet.deleteRule(0);
|
|
165
|
-
}
|
|
166
|
-
function getFirstSS() {
|
|
167
|
-
if (document.styleSheets.length < 1) {
|
|
168
|
-
document.head.appendChild(document.createElement('style'));
|
|
169
|
-
}
|
|
170
|
-
const sheet = find(document.styleSheets, ss => !ss.href);
|
|
171
|
-
if (!sheet) {
|
|
172
|
-
document.head.appendChild(document.createElement('style'));
|
|
173
|
-
}
|
|
174
|
-
return sheet || find(document.styleSheets, ss => !ss.href);
|
|
175
|
-
}
|
|
176
|
-
let cursor = { html: '', body: '' };
|
|
177
|
-
function saveCursor() {
|
|
178
|
-
cursor.body = document.body.style.cursor;
|
|
179
|
-
cursor.html = document.documentElement.style.cursor;
|
|
180
|
-
}
|
|
181
|
-
function setCursor(cursor) {
|
|
182
|
-
document.body.style.cursor = document.documentElement.style.cursor = cursor;
|
|
183
|
-
}
|
|
184
|
-
function restoreCursor() {
|
|
185
|
-
document.body.style.cursor = cursor.body;
|
|
186
|
-
document.documentElement.style.cursor = cursor.html;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
510
|
var _Splittable_instances, _Splittable_checkDirection, _Splittable_bindHandle;
|
|
190
|
-
const THRESHOLD$
|
|
511
|
+
const THRESHOLD$4 = 1;
|
|
191
512
|
const CLASS_SPLITTABLE = "uii-splittable";
|
|
192
513
|
const CLASS_SPLITTABLE_HANDLE = "uii-splittable-handle";
|
|
193
514
|
const CLASS_SPLITTABLE_HANDLE_GHOST = "uii-splittable-handle-ghost";
|
|
@@ -201,17 +522,6 @@ function getRootEl(el, root) {
|
|
|
201
522
|
}
|
|
202
523
|
return rs;
|
|
203
524
|
}
|
|
204
|
-
/**
|
|
205
|
-
* 用于表示一个或多个分割器的定义
|
|
206
|
-
* > 可用CSS接口
|
|
207
|
-
* - .uii-splittable
|
|
208
|
-
* - .uii-splittable-handle
|
|
209
|
-
* - .uii-splittable-handle-ghost
|
|
210
|
-
* - .uii-splittable-handle-active
|
|
211
|
-
* - .uii-splittable-v
|
|
212
|
-
* - .uii-splittable-h
|
|
213
|
-
* @public
|
|
214
|
-
*/
|
|
215
525
|
class Splittable extends Uii {
|
|
216
526
|
constructor(container, opts) {
|
|
217
527
|
super(container, assign({
|
|
@@ -222,58 +532,58 @@ class Splittable extends Uii {
|
|
|
222
532
|
ghost: false
|
|
223
533
|
}, opts));
|
|
224
534
|
_Splittable_instances.add(this);
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
return
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
return this.opts.minSize[i] || 0;
|
|
243
|
-
}
|
|
244
|
-
else {
|
|
245
|
-
return this.opts.minSize;
|
|
246
|
-
}
|
|
247
|
-
});
|
|
248
|
-
const stickyAry = map(children, (c, i) => {
|
|
249
|
-
if (isArray(this.opts.sticky)) {
|
|
250
|
-
return this.opts.sticky[i] || false;
|
|
251
|
-
}
|
|
252
|
-
else {
|
|
253
|
-
return this.opts.sticky;
|
|
254
|
-
}
|
|
255
|
-
});
|
|
256
|
-
if (isEmpty(handleDoms)) {
|
|
257
|
-
const len = children.length - 1;
|
|
258
|
-
for (let i = 0; i < len; i++) {
|
|
259
|
-
__classPrivateFieldGet(this, _Splittable_instances, "m", _Splittable_bindHandle).call(this, minSizeAry.slice(i, i + 2), stickyAry.slice(i, i + 2), this.opts, dir, children[i], children[i + 1]);
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
else {
|
|
263
|
-
each(handleDoms, (h, i) => {
|
|
264
|
-
const isRoot = h.parentNode.classList.contains(CLASS_SPLITTABLE);
|
|
265
|
-
let dom1, dom2;
|
|
266
|
-
if (isRoot) {
|
|
267
|
-
dom1 = h.previousElementSibling;
|
|
268
|
-
dom2 = h.nextElementSibling;
|
|
535
|
+
each(this.ele, con => {
|
|
536
|
+
const pos = window.getComputedStyle(con).position;
|
|
537
|
+
if (pos === "static") {
|
|
538
|
+
con.style.position = "relative";
|
|
539
|
+
}
|
|
540
|
+
con.classList.toggle(CLASS_SPLITTABLE, true);
|
|
541
|
+
const handleDoms = con.querySelectorAll(this.opts.handle);
|
|
542
|
+
const children = reject(con.children, c => {
|
|
543
|
+
if (includes(handleDoms, c))
|
|
544
|
+
return true;
|
|
545
|
+
return false;
|
|
546
|
+
});
|
|
547
|
+
const dir = __classPrivateFieldGet(this, _Splittable_instances, "m", _Splittable_checkDirection).call(this, con);
|
|
548
|
+
con.classList.toggle(dir === 'v' ? CLASS_SPLITTABLE_V : CLASS_SPLITTABLE_H, true);
|
|
549
|
+
const minSizeAry = map(children, (c, i) => {
|
|
550
|
+
if (isArray(this.opts.minSize)) {
|
|
551
|
+
return this.opts.minSize[i] || 0;
|
|
269
552
|
}
|
|
270
553
|
else {
|
|
271
|
-
|
|
272
|
-
dom1 = dom2.previousElementSibling;
|
|
554
|
+
return this.opts.minSize;
|
|
273
555
|
}
|
|
274
|
-
__classPrivateFieldGet(this, _Splittable_instances, "m", _Splittable_bindHandle).call(this, minSizeAry.slice(i, i + 2), stickyAry.slice(i, i + 2), this.opts, dir, dom1, dom2, h);
|
|
275
556
|
});
|
|
276
|
-
|
|
557
|
+
const stickyAry = map(children, (c, i) => {
|
|
558
|
+
if (isArray(this.opts.sticky)) {
|
|
559
|
+
return this.opts.sticky[i] || false;
|
|
560
|
+
}
|
|
561
|
+
else {
|
|
562
|
+
return this.opts.sticky;
|
|
563
|
+
}
|
|
564
|
+
});
|
|
565
|
+
if (isEmpty(handleDoms)) {
|
|
566
|
+
const len = children.length - 1;
|
|
567
|
+
for (let i = 0; i < len; i++) {
|
|
568
|
+
__classPrivateFieldGet(this, _Splittable_instances, "m", _Splittable_bindHandle).call(this, minSizeAry.slice(i, i + 2), stickyAry.slice(i, i + 2), this.opts, dir, children[i], children[i + 1]);
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
else {
|
|
572
|
+
each(handleDoms, (h, i) => {
|
|
573
|
+
const isRoot = h.parentNode.classList.contains(CLASS_SPLITTABLE);
|
|
574
|
+
let dom1, dom2;
|
|
575
|
+
if (isRoot) {
|
|
576
|
+
dom1 = h.previousElementSibling;
|
|
577
|
+
dom2 = h.nextElementSibling;
|
|
578
|
+
}
|
|
579
|
+
else {
|
|
580
|
+
dom2 = getRootEl(h, con);
|
|
581
|
+
dom1 = dom2.previousElementSibling;
|
|
582
|
+
}
|
|
583
|
+
__classPrivateFieldGet(this, _Splittable_instances, "m", _Splittable_bindHandle).call(this, minSizeAry.slice(i, i + 2), stickyAry.slice(i, i + 2), this.opts, dir, dom1, dom2, h);
|
|
584
|
+
});
|
|
585
|
+
}
|
|
586
|
+
});
|
|
277
587
|
}
|
|
278
588
|
}
|
|
279
589
|
_Splittable_instances = new WeakSet(), _Splittable_checkDirection = function _Splittable_checkDirection(container) {
|
|
@@ -320,34 +630,29 @@ _Splittable_instances = new WeakSet(), _Splittable_checkDirection = function _Sp
|
|
|
320
630
|
const oneSideMode = opts.oneSideMode;
|
|
321
631
|
const updateStart = !oneSideMode || oneSideMode === 'start';
|
|
322
632
|
const updateEnd = !oneSideMode || oneSideMode === 'end';
|
|
323
|
-
handle
|
|
324
|
-
// 1. 获取原始高度/宽度;设置宽度/高度
|
|
633
|
+
this.addPointerDown(handle, ({ currentTarget, onPointerStart, onPointerMove, onPointerEnd }) => {
|
|
325
634
|
let originSize = 0;
|
|
326
635
|
let originSize1 = 0;
|
|
327
|
-
const originPosX = e.clientX;
|
|
328
|
-
const originPosY = e.clientY;
|
|
329
636
|
let splitterSize = 1;
|
|
330
|
-
let blockSize = 0;
|
|
637
|
+
let blockSize = 0;
|
|
331
638
|
switch (dir) {
|
|
332
639
|
case 'v':
|
|
333
640
|
originSize = dom1.offsetHeight;
|
|
334
641
|
originSize1 = dom2.offsetHeight;
|
|
335
|
-
splitterSize =
|
|
642
|
+
splitterSize = currentTarget.offsetHeight;
|
|
336
643
|
break;
|
|
337
644
|
case 'h':
|
|
338
645
|
originSize = dom1.offsetWidth;
|
|
339
646
|
originSize1 = dom2.offsetWidth;
|
|
340
|
-
splitterSize =
|
|
647
|
+
splitterSize = currentTarget.offsetWidth;
|
|
341
648
|
break;
|
|
342
649
|
}
|
|
343
650
|
blockSize = splitterSize + originSize + originSize1;
|
|
344
651
|
const dom1Style = dom1.style;
|
|
345
652
|
const dom2Style = dom2.style;
|
|
346
|
-
//ghost
|
|
347
653
|
const ghost = opts.ghost;
|
|
348
654
|
const ghostClass = opts.ghostClass;
|
|
349
655
|
let ghostNode = null;
|
|
350
|
-
// 初始化sticked位置
|
|
351
656
|
let sticked = 'none';
|
|
352
657
|
if (originSize < minSize1 / 2) {
|
|
353
658
|
sticked = 'start';
|
|
@@ -355,43 +660,31 @@ _Splittable_instances = new WeakSet(), _Splittable_checkDirection = function _Sp
|
|
|
355
660
|
else if (blockSize - originSize - splitterSize < minSize2 / 2) {
|
|
356
661
|
sticked = 'end';
|
|
357
662
|
}
|
|
358
|
-
let dragging = false;
|
|
359
|
-
saveCursor();
|
|
360
663
|
let startPos = dir === 'v' ? dom1.offsetTop : dom1.offsetLeft;
|
|
361
664
|
let ds1, anotherSize;
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
ghostNode.
|
|
373
|
-
|
|
374
|
-
ghostNode.classList.add(CLASS_SPLITTABLE_HANDLE_GHOST);
|
|
375
|
-
if (ghostNode) {
|
|
376
|
-
if (ghostClass) {
|
|
377
|
-
ghostNode.className =
|
|
378
|
-
ghostNode.className.replace(ghostClass, '') + ' ' + ghostClass;
|
|
379
|
-
}
|
|
380
|
-
(_a = handle === null || handle === void 0 ? void 0 : handle.parentNode) === null || _a === void 0 ? void 0 : _a.appendChild(ghostNode);
|
|
381
|
-
call(onClone, ghostNode, e);
|
|
382
|
-
}
|
|
665
|
+
onPointerStart(function (args) {
|
|
666
|
+
const { ev } = args;
|
|
667
|
+
currentTarget.classList.add(CLASS_SPLITTABLE_HANDLE_ACTIVE);
|
|
668
|
+
if (ghost) {
|
|
669
|
+
ghostNode = currentTarget.cloneNode(true);
|
|
670
|
+
ghostNode.style.opacity = '0.3';
|
|
671
|
+
ghostNode.style.pointerEvents = 'none';
|
|
672
|
+
ghostNode.classList.add(CLASS_SPLITTABLE_HANDLE_GHOST);
|
|
673
|
+
if (ghostNode) {
|
|
674
|
+
if (ghostClass) {
|
|
675
|
+
ghostNode.className =
|
|
676
|
+
ghostNode.className.replace(ghostClass, '') + ' ' + ghostClass;
|
|
383
677
|
}
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
call(onStart, originSize, originSize1);
|
|
387
|
-
}
|
|
388
|
-
else {
|
|
389
|
-
ev.preventDefault();
|
|
390
|
-
return false;
|
|
678
|
+
currentTarget.parentNode.appendChild(ghostNode);
|
|
679
|
+
onClone && onClone({ clone: ghostNode }, ev);
|
|
391
680
|
}
|
|
392
681
|
}
|
|
682
|
+
onStart && onStart({ size1: originSize, size2: originSize1 }, ev);
|
|
683
|
+
});
|
|
684
|
+
onPointerMove((args) => {
|
|
685
|
+
const { ev, offX, offY, currentStyle } = args;
|
|
393
686
|
let doSticky = false;
|
|
394
|
-
ds1 = dir === 'v' ? originSize +
|
|
687
|
+
ds1 = dir === 'v' ? originSize + offY : originSize + offX;
|
|
395
688
|
if (ds1 < minSize1 / 2 && sticky1 && minSize1 > 0) {
|
|
396
689
|
if (sticked == 'none') {
|
|
397
690
|
doSticky = true;
|
|
@@ -402,7 +695,6 @@ _Splittable_instances = new WeakSet(), _Splittable_checkDirection = function _Sp
|
|
|
402
695
|
else if (ds1 < minSize1) {
|
|
403
696
|
ds1 = minSize1;
|
|
404
697
|
if (sticked == 'start' && sticky1) {
|
|
405
|
-
// 重置状态
|
|
406
698
|
doSticky = true;
|
|
407
699
|
sticked = 'none';
|
|
408
700
|
}
|
|
@@ -418,7 +710,6 @@ _Splittable_instances = new WeakSet(), _Splittable_checkDirection = function _Sp
|
|
|
418
710
|
else if (blockSize - ds1 - splitterSize < minSize2) {
|
|
419
711
|
ds1 = blockSize - minSize2 - splitterSize;
|
|
420
712
|
if (sticked == 'end' && sticky2) {
|
|
421
|
-
// 重置状态
|
|
422
713
|
doSticky = true;
|
|
423
714
|
sticked = 'none';
|
|
424
715
|
}
|
|
@@ -430,6 +721,7 @@ _Splittable_instances = new WeakSet(), _Splittable_checkDirection = function _Sp
|
|
|
430
721
|
}
|
|
431
722
|
else {
|
|
432
723
|
ghostNode.style.left = startPos + ds1 - handleSize / 2 + 'px';
|
|
724
|
+
console.log(ghostNode.style.left);
|
|
433
725
|
}
|
|
434
726
|
}
|
|
435
727
|
else {
|
|
@@ -441,395 +733,499 @@ _Splittable_instances = new WeakSet(), _Splittable_checkDirection = function _Sp
|
|
|
441
733
|
dom2Style.setProperty(updateProp, anotherSize + 'px', 'important');
|
|
442
734
|
}
|
|
443
735
|
if (doSticky) {
|
|
444
|
-
|
|
736
|
+
onSticky && onSticky({ size1: ds1, size2: anotherSize, position: sticked }, ev);
|
|
445
737
|
}
|
|
446
|
-
//update handle
|
|
447
738
|
if (dir === 'v') {
|
|
448
|
-
|
|
739
|
+
currentStyle.top = dom2.offsetTop - handleSize / 2 + 'px';
|
|
449
740
|
}
|
|
450
741
|
else {
|
|
451
|
-
|
|
742
|
+
currentStyle.left = dom2.offsetLeft - handleSize / 2 + 'px';
|
|
452
743
|
}
|
|
453
744
|
}
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
};
|
|
458
|
-
const dragEndListener = (ev) => {
|
|
745
|
+
onSplit && onSplit({ size1: ds1, size2: anotherSize }, ev);
|
|
746
|
+
});
|
|
747
|
+
onPointerEnd((args) => {
|
|
459
748
|
var _a, _b;
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
749
|
+
const { ev, currentStyle } = args;
|
|
750
|
+
switch (dir) {
|
|
751
|
+
case 'v':
|
|
752
|
+
originSize = (dom1 === null || dom1 === void 0 ? void 0 : dom1.offsetHeight) || -1;
|
|
753
|
+
originSize1 = (dom2 === null || dom2 === void 0 ? void 0 : dom2.offsetHeight) || -1;
|
|
754
|
+
break;
|
|
755
|
+
case 'h':
|
|
756
|
+
originSize = (dom1 === null || dom1 === void 0 ? void 0 : dom1.offsetWidth) || -1;
|
|
757
|
+
originSize1 = (dom2 === null || dom2 === void 0 ? void 0 : dom2.offsetWidth) || -1;
|
|
758
|
+
break;
|
|
759
|
+
}
|
|
760
|
+
handle === null || handle === void 0 ? void 0 : handle.classList.remove(CLASS_SPLITTABLE_HANDLE_ACTIVE);
|
|
761
|
+
if (ghostNode) {
|
|
762
|
+
const updateProp = dir === 'v' ? 'height' : 'width';
|
|
763
|
+
if (updateStart) {
|
|
764
|
+
dom1Style.setProperty(updateProp, ds1 + 'px', 'important');
|
|
473
765
|
}
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
const updateProp = dir === 'v' ? 'height' : 'width';
|
|
477
|
-
if (updateStart) {
|
|
478
|
-
dom1Style.setProperty(updateProp, ds1 + 'px', 'important');
|
|
479
|
-
}
|
|
480
|
-
if (updateEnd) {
|
|
481
|
-
dom2Style.setProperty(updateProp, anotherSize + 'px', 'important');
|
|
482
|
-
}
|
|
483
|
-
//update handle
|
|
484
|
-
if (dir === 'v') {
|
|
485
|
-
handle.style.top = startPos + ds1 - handleSize / 2 + 'px';
|
|
486
|
-
}
|
|
487
|
-
else {
|
|
488
|
-
handle.style.left = startPos + ds1 - handleSize / 2 + 'px';
|
|
489
|
-
}
|
|
490
|
-
((_a = ghostNode.parentNode) === null || _a === void 0 ? void 0 : _a.contains(ghostNode)) && ((_b = ghostNode.parentNode) === null || _b === void 0 ? void 0 : _b.removeChild(ghostNode));
|
|
766
|
+
if (updateEnd) {
|
|
767
|
+
dom2Style.setProperty(updateProp, anotherSize + 'px', 'important');
|
|
491
768
|
}
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
769
|
+
if (dir === 'v') {
|
|
770
|
+
currentStyle.top = startPos + ds1 - handleSize / 2 + 'px';
|
|
771
|
+
}
|
|
772
|
+
else {
|
|
773
|
+
currentStyle.left = startPos + ds1 - handleSize / 2 + 'px';
|
|
774
|
+
}
|
|
775
|
+
((_a = ghostNode.parentNode) === null || _a === void 0 ? void 0 : _a.contains(ghostNode)) && ((_b = ghostNode.parentNode) === null || _b === void 0 ? void 0 : _b.removeChild(ghostNode));
|
|
495
776
|
}
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
};
|
|
777
|
+
onEnd && onEnd({ size1: originSize, size2: originSize1 }, ev);
|
|
778
|
+
});
|
|
779
|
+
}, {
|
|
780
|
+
threshold: THRESHOLD$4,
|
|
781
|
+
lockPage: true
|
|
782
|
+
});
|
|
503
783
|
};
|
|
504
|
-
/**
|
|
505
|
-
* Add one or more splittors into the container
|
|
506
|
-
* @param container css selector or html element
|
|
507
|
-
* @param opts SplittableOptions
|
|
508
|
-
* @returns
|
|
509
|
-
*/
|
|
510
784
|
function newSplittable(container, opts) {
|
|
511
785
|
return new Splittable(container, opts);
|
|
512
786
|
}
|
|
513
787
|
|
|
514
|
-
|
|
515
|
-
const THRESHOLD$2 = 2;
|
|
788
|
+
const THRESHOLD$3 = 2;
|
|
516
789
|
const CLASS_RESIZABLE_HANDLE = "uii-resizable-handle";
|
|
517
790
|
const CLASS_RESIZABLE_HANDLE_DIR = "uii-resizable-handle-";
|
|
518
791
|
const CLASS_RESIZABLE_HANDLE_ACTIVE = "uii-resizable-handle-active";
|
|
519
|
-
|
|
520
|
-
* 用于表示一个或多个可改变尺寸元素的定义
|
|
521
|
-
* > 可用CSS接口
|
|
522
|
-
* - .uii-resizable-handle
|
|
523
|
-
* - .uii-resizable-handle-[n/s/e/w/ne/nw/se/sw]
|
|
524
|
-
* - .uii-resizable-handle-active
|
|
525
|
-
* @public
|
|
526
|
-
*/
|
|
792
|
+
const EXP_DIR = new RegExp(CLASS_RESIZABLE_HANDLE_DIR + "(?<dir>[nesw]+)");
|
|
527
793
|
class Resizable extends Uii {
|
|
528
794
|
constructor(els, opts) {
|
|
529
795
|
super(els, assign({
|
|
530
796
|
handleSize: 8,
|
|
531
797
|
minSize: 50,
|
|
532
|
-
dir: [
|
|
798
|
+
dir: ["n", "s", "e", "w", "ne", "nw", "se", "sw"],
|
|
533
799
|
ghost: false,
|
|
534
|
-
offset: 0
|
|
800
|
+
offset: 0,
|
|
535
801
|
}, opts));
|
|
536
802
|
each(this.ele, (el) => {
|
|
537
|
-
initHandle
|
|
803
|
+
this.initHandle(el);
|
|
538
804
|
});
|
|
539
805
|
}
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
if (isFunction(ghost)) {
|
|
641
|
-
ghostNode = ghost();
|
|
642
|
-
}
|
|
643
|
-
else {
|
|
644
|
-
ghostNode = panel.cloneNode(true);
|
|
645
|
-
ghostNode.style.opacity = '0.3';
|
|
646
|
-
ghostNode.style.pointerEvents = 'none';
|
|
647
|
-
}
|
|
648
|
-
if (ghostNode) {
|
|
649
|
-
if (ghostClass) {
|
|
650
|
-
ghostNode.className =
|
|
651
|
-
ghostNode.className.replace(ghostClass, '') + ' ' + ghostClass;
|
|
652
|
-
}
|
|
653
|
-
(_a = panel.parentNode) === null || _a === void 0 ? void 0 : _a.appendChild(ghostNode);
|
|
654
|
-
call(onClone, ghostNode, e);
|
|
655
|
-
}
|
|
656
|
-
style = ghostNode === null || ghostNode === void 0 ? void 0 : ghostNode.style;
|
|
657
|
-
}
|
|
658
|
-
lockPage();
|
|
659
|
-
setCursor(handle.dataset.cursor || '');
|
|
660
|
-
call(onStart, originW, originH);
|
|
661
|
-
}
|
|
662
|
-
else {
|
|
663
|
-
ev.preventDefault();
|
|
664
|
-
return false;
|
|
665
|
-
}
|
|
666
|
-
}
|
|
667
|
-
let w = originW;
|
|
668
|
-
let h = originH;
|
|
669
|
-
let y = originY;
|
|
670
|
-
let x = originX;
|
|
671
|
-
if (changeW) {
|
|
672
|
-
w = originW + offsetx * (changeX ? -1 : 1);
|
|
673
|
-
if (minWidth && w < minWidth)
|
|
674
|
-
w = minWidth;
|
|
675
|
-
if (maxWidth && w > maxWidth)
|
|
676
|
-
w = maxWidth;
|
|
677
|
-
}
|
|
678
|
-
if (changeH) {
|
|
679
|
-
h = originH + offsety * (changeY ? -1 : 1);
|
|
680
|
-
if (minHeight && h < minHeight)
|
|
681
|
-
h = minHeight;
|
|
682
|
-
if (maxHeight && h > maxHeight)
|
|
683
|
-
h = maxHeight;
|
|
684
|
-
}
|
|
685
|
-
if (changeY) {
|
|
686
|
-
y = originY + offsety;
|
|
687
|
-
if (minY && y < minY)
|
|
688
|
-
y = minY;
|
|
689
|
-
if (maxY && y > maxY)
|
|
690
|
-
y = maxY;
|
|
691
|
-
}
|
|
692
|
-
if (changeX) {
|
|
693
|
-
x = originX + offsetx;
|
|
694
|
-
if (minX && x < minX)
|
|
695
|
-
x = minX;
|
|
696
|
-
if (maxX && x > maxX)
|
|
697
|
-
x = maxX;
|
|
698
|
-
}
|
|
699
|
-
if (aspectRatio) {
|
|
700
|
-
if (changeW) {
|
|
701
|
-
style.width = w + 'px';
|
|
702
|
-
style.height = w / aspectRatio + 'px';
|
|
703
|
-
}
|
|
704
|
-
if (changeH && dir !== 'sw') {
|
|
705
|
-
if (dir === 'nw') {
|
|
706
|
-
y = originY - w / aspectRatio + originH;
|
|
806
|
+
bindHandle(handle, dir, panel, opts) {
|
|
807
|
+
const onStart = opts.onStart;
|
|
808
|
+
const onResize = opts.onResize;
|
|
809
|
+
const onEnd = opts.onEnd;
|
|
810
|
+
const onClone = opts.onClone;
|
|
811
|
+
const uiik = this;
|
|
812
|
+
this.addPointerDown(handle, ({ ev, onPointerStart, onPointerMove, onPointerEnd }) => {
|
|
813
|
+
const onPointerDown = opts.onPointerDown;
|
|
814
|
+
if (onPointerDown && onPointerDown(ev) === false)
|
|
815
|
+
return;
|
|
816
|
+
let matrixInfo = getMatrixInfo(panel);
|
|
817
|
+
const offset = getRectInContainer(panel, panel.parentElement);
|
|
818
|
+
const offsetParentRect = panel.parentElement.getBoundingClientRect();
|
|
819
|
+
const offsetParentCStyle = window.getComputedStyle(panel.parentElement);
|
|
820
|
+
const panelCStyle = window.getComputedStyle(panel);
|
|
821
|
+
const originW = parseFloat(panelCStyle.width);
|
|
822
|
+
const originH = parseFloat(panelCStyle.height);
|
|
823
|
+
const originX = offset.x;
|
|
824
|
+
const originY = offset.y;
|
|
825
|
+
let changeW = false;
|
|
826
|
+
let changeH = false;
|
|
827
|
+
let changeX = false;
|
|
828
|
+
let changeY = false;
|
|
829
|
+
let toTransformOrigin = "";
|
|
830
|
+
switch (dir) {
|
|
831
|
+
case "s":
|
|
832
|
+
changeH = true;
|
|
833
|
+
break;
|
|
834
|
+
case "e":
|
|
835
|
+
changeW = true;
|
|
836
|
+
break;
|
|
837
|
+
case "se":
|
|
838
|
+
changeW = true;
|
|
839
|
+
changeH = true;
|
|
840
|
+
break;
|
|
841
|
+
case "n":
|
|
842
|
+
changeX = true;
|
|
843
|
+
changeY = true;
|
|
844
|
+
changeH = true;
|
|
845
|
+
toTransformOrigin = "0 0";
|
|
846
|
+
break;
|
|
847
|
+
case "w":
|
|
848
|
+
changeX = true;
|
|
849
|
+
changeY = true;
|
|
850
|
+
changeW = true;
|
|
851
|
+
toTransformOrigin = "0 0";
|
|
852
|
+
break;
|
|
853
|
+
case "sw":
|
|
854
|
+
case "ne":
|
|
855
|
+
case "nw":
|
|
856
|
+
changeX = true;
|
|
857
|
+
changeY = true;
|
|
858
|
+
changeW = true;
|
|
859
|
+
changeH = true;
|
|
860
|
+
toTransformOrigin = "0 0";
|
|
861
|
+
break;
|
|
862
|
+
}
|
|
863
|
+
let minWidth;
|
|
864
|
+
let minHeight;
|
|
865
|
+
let maxWidth;
|
|
866
|
+
let maxHeight;
|
|
867
|
+
if (isArray(opts.minSize)) {
|
|
868
|
+
minWidth = opts.minSize[0];
|
|
869
|
+
minHeight = opts.minSize[1];
|
|
870
|
+
}
|
|
871
|
+
else if (isNumber(opts.minSize)) {
|
|
872
|
+
minWidth = opts.minSize;
|
|
873
|
+
minHeight = opts.minSize;
|
|
874
|
+
}
|
|
875
|
+
if (isArray(opts.maxSize)) {
|
|
876
|
+
maxWidth = opts.maxSize[0];
|
|
877
|
+
maxHeight = opts.maxSize[1];
|
|
878
|
+
}
|
|
879
|
+
else if (isNumber(opts.maxSize)) {
|
|
880
|
+
maxWidth = opts.maxSize;
|
|
881
|
+
maxHeight = opts.maxSize;
|
|
882
|
+
}
|
|
883
|
+
const ghost = opts.ghost;
|
|
884
|
+
const ghostClass = opts.ghostClass;
|
|
885
|
+
let ghostNode = null;
|
|
886
|
+
const aspectRatio = opts.aspectRatio;
|
|
887
|
+
const panelStyle = panel.style;
|
|
888
|
+
let style = panelStyle;
|
|
889
|
+
let currentW = originW;
|
|
890
|
+
let currentH = originH;
|
|
891
|
+
let transformer;
|
|
892
|
+
let lastX = 0, lastY = 0;
|
|
893
|
+
let originalTransformOrigin = "";
|
|
894
|
+
let originVertex;
|
|
895
|
+
let vertexBeforeTransform;
|
|
896
|
+
let currentVertex;
|
|
897
|
+
let refPoint;
|
|
898
|
+
let k1;
|
|
899
|
+
onPointerStart(function (args) {
|
|
900
|
+
var _a;
|
|
901
|
+
const { ev } = args;
|
|
902
|
+
handle.classList.add(CLASS_RESIZABLE_HANDLE_ACTIVE);
|
|
903
|
+
if (ghost) {
|
|
904
|
+
if (isFunction(ghost)) {
|
|
905
|
+
ghostNode = ghost(panel);
|
|
707
906
|
}
|
|
708
907
|
else {
|
|
709
|
-
|
|
710
|
-
style.
|
|
908
|
+
ghostNode = panel.cloneNode(true);
|
|
909
|
+
ghostNode.style.opacity = "0.3";
|
|
910
|
+
ghostNode.style.pointerEvents = "none";
|
|
711
911
|
}
|
|
912
|
+
if (ghostNode) {
|
|
913
|
+
if (ghostClass) {
|
|
914
|
+
ghostNode.className =
|
|
915
|
+
ghostNode.className.replace(ghostClass, "") +
|
|
916
|
+
" " +
|
|
917
|
+
ghostClass;
|
|
918
|
+
}
|
|
919
|
+
(_a = panel.parentNode) === null || _a === void 0 ? void 0 : _a.appendChild(ghostNode);
|
|
920
|
+
transformer = wrapper(ghostNode);
|
|
921
|
+
onClone && onClone({ clone: ghostNode }, ev);
|
|
922
|
+
}
|
|
923
|
+
style = ghostNode === null || ghostNode === void 0 ? void 0 : ghostNode.style;
|
|
712
924
|
}
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
if (changeW) {
|
|
716
|
-
style.width = w + 'px';
|
|
925
|
+
else {
|
|
926
|
+
transformer = wrapper(panel);
|
|
717
927
|
}
|
|
718
|
-
|
|
719
|
-
|
|
928
|
+
const { x, y, sx, sy } = getCenterXy(panel);
|
|
929
|
+
let centerX = x, centerY = y;
|
|
930
|
+
const deg = matrixInfo.angle * ONE_ANG;
|
|
931
|
+
originVertex = [
|
|
932
|
+
{ x: 0, y: 0 },
|
|
933
|
+
{ x: originW, y: 0 },
|
|
934
|
+
{ x: 0, y: originH },
|
|
935
|
+
{ x: originW, y: originH },
|
|
936
|
+
];
|
|
937
|
+
currentVertex = vertexBeforeTransform = map(originVertex, ({ x, y }) => {
|
|
938
|
+
const nx = (x - centerX + sx) * Math.cos(deg) -
|
|
939
|
+
(y - centerY + sy) * Math.sin(deg);
|
|
940
|
+
const ny = (x - centerX + sx) * Math.sin(deg) +
|
|
941
|
+
(y - centerY + sy) * Math.cos(deg);
|
|
942
|
+
return { x: centerX + nx, y: centerY + ny };
|
|
943
|
+
});
|
|
944
|
+
switch (dir) {
|
|
945
|
+
case "s":
|
|
946
|
+
case "e":
|
|
947
|
+
case "se":
|
|
948
|
+
refPoint = currentVertex[0];
|
|
949
|
+
break;
|
|
950
|
+
case "n":
|
|
951
|
+
case "w":
|
|
952
|
+
case "nw":
|
|
953
|
+
refPoint = currentVertex[3];
|
|
954
|
+
break;
|
|
955
|
+
case "sw":
|
|
956
|
+
refPoint = currentVertex[1];
|
|
957
|
+
break;
|
|
958
|
+
case "ne":
|
|
959
|
+
refPoint = currentVertex[2];
|
|
960
|
+
break;
|
|
720
961
|
}
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
};
|
|
753
|
-
document.addEventListener('mousemove', dragListener, false);
|
|
754
|
-
document.addEventListener('mouseup', dragEndListener, false);
|
|
755
|
-
window.addEventListener('blur', dragEndListener, false);
|
|
756
|
-
e.preventDefault();
|
|
757
|
-
return false;
|
|
758
|
-
};
|
|
759
|
-
}
|
|
760
|
-
function initHandle$1(panel, opts) {
|
|
761
|
-
// create handles
|
|
762
|
-
const handleSize = opts.handleSize;
|
|
763
|
-
const offset = opts.offset || 0;
|
|
764
|
-
each(opts.dir || ['n', 's', 'e', 'w', 'ne', 'nw', 'se', 'sw'], (dir) => {
|
|
765
|
-
const handle = document.createElement('div');
|
|
766
|
-
handle.classList.add(CLASS_RESIZABLE_HANDLE, CLASS_RESIZABLE_HANDLE_DIR + dir);
|
|
767
|
-
handle.setAttribute('name', 'handle');
|
|
768
|
-
let css = '';
|
|
769
|
-
switch (dir) {
|
|
770
|
-
case 'n':
|
|
771
|
-
css = `left:0px;top:${-offset}px;width:100%;height:${handleSize}px;`;
|
|
772
|
-
break;
|
|
773
|
-
case 's':
|
|
774
|
-
css = `left:0px;bottom:${-offset}px;width:100%;height:${handleSize}px;`;
|
|
775
|
-
break;
|
|
776
|
-
case 'w':
|
|
777
|
-
css = `top:0px;left:${-offset}px;width:${handleSize}px;height:100%;`;
|
|
778
|
-
break;
|
|
779
|
-
case 'e':
|
|
780
|
-
css = `top:0px;right:${-offset}px;width:${handleSize}px;height:100%;`;
|
|
781
|
-
break;
|
|
782
|
-
default:
|
|
783
|
-
css = `width:${handleSize}px;height:${handleSize}px;z-index:9;`;
|
|
962
|
+
k1 =
|
|
963
|
+
(currentVertex[1].y - refPoint.y) /
|
|
964
|
+
(currentVertex[1].x - refPoint.x);
|
|
965
|
+
style.transition = "none";
|
|
966
|
+
originalTransformOrigin = style.transformOrigin;
|
|
967
|
+
if (toTransformOrigin) {
|
|
968
|
+
style.transformOrigin = toTransformOrigin;
|
|
969
|
+
}
|
|
970
|
+
else {
|
|
971
|
+
style.transformOrigin = `${centerX - transformer.x}px ${centerY - transformer.y}px`;
|
|
972
|
+
}
|
|
973
|
+
onStart && onStart.call(uiik, { w: originW, h: originH }, ev);
|
|
974
|
+
});
|
|
975
|
+
onPointerMove((args) => {
|
|
976
|
+
const { ev } = args;
|
|
977
|
+
const currentXy = getPointInContainer(ev, panel.parentElement, offsetParentRect, offsetParentCStyle);
|
|
978
|
+
let newX = currentXy.x;
|
|
979
|
+
let newY = currentXy.y;
|
|
980
|
+
let angle = Math.atan2(newY - refPoint.y, newX - refPoint.x) * ONE_RAD -
|
|
981
|
+
matrixInfo.angle;
|
|
982
|
+
let hyLen = Math.sqrt((newX - refPoint.x) * (newX - refPoint.x) +
|
|
983
|
+
(newY - refPoint.y) * (newY - refPoint.y));
|
|
984
|
+
let pl1 = Math.abs(k1 === Infinity
|
|
985
|
+
? newY - refPoint.y
|
|
986
|
+
: hyLen * Math.cos(angle * ONE_ANG));
|
|
987
|
+
let pl2 = Math.sqrt(hyLen * hyLen - pl1 * pl1);
|
|
988
|
+
let w = originW;
|
|
989
|
+
let h = originH;
|
|
990
|
+
let y = originY;
|
|
991
|
+
let x = originX;
|
|
992
|
+
let angl = 0;
|
|
784
993
|
switch (dir) {
|
|
785
|
-
case
|
|
786
|
-
|
|
994
|
+
case "s":
|
|
995
|
+
h = pl2;
|
|
996
|
+
break;
|
|
997
|
+
case "e":
|
|
998
|
+
w = pl1;
|
|
999
|
+
break;
|
|
1000
|
+
case "se":
|
|
1001
|
+
w = pl1;
|
|
1002
|
+
h = pl2;
|
|
1003
|
+
break;
|
|
1004
|
+
case "n":
|
|
1005
|
+
h = pl2;
|
|
1006
|
+
angl =
|
|
1007
|
+
Math.atan2(currentVertex[0].y - currentVertex[2].y, currentVertex[0].x - currentVertex[2].x) * ONE_RAD;
|
|
1008
|
+
let plh;
|
|
1009
|
+
if (angl === 90) {
|
|
1010
|
+
h = newY - currentVertex[2].y;
|
|
1011
|
+
x = currentVertex[2].x;
|
|
1012
|
+
y = newY;
|
|
1013
|
+
}
|
|
1014
|
+
else if (currentVertex[2].y > currentVertex[0].y) {
|
|
1015
|
+
plh = h * Math.cos(angl * ONE_ANG);
|
|
1016
|
+
x = currentVertex[2].x + plh;
|
|
1017
|
+
y = currentVertex[2].y - Math.sqrt(h * h - plh * plh);
|
|
1018
|
+
}
|
|
1019
|
+
else {
|
|
1020
|
+
plh = h * Math.cos((180 - angl) * ONE_ANG);
|
|
1021
|
+
x = currentVertex[2].x - plh;
|
|
1022
|
+
y = currentVertex[2].y + Math.sqrt(h * h - plh * plh);
|
|
1023
|
+
}
|
|
787
1024
|
break;
|
|
788
|
-
case
|
|
789
|
-
|
|
1025
|
+
case "w":
|
|
1026
|
+
w = pl1;
|
|
1027
|
+
angl =
|
|
1028
|
+
Math.atan2(currentVertex[0].y - currentVertex[1].y, currentVertex[0].x - currentVertex[1].x) * ONE_RAD;
|
|
1029
|
+
let plw;
|
|
1030
|
+
if (angl === 0) {
|
|
1031
|
+
w = newX - currentVertex[1].x;
|
|
1032
|
+
x = newX;
|
|
1033
|
+
y = currentVertex[1].y;
|
|
1034
|
+
}
|
|
1035
|
+
else if (currentVertex[1].y > currentVertex[0].y) {
|
|
1036
|
+
plw = w * Math.cos((180 - angl) * ONE_ANG);
|
|
1037
|
+
x = currentVertex[1].x - plw;
|
|
1038
|
+
y = currentVertex[1].y - Math.sqrt(w * w - plw * plw);
|
|
1039
|
+
}
|
|
1040
|
+
else {
|
|
1041
|
+
plw = w * Math.cos(angl * ONE_ANG);
|
|
1042
|
+
x = currentVertex[1].x + plw;
|
|
1043
|
+
y = currentVertex[1].y + Math.sqrt(w * w - plw * plw);
|
|
1044
|
+
}
|
|
1045
|
+
break;
|
|
1046
|
+
case "nw":
|
|
1047
|
+
w = pl1;
|
|
1048
|
+
h = pl2;
|
|
1049
|
+
x = newX;
|
|
1050
|
+
y = newY;
|
|
1051
|
+
if (matrixInfo.angle === 180) {
|
|
1052
|
+
w = newX - currentVertex[3].x;
|
|
1053
|
+
h = newY - currentVertex[3].y;
|
|
1054
|
+
}
|
|
1055
|
+
break;
|
|
1056
|
+
case "sw":
|
|
1057
|
+
w = pl1;
|
|
1058
|
+
h = pl2;
|
|
1059
|
+
angl =
|
|
1060
|
+
Math.atan2(currentVertex[0].y - currentVertex[1].y, currentVertex[0].x - currentVertex[1].x) * ONE_RAD;
|
|
1061
|
+
let plw1;
|
|
1062
|
+
if (angl === 0) {
|
|
1063
|
+
x = newX;
|
|
1064
|
+
y = currentVertex[0].y;
|
|
1065
|
+
}
|
|
1066
|
+
else if (currentVertex[1].y > currentVertex[0].y) {
|
|
1067
|
+
plw1 = w * Math.cos((180 - angl) * ONE_ANG);
|
|
1068
|
+
x = currentVertex[1].x - plw1;
|
|
1069
|
+
y = currentVertex[1].y - Math.sqrt(w * w - plw1 * plw1);
|
|
1070
|
+
}
|
|
1071
|
+
else {
|
|
1072
|
+
plw1 = w * Math.cos((180 - angl) * ONE_ANG);
|
|
1073
|
+
x = currentVertex[1].x - plw1;
|
|
1074
|
+
y = currentVertex[1].y + Math.sqrt(w * w - plw1 * plw1);
|
|
1075
|
+
}
|
|
790
1076
|
break;
|
|
791
|
-
case
|
|
792
|
-
|
|
1077
|
+
case "ne":
|
|
1078
|
+
w = pl1;
|
|
1079
|
+
h = pl2;
|
|
1080
|
+
angl =
|
|
1081
|
+
Math.atan2(currentVertex[0].y - currentVertex[2].y, currentVertex[0].x - currentVertex[2].x) * ONE_RAD;
|
|
1082
|
+
let plne;
|
|
1083
|
+
if (angl === 0) {
|
|
1084
|
+
x = newX;
|
|
1085
|
+
y = currentVertex[0].y;
|
|
1086
|
+
}
|
|
1087
|
+
else if (currentVertex[1].x > currentVertex[0].x) {
|
|
1088
|
+
plne = h * Math.cos((180 - angl) * ONE_ANG);
|
|
1089
|
+
x = currentVertex[2].x - plne;
|
|
1090
|
+
y = currentVertex[2].y - Math.sqrt(h * h - plne * plne);
|
|
1091
|
+
}
|
|
1092
|
+
else {
|
|
1093
|
+
plne = h * Math.cos(angl * ONE_ANG);
|
|
1094
|
+
x = currentVertex[2].x + plne;
|
|
1095
|
+
y = currentVertex[2].y + Math.sqrt(h * h - plne * plne);
|
|
1096
|
+
}
|
|
793
1097
|
break;
|
|
794
|
-
case 'sw':
|
|
795
|
-
css += `bottom:${-offset}px;left:${-offset}px;`;
|
|
796
1098
|
}
|
|
1099
|
+
if (changeW) {
|
|
1100
|
+
if (minWidth && w < minWidth)
|
|
1101
|
+
w = minWidth;
|
|
1102
|
+
if (maxWidth && w > maxWidth)
|
|
1103
|
+
w = maxWidth;
|
|
1104
|
+
}
|
|
1105
|
+
if (changeH) {
|
|
1106
|
+
if (minHeight && h < minHeight)
|
|
1107
|
+
h = minHeight;
|
|
1108
|
+
if (maxHeight && h > maxHeight)
|
|
1109
|
+
h = maxHeight;
|
|
1110
|
+
}
|
|
1111
|
+
if (aspectRatio) {
|
|
1112
|
+
if (changeW) {
|
|
1113
|
+
style.width = w + "px";
|
|
1114
|
+
style.height = w / aspectRatio + "px";
|
|
1115
|
+
}
|
|
1116
|
+
if (changeH && dir !== "sw") {
|
|
1117
|
+
if (dir === "nw") {
|
|
1118
|
+
y = originY - w / aspectRatio + originH;
|
|
1119
|
+
}
|
|
1120
|
+
else {
|
|
1121
|
+
style.width = h * aspectRatio + "px";
|
|
1122
|
+
style.height = h + "px";
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1126
|
+
else {
|
|
1127
|
+
if (changeW) {
|
|
1128
|
+
style.width = w + "px";
|
|
1129
|
+
}
|
|
1130
|
+
if (changeH) {
|
|
1131
|
+
style.height = h + "px";
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
if (changeY) {
|
|
1135
|
+
transformer.moveToY(y);
|
|
1136
|
+
}
|
|
1137
|
+
if (changeX) {
|
|
1138
|
+
transformer.moveToX(x);
|
|
1139
|
+
}
|
|
1140
|
+
lastX = x;
|
|
1141
|
+
lastY = y;
|
|
1142
|
+
currentW = w;
|
|
1143
|
+
currentH = h;
|
|
1144
|
+
onResize &&
|
|
1145
|
+
onResize.call(uiik, { w, h, ow: w - originW, oh: h - originH }, ev);
|
|
1146
|
+
});
|
|
1147
|
+
onPointerEnd((args) => {
|
|
1148
|
+
var _a, _b;
|
|
1149
|
+
const { ev } = args;
|
|
1150
|
+
if (ghost && ghostNode) {
|
|
1151
|
+
((_a = panel.parentNode) === null || _a === void 0 ? void 0 : _a.contains(ghostNode)) &&
|
|
1152
|
+
((_b = panel.parentNode) === null || _b === void 0 ? void 0 : _b.removeChild(ghostNode));
|
|
1153
|
+
panelStyle.left = ghostNode.style.left;
|
|
1154
|
+
panelStyle.top = ghostNode.style.top;
|
|
1155
|
+
moveTo(panel, lastX / matrixInfo.scale, lastY / matrixInfo.scale);
|
|
1156
|
+
panelStyle.width = ghostNode.style.width;
|
|
1157
|
+
panelStyle.height = ghostNode.style.height;
|
|
1158
|
+
}
|
|
1159
|
+
panel.style.transformOrigin = originalTransformOrigin;
|
|
1160
|
+
const { x, y, sx, sy } = getCenterXy(panel);
|
|
1161
|
+
let centerX = x, centerY = y;
|
|
1162
|
+
const deg = matrixInfo.angle * ONE_ANG;
|
|
1163
|
+
const currentVertex = map(originVertex, ({ x, y }) => {
|
|
1164
|
+
const nx = (x - centerX + sx) * Math.cos(deg) -
|
|
1165
|
+
(y - centerY + sy) * Math.sin(deg);
|
|
1166
|
+
const ny = (x - centerX + sx) * Math.sin(deg) +
|
|
1167
|
+
(y - centerY + sy) * Math.cos(deg);
|
|
1168
|
+
return { x: centerX + nx, y: centerY + ny };
|
|
1169
|
+
});
|
|
1170
|
+
if (changeX || changeY) {
|
|
1171
|
+
transformer.moveTo(transformer.x - (currentVertex[0].x - lastX), transformer.y - (currentVertex[0].y - lastY));
|
|
1172
|
+
}
|
|
1173
|
+
else {
|
|
1174
|
+
transformer.moveTo(transformer.x - (currentVertex[0].x - vertexBeforeTransform[0].x), transformer.y - (currentVertex[0].y - vertexBeforeTransform[0].y));
|
|
1175
|
+
}
|
|
1176
|
+
handle.classList.remove(CLASS_RESIZABLE_HANDLE_ACTIVE);
|
|
1177
|
+
onEnd && onEnd.call(uiik, { w: currentW, h: currentH }, ev);
|
|
1178
|
+
});
|
|
1179
|
+
}, {
|
|
1180
|
+
threshold: THRESHOLD$3,
|
|
1181
|
+
lockPage: true,
|
|
1182
|
+
});
|
|
1183
|
+
}
|
|
1184
|
+
initHandle(panel) {
|
|
1185
|
+
const opts = this.opts;
|
|
1186
|
+
let handleStr = opts.handle;
|
|
1187
|
+
let handles;
|
|
1188
|
+
if (isString(handleStr)) {
|
|
1189
|
+
handles = document.querySelectorAll(handleStr);
|
|
797
1190
|
}
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
1191
|
+
else if (isFunction(handleStr)) {
|
|
1192
|
+
handles = handleStr(panel);
|
|
1193
|
+
}
|
|
1194
|
+
if (!handles) {
|
|
1195
|
+
console.error('Can not find handles with "' + panel.outerHTML + '"');
|
|
1196
|
+
return;
|
|
1197
|
+
}
|
|
1198
|
+
handles = isArrayLike(handles) ? handles : [handles];
|
|
1199
|
+
each(handles, (h) => {
|
|
1200
|
+
const className = h.getAttribute("class") || "";
|
|
1201
|
+
const matchRs = className.match(EXP_DIR);
|
|
1202
|
+
let dir = "se";
|
|
1203
|
+
if (matchRs) {
|
|
1204
|
+
dir = matchRs.groups.dir;
|
|
1205
|
+
}
|
|
1206
|
+
h.classList.add(CLASS_RESIZABLE_HANDLE);
|
|
1207
|
+
this.bindHandle(h, dir, panel, opts);
|
|
1208
|
+
h.style.cursor = `${dir}-resize`;
|
|
1209
|
+
h.dataset.cursor = `${dir}-resize`;
|
|
1210
|
+
h.setAttribute("name", "handle");
|
|
1211
|
+
});
|
|
1212
|
+
}
|
|
803
1213
|
}
|
|
804
|
-
/**
|
|
805
|
-
* Make els resizable
|
|
806
|
-
* @param els selector string / html element
|
|
807
|
-
* @param opts
|
|
808
|
-
* @returns
|
|
809
|
-
*/
|
|
810
1214
|
function newResizable(els, opts) {
|
|
811
1215
|
return new Resizable(els, opts);
|
|
812
1216
|
}
|
|
813
1217
|
|
|
814
|
-
var _Draggable_handleMap;
|
|
1218
|
+
var _Draggable_instances, _Draggable_handleMap, _Draggable_container, _Draggable_initStyle;
|
|
815
1219
|
const DRAGGER_GROUPS = {};
|
|
816
1220
|
const CLASS_DRAGGABLE = "uii-draggable";
|
|
817
1221
|
const CLASS_DRAGGABLE_HANDLE = "uii-draggable-handle";
|
|
818
1222
|
const CLASS_DRAGGABLE_ACTIVE = "uii-draggable-active";
|
|
819
1223
|
const CLASS_DRAGGABLE_GHOST = "uii-draggable-ghost";
|
|
820
|
-
/**
|
|
821
|
-
* 用于表示一个或多个可拖动元素的定义
|
|
822
|
-
* > 可用CSS接口
|
|
823
|
-
* - .uii-draggable
|
|
824
|
-
* - .uii-draggable-handle
|
|
825
|
-
* - .uii-draggable-active
|
|
826
|
-
* - .uii-draggable-ghost
|
|
827
|
-
* @public
|
|
828
|
-
*/
|
|
829
1224
|
class Draggable extends Uii {
|
|
830
1225
|
constructor(els, opts) {
|
|
831
1226
|
super(els, assign({
|
|
832
|
-
|
|
1227
|
+
containment: false,
|
|
1228
|
+
watch: true,
|
|
833
1229
|
threshold: 0,
|
|
834
1230
|
ghost: false,
|
|
835
1231
|
direction: "",
|
|
@@ -838,7 +1234,9 @@ class Draggable extends Uii {
|
|
|
838
1234
|
tolerance: 10,
|
|
839
1235
|
}
|
|
840
1236
|
}, opts));
|
|
1237
|
+
_Draggable_instances.add(this);
|
|
841
1238
|
_Draggable_handleMap.set(this, new WeakMap());
|
|
1239
|
+
_Draggable_container.set(this, null);
|
|
842
1240
|
if (this.opts.handle) {
|
|
843
1241
|
each(this.ele, (el) => {
|
|
844
1242
|
const h = el.querySelector(this.opts.handle);
|
|
@@ -850,465 +1248,428 @@ class Draggable extends Uii {
|
|
|
850
1248
|
});
|
|
851
1249
|
}
|
|
852
1250
|
this.onOptionChanged(this.opts);
|
|
853
|
-
//put into group
|
|
854
1251
|
if (this.opts.group) {
|
|
855
1252
|
if (!DRAGGER_GROUPS[this.opts.group]) {
|
|
856
1253
|
DRAGGER_GROUPS[this.opts.group] = [];
|
|
857
1254
|
}
|
|
858
1255
|
DRAGGER_GROUPS[this.opts.group].push(...this.ele);
|
|
859
1256
|
}
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
if (
|
|
863
|
-
|
|
864
|
-
el.classList.toggle(CLASS_DRAGGABLE, true);
|
|
865
|
-
const ee = __classPrivateFieldGet(this, _Draggable_handleMap, "f").get(el) || el;
|
|
866
|
-
ee.classList.toggle(CLASS_DRAGGABLE_HANDLE, true);
|
|
867
|
-
if (isDefined(this.opts.cursor)) {
|
|
868
|
-
el.style.cursor = this.opts.cursor.default || 'move';
|
|
869
|
-
if (isDefined(this.opts.cursor.over)) {
|
|
870
|
-
el.dataset.cursorOver = this.opts.cursor.over;
|
|
871
|
-
el.dataset.cursorActive = this.opts.cursor.active || 'move';
|
|
872
|
-
}
|
|
1257
|
+
__classPrivateFieldGet(this, _Draggable_instances, "m", _Draggable_initStyle).call(this, this.ele);
|
|
1258
|
+
if (this.opts.containment) {
|
|
1259
|
+
if (isBoolean(this.opts.containment)) {
|
|
1260
|
+
__classPrivateFieldSet(this, _Draggable_container, isEmpty(this.ele) ? null : this.ele[0].parentElement, "f");
|
|
873
1261
|
}
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
/**
|
|
877
|
-
* @internal
|
|
878
|
-
*/
|
|
879
|
-
onOptionChanged(opts) {
|
|
880
|
-
const droppable = opts.droppable;
|
|
881
|
-
if (!isFunction(droppable)) {
|
|
882
|
-
if (isUndefined(droppable)) {
|
|
883
|
-
opts.droppable = () => { };
|
|
1262
|
+
else if (isString(this.opts.containment)) {
|
|
1263
|
+
__classPrivateFieldSet(this, _Draggable_container, document.querySelector(this.opts.containment), "f");
|
|
884
1264
|
}
|
|
885
|
-
else if (
|
|
886
|
-
|
|
1265
|
+
else if (isElement(this.opts.containment)) {
|
|
1266
|
+
__classPrivateFieldSet(this, _Draggable_container, this.opts.containment, "f");
|
|
887
1267
|
}
|
|
888
|
-
|
|
889
|
-
|
|
1268
|
+
}
|
|
1269
|
+
if (this.opts.watch && this.eleString) {
|
|
1270
|
+
let con;
|
|
1271
|
+
if (isString(this.opts.watch)) {
|
|
1272
|
+
con = document.querySelector(this.opts.watch);
|
|
890
1273
|
}
|
|
891
|
-
else
|
|
892
|
-
|
|
1274
|
+
else {
|
|
1275
|
+
con = isEmpty(this.ele) ? null : this.ele[0].parentElement;
|
|
893
1276
|
}
|
|
1277
|
+
this.bindEvent(con || document.body, this.opts, __classPrivateFieldGet(this, _Draggable_handleMap, "f"));
|
|
894
1278
|
}
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
function bindEvent(registerEvent, el, opts, handleMap) {
|
|
899
|
-
registerEvent(el, "mousedown", (e) => {
|
|
900
|
-
var _a;
|
|
901
|
-
// get options
|
|
902
|
-
let dragDom = e.currentTarget;
|
|
903
|
-
let t = e.target;
|
|
904
|
-
if (!t)
|
|
905
|
-
return;
|
|
906
|
-
let handle = handleMap.get(dragDom);
|
|
907
|
-
if (handle && !handle.contains(t)) {
|
|
908
|
-
return;
|
|
909
|
-
}
|
|
910
|
-
const filter = opts.filter;
|
|
911
|
-
//check filter
|
|
912
|
-
if (filter) {
|
|
913
|
-
if (some(el.querySelectorAll(filter), ele => ele.contains(t)))
|
|
914
|
-
return;
|
|
915
|
-
}
|
|
916
|
-
const computedStyle = window.getComputedStyle(dragDom);
|
|
917
|
-
const container = dragDom.offsetParent || document.body;
|
|
918
|
-
const inContainer = opts.container;
|
|
919
|
-
const threshold = opts.threshold || 0;
|
|
920
|
-
const ghost = opts.ghost;
|
|
921
|
-
const ghostClass = opts.ghostClass;
|
|
922
|
-
const direction = opts.direction;
|
|
923
|
-
const onStart = opts.onStart;
|
|
924
|
-
const onDrag = opts.onDrag;
|
|
925
|
-
const onEnd = opts.onEnd;
|
|
926
|
-
const onClone = opts.onClone;
|
|
927
|
-
const originalZIndex = computedStyle.zIndex;
|
|
928
|
-
let zIndex = opts.zIndex || originalZIndex;
|
|
929
|
-
const classes = opts.classes || '';
|
|
930
|
-
const group = opts.group;
|
|
931
|
-
if (group) {
|
|
932
|
-
let i = -1;
|
|
933
|
-
each(DRAGGER_GROUPS[group], el => {
|
|
934
|
-
const z = parseInt(window.getComputedStyle(el).zIndex) || 0;
|
|
935
|
-
if (z > i)
|
|
936
|
-
i = z;
|
|
1279
|
+
else {
|
|
1280
|
+
each(this.ele, (el) => {
|
|
1281
|
+
this.bindEvent(el, this.opts, __classPrivateFieldGet(this, _Draggable_handleMap, "f"));
|
|
937
1282
|
});
|
|
938
|
-
zIndex = i + 1;
|
|
939
|
-
}
|
|
940
|
-
const scroll = opts.scroll;
|
|
941
|
-
const scrollSpeed = opts.scrollSpeed || 10;
|
|
942
|
-
let gridX, gridY;
|
|
943
|
-
const grid = opts.grid;
|
|
944
|
-
if (isArray(grid)) {
|
|
945
|
-
gridX = grid[0];
|
|
946
|
-
gridY = grid[1];
|
|
947
1283
|
}
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
const
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
offX += el.offsetLeft;
|
|
963
|
-
offY += el.offsetTop;
|
|
964
|
-
return false;
|
|
965
|
-
}, "offsetParent");
|
|
966
|
-
return {
|
|
967
|
-
x1: offX,
|
|
968
|
-
y1: offY,
|
|
969
|
-
x2: offX + el.offsetWidth,
|
|
970
|
-
y2: offY + el.offsetHeight,
|
|
971
|
-
el: el,
|
|
972
|
-
};
|
|
973
|
-
});
|
|
974
|
-
closest(dragDom, (el, times) => {
|
|
975
|
-
if (times > 0) {
|
|
976
|
-
parentOffsetX += el.offsetLeft;
|
|
977
|
-
parentOffsetY += el.offsetTop;
|
|
978
|
-
}
|
|
979
|
-
return false;
|
|
980
|
-
}, "offsetParent");
|
|
981
|
-
}
|
|
982
|
-
const originW = dragDom.offsetWidth + parseFloat(computedStyle.borderLeftWidth) + parseFloat(computedStyle.borderRightWidth);
|
|
983
|
-
const originH = dragDom.offsetHeight + parseFloat(computedStyle.borderTopWidth) + parseFloat(computedStyle.borderBottomWidth);
|
|
984
|
-
// boundary
|
|
985
|
-
let minX = 0;
|
|
986
|
-
let minY = 0;
|
|
987
|
-
let maxX = 0;
|
|
988
|
-
let maxY = 0;
|
|
989
|
-
if (inContainer) {
|
|
990
|
-
maxX = container.scrollWidth - originW;
|
|
991
|
-
maxY = container.scrollHeight - originH;
|
|
992
|
-
}
|
|
993
|
-
if (maxX < 0)
|
|
994
|
-
maxX = 0;
|
|
995
|
-
if (maxY < 0)
|
|
996
|
-
maxY = 0;
|
|
997
|
-
//start point
|
|
998
|
-
const rect = container.getBoundingClientRect();
|
|
999
|
-
const offset = getOffset(t, container);
|
|
1000
|
-
const ox = e.offsetX || 0;
|
|
1001
|
-
const oy = e.offsetY || 0;
|
|
1002
|
-
let hitPosX = offset.x + ox + container.scrollLeft;
|
|
1003
|
-
let hitPosY = offset.y + oy + container.scrollTop;
|
|
1004
|
-
let cursorX = ox, cursorY = e.offsetY;
|
|
1005
|
-
if (e.target !== dragDom) {
|
|
1006
|
-
const offset = getOffset(t, dragDom);
|
|
1007
|
-
const style = window.getComputedStyle(t);
|
|
1008
|
-
cursorX = offset.x + ox + parseFloat(style.borderLeftWidth);
|
|
1009
|
-
cursorY = offset.y + oy + parseFloat(style.borderTopWidth);
|
|
1010
|
-
}
|
|
1011
|
-
const cursorAt = opts.cursorAt;
|
|
1012
|
-
if (cursorAt) {
|
|
1013
|
-
const l = cursorAt.left;
|
|
1014
|
-
const t = cursorAt.top;
|
|
1015
|
-
if (isString(l)) {
|
|
1016
|
-
cursorX = parseFloat(l) / 100 * dragDom.offsetWidth;
|
|
1284
|
+
}
|
|
1285
|
+
bindEvent(bindTarget, opts, handleMap) {
|
|
1286
|
+
const container = __classPrivateFieldGet(this, _Draggable_container, "f");
|
|
1287
|
+
let draggableList = this.ele;
|
|
1288
|
+
const eleString = this.eleString;
|
|
1289
|
+
const initStyle = __classPrivateFieldGet(this, _Draggable_instances, "m", _Draggable_initStyle).bind(this);
|
|
1290
|
+
this.addPointerDown(bindTarget, ({ ev, currentTarget, currentStyle, currentCStyle, pointX, pointY, onPointerStart, onPointerMove, onPointerEnd }) => {
|
|
1291
|
+
var _a;
|
|
1292
|
+
let t = ev.target;
|
|
1293
|
+
if (!t)
|
|
1294
|
+
return;
|
|
1295
|
+
if (opts.watch && eleString) {
|
|
1296
|
+
draggableList = bindTarget.querySelectorAll(eleString);
|
|
1297
|
+
initStyle(draggableList);
|
|
1017
1298
|
}
|
|
1018
|
-
|
|
1019
|
-
|
|
1299
|
+
let findRs = find(draggableList, el => el.contains(t));
|
|
1300
|
+
if (!findRs)
|
|
1301
|
+
return;
|
|
1302
|
+
const dragDom = findRs;
|
|
1303
|
+
let handle = handleMap.get(dragDom);
|
|
1304
|
+
if (handle && !handle.contains(t)) {
|
|
1305
|
+
return;
|
|
1020
1306
|
}
|
|
1021
|
-
|
|
1022
|
-
|
|
1307
|
+
const onPointerDown = opts.onPointerDown;
|
|
1308
|
+
if (onPointerDown && onPointerDown({ draggable: dragDom }, ev) === false)
|
|
1309
|
+
return;
|
|
1310
|
+
const filter = opts.filter;
|
|
1311
|
+
if (filter) {
|
|
1312
|
+
if (some(dragDom.querySelectorAll(filter), ele => ele.contains(t)))
|
|
1313
|
+
return;
|
|
1023
1314
|
}
|
|
1024
|
-
|
|
1025
|
-
|
|
1315
|
+
const offsetParent = dragDom instanceof HTMLElement ? dragDom.offsetParent || document.body : dragDom.ownerSVGElement;
|
|
1316
|
+
const offsetParentRect = offsetParent.getBoundingClientRect();
|
|
1317
|
+
const offsetParentCStyle = window.getComputedStyle(offsetParent);
|
|
1318
|
+
const offsetXy = getPointInContainer(ev, dragDom);
|
|
1319
|
+
let offsetPointX = offsetXy.x;
|
|
1320
|
+
let offsetPointY = offsetXy.y;
|
|
1321
|
+
const matrixInfo = getMatrixInfo(dragDom);
|
|
1322
|
+
const currentXy = getPointInContainer(ev, offsetParent, offsetParentRect, offsetParentCStyle);
|
|
1323
|
+
if (matrixInfo.angle != 0) {
|
|
1324
|
+
offsetPointX = currentXy.x - matrixInfo.x;
|
|
1325
|
+
offsetPointY = currentXy.y - matrixInfo.y;
|
|
1326
|
+
}
|
|
1327
|
+
const inContainer = !!container;
|
|
1328
|
+
const ghost = opts.ghost;
|
|
1329
|
+
const ghostClass = opts.ghostClass;
|
|
1330
|
+
const direction = opts.direction;
|
|
1331
|
+
const onStart = opts.onStart;
|
|
1332
|
+
const onDrag = opts.onDrag;
|
|
1333
|
+
const onEnd = opts.onEnd;
|
|
1334
|
+
const onClone = opts.onClone;
|
|
1335
|
+
const originalZIndex = currentCStyle.zIndex;
|
|
1336
|
+
let zIndex = opts.zIndex || originalZIndex;
|
|
1337
|
+
const classes = opts.classes || '';
|
|
1338
|
+
const group = opts.group;
|
|
1339
|
+
if (group) {
|
|
1340
|
+
let i = -1;
|
|
1341
|
+
each(DRAGGER_GROUPS[group], el => {
|
|
1342
|
+
const z = parseInt(currentCStyle.zIndex) || 0;
|
|
1343
|
+
if (z > i)
|
|
1344
|
+
i = z;
|
|
1345
|
+
});
|
|
1346
|
+
zIndex = i + 1;
|
|
1347
|
+
}
|
|
1348
|
+
const scroll = opts.scroll;
|
|
1349
|
+
const scrollSpeed = opts.scrollSpeed || 10;
|
|
1350
|
+
let gridX, gridY;
|
|
1351
|
+
const grid = opts.grid;
|
|
1352
|
+
if (isArray(grid)) {
|
|
1353
|
+
gridX = grid[0];
|
|
1354
|
+
gridY = grid[1];
|
|
1355
|
+
}
|
|
1356
|
+
else if (isNumber(grid)) {
|
|
1357
|
+
gridX = gridY = grid;
|
|
1358
|
+
}
|
|
1359
|
+
const snapOn = opts.snap;
|
|
1360
|
+
let snappable;
|
|
1361
|
+
const snapTolerance = ((_a = opts.snapOptions) === null || _a === void 0 ? void 0 : _a.tolerance) || 10;
|
|
1362
|
+
const onSnap = opts.onSnap;
|
|
1363
|
+
let lastSnapDirY = "", lastSnapDirX = "";
|
|
1364
|
+
let lastSnapping = "";
|
|
1365
|
+
if (snapOn) {
|
|
1366
|
+
snappable = map((container || document).querySelectorAll(snapOn), (el) => {
|
|
1367
|
+
const { x, y, w, h } = getRectInContainer(el, offsetParent);
|
|
1368
|
+
return {
|
|
1369
|
+
x1: x,
|
|
1370
|
+
y1: y,
|
|
1371
|
+
x2: x + w,
|
|
1372
|
+
y2: y + h,
|
|
1373
|
+
el: el,
|
|
1374
|
+
};
|
|
1375
|
+
});
|
|
1026
1376
|
}
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
copyNode
|
|
1058
|
-
copyNode.style.zIndex = zIndex + '';
|
|
1059
|
-
if (ghostClass) {
|
|
1060
|
-
copyNode.classList.add(...compact(split(ghostClass, ' ')));
|
|
1061
|
-
}
|
|
1062
|
-
copyNode.classList.add(...compact(split(classes, ' ')));
|
|
1063
|
-
copyNode.classList.toggle(CLASS_DRAGGABLE_GHOST, true);
|
|
1064
|
-
(_a = dragDom.parentNode) === null || _a === void 0 ? void 0 : _a.appendChild(copyNode);
|
|
1065
|
-
if (onClone) {
|
|
1066
|
-
onClone(copyNode, ev);
|
|
1067
|
-
}
|
|
1377
|
+
const dragDomRect = dragDom.getBoundingClientRect();
|
|
1378
|
+
const originW = dragDomRect.width + parseFloat(currentCStyle.borderLeftWidth) + parseFloat(currentCStyle.borderRightWidth);
|
|
1379
|
+
const originH = dragDomRect.height + parseFloat(currentCStyle.borderTopWidth) + parseFloat(currentCStyle.borderBottomWidth);
|
|
1380
|
+
let minX = 0;
|
|
1381
|
+
let minY = 0;
|
|
1382
|
+
let maxX = 0;
|
|
1383
|
+
let maxY = 0;
|
|
1384
|
+
let originOffX = 0;
|
|
1385
|
+
let originOffY = 0;
|
|
1386
|
+
if (inContainer) {
|
|
1387
|
+
maxX = container.scrollWidth - originW;
|
|
1388
|
+
maxY = container.scrollHeight - originH;
|
|
1389
|
+
}
|
|
1390
|
+
if (maxX < 0)
|
|
1391
|
+
maxX = 0;
|
|
1392
|
+
if (maxY < 0)
|
|
1393
|
+
maxY = 0;
|
|
1394
|
+
let copyNode;
|
|
1395
|
+
let transformer;
|
|
1396
|
+
let timer = null;
|
|
1397
|
+
let toLeft = false;
|
|
1398
|
+
let toTop = false;
|
|
1399
|
+
let toRight = false;
|
|
1400
|
+
let toBottom = false;
|
|
1401
|
+
let endX = 0, endY = 0;
|
|
1402
|
+
onPointerStart(function (args) {
|
|
1403
|
+
var _a;
|
|
1404
|
+
const { ev } = args;
|
|
1405
|
+
if (ghost) {
|
|
1406
|
+
if (isFunction(ghost)) {
|
|
1407
|
+
copyNode = ghost(dragDom);
|
|
1068
1408
|
}
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
if (
|
|
1077
|
-
|
|
1409
|
+
else {
|
|
1410
|
+
copyNode = dragDom.cloneNode(true);
|
|
1411
|
+
copyNode.style.opacity = "0.3";
|
|
1412
|
+
copyNode.style.pointerEvents = "none";
|
|
1413
|
+
copyNode.style.position = "absolute";
|
|
1414
|
+
}
|
|
1415
|
+
copyNode.style.zIndex = zIndex + '';
|
|
1416
|
+
if (ghostClass) {
|
|
1417
|
+
copyNode.classList.add(...compact(split(ghostClass, ' ')));
|
|
1078
1418
|
}
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
dragDom.
|
|
1419
|
+
copyNode.classList.add(...compact(split(classes, ' ')));
|
|
1420
|
+
copyNode.classList.toggle(CLASS_DRAGGABLE_GHOST, true);
|
|
1421
|
+
(_a = dragDom.parentNode) === null || _a === void 0 ? void 0 : _a.appendChild(copyNode);
|
|
1422
|
+
transformer = wrapper(copyNode);
|
|
1423
|
+
onClone && onClone({ clone: copyNode }, ev);
|
|
1082
1424
|
}
|
|
1083
1425
|
else {
|
|
1084
|
-
|
|
1085
|
-
return false;
|
|
1426
|
+
transformer = wrapper(dragDom);
|
|
1086
1427
|
}
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
const
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1428
|
+
dragDom.classList.add(...compact(split(classes, ' ')));
|
|
1429
|
+
if (!copyNode)
|
|
1430
|
+
dragDom.style.zIndex = zIndex + '';
|
|
1431
|
+
dragDom.classList.toggle(CLASS_DRAGGABLE_ACTIVE, true);
|
|
1432
|
+
onStart && onStart({ draggable: dragDom, x: currentXy.x, y: currentXy.y }, ev);
|
|
1433
|
+
const customEv = new Event("uii-dragactive", { "bubbles": true, "cancelable": false });
|
|
1434
|
+
dragDom.dispatchEvent(customEv);
|
|
1435
|
+
});
|
|
1436
|
+
onPointerMove((args) => {
|
|
1437
|
+
const { ev, pointX, pointY, offX, offY } = args;
|
|
1438
|
+
const currentXy = getPointInContainer(ev, offsetParent, offsetParentRect, offsetParentCStyle);
|
|
1439
|
+
let newX = currentXy.x;
|
|
1440
|
+
let newY = currentXy.y;
|
|
1441
|
+
if (scroll) {
|
|
1442
|
+
const lX = pointX - offsetParentRect.x;
|
|
1443
|
+
const lY = pointY - offsetParentRect.y;
|
|
1444
|
+
const rX = offsetParentRect.x + offsetParentRect.width - pointX;
|
|
1445
|
+
const rY = offsetParentRect.y + offsetParentRect.height - pointY;
|
|
1446
|
+
toLeft = lX < EDGE_THRESHOLD;
|
|
1447
|
+
toTop = lY < EDGE_THRESHOLD;
|
|
1448
|
+
toRight = rX < EDGE_THRESHOLD;
|
|
1449
|
+
toBottom = rY < EDGE_THRESHOLD;
|
|
1450
|
+
if (toLeft || toTop
|
|
1451
|
+
||
|
|
1452
|
+
toRight || toBottom) {
|
|
1453
|
+
if (!timer) {
|
|
1454
|
+
timer = setInterval(() => {
|
|
1455
|
+
if (toLeft) {
|
|
1456
|
+
offsetParent.scrollLeft -= scrollSpeed;
|
|
1457
|
+
}
|
|
1458
|
+
else if (toRight) {
|
|
1459
|
+
offsetParent.scrollLeft += scrollSpeed;
|
|
1460
|
+
}
|
|
1461
|
+
if (toTop) {
|
|
1462
|
+
offsetParent.scrollTop -= scrollSpeed;
|
|
1463
|
+
}
|
|
1464
|
+
else if (toBottom) {
|
|
1465
|
+
offsetParent.scrollTop += scrollSpeed;
|
|
1466
|
+
}
|
|
1467
|
+
}, 20);
|
|
1468
|
+
}
|
|
1469
|
+
}
|
|
1470
|
+
else {
|
|
1471
|
+
if (timer) {
|
|
1472
|
+
clearInterval(timer);
|
|
1473
|
+
timer = null;
|
|
1474
|
+
}
|
|
1475
|
+
}
|
|
1476
|
+
}
|
|
1477
|
+
let x = newX - offsetPointX + 0;
|
|
1478
|
+
let y = newY - offsetPointY + 0;
|
|
1479
|
+
if (isNumber(gridX) && isNumber(gridY)) {
|
|
1480
|
+
x = ((x / gridX) >> 0) * gridX;
|
|
1481
|
+
y = ((y / gridY) >> 0) * gridY;
|
|
1482
|
+
}
|
|
1483
|
+
if (inContainer) {
|
|
1484
|
+
if (originOffX + x < minX) {
|
|
1485
|
+
x = -0;
|
|
1486
|
+
}
|
|
1487
|
+
if (originOffY + y < minY) {
|
|
1488
|
+
y = -0;
|
|
1489
|
+
}
|
|
1490
|
+
if (originOffX + x > maxX) {
|
|
1491
|
+
x = maxX - originOffX;
|
|
1492
|
+
}
|
|
1493
|
+
if (originOffY + y > maxY) {
|
|
1494
|
+
y = maxY - originOffY;
|
|
1495
|
+
}
|
|
1496
|
+
}
|
|
1497
|
+
let canDrag = true;
|
|
1498
|
+
let emitSnap = false;
|
|
1499
|
+
if (snapOn) {
|
|
1500
|
+
const currPageX1 = x;
|
|
1501
|
+
const currPageY1 = y;
|
|
1502
|
+
const currPageX2 = currPageX1 + originW;
|
|
1503
|
+
const currPageY2 = currPageY1 + originH;
|
|
1504
|
+
let snapX = NaN, snapY = NaN;
|
|
1505
|
+
let targetX, targetY;
|
|
1506
|
+
let snapDirX, snapDirY;
|
|
1507
|
+
if (!direction || direction === "v") {
|
|
1508
|
+
each(snappable, (data) => {
|
|
1509
|
+
if (Math.abs(data.y1 - currPageY1) <= snapTolerance) {
|
|
1510
|
+
snapY = data.y1;
|
|
1511
|
+
snapDirY = "t2t";
|
|
1105
1512
|
}
|
|
1106
|
-
else if (
|
|
1107
|
-
|
|
1513
|
+
else if (Math.abs(data.y2 - currPageY1) <= snapTolerance) {
|
|
1514
|
+
snapY = data.y2;
|
|
1515
|
+
snapDirY = "t2b";
|
|
1108
1516
|
}
|
|
1109
|
-
if (
|
|
1110
|
-
|
|
1517
|
+
else if (Math.abs(data.y1 - currPageY2) <= snapTolerance) {
|
|
1518
|
+
snapY = data.y1 - originH;
|
|
1519
|
+
snapDirY = "b2t";
|
|
1111
1520
|
}
|
|
1112
|
-
else if (
|
|
1113
|
-
|
|
1521
|
+
else if (Math.abs(data.y2 - currPageY2) <= snapTolerance) {
|
|
1522
|
+
snapY = data.y2 - originH;
|
|
1523
|
+
snapDirY = "b2b";
|
|
1114
1524
|
}
|
|
1115
|
-
|
|
1525
|
+
if (snapY) {
|
|
1526
|
+
lastSnapDirY = snapDirY;
|
|
1527
|
+
targetY = data.el;
|
|
1528
|
+
return false;
|
|
1529
|
+
}
|
|
1530
|
+
});
|
|
1116
1531
|
}
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1532
|
+
if (!direction || direction === "h") {
|
|
1533
|
+
each(snappable, (data) => {
|
|
1534
|
+
if (Math.abs(data.x1 - currPageX1) <= snapTolerance) {
|
|
1535
|
+
snapX = data.x1;
|
|
1536
|
+
snapDirX = "l2l";
|
|
1537
|
+
}
|
|
1538
|
+
else if (Math.abs(data.x2 - currPageX1) <= snapTolerance) {
|
|
1539
|
+
snapX = data.x2;
|
|
1540
|
+
snapDirX = "l2r";
|
|
1541
|
+
}
|
|
1542
|
+
else if (Math.abs(data.x1 - currPageX2) <= snapTolerance) {
|
|
1543
|
+
snapX = data.x1 - originW;
|
|
1544
|
+
snapDirX = "r2l";
|
|
1545
|
+
}
|
|
1546
|
+
else if (Math.abs(data.x2 - currPageX2) <= snapTolerance) {
|
|
1547
|
+
snapX = data.x2 - originW;
|
|
1548
|
+
snapDirX = "r2r";
|
|
1549
|
+
}
|
|
1550
|
+
if (snapX) {
|
|
1551
|
+
lastSnapDirX = snapDirX;
|
|
1552
|
+
targetX = data.el;
|
|
1553
|
+
return false;
|
|
1554
|
+
}
|
|
1555
|
+
});
|
|
1122
1556
|
}
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
let y = newY - cursorY;
|
|
1127
|
-
//grid
|
|
1128
|
-
if (isNumber(gridX) && isNumber(gridY)) {
|
|
1129
|
-
x = ((x / gridX) >> 0) * gridX;
|
|
1130
|
-
y = ((y / gridY) >> 0) * gridY;
|
|
1131
|
-
}
|
|
1132
|
-
if (inContainer) {
|
|
1133
|
-
if (x < minX)
|
|
1134
|
-
x = minX;
|
|
1135
|
-
if (y < minY)
|
|
1136
|
-
y = minY;
|
|
1137
|
-
if (x > maxX)
|
|
1138
|
-
x = maxX;
|
|
1139
|
-
if (y > maxY)
|
|
1140
|
-
y = maxY;
|
|
1141
|
-
}
|
|
1142
|
-
let canDrag = true;
|
|
1143
|
-
let emitSnap = false;
|
|
1144
|
-
if (snapOn) {
|
|
1145
|
-
const currPageX1 = parentOffsetX + x;
|
|
1146
|
-
const currPageY1 = parentOffsetY + y;
|
|
1147
|
-
const currPageX2 = currPageX1 + originW;
|
|
1148
|
-
const currPageY2 = currPageY1 + originH;
|
|
1149
|
-
//check snappable
|
|
1150
|
-
let snapX = NaN, snapY = NaN;
|
|
1151
|
-
let targetX, targetY;
|
|
1152
|
-
let snapDirX, snapDirY;
|
|
1153
|
-
if (!direction || direction === "v") {
|
|
1154
|
-
each(snappable, (data) => {
|
|
1155
|
-
if (Math.abs(data.y1 - currPageY1) <= snapTolerance) {
|
|
1156
|
-
//top parallel
|
|
1157
|
-
snapY = data.y1;
|
|
1158
|
-
snapDirY = "t2t";
|
|
1159
|
-
}
|
|
1160
|
-
else if (Math.abs(data.y2 - currPageY1) <= snapTolerance) {
|
|
1161
|
-
//b2t
|
|
1162
|
-
snapY = data.y2;
|
|
1163
|
-
snapDirY = "t2b";
|
|
1164
|
-
}
|
|
1165
|
-
else if (Math.abs(data.y1 - currPageY2) <= snapTolerance) {
|
|
1166
|
-
//t2b
|
|
1167
|
-
snapY = data.y1 - originH;
|
|
1168
|
-
snapDirY = "b2t";
|
|
1169
|
-
}
|
|
1170
|
-
else if (Math.abs(data.y2 - currPageY2) <= snapTolerance) {
|
|
1171
|
-
//bottom parallel
|
|
1172
|
-
snapY = data.y2 - originH;
|
|
1173
|
-
snapDirY = "b2b";
|
|
1557
|
+
if (snapX || snapY) {
|
|
1558
|
+
if (snapX) {
|
|
1559
|
+
x = snapX;
|
|
1174
1560
|
}
|
|
1175
1561
|
if (snapY) {
|
|
1176
|
-
|
|
1177
|
-
targetY = data.el;
|
|
1178
|
-
return false;
|
|
1179
|
-
}
|
|
1180
|
-
});
|
|
1181
|
-
}
|
|
1182
|
-
if (!direction || direction === "h") {
|
|
1183
|
-
each(snappable, (data) => {
|
|
1184
|
-
if (Math.abs(data.x1 - currPageX1) <= snapTolerance) {
|
|
1185
|
-
//left parallel
|
|
1186
|
-
snapX = data.x1;
|
|
1187
|
-
snapDirX = "l2l";
|
|
1562
|
+
y = snapY;
|
|
1188
1563
|
}
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
//right parallel
|
|
1201
|
-
snapX = data.x2 - originW;
|
|
1202
|
-
snapDirX = "r2r";
|
|
1203
|
-
}
|
|
1204
|
-
if (snapX) {
|
|
1205
|
-
lastSnapDirX = snapDirX;
|
|
1206
|
-
targetX = data.el;
|
|
1207
|
-
return false;
|
|
1564
|
+
if (onSnap && lastSnapping !== lastSnapDirX + "" + lastSnapDirY) {
|
|
1565
|
+
setTimeout(() => {
|
|
1566
|
+
onSnap({
|
|
1567
|
+
el: copyNode || dragDom,
|
|
1568
|
+
targetH: targetX,
|
|
1569
|
+
targetV: targetY,
|
|
1570
|
+
dirH: snapDirX,
|
|
1571
|
+
dirV: snapDirY,
|
|
1572
|
+
}, ev);
|
|
1573
|
+
}, 0);
|
|
1574
|
+
lastSnapping = lastSnapDirX + "" + lastSnapDirY;
|
|
1208
1575
|
}
|
|
1209
|
-
|
|
1210
|
-
}
|
|
1211
|
-
if (snapX || snapY) {
|
|
1212
|
-
if (snapX) {
|
|
1213
|
-
x = snapX - parentOffsetX;
|
|
1576
|
+
emitSnap = true;
|
|
1214
1577
|
}
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
}
|
|
1218
|
-
if (onSnap && lastSnapping !== lastSnapDirX + "" + lastSnapDirY) {
|
|
1219
|
-
setTimeout(() => {
|
|
1220
|
-
//emit after relocate
|
|
1221
|
-
onSnap(copyNode || dragDom, targetX, targetY, snapDirX, snapDirY);
|
|
1222
|
-
}, 0);
|
|
1223
|
-
lastSnapping = lastSnapDirX + "" + lastSnapDirY;
|
|
1578
|
+
else {
|
|
1579
|
+
lastSnapDirX = lastSnapDirY = lastSnapping = "";
|
|
1224
1580
|
}
|
|
1225
|
-
emitSnap = true;
|
|
1226
|
-
}
|
|
1227
|
-
else {
|
|
1228
|
-
lastSnapDirX = lastSnapDirY = lastSnapping = "";
|
|
1229
|
-
}
|
|
1230
|
-
}
|
|
1231
|
-
if (onDrag && !emitSnap) {
|
|
1232
|
-
if (onDrag(dragDom, ev, offsetx, offsety, x, y) === false) {
|
|
1233
|
-
canDrag = false;
|
|
1234
1581
|
}
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
copyNode.style.top = `${y}px`;
|
|
1582
|
+
if (onDrag && !emitSnap) {
|
|
1583
|
+
if (onDrag({
|
|
1584
|
+
draggable: dragDom,
|
|
1585
|
+
ox: offX,
|
|
1586
|
+
oy: offY,
|
|
1587
|
+
x: x,
|
|
1588
|
+
y: y
|
|
1589
|
+
}, ev) === false) {
|
|
1590
|
+
canDrag = false;
|
|
1591
|
+
endX = x;
|
|
1592
|
+
endY = y;
|
|
1247
1593
|
}
|
|
1248
1594
|
}
|
|
1249
|
-
|
|
1595
|
+
if (canDrag) {
|
|
1250
1596
|
if (direction === "v") {
|
|
1251
|
-
|
|
1597
|
+
transformer.moveToY(y);
|
|
1252
1598
|
}
|
|
1253
1599
|
else if (direction === "h") {
|
|
1254
|
-
|
|
1600
|
+
transformer.moveToX(x);
|
|
1255
1601
|
}
|
|
1256
1602
|
else {
|
|
1257
|
-
|
|
1258
|
-
|
|
1603
|
+
transformer.moveTo(x, y);
|
|
1604
|
+
}
|
|
1605
|
+
endX = x;
|
|
1606
|
+
endY = y;
|
|
1607
|
+
}
|
|
1608
|
+
});
|
|
1609
|
+
onPointerEnd((args) => {
|
|
1610
|
+
var _a, _b;
|
|
1611
|
+
const { ev, currentStyle } = args;
|
|
1612
|
+
if (scroll) {
|
|
1613
|
+
if (timer) {
|
|
1614
|
+
clearInterval(timer);
|
|
1615
|
+
timer = null;
|
|
1259
1616
|
}
|
|
1260
1617
|
}
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
document.removeEventListener("mousemove", dragListener);
|
|
1268
|
-
document.removeEventListener("mouseup", dragEndListener);
|
|
1269
|
-
window.removeEventListener("blur", dragEndListener);
|
|
1270
|
-
if (scroll) {
|
|
1271
|
-
if (timer) {
|
|
1272
|
-
clearInterval(timer);
|
|
1273
|
-
timer = null;
|
|
1618
|
+
dragDom.classList.remove(...compact(split(classes, ' ')));
|
|
1619
|
+
currentStyle.zIndex = originalZIndex;
|
|
1620
|
+
dragDom.classList.remove(CLASS_DRAGGABLE_ACTIVE);
|
|
1621
|
+
let moveToGhost = true;
|
|
1622
|
+
if (onEnd) {
|
|
1623
|
+
moveToGhost = onEnd({ draggable: dragDom, x: endX, y: endY }, ev) === false ? false : true;
|
|
1274
1624
|
}
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
dragDom.classList.remove(...compact(split(classes, ' ')));
|
|
1278
|
-
dragDom.style.zIndex = originalZIndex;
|
|
1279
|
-
dragDom.classList.remove(CLASS_DRAGGABLE_ACTIVE);
|
|
1280
|
-
let moveToGhost = true;
|
|
1281
|
-
if (dragging) {
|
|
1282
|
-
moveToGhost = call(onEnd, dragDom, ev);
|
|
1283
|
-
}
|
|
1284
|
-
//notify
|
|
1285
|
-
const customEv = new Event("uii-dragdeactive", { "bubbles": true, "cancelable": false });
|
|
1286
|
-
dragDom.dispatchEvent(customEv);
|
|
1287
|
-
if (dragging) {
|
|
1288
|
-
unlockPage();
|
|
1289
|
-
restoreCursor();
|
|
1625
|
+
const customEv = new Event("uii-dragdeactive", { "bubbles": true, "cancelable": false });
|
|
1626
|
+
dragDom.dispatchEvent(customEv);
|
|
1290
1627
|
if (ghost) {
|
|
1291
1628
|
((_a = dragDom.parentNode) === null || _a === void 0 ? void 0 : _a.contains(copyNode)) && ((_b = dragDom.parentNode) === null || _b === void 0 ? void 0 : _b.removeChild(copyNode));
|
|
1292
1629
|
if (moveToGhost !== false) {
|
|
1293
|
-
|
|
1294
|
-
style.top = copyNode.style.top;
|
|
1630
|
+
wrapper(dragDom).moveTo(transformer.x, transformer.y);
|
|
1295
1631
|
}
|
|
1296
1632
|
}
|
|
1633
|
+
});
|
|
1634
|
+
}, {
|
|
1635
|
+
threshold: this.opts.threshold || 0,
|
|
1636
|
+
lockPage: true
|
|
1637
|
+
});
|
|
1638
|
+
}
|
|
1639
|
+
onOptionChanged(opts) {
|
|
1640
|
+
const droppable = opts.droppable;
|
|
1641
|
+
if (!isFunction(droppable)) {
|
|
1642
|
+
if (isUndefined(droppable)) {
|
|
1643
|
+
opts.droppable = () => { };
|
|
1297
1644
|
}
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1645
|
+
else if (isString(droppable)) {
|
|
1646
|
+
opts.droppable = () => document.querySelectorAll(droppable);
|
|
1647
|
+
}
|
|
1648
|
+
else if (isArrayLike(droppable)) {
|
|
1649
|
+
opts.droppable = () => droppable;
|
|
1650
|
+
}
|
|
1651
|
+
else if (isElement(droppable)) {
|
|
1652
|
+
opts.droppable = () => [droppable];
|
|
1653
|
+
}
|
|
1654
|
+
}
|
|
1655
|
+
}
|
|
1305
1656
|
}
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1657
|
+
_Draggable_handleMap = new WeakMap(), _Draggable_container = new WeakMap(), _Draggable_instances = new WeakSet(), _Draggable_initStyle = function _Draggable_initStyle(draggableList) {
|
|
1658
|
+
each(draggableList, (el) => {
|
|
1659
|
+
if (isDefined(this.opts.type))
|
|
1660
|
+
el.dataset.dropType = this.opts.type;
|
|
1661
|
+
el.classList.toggle(CLASS_DRAGGABLE, true);
|
|
1662
|
+
const ee = __classPrivateFieldGet(this, _Draggable_handleMap, "f").get(el) || el;
|
|
1663
|
+
ee.classList.toggle(CLASS_DRAGGABLE_HANDLE, true);
|
|
1664
|
+
if (isDefined(this.opts.cursor)) {
|
|
1665
|
+
el.style.cursor = this.opts.cursor.default || 'move';
|
|
1666
|
+
if (isDefined(this.opts.cursor.over)) {
|
|
1667
|
+
el.dataset.cursorOver = this.opts.cursor.over;
|
|
1668
|
+
el.dataset.cursorActive = this.opts.cursor.active || 'move';
|
|
1669
|
+
}
|
|
1670
|
+
}
|
|
1671
|
+
});
|
|
1672
|
+
};
|
|
1312
1673
|
function newDraggable(els, opts) {
|
|
1313
1674
|
return new Draggable(els, opts);
|
|
1314
1675
|
}
|
|
@@ -1316,121 +1677,98 @@ function newDraggable(els, opts) {
|
|
|
1316
1677
|
var _Droppable_active;
|
|
1317
1678
|
const Droppables = [];
|
|
1318
1679
|
const CLASS_DROPPABLE = "uii-droppable";
|
|
1319
|
-
/**
|
|
1320
|
-
* 用于表示一个或多个可响应拖动元素的定义
|
|
1321
|
-
* > 可用CSS接口
|
|
1322
|
-
* - .uii-droppable
|
|
1323
|
-
* @public
|
|
1324
|
-
*/
|
|
1325
1680
|
class Droppable extends Uii {
|
|
1326
1681
|
constructor(el, opts) {
|
|
1327
1682
|
super(el, assign({}, opts));
|
|
1328
1683
|
_Droppable_active.set(this, void 0);
|
|
1329
1684
|
Droppables.push(this);
|
|
1330
1685
|
}
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
*/
|
|
1334
|
-
bindEvent(el, opts) {
|
|
1335
|
-
//dragenter
|
|
1336
|
-
this.registerEvent(el, "mouseenter", (e) => {
|
|
1686
|
+
bindEvent(droppable, opts) {
|
|
1687
|
+
this.registerEvent(droppable, "mouseenter", (e) => {
|
|
1337
1688
|
if (!__classPrivateFieldGet(this, _Droppable_active, "f"))
|
|
1338
1689
|
return;
|
|
1339
1690
|
if (opts.hoverClass) {
|
|
1340
1691
|
each(split(opts.hoverClass, ' '), cls => {
|
|
1341
|
-
|
|
1692
|
+
droppable.classList.toggle(cls, true);
|
|
1342
1693
|
});
|
|
1343
1694
|
}
|
|
1344
1695
|
if (__classPrivateFieldGet(this, _Droppable_active, "f").dataset.cursorOver) {
|
|
1345
1696
|
setCursor(__classPrivateFieldGet(this, _Droppable_active, "f").dataset.cursorOver);
|
|
1346
1697
|
}
|
|
1347
|
-
|
|
1698
|
+
opts.onEnter && opts.onEnter({ draggable: __classPrivateFieldGet(this, _Droppable_active, "f"), droppable }, e);
|
|
1348
1699
|
});
|
|
1349
|
-
|
|
1350
|
-
this.registerEvent(el, "mouseleave", (e) => {
|
|
1700
|
+
this.registerEvent(droppable, "mouseleave", (e) => {
|
|
1351
1701
|
if (!__classPrivateFieldGet(this, _Droppable_active, "f"))
|
|
1352
1702
|
return;
|
|
1353
1703
|
if (opts.hoverClass) {
|
|
1354
1704
|
each(split(opts.hoverClass, ' '), cls => {
|
|
1355
|
-
|
|
1705
|
+
droppable.classList.toggle(cls, false);
|
|
1356
1706
|
});
|
|
1357
1707
|
}
|
|
1358
1708
|
if (__classPrivateFieldGet(this, _Droppable_active, "f").dataset.cursorOver) {
|
|
1359
1709
|
setCursor(__classPrivateFieldGet(this, _Droppable_active, "f").dataset.cursorActive || '');
|
|
1360
1710
|
}
|
|
1361
|
-
|
|
1711
|
+
opts.onLeave && opts.onLeave({ draggable: __classPrivateFieldGet(this, _Droppable_active, "f"), droppable }, e);
|
|
1362
1712
|
});
|
|
1363
|
-
|
|
1364
|
-
this.registerEvent(el, "mousemove", (e) => {
|
|
1713
|
+
this.registerEvent(droppable, "mousemove", (e) => {
|
|
1365
1714
|
if (!__classPrivateFieldGet(this, _Droppable_active, "f"))
|
|
1366
1715
|
return;
|
|
1367
|
-
|
|
1368
|
-
opts.onDragOver(el, e);
|
|
1369
|
-
}
|
|
1716
|
+
opts.onOver && opts.onOver({ draggable: __classPrivateFieldGet(this, _Droppable_active, "f"), droppable }, e);
|
|
1370
1717
|
});
|
|
1371
|
-
|
|
1372
|
-
this.registerEvent(el, "mouseup", (e) => {
|
|
1718
|
+
this.registerEvent(droppable, "mouseup", (e) => {
|
|
1373
1719
|
if (!__classPrivateFieldGet(this, _Droppable_active, "f"))
|
|
1374
1720
|
return;
|
|
1375
1721
|
if (opts.hoverClass) {
|
|
1376
1722
|
each(split(opts.hoverClass, ' '), cls => {
|
|
1377
|
-
|
|
1723
|
+
droppable.classList.toggle(cls, false);
|
|
1378
1724
|
});
|
|
1379
1725
|
}
|
|
1380
|
-
|
|
1726
|
+
opts.onDrop && opts.onDrop({ draggable: __classPrivateFieldGet(this, _Droppable_active, "f"), droppable }, e);
|
|
1381
1727
|
});
|
|
1382
1728
|
}
|
|
1383
|
-
/**
|
|
1384
|
-
* @internal
|
|
1385
|
-
*/
|
|
1386
1729
|
active(target) {
|
|
1387
1730
|
let valid = true;
|
|
1388
|
-
|
|
1389
|
-
if (isString(
|
|
1390
|
-
valid = !!target.dataset.dropType && test(
|
|
1731
|
+
const opts = this.opts;
|
|
1732
|
+
if (isString(opts.accepts)) {
|
|
1733
|
+
valid = !!target.dataset.dropType && test(opts.accepts, target.dataset.dropType);
|
|
1391
1734
|
}
|
|
1392
|
-
else if (isFunction(
|
|
1393
|
-
valid =
|
|
1735
|
+
else if (isFunction(opts.accepts)) {
|
|
1736
|
+
valid = opts.accepts(this.ele, target);
|
|
1394
1737
|
}
|
|
1395
1738
|
if (!valid)
|
|
1396
1739
|
return;
|
|
1397
1740
|
__classPrivateFieldSet(this, _Droppable_active, target, "f");
|
|
1398
|
-
if (
|
|
1741
|
+
if (opts.activeClass) {
|
|
1399
1742
|
each(this.ele, el => {
|
|
1400
|
-
each(split(
|
|
1743
|
+
each(split(opts.activeClass || '', ' '), cls => {
|
|
1401
1744
|
el.classList.toggle(cls, true);
|
|
1402
1745
|
});
|
|
1403
1746
|
});
|
|
1404
1747
|
}
|
|
1405
|
-
|
|
1406
|
-
//bind events
|
|
1748
|
+
opts.onActive && opts.onActive({ draggable: target, droppables: this.ele });
|
|
1407
1749
|
each(this.ele, (el) => {
|
|
1408
1750
|
el.classList.toggle(CLASS_DROPPABLE, true);
|
|
1409
1751
|
el.style.pointerEvents = 'initial';
|
|
1410
|
-
this.bindEvent(el,
|
|
1752
|
+
this.bindEvent(el, opts);
|
|
1411
1753
|
});
|
|
1412
1754
|
}
|
|
1413
|
-
/**
|
|
1414
|
-
* @internal
|
|
1415
|
-
*/
|
|
1416
1755
|
deactive(target) {
|
|
1417
1756
|
if (!__classPrivateFieldGet(this, _Droppable_active, "f"))
|
|
1418
1757
|
return;
|
|
1419
1758
|
__classPrivateFieldSet(this, _Droppable_active, null, "f");
|
|
1420
|
-
|
|
1759
|
+
const opts = this.opts;
|
|
1760
|
+
if (opts.activeClass) {
|
|
1421
1761
|
each(this.ele, el => {
|
|
1422
|
-
each(split(
|
|
1762
|
+
each(split(opts.activeClass || '', ' '), cls => {
|
|
1423
1763
|
el.classList.toggle(cls, false);
|
|
1424
1764
|
});
|
|
1425
1765
|
});
|
|
1426
1766
|
}
|
|
1427
|
-
|
|
1428
|
-
//unbind events
|
|
1767
|
+
opts.onDeactive && opts.onDeactive({ draggable: target, droppables: this.ele });
|
|
1429
1768
|
this.destroy();
|
|
1430
1769
|
}
|
|
1431
1770
|
}
|
|
1432
1771
|
_Droppable_active = new WeakMap();
|
|
1433
|
-
//uii-drag active
|
|
1434
1772
|
document.addEventListener("uii-dragactive", (e) => {
|
|
1435
1773
|
each(Droppables, dpb => {
|
|
1436
1774
|
dpb.active(e.target);
|
|
@@ -1441,142 +1779,83 @@ document.addEventListener("uii-dragdeactive", (e) => {
|
|
|
1441
1779
|
dpb.deactive(e.target);
|
|
1442
1780
|
});
|
|
1443
1781
|
});
|
|
1444
|
-
/**
|
|
1445
|
-
* Enable els to response to draggable objects
|
|
1446
|
-
* @param els selector string / html element
|
|
1447
|
-
* @param opts
|
|
1448
|
-
* @returns
|
|
1449
|
-
*/
|
|
1450
1782
|
function newDroppable(els, opts) {
|
|
1451
1783
|
return new Droppable(els, opts);
|
|
1452
1784
|
}
|
|
1453
1785
|
|
|
1454
|
-
|
|
1455
|
-
const ONE_DEG = 180 / Math.PI;
|
|
1456
|
-
const THRESHOLD$1 = 2;
|
|
1786
|
+
const THRESHOLD$2 = 2;
|
|
1457
1787
|
const CLASS_ROTATABLE = "uii-rotatable";
|
|
1458
1788
|
const CLASS_ROTATABLE_HANDLE = "uii-rotatable-handle";
|
|
1459
1789
|
const CLASS_ROTATABLE_ACTIVE = "uii-rotatable-active";
|
|
1460
|
-
/**
|
|
1461
|
-
* 用于表示一个或多个可旋转元素的定义
|
|
1462
|
-
* > 可用CSS接口
|
|
1463
|
-
* - .uii-rotatable
|
|
1464
|
-
* - .uii-rotatable-handle
|
|
1465
|
-
* - .uii-rotatable-active
|
|
1466
|
-
* @public
|
|
1467
|
-
*/
|
|
1468
1790
|
class Rotatable extends Uii {
|
|
1469
1791
|
constructor(els, opts) {
|
|
1470
1792
|
super(els, opts);
|
|
1471
1793
|
each(this.ele, (el) => {
|
|
1472
|
-
initHandle(el, this.opts);
|
|
1794
|
+
initHandle(this, el, this.opts);
|
|
1473
1795
|
});
|
|
1474
1796
|
}
|
|
1475
1797
|
}
|
|
1476
|
-
function initHandle(el, opts) {
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1798
|
+
function initHandle(uiik, el, opts) {
|
|
1799
|
+
let handleStr = opts.handle;
|
|
1800
|
+
let handles;
|
|
1801
|
+
if (isString(handleStr)) {
|
|
1802
|
+
handles = document.querySelectorAll(handleStr);
|
|
1803
|
+
}
|
|
1804
|
+
else if (isFunction(handleStr)) {
|
|
1805
|
+
handles = handleStr(el);
|
|
1806
|
+
}
|
|
1807
|
+
if (!handles) {
|
|
1808
|
+
console.error('Can not find handles with "' + el.outerHTML + '"');
|
|
1809
|
+
return;
|
|
1810
|
+
}
|
|
1811
|
+
each(handles, (h) => {
|
|
1812
|
+
var _a;
|
|
1813
|
+
h.classList.add(CLASS_ROTATABLE_HANDLE);
|
|
1814
|
+
h.style.cursor = ((_a = opts.cursor) === null || _a === void 0 ? void 0 : _a.default) || "crosshair";
|
|
1815
|
+
bindHandle(uiik, h, el, opts);
|
|
1816
|
+
});
|
|
1490
1817
|
el.classList.toggle(CLASS_ROTATABLE, true);
|
|
1491
|
-
el.appendChild(handle);
|
|
1492
1818
|
}
|
|
1493
|
-
function bindHandle(handle, el, opts) {
|
|
1819
|
+
function bindHandle(uiik, handle, el, opts) {
|
|
1494
1820
|
const onStart = opts.onStart;
|
|
1495
1821
|
const onRotate = opts.onRotate;
|
|
1496
1822
|
const onEnd = opts.onEnd;
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
deg
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
if (!dragging) {
|
|
1533
|
-
if (Math.abs(offsetx) > THRESHOLD$1 || Math.abs(offsety) > THRESHOLD$1) {
|
|
1534
|
-
dragging = true;
|
|
1535
|
-
//apply classes
|
|
1536
|
-
el.classList.toggle(CLASS_ROTATABLE_ACTIVE, true);
|
|
1537
|
-
call(onStart, deg);
|
|
1538
|
-
lockPage();
|
|
1539
|
-
if (isDefined(opts.cursor)) {
|
|
1540
|
-
setCursor(((_a = opts.cursor) === null || _a === void 0 ? void 0 : _a.active) || 'crosshair');
|
|
1541
|
-
}
|
|
1542
|
-
}
|
|
1543
|
-
else {
|
|
1544
|
-
ev.preventDefault();
|
|
1545
|
-
return false;
|
|
1546
|
-
}
|
|
1547
|
-
}
|
|
1548
|
-
deg = Math.atan2(offsety, offsetx) * ONE_DEG + 90 - offsetDeg;
|
|
1549
|
-
if (deg < 0)
|
|
1550
|
-
deg = 360 + deg;
|
|
1551
|
-
call(onRotate, deg);
|
|
1552
|
-
style.transform = style.transform.replace(/rotateZ\(.*?\)/, '') + ' rotateZ(' + deg + 'deg)';
|
|
1553
|
-
ev.preventDefault();
|
|
1554
|
-
return false;
|
|
1555
|
-
};
|
|
1556
|
-
const dragEndListener = (ev) => {
|
|
1557
|
-
document.removeEventListener('mousemove', dragListener, false);
|
|
1558
|
-
document.removeEventListener('mouseup', dragEndListener, false);
|
|
1559
|
-
window.removeEventListener('blur', dragEndListener, false);
|
|
1560
|
-
if (dragging) {
|
|
1561
|
-
unlockPage();
|
|
1562
|
-
restoreCursor();
|
|
1563
|
-
el.classList.toggle(CLASS_ROTATABLE_ACTIVE, false);
|
|
1564
|
-
call(onEnd, deg);
|
|
1565
|
-
}
|
|
1566
|
-
};
|
|
1567
|
-
document.addEventListener('mousemove', dragListener, false);
|
|
1568
|
-
document.addEventListener('mouseup', dragEndListener, false);
|
|
1569
|
-
window.addEventListener('blur', dragEndListener, false);
|
|
1570
|
-
e.preventDefault();
|
|
1571
|
-
return false;
|
|
1572
|
-
};
|
|
1823
|
+
let deg = 0;
|
|
1824
|
+
uiik.addPointerDown(handle, ({ onPointerStart, onPointerMove, onPointerEnd }) => {
|
|
1825
|
+
const { x, y, ox, oy } = getCenterXy(el);
|
|
1826
|
+
let centerX = x, centerY = y;
|
|
1827
|
+
let startDeg = 0;
|
|
1828
|
+
onPointerStart(function (args) {
|
|
1829
|
+
const { ev } = args;
|
|
1830
|
+
const currentXy = getPointInContainer(ev, el.parentElement);
|
|
1831
|
+
startDeg =
|
|
1832
|
+
Math.atan2(currentXy.y - centerY, currentXy.x - centerX) * ONE_RAD + 90;
|
|
1833
|
+
if (startDeg < 0)
|
|
1834
|
+
startDeg = 360 + startDeg;
|
|
1835
|
+
let matrixInfo = getMatrixInfo(el);
|
|
1836
|
+
startDeg -= matrixInfo.angle;
|
|
1837
|
+
el.classList.toggle(CLASS_ROTATABLE_ACTIVE, true);
|
|
1838
|
+
onStart && onStart({ deg, cx: centerX, cy: centerY }, ev);
|
|
1839
|
+
});
|
|
1840
|
+
onPointerMove((args) => {
|
|
1841
|
+
const { ev } = args;
|
|
1842
|
+
const currentXy = getPointInContainer(ev, el.parentElement);
|
|
1843
|
+
deg =
|
|
1844
|
+
Math.atan2(currentXy.y - centerY, currentXy.x - centerX) * ONE_RAD +
|
|
1845
|
+
90 - startDeg;
|
|
1846
|
+
onRotate && onRotate({ deg, cx: centerX, cy: centerY }, ev);
|
|
1847
|
+
rotateTo(el, deg, ox, oy);
|
|
1848
|
+
});
|
|
1849
|
+
onPointerEnd((args) => {
|
|
1850
|
+
const { ev } = args;
|
|
1851
|
+
el.classList.toggle(CLASS_ROTATABLE_ACTIVE, false);
|
|
1852
|
+
onEnd && onEnd({ deg }, ev);
|
|
1853
|
+
});
|
|
1854
|
+
}, {
|
|
1855
|
+
threshold: THRESHOLD$2,
|
|
1856
|
+
lockPage: true,
|
|
1857
|
+
});
|
|
1573
1858
|
}
|
|
1574
|
-
/**
|
|
1575
|
-
* Make els rotatable
|
|
1576
|
-
* @param els selector string / html element
|
|
1577
|
-
* @param opts
|
|
1578
|
-
* @returns
|
|
1579
|
-
*/
|
|
1580
1859
|
function newRotatable(els, opts) {
|
|
1581
1860
|
return new Rotatable(els, opts);
|
|
1582
1861
|
}
|
|
@@ -1597,8 +1876,7 @@ class CollisionDetector {
|
|
|
1597
1876
|
}
|
|
1598
1877
|
const ele = domEl;
|
|
1599
1878
|
this.el = domEl;
|
|
1600
|
-
|
|
1601
|
-
const offset = getOffset(ele, this.opts.container);
|
|
1879
|
+
const offset = getBox(ele, this.opts.container);
|
|
1602
1880
|
const rect = { x: offset.x, y: offset.y, width: ele.offsetWidth, height: ele.offsetHeight };
|
|
1603
1881
|
this.elData = {
|
|
1604
1882
|
x1: rect.x,
|
|
@@ -1606,12 +1884,8 @@ class CollisionDetector {
|
|
|
1606
1884
|
x2: rect.x + rect.width,
|
|
1607
1885
|
y2: rect.y + rect.height,
|
|
1608
1886
|
};
|
|
1609
|
-
//targets data
|
|
1610
1887
|
this.update();
|
|
1611
1888
|
}
|
|
1612
|
-
/**
|
|
1613
|
-
* update targets data if them changed
|
|
1614
|
-
*/
|
|
1615
1889
|
update() {
|
|
1616
1890
|
let targets;
|
|
1617
1891
|
if (isFunction(__classPrivateFieldGet(this, _CollisionDetector__targets, "f"))) {
|
|
@@ -1619,6 +1893,7 @@ class CollisionDetector {
|
|
|
1619
1893
|
}
|
|
1620
1894
|
else if (isString(__classPrivateFieldGet(this, _CollisionDetector__targets, "f"))) {
|
|
1621
1895
|
targets = this.opts.container.querySelectorAll(__classPrivateFieldGet(this, _CollisionDetector__targets, "f"));
|
|
1896
|
+
targets = reject(targets, t => t === this.el);
|
|
1622
1897
|
}
|
|
1623
1898
|
else if (isElement(__classPrivateFieldGet(this, _CollisionDetector__targets, "f"))) {
|
|
1624
1899
|
targets = [__classPrivateFieldGet(this, _CollisionDetector__targets, "f")];
|
|
@@ -1629,15 +1904,12 @@ class CollisionDetector {
|
|
|
1629
1904
|
this.targetsData = flatMap(targets, t => {
|
|
1630
1905
|
if (!t)
|
|
1631
1906
|
return [];
|
|
1632
|
-
|
|
1633
|
-
return [];
|
|
1634
|
-
const offset = getOffset(t, this.opts.container);
|
|
1635
|
-
const rect = { x: offset.x, y: offset.y, width: t.offsetWidth, height: t.offsetHeight };
|
|
1907
|
+
const rect = getRectInContainer(t, this.opts.container);
|
|
1636
1908
|
return {
|
|
1637
1909
|
x1: rect.x,
|
|
1638
1910
|
y1: rect.y,
|
|
1639
|
-
x2: rect.x + rect.
|
|
1640
|
-
y2: rect.y + rect.
|
|
1911
|
+
x2: rect.x + rect.w,
|
|
1912
|
+
y2: rect.y + rect.h,
|
|
1641
1913
|
el: t
|
|
1642
1914
|
};
|
|
1643
1915
|
});
|
|
@@ -1678,36 +1950,15 @@ class CollisionDetector {
|
|
|
1678
1950
|
}
|
|
1679
1951
|
}
|
|
1680
1952
|
_CollisionDetector__targets = new WeakMap();
|
|
1681
|
-
/**
|
|
1682
|
-
* create a detector for the el and return
|
|
1683
|
-
* @param el element to be detected
|
|
1684
|
-
* @param targets
|
|
1685
|
-
* @param opts CollisionDetectorOptions
|
|
1686
|
-
* @param opts.container a root element of targets
|
|
1687
|
-
* @returns
|
|
1688
|
-
*/
|
|
1689
1953
|
function newCollisionDetector(el, targets, opts) {
|
|
1690
1954
|
return new CollisionDetector(el, targets, opts);
|
|
1691
1955
|
}
|
|
1692
1956
|
|
|
1693
|
-
/* eslint-disable max-len */
|
|
1694
|
-
/**
|
|
1695
|
-
* selector
|
|
1696
|
-
* @author holyhigh2
|
|
1697
|
-
*/
|
|
1698
1957
|
var _Selectable_instances, _Selectable__detector, _Selectable__lastSelected, _Selectable_bindEvent;
|
|
1699
1958
|
const CLASS_SELECTOR = "uii-selector";
|
|
1700
1959
|
const CLASS_SELECTING = "uii-selecting";
|
|
1701
1960
|
const CLASS_SELECTED = "uii-selected";
|
|
1702
|
-
const THRESHOLD = 2;
|
|
1703
|
-
/**
|
|
1704
|
-
* 用于表示一个元素选择器的定义
|
|
1705
|
-
* > 可用CSS接口
|
|
1706
|
-
* - .uii-selector
|
|
1707
|
-
* - .uii-selecting
|
|
1708
|
-
* - .uii-selected
|
|
1709
|
-
* @public
|
|
1710
|
-
*/
|
|
1961
|
+
const THRESHOLD$1 = 2;
|
|
1711
1962
|
class Selectable extends Uii {
|
|
1712
1963
|
constructor(container, opts) {
|
|
1713
1964
|
super(container, assign({
|
|
@@ -1718,117 +1969,99 @@ class Selectable extends Uii {
|
|
|
1718
1969
|
_Selectable__detector.set(this, void 0);
|
|
1719
1970
|
_Selectable__lastSelected.set(this, void 0);
|
|
1720
1971
|
const domEl = this.ele[0];
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1972
|
+
let selector = document.createElement("div");
|
|
1973
|
+
if (domEl instanceof SVGElement) {
|
|
1974
|
+
selector = document.createElementNS('http://www.w3.org/2000/svg', "rect");
|
|
1975
|
+
}
|
|
1976
|
+
selector.setAttribute('class', CLASS_SELECTOR);
|
|
1724
1977
|
selector.style.cssText = `
|
|
1725
1978
|
position:absolute;
|
|
1726
|
-
left
|
|
1979
|
+
left:0;top:0;
|
|
1727
1980
|
`;
|
|
1728
1981
|
if (this.opts.class) {
|
|
1729
|
-
selector.
|
|
1982
|
+
selector.setAttribute('class', selector.getAttribute('class') + " " + this.opts.class);
|
|
1730
1983
|
}
|
|
1731
1984
|
else {
|
|
1732
|
-
selector.style.cssText += "border:1px dashed #000;";
|
|
1985
|
+
selector.style.cssText += "border:1px dashed #000;stroke:#000;";
|
|
1733
1986
|
}
|
|
1987
|
+
selector.style.display = 'none';
|
|
1734
1988
|
domEl.appendChild(selector);
|
|
1735
|
-
//create detector
|
|
1736
1989
|
__classPrivateFieldSet(this, _Selectable__detector, newCollisionDetector(selector, this.opts.targets, {
|
|
1737
1990
|
container: domEl,
|
|
1738
1991
|
}), "f");
|
|
1739
1992
|
__classPrivateFieldGet(this, _Selectable_instances, "m", _Selectable_bindEvent).call(this, selector, domEl);
|
|
1740
1993
|
}
|
|
1741
|
-
/**
|
|
1742
|
-
* 更新targets
|
|
1743
|
-
*/
|
|
1744
1994
|
updateTargets() {
|
|
1745
1995
|
__classPrivateFieldGet(this, _Selectable__detector, "f").update();
|
|
1746
1996
|
}
|
|
1747
|
-
/**
|
|
1748
|
-
* @internal
|
|
1749
|
-
*/
|
|
1750
1997
|
onOptionChanged() {
|
|
1751
1998
|
this.updateTargets();
|
|
1752
1999
|
}
|
|
1753
2000
|
}
|
|
1754
2001
|
_Selectable__detector = new WeakMap(), _Selectable__lastSelected = new WeakMap(), _Selectable_instances = new WeakSet(), _Selectable_bindEvent = function _Selectable_bindEvent(selector, con) {
|
|
1755
2002
|
const that = this;
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
const onStart =
|
|
1759
|
-
const onSelect =
|
|
1760
|
-
const onEnd =
|
|
1761
|
-
const mode =
|
|
1762
|
-
const scroll =
|
|
1763
|
-
const scrollSpeed =
|
|
1764
|
-
const filter =
|
|
1765
|
-
const selectingClassAry = compact(split(
|
|
1766
|
-
const selectedClassAry = compact(split(
|
|
1767
|
-
//check filter
|
|
2003
|
+
const opts = this.opts;
|
|
2004
|
+
this.addPointerDown(con, ({ ev, target, currentRect, currentCStyle, currentTarget, onPointerStart, onPointerMove, onPointerEnd }) => {
|
|
2005
|
+
const onStart = opts.onStart;
|
|
2006
|
+
const onSelect = opts.onSelect;
|
|
2007
|
+
const onEnd = opts.onEnd;
|
|
2008
|
+
const mode = opts.mode || "overlap";
|
|
2009
|
+
const scroll = opts.scroll;
|
|
2010
|
+
const scrollSpeed = opts.scrollSpeed || 10;
|
|
2011
|
+
const filter = opts.filter;
|
|
2012
|
+
const selectingClassAry = compact(split(opts.selectingClass, " "));
|
|
2013
|
+
const selectedClassAry = compact(split(opts.selectedClass, " "));
|
|
1768
2014
|
if (filter) {
|
|
1769
2015
|
if (isFunction(filter)) {
|
|
1770
|
-
if (filter(
|
|
2016
|
+
if (filter(target))
|
|
1771
2017
|
return;
|
|
1772
2018
|
}
|
|
1773
|
-
else if (some(con.querySelectorAll(filter), (el) => el.contains(
|
|
2019
|
+
else if (some(con.querySelectorAll(filter), (el) => el.contains(target)))
|
|
1774
2020
|
return;
|
|
1775
2021
|
}
|
|
2022
|
+
const onPointerDown = opts.onPointerDown;
|
|
2023
|
+
if (onPointerDown && onPointerDown(ev) === false)
|
|
2024
|
+
return;
|
|
1776
2025
|
let originPos = "";
|
|
1777
|
-
|
|
1778
|
-
const
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
const btw = parseFloat(conStyle.borderTopWidth);
|
|
1782
|
-
let hitPosX = e.offsetX + con.scrollLeft, hitPosY = e.offsetY + con.scrollTop;
|
|
1783
|
-
if (t !== con) {
|
|
1784
|
-
const offset = getOffset(t, con);
|
|
1785
|
-
const style = window.getComputedStyle(t);
|
|
1786
|
-
hitPosX = offset.x + e.offsetX + parseFloat(style.borderLeftWidth);
|
|
1787
|
-
hitPosY = offset.y + e.offsetY + parseFloat(style.borderTopWidth);
|
|
1788
|
-
}
|
|
2026
|
+
let matrixInfo = getMatrixInfo(currentCStyle);
|
|
2027
|
+
const startxy = getPointInContainer(ev, con, currentRect, currentCStyle, matrixInfo);
|
|
2028
|
+
let hitPosX = startxy.x;
|
|
2029
|
+
let hitPosY = startxy.y;
|
|
1789
2030
|
const style = selector.style;
|
|
1790
2031
|
let selection = [];
|
|
1791
2032
|
let lastSelection = [];
|
|
1792
2033
|
let x1 = hitPosX, y1 = hitPosY;
|
|
1793
|
-
let dragging = false;
|
|
1794
2034
|
let timer = null;
|
|
1795
2035
|
let toLeft = false;
|
|
1796
2036
|
let toTop = false;
|
|
1797
2037
|
let toRight = false;
|
|
1798
2038
|
let toBottom = false;
|
|
1799
|
-
|
|
1800
|
-
const
|
|
1801
|
-
|
|
1802
|
-
const
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
}
|
|
1821
|
-
else {
|
|
1822
|
-
ev.preventDefault();
|
|
1823
|
-
return false;
|
|
1824
|
-
}
|
|
1825
|
-
}
|
|
1826
|
-
//edge detect
|
|
2039
|
+
onPointerStart(function (args) {
|
|
2040
|
+
const { ev } = args;
|
|
2041
|
+
__classPrivateFieldGet(that, _Selectable__detector, "f").update();
|
|
2042
|
+
const pos = currentCStyle.position;
|
|
2043
|
+
if (pos === "static") {
|
|
2044
|
+
originPos = con.style.position;
|
|
2045
|
+
con.style.position = "relative";
|
|
2046
|
+
}
|
|
2047
|
+
each(__classPrivateFieldGet(that, _Selectable__lastSelected, "f"), t => {
|
|
2048
|
+
target.classList.toggle(CLASS_SELECTED, false);
|
|
2049
|
+
});
|
|
2050
|
+
style.display = 'block';
|
|
2051
|
+
onStart && onStart({ selection: __classPrivateFieldGet(that, _Selectable__lastSelected, "f"), selectable: con }, ev);
|
|
2052
|
+
});
|
|
2053
|
+
onPointerMove((args) => {
|
|
2054
|
+
const { ev } = args;
|
|
2055
|
+
const currentXy = getPointInContainer(ev, currentTarget, currentRect, currentCStyle, matrixInfo);
|
|
2056
|
+
let pointX = currentXy.x;
|
|
2057
|
+
let pointY = currentXy.y;
|
|
2058
|
+
let offX = pointX - hitPosX;
|
|
2059
|
+
let offY = pointY - hitPosY;
|
|
1827
2060
|
if (scroll) {
|
|
1828
|
-
const ltX = ev.clientX -
|
|
1829
|
-
const ltY = ev.clientY -
|
|
1830
|
-
const rbX =
|
|
1831
|
-
const rbY =
|
|
2061
|
+
const ltX = ev.clientX - currentRect.x;
|
|
2062
|
+
const ltY = ev.clientY - currentRect.y;
|
|
2063
|
+
const rbX = currentRect.x + currentRect.width - ev.clientX;
|
|
2064
|
+
const rbY = currentRect.y + currentRect.height - ev.clientY;
|
|
1832
2065
|
toLeft = ltX < EDGE_THRESHOLD;
|
|
1833
2066
|
toTop = ltY < EDGE_THRESHOLD;
|
|
1834
2067
|
toRight = rbX < EDGE_THRESHOLD;
|
|
@@ -1858,26 +2091,24 @@ _Selectable__detector = new WeakMap(), _Selectable__lastSelected = new WeakMap()
|
|
|
1858
2091
|
}
|
|
1859
2092
|
}
|
|
1860
2093
|
}
|
|
1861
|
-
let x = hitPosX, y = hitPosY, w = Math.abs(
|
|
1862
|
-
if (
|
|
2094
|
+
let x = hitPosX, y = hitPosY, w = Math.abs(offX), h = Math.abs(offY);
|
|
2095
|
+
if (offX > 0 && offY > 0) {
|
|
1863
2096
|
x1 = hitPosX;
|
|
1864
2097
|
y1 = hitPosY;
|
|
1865
2098
|
}
|
|
1866
|
-
else if (
|
|
1867
|
-
x = x1 =
|
|
1868
|
-
y = y1 =
|
|
2099
|
+
else if (offX < 0 && offY < 0) {
|
|
2100
|
+
x = x1 = pointX;
|
|
2101
|
+
y = y1 = pointY;
|
|
1869
2102
|
}
|
|
1870
|
-
else if (
|
|
1871
|
-
x = x1 =
|
|
2103
|
+
else if (offX < 0) {
|
|
2104
|
+
x = x1 = pointX;
|
|
1872
2105
|
}
|
|
1873
|
-
else if (
|
|
1874
|
-
y = y1 =
|
|
2106
|
+
else if (offY < 0) {
|
|
2107
|
+
y = y1 = pointY;
|
|
1875
2108
|
}
|
|
1876
|
-
style.left = x + "px";
|
|
1877
|
-
style.top = y + "px";
|
|
1878
2109
|
style.width = w + "px";
|
|
1879
2110
|
style.height = h + "px";
|
|
1880
|
-
|
|
2111
|
+
style.transform = `translate3d(${x}px,${y}px,0)`;
|
|
1881
2112
|
if (mode === "overlap") {
|
|
1882
2113
|
selection = __classPrivateFieldGet(that, _Selectable__detector, "f").getOverlaps(x1, y1, x1 + w, y1 + h);
|
|
1883
2114
|
}
|
|
@@ -1900,24 +2131,18 @@ _Selectable__detector = new WeakMap(), _Selectable__lastSelected = new WeakMap()
|
|
|
1900
2131
|
});
|
|
1901
2132
|
const changed = lastSelection.length != selection.length;
|
|
1902
2133
|
lastSelection = selection;
|
|
1903
|
-
if (changed)
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
style.left = "-9999px";
|
|
1910
|
-
style.width = style.height = "0px";
|
|
1911
|
-
document.removeEventListener("mousemove", dragListener, false);
|
|
1912
|
-
document.removeEventListener("mouseup", dragEndListener, false);
|
|
1913
|
-
window.removeEventListener("blur", dragEndListener, false);
|
|
2134
|
+
if (changed && onSelect)
|
|
2135
|
+
onSelect({ selection, selectable: con }, ev);
|
|
2136
|
+
});
|
|
2137
|
+
onPointerEnd((args) => {
|
|
2138
|
+
const { ev, currentStyle } = args;
|
|
2139
|
+
style.display = 'none';
|
|
1914
2140
|
if (scroll) {
|
|
1915
2141
|
if (timer) {
|
|
1916
2142
|
clearInterval(timer);
|
|
1917
2143
|
timer = null;
|
|
1918
2144
|
}
|
|
1919
2145
|
}
|
|
1920
|
-
//restore container position
|
|
1921
2146
|
if (originPos) {
|
|
1922
2147
|
con.style.position = originPos;
|
|
1923
2148
|
}
|
|
@@ -1931,34 +2156,407 @@ _Selectable__detector = new WeakMap(), _Selectable__lastSelected = new WeakMap()
|
|
|
1931
2156
|
t.classList.toggle(CLASS_SELECTING, false);
|
|
1932
2157
|
t.classList.toggle(CLASS_SELECTED, true);
|
|
1933
2158
|
});
|
|
1934
|
-
__classPrivateFieldSet(
|
|
1935
|
-
if (
|
|
1936
|
-
|
|
1937
|
-
};
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
e.preventDefault();
|
|
1942
|
-
return false;
|
|
2159
|
+
__classPrivateFieldSet(that, _Selectable__lastSelected, selection, "f");
|
|
2160
|
+
if (onEnd)
|
|
2161
|
+
onEnd({ selection, selectable: con }, ev);
|
|
2162
|
+
});
|
|
2163
|
+
}, {
|
|
2164
|
+
threshold: THRESHOLD$1,
|
|
2165
|
+
lockPage: true
|
|
1943
2166
|
});
|
|
1944
2167
|
};
|
|
1945
|
-
/**
|
|
1946
|
-
* Add a selector into the container
|
|
1947
|
-
* @param container css selector or html element
|
|
1948
|
-
* @param opts
|
|
1949
|
-
* @returns
|
|
1950
|
-
*/
|
|
1951
2168
|
function newSelectable(container, opts) {
|
|
1952
2169
|
return new Selectable(container, opts);
|
|
1953
2170
|
}
|
|
1954
2171
|
|
|
1955
|
-
var
|
|
2172
|
+
var _Sortable_removeListenItems;
|
|
2173
|
+
const SORTABLE_GROUPS = {};
|
|
2174
|
+
const CLASS_SORTABLE_CONTAINER = "uii-sortable-container";
|
|
2175
|
+
const CLASS_SORTABLE_GHOST = "uii-sortable-ghost";
|
|
2176
|
+
const CLASS_SORTABLE_ACTIVE = "uii-sortable-active";
|
|
2177
|
+
const ATTR_SORTABLE_ACTIVE = "uii-sortable-active";
|
|
2178
|
+
const THRESHOLD = 2;
|
|
2179
|
+
class Sortable extends Uii {
|
|
2180
|
+
constructor(container, opts) {
|
|
2181
|
+
super(container, merge({
|
|
2182
|
+
move: {
|
|
2183
|
+
from: true,
|
|
2184
|
+
to: true,
|
|
2185
|
+
},
|
|
2186
|
+
scroll: true,
|
|
2187
|
+
sort: true
|
|
2188
|
+
}, opts));
|
|
2189
|
+
_Sortable_removeListenItems.set(this, void 0);
|
|
2190
|
+
if (size(this.ele) > 1 && !this.opts.group) {
|
|
2191
|
+
this.opts.group = "uii_sortable_" + alphaId();
|
|
2192
|
+
}
|
|
2193
|
+
each(this.ele, (el) => {
|
|
2194
|
+
el.classList.add(CLASS_SORTABLE_CONTAINER);
|
|
2195
|
+
el.style.position = "relative";
|
|
2196
|
+
el.style.pointerEvents = "initial";
|
|
2197
|
+
bindContainer(this.registerEvent.bind(this), el, this.opts);
|
|
2198
|
+
});
|
|
2199
|
+
if (this.opts.group) {
|
|
2200
|
+
if (!SORTABLE_GROUPS[this.opts.group]) {
|
|
2201
|
+
SORTABLE_GROUPS[this.opts.group] = [];
|
|
2202
|
+
}
|
|
2203
|
+
SORTABLE_GROUPS[this.opts.group].push([this, this.ele]);
|
|
2204
|
+
}
|
|
2205
|
+
}
|
|
2206
|
+
active(draggingItem, fromContainer, toContainers, toOpts) {
|
|
2207
|
+
var _a;
|
|
2208
|
+
const moveFrom = (_a = toOpts.move) === null || _a === void 0 ? void 0 : _a.from;
|
|
2209
|
+
const acceptFn = isFunction(moveFrom) ? moveFrom : () => !!moveFrom;
|
|
2210
|
+
const activableContainers = flatMap(toContainers, (el) => {
|
|
2211
|
+
const valid = acceptFn(draggingItem, fromContainer, el);
|
|
2212
|
+
return valid ? el : [];
|
|
2213
|
+
});
|
|
2214
|
+
each(activableContainers, (el) => {
|
|
2215
|
+
el.setAttribute(ATTR_SORTABLE_ACTIVE, "1");
|
|
2216
|
+
if (toOpts.activeClass) {
|
|
2217
|
+
each(split(toOpts.activeClass || "", " "), (cls) => {
|
|
2218
|
+
el.classList.toggle(cls, true);
|
|
2219
|
+
});
|
|
2220
|
+
}
|
|
2221
|
+
});
|
|
2222
|
+
__classPrivateFieldSet(this, _Sortable_removeListenItems, map(activableContainers, (con) => {
|
|
2223
|
+
const filteredItems = con.querySelectorAll(":scope > *");
|
|
2224
|
+
return listenItems(toOpts, con, draggingItem, filteredItems);
|
|
2225
|
+
}), "f");
|
|
2226
|
+
toOpts.onActive &&
|
|
2227
|
+
toOpts.onActive({ item: draggingItem, from: fromContainer });
|
|
2228
|
+
}
|
|
2229
|
+
deactive(draggingItem, fromContainer, toContainers, opts) {
|
|
2230
|
+
each(toContainers, (el) => {
|
|
2231
|
+
el.removeAttribute(ATTR_SORTABLE_ACTIVE);
|
|
2232
|
+
if (opts.activeClass) {
|
|
2233
|
+
each(split(opts.activeClass || "", " "), (cls) => {
|
|
2234
|
+
el.classList.toggle(cls, false);
|
|
2235
|
+
});
|
|
2236
|
+
}
|
|
2237
|
+
});
|
|
2238
|
+
each(__classPrivateFieldGet(this, _Sortable_removeListenItems, "f"), (fn) => {
|
|
2239
|
+
fn();
|
|
2240
|
+
});
|
|
2241
|
+
opts.onDeactive &&
|
|
2242
|
+
opts.onDeactive({ item: draggingItem, from: fromContainer });
|
|
2243
|
+
}
|
|
2244
|
+
onOptionChanged() { }
|
|
2245
|
+
}
|
|
2246
|
+
_Sortable_removeListenItems = new WeakMap();
|
|
2247
|
+
let DraggingData = null;
|
|
2248
|
+
function bindContainer(registerEvent, container, opts) {
|
|
2249
|
+
registerEvent(container, "mousedown", (e) => {
|
|
2250
|
+
var _a;
|
|
2251
|
+
let con = e.currentTarget;
|
|
2252
|
+
let t = e.target;
|
|
2253
|
+
if (t === con)
|
|
2254
|
+
return;
|
|
2255
|
+
const filterStr = opts.filter ? `:not(${opts.filter})` : "";
|
|
2256
|
+
const filteredItems = con.querySelectorAll(":scope > *" + filterStr);
|
|
2257
|
+
const handles = opts.handle
|
|
2258
|
+
? map(filteredItems, (el) => el.querySelector(opts.handle || ""))
|
|
2259
|
+
: toArray(filteredItems);
|
|
2260
|
+
const i = findIndex(handles, (handle) => handle.contains(t));
|
|
2261
|
+
if (i < 0)
|
|
2262
|
+
return;
|
|
2263
|
+
const draggingItem = filteredItems[i];
|
|
2264
|
+
const ghostContainer = opts.ghostContainer || con;
|
|
2265
|
+
const onStart = opts.onStart;
|
|
2266
|
+
const onEnd = opts.onEnd;
|
|
2267
|
+
const ghostClass = opts.ghostClass;
|
|
2268
|
+
const group = opts.group;
|
|
2269
|
+
let moveTo = (_a = opts.move) === null || _a === void 0 ? void 0 : _a.to;
|
|
2270
|
+
const toCopy = moveTo === "copy";
|
|
2271
|
+
const toOutFn = isFunction(moveTo) ? moveTo : () => !!moveTo;
|
|
2272
|
+
const moveMode = toOutFn(draggingItem, con);
|
|
2273
|
+
const sort = opts.sort;
|
|
2274
|
+
opts.scroll;
|
|
2275
|
+
opts.scrollSpeed || 10;
|
|
2276
|
+
let hitPosX = e.offsetX + con.scrollLeft, hitPosY = e.offsetY + con.scrollTop;
|
|
2277
|
+
saveCursor();
|
|
2278
|
+
let dragging = false;
|
|
2279
|
+
let ghostNode = null;
|
|
2280
|
+
let removeListenItems = null;
|
|
2281
|
+
const dragListener = (ev) => {
|
|
2282
|
+
const newX = ev.clientX;
|
|
2283
|
+
const newY = ev.clientY;
|
|
2284
|
+
let offsetx = newX - hitPosX;
|
|
2285
|
+
let offsety = newY - hitPosY;
|
|
2286
|
+
if (!dragging) {
|
|
2287
|
+
if (Math.abs(offsetx) > THRESHOLD || Math.abs(offsety) > THRESHOLD) {
|
|
2288
|
+
dragging = true;
|
|
2289
|
+
ghostNode = draggingItem.cloneNode(true);
|
|
2290
|
+
ghostNode.style.opacity = "0.3";
|
|
2291
|
+
ghostNode.style.pointerEvents = "none";
|
|
2292
|
+
ghostNode.style.position = "fixed";
|
|
2293
|
+
ghostNode.style.zIndex = "999";
|
|
2294
|
+
ghostNode.style.left = draggingItem.style.left;
|
|
2295
|
+
ghostNode.style.top = draggingItem.style.top;
|
|
2296
|
+
if (ghostClass) {
|
|
2297
|
+
ghostNode.classList.add(...compact(split(ghostClass, " ")));
|
|
2298
|
+
}
|
|
2299
|
+
ghostNode.classList.toggle(CLASS_SORTABLE_GHOST, true);
|
|
2300
|
+
ghostContainer.appendChild(ghostNode);
|
|
2301
|
+
if (!toCopy)
|
|
2302
|
+
draggingItem.classList.toggle(CLASS_SORTABLE_ACTIVE, true);
|
|
2303
|
+
let copy = undefined;
|
|
2304
|
+
if (toCopy) {
|
|
2305
|
+
copy = draggingItem.cloneNode(true);
|
|
2306
|
+
copy.classList.toggle(CLASS_SORTABLE_ACTIVE, true);
|
|
2307
|
+
}
|
|
2308
|
+
DraggingData = {
|
|
2309
|
+
item: draggingItem,
|
|
2310
|
+
fromIndex: i,
|
|
2311
|
+
fromContainer: con,
|
|
2312
|
+
toContainer: con,
|
|
2313
|
+
moveTo: toCopy ? "copy" : moveMode,
|
|
2314
|
+
spill: opts.spill,
|
|
2315
|
+
copy
|
|
2316
|
+
};
|
|
2317
|
+
onStart && onStart({ item: draggingItem, from: con, index: i }, ev);
|
|
2318
|
+
lockPage();
|
|
2319
|
+
if (sort) {
|
|
2320
|
+
removeListenItems = listenItems(opts, con, toCopy ? draggingItem : copy, filteredItems, i);
|
|
2321
|
+
}
|
|
2322
|
+
if (moveMode && group && SORTABLE_GROUPS[group]) {
|
|
2323
|
+
each(SORTABLE_GROUPS[group], ([sortable, ele]) => {
|
|
2324
|
+
const filtered = reject(ele, (el) => el === container);
|
|
2325
|
+
if (isEmpty(filtered))
|
|
2326
|
+
return;
|
|
2327
|
+
sortable.active(toCopy ? draggingItem : copy, container, filtered, sortable.getOptions());
|
|
2328
|
+
});
|
|
2329
|
+
}
|
|
2330
|
+
}
|
|
2331
|
+
else {
|
|
2332
|
+
ev.preventDefault();
|
|
2333
|
+
return false;
|
|
2334
|
+
}
|
|
2335
|
+
}
|
|
2336
|
+
ghostNode.style.left = newX + "px";
|
|
2337
|
+
ghostNode.style.top = newY + "px";
|
|
2338
|
+
ev.preventDefault();
|
|
2339
|
+
return false;
|
|
2340
|
+
};
|
|
2341
|
+
const dragEndListener = (ev) => {
|
|
2342
|
+
var _a;
|
|
2343
|
+
document.removeEventListener("mousemove", dragListener);
|
|
2344
|
+
document.removeEventListener("mouseup", dragEndListener);
|
|
2345
|
+
window.removeEventListener("blur", dragEndListener);
|
|
2346
|
+
if (dragging) {
|
|
2347
|
+
unlockPage();
|
|
2348
|
+
restoreCursor();
|
|
2349
|
+
if (ghostNode)
|
|
2350
|
+
ghostContainer.removeChild(ghostNode);
|
|
2351
|
+
const toContainer = DraggingData === null || DraggingData === void 0 ? void 0 : DraggingData.toContainer;
|
|
2352
|
+
DraggingData === null || DraggingData === void 0 ? void 0 : DraggingData.item.classList.remove(CLASS_SORTABLE_ACTIVE);
|
|
2353
|
+
(_a = DraggingData === null || DraggingData === void 0 ? void 0 : DraggingData.copy) === null || _a === void 0 ? void 0 : _a.classList.remove(CLASS_SORTABLE_ACTIVE);
|
|
2354
|
+
DraggingData = null;
|
|
2355
|
+
if (removeListenItems)
|
|
2356
|
+
removeListenItems();
|
|
2357
|
+
if (group && SORTABLE_GROUPS[group]) {
|
|
2358
|
+
each(SORTABLE_GROUPS[group], ([sortable, ele]) => {
|
|
2359
|
+
const filtered = reject(ele, (el) => el === container);
|
|
2360
|
+
if (isEmpty(filtered))
|
|
2361
|
+
return;
|
|
2362
|
+
sortable.deactive(draggingItem, container, filtered, sortable.getOptions());
|
|
2363
|
+
});
|
|
2364
|
+
}
|
|
2365
|
+
onEnd && onEnd({ item: draggingItem, from: container, to: toContainer }, e);
|
|
2366
|
+
}
|
|
2367
|
+
};
|
|
2368
|
+
document.addEventListener("mousemove", dragListener);
|
|
2369
|
+
document.addEventListener("mouseup", dragEndListener);
|
|
2370
|
+
window.addEventListener("blur", dragEndListener);
|
|
2371
|
+
e.preventDefault();
|
|
2372
|
+
return false;
|
|
2373
|
+
});
|
|
2374
|
+
registerEvent(container, "mouseleave", (e) => {
|
|
2375
|
+
var _a, _b;
|
|
2376
|
+
if (!DraggingData)
|
|
2377
|
+
return;
|
|
2378
|
+
opts.onLeave &&
|
|
2379
|
+
opts.onLeave({
|
|
2380
|
+
item: DraggingData.item,
|
|
2381
|
+
from: DraggingData.fromContainer,
|
|
2382
|
+
to: container,
|
|
2383
|
+
}, e);
|
|
2384
|
+
if (DraggingData.moveTo !== 'copy') {
|
|
2385
|
+
if (DraggingData.spill === 'remove') {
|
|
2386
|
+
(_a = DraggingData.item.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(DraggingData.item);
|
|
2387
|
+
}
|
|
2388
|
+
else if (DraggingData.spill === 'revert') {
|
|
2389
|
+
(_b = DraggingData.item.parentElement) === null || _b === void 0 ? void 0 : _b.removeChild(DraggingData.item);
|
|
2390
|
+
const nextSibling = DraggingData.fromContainer.children[DraggingData.fromIndex];
|
|
2391
|
+
DraggingData.fromContainer.insertBefore(DraggingData.item, nextSibling);
|
|
2392
|
+
}
|
|
2393
|
+
}
|
|
2394
|
+
});
|
|
2395
|
+
registerEvent(container, "mouseenter", (e) => {
|
|
2396
|
+
var _a;
|
|
2397
|
+
if (!DraggingData)
|
|
2398
|
+
return;
|
|
2399
|
+
let draggingItem = DraggingData.item;
|
|
2400
|
+
draggingItem.parentElement;
|
|
2401
|
+
const cx = e.clientX;
|
|
2402
|
+
const cy = e.clientY;
|
|
2403
|
+
const rect = container.getBoundingClientRect();
|
|
2404
|
+
const centerX = rect.width / 2;
|
|
2405
|
+
const centerY = rect.height / 2;
|
|
2406
|
+
const offsetX = cx - rect.x;
|
|
2407
|
+
const offsetY = cy - rect.y;
|
|
2408
|
+
let dir = "";
|
|
2409
|
+
if (offsetX < centerX && offsetY < centerY) {
|
|
2410
|
+
dir = "tl";
|
|
2411
|
+
}
|
|
2412
|
+
else if (offsetX > centerX && offsetY > centerY) {
|
|
2413
|
+
dir = "br";
|
|
2414
|
+
}
|
|
2415
|
+
else if (offsetX < centerX && offsetY > centerY) {
|
|
2416
|
+
dir = "bl";
|
|
2417
|
+
}
|
|
2418
|
+
else if (offsetX > centerX && offsetY < centerY) {
|
|
2419
|
+
dir = "tr";
|
|
2420
|
+
}
|
|
2421
|
+
opts.onEnter &&
|
|
2422
|
+
opts.onEnter({
|
|
2423
|
+
item: DraggingData.item,
|
|
2424
|
+
from: DraggingData.fromContainer,
|
|
2425
|
+
to: container,
|
|
2426
|
+
dir,
|
|
2427
|
+
}, e);
|
|
2428
|
+
DraggingData.toContainer = container;
|
|
2429
|
+
if (container.getAttribute(ATTR_SORTABLE_ACTIVE)) {
|
|
2430
|
+
let valid = true;
|
|
2431
|
+
const moveFrom = (_a = opts.move) === null || _a === void 0 ? void 0 : _a.from;
|
|
2432
|
+
const acceptFn = isFunction(moveFrom) ? moveFrom : () => !!moveFrom;
|
|
2433
|
+
valid = acceptFn(DraggingData.item, DraggingData.fromContainer, container);
|
|
2434
|
+
if (!valid)
|
|
2435
|
+
return;
|
|
2436
|
+
if (container.contains(draggingItem)) {
|
|
2437
|
+
return;
|
|
2438
|
+
}
|
|
2439
|
+
const moveTo = DraggingData.moveTo;
|
|
2440
|
+
if (moveTo === "copy") {
|
|
2441
|
+
draggingItem = DraggingData.copy;
|
|
2442
|
+
}
|
|
2443
|
+
if (draggingItem.parentElement)
|
|
2444
|
+
draggingItem.parentElement.removeChild(draggingItem);
|
|
2445
|
+
let toIndex = 0;
|
|
2446
|
+
if (dir[0] === "t") {
|
|
2447
|
+
container.insertBefore(draggingItem, container.children[0]);
|
|
2448
|
+
}
|
|
2449
|
+
else {
|
|
2450
|
+
container.appendChild(draggingItem);
|
|
2451
|
+
toIndex = container.children.length - 1;
|
|
2452
|
+
}
|
|
2453
|
+
opts.onAdd &&
|
|
2454
|
+
opts.onAdd({
|
|
2455
|
+
item: draggingItem,
|
|
2456
|
+
from: DraggingData.fromContainer,
|
|
2457
|
+
to: container,
|
|
2458
|
+
index: toIndex,
|
|
2459
|
+
}, e);
|
|
2460
|
+
}
|
|
2461
|
+
else if (container === DraggingData.fromContainer) {
|
|
2462
|
+
if (DraggingData.copy) {
|
|
2463
|
+
let parent = DraggingData.copy.parentElement;
|
|
2464
|
+
if (parent)
|
|
2465
|
+
parent.removeChild(DraggingData === null || DraggingData === void 0 ? void 0 : DraggingData.copy);
|
|
2466
|
+
}
|
|
2467
|
+
else {
|
|
2468
|
+
if (draggingItem.parentElement)
|
|
2469
|
+
draggingItem.parentElement.removeChild(draggingItem);
|
|
2470
|
+
if (dir[0] === "t") {
|
|
2471
|
+
container.insertBefore(draggingItem, container.children[0]);
|
|
2472
|
+
}
|
|
2473
|
+
else {
|
|
2474
|
+
container.appendChild(draggingItem);
|
|
2475
|
+
container.children.length - 1;
|
|
2476
|
+
}
|
|
2477
|
+
}
|
|
2478
|
+
}
|
|
2479
|
+
});
|
|
2480
|
+
}
|
|
2481
|
+
function listenItems(opts, toContainer, draggingItem, items, fromIndex = 0) {
|
|
2482
|
+
const listener = (e) => {
|
|
2483
|
+
const ct = e.currentTarget;
|
|
2484
|
+
if (ct.style.transform) {
|
|
2485
|
+
return;
|
|
2486
|
+
}
|
|
2487
|
+
const toIndex = ct._uiik_i;
|
|
2488
|
+
let draggingItem = (DraggingData === null || DraggingData === void 0 ? void 0 : DraggingData.copy) || (DraggingData === null || DraggingData === void 0 ? void 0 : DraggingData.item);
|
|
2489
|
+
if (toContainer === (DraggingData === null || DraggingData === void 0 ? void 0 : DraggingData.fromContainer)) {
|
|
2490
|
+
draggingItem = DraggingData === null || DraggingData === void 0 ? void 0 : DraggingData.item;
|
|
2491
|
+
}
|
|
2492
|
+
let parent = draggingItem.parentElement;
|
|
2493
|
+
parent === null || parent === void 0 ? void 0 : parent.removeChild(draggingItem);
|
|
2494
|
+
const sameContainer = parent === ct.parentElement;
|
|
2495
|
+
if (!sameContainer) {
|
|
2496
|
+
parent = ct.parentElement;
|
|
2497
|
+
}
|
|
2498
|
+
const oldIndex = fromIndex;
|
|
2499
|
+
if (toIndex > fromIndex) {
|
|
2500
|
+
fromIndex = toIndex;
|
|
2501
|
+
parent === null || parent === void 0 ? void 0 : parent.insertBefore(draggingItem, ct.nextElementSibling);
|
|
2502
|
+
}
|
|
2503
|
+
else {
|
|
2504
|
+
fromIndex = toIndex - 1;
|
|
2505
|
+
parent === null || parent === void 0 ? void 0 : parent.insertBefore(draggingItem, ct);
|
|
2506
|
+
}
|
|
2507
|
+
opts.onChange &&
|
|
2508
|
+
opts.onChange({
|
|
2509
|
+
item: draggingItem,
|
|
2510
|
+
from: DraggingData === null || DraggingData === void 0 ? void 0 : DraggingData.fromContainer,
|
|
2511
|
+
to: toContainer,
|
|
2512
|
+
fromIndex: oldIndex,
|
|
2513
|
+
toIndex: fromIndex,
|
|
2514
|
+
}, e);
|
|
2515
|
+
const toPos = { x: ct.offsetLeft, y: ct.offsetTop };
|
|
2516
|
+
const fromPos = { x: draggingItem.offsetLeft, y: draggingItem.offsetTop };
|
|
2517
|
+
ct.style.transform = `translate3d(${fromPos.x - toPos.x}px,${fromPos.y - toPos.y}px,0)`;
|
|
2518
|
+
draggingItem.style.transform = `translate3d(${toPos.x - fromPos.x}px,${toPos.y - fromPos.y}px,0)`;
|
|
2519
|
+
draggingItem.offsetHeight;
|
|
2520
|
+
ct.offsetHeight;
|
|
2521
|
+
draggingItem.style.transition = "transform .15s";
|
|
2522
|
+
draggingItem.style.transform = `translate3d(0px,0px,0)`;
|
|
2523
|
+
ct.style.transition = "transform .15s";
|
|
2524
|
+
ct.style.transform = `translate3d(0px,0px,0)`;
|
|
2525
|
+
setTimeout(() => {
|
|
2526
|
+
ct.style.transition = "";
|
|
2527
|
+
ct.style.transform = ``;
|
|
2528
|
+
draggingItem.style.transition = "";
|
|
2529
|
+
draggingItem.style.transform = ``;
|
|
2530
|
+
}, 150);
|
|
2531
|
+
e.stopPropagation();
|
|
2532
|
+
e.preventDefault();
|
|
2533
|
+
};
|
|
2534
|
+
each(items, (item, i) => {
|
|
2535
|
+
item.style.position = "relative";
|
|
2536
|
+
if (item === draggingItem)
|
|
2537
|
+
return;
|
|
2538
|
+
item.style.pointerEvents = "initial";
|
|
2539
|
+
item._uiik_i = i;
|
|
2540
|
+
item.addEventListener("mouseenter", listener);
|
|
2541
|
+
});
|
|
2542
|
+
return () => {
|
|
2543
|
+
each(items, (item, i) => {
|
|
2544
|
+
if (item === draggingItem)
|
|
2545
|
+
return;
|
|
2546
|
+
item.removeEventListener("mouseenter", listener);
|
|
2547
|
+
});
|
|
2548
|
+
};
|
|
2549
|
+
}
|
|
2550
|
+
function newSortable(container, opts) {
|
|
2551
|
+
return new Sortable(container, opts);
|
|
2552
|
+
}
|
|
2553
|
+
|
|
2554
|
+
var version = "1.3.0-alpha";
|
|
1956
2555
|
var repository = {
|
|
1957
2556
|
type: "git",
|
|
1958
2557
|
url: "https://github.com/holyhigh2/uiik"
|
|
1959
2558
|
};
|
|
1960
2559
|
|
|
1961
|
-
// welcome info
|
|
1962
2560
|
const welcome = globalThis.welcome;
|
|
1963
2561
|
if (!welcome) {
|
|
1964
2562
|
const ssAry = [];
|
|
@@ -1982,7 +2580,8 @@ var index = {
|
|
|
1982
2580
|
newDraggable,
|
|
1983
2581
|
newDroppable,
|
|
1984
2582
|
newRotatable,
|
|
1985
|
-
newSelectable
|
|
2583
|
+
newSelectable,
|
|
2584
|
+
newSortable
|
|
1986
2585
|
};
|
|
1987
2586
|
|
|
1988
|
-
export { CollisionDetector, Draggable, Droppable, Resizable, Rotatable, Selectable, Splittable, Uii, VERSION, index as default, newCollisionDetector, newDraggable, newDroppable, newResizable, newRotatable, newSelectable, newSplittable };
|
|
2587
|
+
export { CollisionDetector, DRAGGING_RULE, Draggable, Droppable, EDGE_THRESHOLD, ONE_ANG, ONE_RAD, Resizable, Rotatable, Selectable, Sortable, Splittable, Uii, UiiTransformer, VERSION, index as default, getBox, getCenterXy, getMatrixInfo, getPointInContainer, getPointOffset, getRectInContainer, getStyleXy, getTranslate, isSVGEl, lockPage, moveBy, moveTo, newCollisionDetector, newDraggable, newDroppable, newResizable, newRotatable, newSelectable, newSortable, newSplittable, restoreCursor, rotateTo, saveCursor, setCursor, unlockPage, wrapper };
|