uiik 1.3.0-beta.4 → 1.3.3
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 +13 -0
- package/index.esm.js +506 -329
- package/index.js +512 -330
- package/package.json +2 -2
- package/transform.d.ts +6 -2
- package/types.d.ts +3 -0
- package/utils.d.ts +19 -2
package/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* uiik v1.3.
|
|
2
|
+
* uiik v1.3.3
|
|
3
3
|
* A UI interactions kit includes draggable, splittable, rotatable, selectable, etc.
|
|
4
4
|
* https://github.com/holyhigh2/uiik
|
|
5
|
-
* c) 2021-
|
|
5
|
+
* c) 2021-2025 @holyhigh2 may be freely distributed under the MIT license
|
|
6
6
|
*/
|
|
7
7
|
(function (global, factory) {
|
|
8
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('myfx/
|
|
9
|
-
typeof define === 'function' && define.amd ? define(['exports', 'myfx/
|
|
10
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.uiik = {}, global.
|
|
11
|
-
})(this, (function (exports,
|
|
8
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('myfx/collection'), require('myfx/is'), require('myfx/object'), require('myfx/array'), require('myfx/string'), require('myfx/tree'), require('myfx/utils')) :
|
|
9
|
+
typeof define === 'function' && define.amd ? define(['exports', 'myfx/collection', 'myfx/is', 'myfx/object', 'myfx/array', 'myfx/string', 'myfx/tree', 'myfx/utils'], factory) :
|
|
10
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.uiik = {}, global.collection, global.is, global.object, global.array, global.string, global.tree, global.utils));
|
|
11
|
+
})(this, (function (exports, collection, is, object, array, string, tree, utils) { 'use strict';
|
|
12
12
|
|
|
13
13
|
/******************************************************************************
|
|
14
14
|
Copyright (c) Microsoft Corporation.
|
|
@@ -45,45 +45,47 @@
|
|
|
45
45
|
|
|
46
46
|
const UtMap = new WeakMap();
|
|
47
47
|
class UiiTransform {
|
|
48
|
-
constructor(el) {
|
|
48
|
+
constructor(el, useTransform = true) {
|
|
49
49
|
this.angle = 0;
|
|
50
50
|
this.el = el;
|
|
51
|
+
this.useTransform = useTransform;
|
|
51
52
|
this.normalize(el);
|
|
52
53
|
UtMap.set(el, this);
|
|
53
54
|
}
|
|
54
55
|
normalize(el) {
|
|
55
|
-
let {
|
|
56
|
-
this.
|
|
57
|
-
this.
|
|
56
|
+
let { offx, offy } = normalize(el || this.el, this.useTransform);
|
|
57
|
+
this.offx = offx * -1;
|
|
58
|
+
this.offy = offy * -1;
|
|
58
59
|
return this;
|
|
59
60
|
}
|
|
60
61
|
moveTo(x, y) {
|
|
61
62
|
this.x = x;
|
|
62
63
|
this.y = y;
|
|
63
|
-
moveTo(this.el, this.x, this.y);
|
|
64
|
+
(this.useTransform ? transformMoveTo : moveTo)(this.el, this.x + this.offx, this.y + this.offy);
|
|
64
65
|
}
|
|
65
66
|
moveToX(x) {
|
|
66
67
|
this.x = x;
|
|
67
|
-
moveTo(this.el, this.x
|
|
68
|
+
(this.useTransform ? transformMoveTo : moveTo)(this.el, this.x + this.offx, NaN);
|
|
68
69
|
}
|
|
69
70
|
moveToY(y) {
|
|
70
71
|
this.y = y;
|
|
71
|
-
moveTo(this.el, this.
|
|
72
|
+
(this.useTransform ? transformMoveTo : moveTo)(this.el, NaN, this.y + this.offy);
|
|
72
73
|
}
|
|
73
74
|
rotateTo(deg, cx, cy) {
|
|
74
75
|
this.angle = deg;
|
|
75
76
|
rotateTo(this.el, deg, cx, cy);
|
|
76
77
|
}
|
|
77
78
|
}
|
|
78
|
-
function normalize(el) {
|
|
79
|
+
function normalize(el, useTransform) {
|
|
79
80
|
const style = window.getComputedStyle(el);
|
|
81
|
+
let offx = 0, offy = 0;
|
|
80
82
|
let x = 0, y = 0;
|
|
83
|
+
let mx = 0, my = 0;
|
|
81
84
|
if (el instanceof HTMLElement) {
|
|
82
|
-
x =
|
|
83
|
-
y =
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
el.style.setProperty("margin", "0", "important");
|
|
85
|
+
x = parseFloat(style.left) || 0;
|
|
86
|
+
y = parseFloat(style.top) || 0;
|
|
87
|
+
mx = parseFloat(style.marginLeft) || 0;
|
|
88
|
+
my = parseFloat(style.marginTop) || 0;
|
|
87
89
|
}
|
|
88
90
|
else {
|
|
89
91
|
x =
|
|
@@ -92,24 +94,30 @@
|
|
|
92
94
|
y =
|
|
93
95
|
parseFloat(object.get(el, "y.baseVal.value") || object.get(el, "cy.baseVal.value")) ||
|
|
94
96
|
0;
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
moveTo(el, x, y);
|
|
104
|
-
return { x, y };
|
|
97
|
+
}
|
|
98
|
+
if (useTransform) {
|
|
99
|
+
(offx = x), (offy = y);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
(offx = 0), (offy = 0);
|
|
103
|
+
}
|
|
104
|
+
return { offx: offx + mx, offy: offy + my };
|
|
105
105
|
}
|
|
106
|
-
function wrapper(el) {
|
|
106
|
+
function wrapper(el, useTransform = true) {
|
|
107
107
|
let ut = UtMap.get(el);
|
|
108
108
|
if (ut)
|
|
109
109
|
return ut.normalize(el);
|
|
110
|
-
return new UiiTransform(el);
|
|
110
|
+
return new UiiTransform(el, useTransform);
|
|
111
111
|
}
|
|
112
112
|
function transformMove(transofrmStr, x, y, unit = false) {
|
|
113
|
+
if (!is.isNumber(x) || is.isNaN(x)) {
|
|
114
|
+
return (`translateY(${y}${unit ? "px" : ""}) ` +
|
|
115
|
+
transofrmStr.replace(/translateY\([^)]+?\)/, "").trim());
|
|
116
|
+
}
|
|
117
|
+
if (!is.isNumber(y) || is.isNaN(x)) {
|
|
118
|
+
return (`translateX(${x}${unit ? "px" : ""}) ` +
|
|
119
|
+
transofrmStr.replace(/translateX\([^)]+?\)/, "").trim());
|
|
120
|
+
}
|
|
113
121
|
return (`translate(${x}${unit ? "px" : ""},${y}${unit ? "px" : ""}) ` +
|
|
114
122
|
transofrmStr.replace(/translate\([^)]+?\)/, "").trim());
|
|
115
123
|
}
|
|
@@ -118,6 +126,14 @@
|
|
|
118
126
|
let transformStr = "";
|
|
119
127
|
if (el instanceof SVGGraphicsElement) {
|
|
120
128
|
transformStr = el.getAttribute("transform") || "";
|
|
129
|
+
if (!transformStr) {
|
|
130
|
+
xVal =
|
|
131
|
+
parseFloat(object.get(el, "x.baseVal.value") || object.get(el, "cx.baseVal.value")) ||
|
|
132
|
+
0;
|
|
133
|
+
yVal =
|
|
134
|
+
parseFloat(object.get(el, "y.baseVal.value") || object.get(el, "cy.baseVal.value")) ||
|
|
135
|
+
0;
|
|
136
|
+
}
|
|
121
137
|
}
|
|
122
138
|
else {
|
|
123
139
|
let style = el.style;
|
|
@@ -145,11 +161,26 @@
|
|
|
145
161
|
}
|
|
146
162
|
function moveTo(el, x, y) {
|
|
147
163
|
if (el instanceof SVGGraphicsElement) {
|
|
148
|
-
|
|
164
|
+
if (x)
|
|
165
|
+
el.setAttribute("x", x + "");
|
|
166
|
+
if (y)
|
|
167
|
+
el.setAttribute("y", y + "");
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
let style = el.style;
|
|
171
|
+
if (x)
|
|
172
|
+
style.left = x + "px";
|
|
173
|
+
if (y)
|
|
174
|
+
style.top = y + "px";
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
function transformMoveTo(el, x, y) {
|
|
178
|
+
if (el instanceof SVGGraphicsElement) {
|
|
179
|
+
el.setAttribute("transform", transformMove(el.getAttribute("transform") || "", x || 0, y || 0));
|
|
149
180
|
}
|
|
150
181
|
else {
|
|
151
182
|
let style = el.style;
|
|
152
|
-
style.transform = transformMove(style.transform || "", x, y, true);
|
|
183
|
+
style.transform = transformMove(style.transform || "", x || 0, y || 0, true);
|
|
153
184
|
}
|
|
154
185
|
}
|
|
155
186
|
const EXP_GET_TRANSLATE = /translate\(\s*(?<x>[\d.-]+)\D*,\s*(?<y>[\d.-]+)\D*\)/gim;
|
|
@@ -198,6 +229,7 @@
|
|
|
198
229
|
|
|
199
230
|
const ONE_ANG = Math.PI / 180;
|
|
200
231
|
const ONE_RAD = 180 / Math.PI;
|
|
232
|
+
const THRESHOLD = 3;
|
|
201
233
|
function getBox(child, parent) {
|
|
202
234
|
const rect = child.getBoundingClientRect();
|
|
203
235
|
const rs = { x: 0, y: 0, w: rect.width, h: rect.height };
|
|
@@ -277,33 +309,30 @@
|
|
|
277
309
|
return { x, y };
|
|
278
310
|
}
|
|
279
311
|
function getStyleSize(el, cStyle) {
|
|
312
|
+
if ("getBBox" in el) {
|
|
313
|
+
let { width, height } = el.getBBox();
|
|
314
|
+
return { w: width, h: height };
|
|
315
|
+
}
|
|
280
316
|
if (!cStyle)
|
|
281
317
|
cStyle = window.getComputedStyle(el);
|
|
282
318
|
const w = parseFloat(cStyle.width);
|
|
283
319
|
const h = parseFloat(cStyle.height);
|
|
284
320
|
return { w, h };
|
|
285
321
|
}
|
|
286
|
-
const EXP_MATRIX = /matrix\((?<a>[\d.-]+)\s*,\s*(?<b>[\d.-]+)\s*,\s*(?<c>[\d.-]+)\s*,\s*(?<d>[\d.-]+)\s*,\s*(?<e>[\d.-]+)\s*,\s*(?<f>[\d.-]+)\s*\)/;
|
|
287
322
|
function getMatrixInfo(el, recur = false) {
|
|
288
|
-
const rs =
|
|
323
|
+
const rs = { scale: 1, angle: 0, x: 0, y: 0 };
|
|
324
|
+
let a = 1, b = 0;
|
|
325
|
+
let elCStyle = window.getComputedStyle(el);
|
|
326
|
+
let matrix = new DOMMatrix(elCStyle.transform);
|
|
289
327
|
if (recur) {
|
|
290
328
|
let p = el.parentElement;
|
|
291
|
-
while (p && p.tagName !== "BODY") {
|
|
292
|
-
let
|
|
293
|
-
|
|
329
|
+
while (p && p.tagName !== "BODY" && p.tagName.toLowerCase() !== "svg") {
|
|
330
|
+
let pCStyle = window.getComputedStyle(p);
|
|
331
|
+
const pMatrix = new DOMMatrix(pCStyle.transform);
|
|
332
|
+
matrix = matrix.multiply(pMatrix);
|
|
294
333
|
p = p.parentElement;
|
|
295
334
|
}
|
|
296
335
|
}
|
|
297
|
-
return rs;
|
|
298
|
-
}
|
|
299
|
-
function _getMatrixInfo(el) {
|
|
300
|
-
const rs = { scale: 1, angle: 0, x: 0, y: 0 };
|
|
301
|
-
let a = 1, b = 0;
|
|
302
|
-
let elCStyle;
|
|
303
|
-
if (el instanceof SVGGraphicsElement || el instanceof HTMLElement) {
|
|
304
|
-
elCStyle = window.getComputedStyle(el);
|
|
305
|
-
}
|
|
306
|
-
let matrix = _getMatrix(elCStyle.transform);
|
|
307
336
|
if (matrix) {
|
|
308
337
|
a = matrix.a;
|
|
309
338
|
b = matrix.b;
|
|
@@ -316,30 +345,11 @@
|
|
|
316
345
|
rs.angle = Math.round(Math.atan2(b, a) * (180 / Math.PI));
|
|
317
346
|
return rs;
|
|
318
347
|
}
|
|
319
|
-
function _getMatrix(transform) {
|
|
320
|
-
let matrix = null;
|
|
321
|
-
if (window.WebKitCSSMatrix) {
|
|
322
|
-
matrix = new WebKitCSSMatrix(transform);
|
|
323
|
-
}
|
|
324
|
-
else {
|
|
325
|
-
const matched = transform.match(EXP_MATRIX);
|
|
326
|
-
if (matched && matched.groups) {
|
|
327
|
-
matrix = {
|
|
328
|
-
a: parseFloat(matched.groups.a),
|
|
329
|
-
b: parseFloat(matched.groups.b),
|
|
330
|
-
c: parseFloat(matched.groups.c),
|
|
331
|
-
d: parseFloat(matched.groups.d),
|
|
332
|
-
e: parseFloat(matched.groups.e),
|
|
333
|
-
f: parseFloat(matched.groups.f),
|
|
334
|
-
};
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
return matrix;
|
|
338
|
-
}
|
|
339
348
|
function getPointInContainer(event, el, elRect, elCStyle, matrixInfo) {
|
|
340
349
|
if (!elRect) {
|
|
341
350
|
elRect = el.getBoundingClientRect();
|
|
342
351
|
}
|
|
352
|
+
let rx = elRect.x, ry = elRect.y;
|
|
343
353
|
if (!elCStyle) {
|
|
344
354
|
elCStyle = window.getComputedStyle(el);
|
|
345
355
|
}
|
|
@@ -348,20 +358,20 @@
|
|
|
348
358
|
}
|
|
349
359
|
const scale = matrixInfo.scale;
|
|
350
360
|
let x = event.clientX -
|
|
351
|
-
|
|
361
|
+
rx -
|
|
352
362
|
(parseFloat(elCStyle.borderLeftWidth) || 0) * scale +
|
|
353
363
|
el.scrollLeft * scale;
|
|
354
364
|
let y = event.clientY -
|
|
355
|
-
|
|
365
|
+
ry -
|
|
356
366
|
(parseFloat(elCStyle.borderTopWidth) || 0) * scale +
|
|
357
367
|
el.scrollTop * scale;
|
|
358
|
-
return { x: x / scale, y: y / scale };
|
|
368
|
+
return { x: x / scale, y: y / scale, scale };
|
|
359
369
|
}
|
|
360
|
-
function getRectInContainer(el, container) {
|
|
370
|
+
function getRectInContainer(el, container, matrixInfo) {
|
|
361
371
|
const elRect = el.getBoundingClientRect();
|
|
362
372
|
const containerRect = container.getBoundingClientRect();
|
|
363
373
|
const elCStyle = window.getComputedStyle(container);
|
|
364
|
-
|
|
374
|
+
matrixInfo = matrixInfo || getMatrixInfo(container, true);
|
|
365
375
|
const scale = matrixInfo.scale;
|
|
366
376
|
let x = elRect.x -
|
|
367
377
|
containerRect.x -
|
|
@@ -378,6 +388,12 @@
|
|
|
378
388
|
h: elRect.height / scale,
|
|
379
389
|
};
|
|
380
390
|
}
|
|
391
|
+
function getRectCenter(el, matrixInfo) {
|
|
392
|
+
const panelRect = getRectInContainer(el, el.parentElement, matrixInfo);
|
|
393
|
+
let x = Math.round(panelRect.x + panelRect.w / 2);
|
|
394
|
+
let y = Math.round(panelRect.y + panelRect.h / 2);
|
|
395
|
+
return { x, y };
|
|
396
|
+
}
|
|
381
397
|
function getCenterXy(el, ox, oy) {
|
|
382
398
|
const cStyle = window.getComputedStyle(el);
|
|
383
399
|
const center = cStyle.transformOrigin;
|
|
@@ -397,7 +413,19 @@
|
|
|
397
413
|
return { sx: startX, sy: startY, x: startX + ox, y: startY + oy, ox, oy };
|
|
398
414
|
}
|
|
399
415
|
function getCenterXySVG(el, ox, oy) {
|
|
400
|
-
|
|
416
|
+
let elRect = el.getBoundingClientRect();
|
|
417
|
+
let svgRect = el.ownerSVGElement.getBoundingClientRect();
|
|
418
|
+
let x = elRect.x - svgRect.x;
|
|
419
|
+
let y = elRect.y - svgRect.y;
|
|
420
|
+
const shadowDom = el.cloneNode();
|
|
421
|
+
rotateTo(shadowDom, 0);
|
|
422
|
+
const parentEl = el.parentElement;
|
|
423
|
+
if (parentEl) {
|
|
424
|
+
parentEl.appendChild(shadowDom);
|
|
425
|
+
const offsetXY = getRectInContainer(shadowDom, parentEl);
|
|
426
|
+
(offsetXY.x), (offsetXY.y);
|
|
427
|
+
parentEl.removeChild(shadowDom);
|
|
428
|
+
}
|
|
401
429
|
return { sx: x, sy: y, x: x + ox, y: y + oy, ox, oy };
|
|
402
430
|
}
|
|
403
431
|
function getVertex(el, ox, oy) {
|
|
@@ -405,7 +433,9 @@
|
|
|
405
433
|
const w = parseFloat(cStyle.width);
|
|
406
434
|
const h = parseFloat(cStyle.height);
|
|
407
435
|
const { originX, originY } = parseOxy(ox, oy, w, h);
|
|
408
|
-
const { x, y, sx, sy } = el instanceof SVGGraphicsElement
|
|
436
|
+
const { x, y, sx, sy } = el instanceof SVGGraphicsElement
|
|
437
|
+
? getCenterXySVG(el, originX, originY)
|
|
438
|
+
: getCenterXy(el);
|
|
409
439
|
const { angle } = getMatrixInfo(el);
|
|
410
440
|
return calcVertex(w, h, x, y, sx, sy, angle * ONE_ANG);
|
|
411
441
|
}
|
|
@@ -417,28 +447,50 @@
|
|
|
417
447
|
{ x: w, y: h },
|
|
418
448
|
];
|
|
419
449
|
return collection.map(originVertex, ({ x, y }) => {
|
|
420
|
-
const nx = (x - cx + sx) * Math.cos(radian) -
|
|
421
|
-
|
|
422
|
-
const ny = (x - cx + sx) * Math.sin(radian) +
|
|
423
|
-
(y - cy + sy) * Math.cos(radian);
|
|
450
|
+
const nx = (x - cx + sx) * Math.cos(radian) - (y - cy + sy) * Math.sin(radian);
|
|
451
|
+
const ny = (x - cx + sx) * Math.sin(radian) + (y - cy + sy) * Math.cos(radian);
|
|
424
452
|
return { x: cx + nx, y: cy + ny };
|
|
425
453
|
});
|
|
426
454
|
}
|
|
427
|
-
function parseOxy(ox, oy, w, h) {
|
|
455
|
+
function parseOxy(ox, oy, w, h, el) {
|
|
428
456
|
let originX = 0, originY = 0;
|
|
457
|
+
let transformOrigin;
|
|
429
458
|
if (is.isString(ox)) {
|
|
430
459
|
originX = (parseFloat(ox) / 100) * w;
|
|
431
460
|
}
|
|
432
461
|
else if (is.isNumber(ox)) {
|
|
433
462
|
originX = ox;
|
|
434
463
|
}
|
|
464
|
+
else if (el) {
|
|
465
|
+
if (!transformOrigin)
|
|
466
|
+
transformOrigin = window.getComputedStyle(el).transformOrigin;
|
|
467
|
+
const centerPair = transformOrigin.split(" ");
|
|
468
|
+
originX = parseFloat(centerPair[0]);
|
|
469
|
+
}
|
|
435
470
|
if (is.isString(oy)) {
|
|
436
471
|
originY = (parseFloat(oy) / 100) * h;
|
|
437
472
|
}
|
|
438
473
|
else if (is.isNumber(oy)) {
|
|
439
474
|
originY = oy;
|
|
440
475
|
}
|
|
476
|
+
else if (el) {
|
|
477
|
+
if (!transformOrigin)
|
|
478
|
+
transformOrigin = window.getComputedStyle(el).transformOrigin;
|
|
479
|
+
const centerPair = transformOrigin.split(" ");
|
|
480
|
+
originY = parseFloat(centerPair[1]);
|
|
481
|
+
}
|
|
441
482
|
return { originX, originY };
|
|
483
|
+
}
|
|
484
|
+
function normalizeVector(x, y) {
|
|
485
|
+
let len = Math.sqrt(x * x + y * y);
|
|
486
|
+
return { x: x / len, y: y / len };
|
|
487
|
+
}
|
|
488
|
+
function isVisible(el) {
|
|
489
|
+
let rect = el.getBoundingClientRect();
|
|
490
|
+
if (rect.width === 0 || rect.height === 0) {
|
|
491
|
+
return false;
|
|
492
|
+
}
|
|
493
|
+
return true;
|
|
442
494
|
}
|
|
443
495
|
|
|
444
496
|
var _Uii_listeners;
|
|
@@ -535,9 +587,10 @@
|
|
|
535
587
|
e.preventDefault();
|
|
536
588
|
return false;
|
|
537
589
|
}
|
|
590
|
+
let matrixInfo = getMatrixInfo(el, true);
|
|
538
591
|
const pointerMove = (ev) => {
|
|
539
|
-
const offX = ev.clientX - originPosX;
|
|
540
|
-
const offY = ev.clientY - originPosY;
|
|
592
|
+
const offX = (ev.clientX - originPosX) / matrixInfo.scale;
|
|
593
|
+
const offY = (ev.clientY - originPosY) / matrixInfo.scale;
|
|
541
594
|
if (!dragging) {
|
|
542
595
|
if (Math.abs(offX) > threshold || Math.abs(offY) > threshold) {
|
|
543
596
|
dragging = true;
|
|
@@ -620,7 +673,6 @@
|
|
|
620
673
|
_Uii_listeners = new WeakMap();
|
|
621
674
|
|
|
622
675
|
var _Splittable_instances, _Splittable_checkDirection, _Splittable_bindHandle;
|
|
623
|
-
const THRESHOLD$4 = 1;
|
|
624
676
|
const CLASS_SPLITTABLE = "uii-splittable";
|
|
625
677
|
const CLASS_SPLITTABLE_HANDLE = "uii-splittable-handle";
|
|
626
678
|
const CLASS_SPLITTABLE_HANDLE_GHOST = "uii-splittable-handle-ghost";
|
|
@@ -646,7 +698,7 @@
|
|
|
646
698
|
_Splittable_instances.add(this);
|
|
647
699
|
collection.each(this.ele, con => {
|
|
648
700
|
const pos = window.getComputedStyle(con).position;
|
|
649
|
-
if (pos === "static") {
|
|
701
|
+
if (pos === "static" || is.isBlank(pos)) {
|
|
650
702
|
con.style.position = "relative";
|
|
651
703
|
}
|
|
652
704
|
con.classList.toggle(CLASS_SPLITTABLE, true);
|
|
@@ -689,8 +741,17 @@
|
|
|
689
741
|
dom2 = h.nextElementSibling;
|
|
690
742
|
}
|
|
691
743
|
else {
|
|
692
|
-
|
|
693
|
-
|
|
744
|
+
let domCon = getRootEl(h, con);
|
|
745
|
+
let domL = domCon.previousElementSibling;
|
|
746
|
+
let domR = domCon.nextElementSibling;
|
|
747
|
+
if (domL && !domL.querySelector(this.opts.handle)) {
|
|
748
|
+
dom1 = domL;
|
|
749
|
+
dom2 = domCon;
|
|
750
|
+
}
|
|
751
|
+
else {
|
|
752
|
+
dom1 = domCon;
|
|
753
|
+
dom2 = domR;
|
|
754
|
+
}
|
|
694
755
|
}
|
|
695
756
|
__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);
|
|
696
757
|
});
|
|
@@ -710,7 +771,7 @@
|
|
|
710
771
|
});
|
|
711
772
|
return dir;
|
|
712
773
|
}, _Splittable_bindHandle = function _Splittable_bindHandle(minSizeAry, stickyAry, opts, dir, dom1, dom2, handle) {
|
|
713
|
-
var _a;
|
|
774
|
+
var _a, _b;
|
|
714
775
|
const handleSize = opts.handleSize;
|
|
715
776
|
if (!handle) {
|
|
716
777
|
handle = document.createElement('div');
|
|
@@ -718,6 +779,12 @@
|
|
|
718
779
|
if (!opts.inside) {
|
|
719
780
|
initPos = (dir === 'v' ? dom2.offsetTop : dom2.offsetLeft);
|
|
720
781
|
}
|
|
782
|
+
if (!isVisible(dom2)) {
|
|
783
|
+
(_a = dom2.parentElement) === null || _a === void 0 ? void 0 : _a.addEventListener('mouseenter', () => {
|
|
784
|
+
initPos = (dir === 'v' ? dom2.offsetTop : dom2.offsetLeft);
|
|
785
|
+
handle.style.left = initPos - handleSize / 2 + 'px';
|
|
786
|
+
}, { once: true });
|
|
787
|
+
}
|
|
721
788
|
const sensorHCss = `width:${handleSize}px;height:100%;top:0;left:${initPos - handleSize / 2}px;z-index:9;`;
|
|
722
789
|
const sensorVCss = `height:${handleSize}px;width:100%;left:0;top:${initPos - handleSize / 2}px;z-index:9;`;
|
|
723
790
|
handle.style.cssText =
|
|
@@ -725,7 +792,7 @@
|
|
|
725
792
|
if (opts.inside) {
|
|
726
793
|
dom2.appendChild(handle);
|
|
727
794
|
}
|
|
728
|
-
(
|
|
795
|
+
(_b = dom2.parentNode) === null || _b === void 0 ? void 0 : _b.insertBefore(handle, dom2);
|
|
729
796
|
}
|
|
730
797
|
handle.style.cursor = dir === 'v' ? 's-resize' : 'e-resize';
|
|
731
798
|
handle.dataset.cursor = handle.style.cursor;
|
|
@@ -764,6 +831,7 @@
|
|
|
764
831
|
const dom2Style = dom2.style;
|
|
765
832
|
const ghost = opts.ghost;
|
|
766
833
|
const ghostClass = opts.ghostClass;
|
|
834
|
+
const ghostTo = opts.ghostTo;
|
|
767
835
|
let ghostNode = null;
|
|
768
836
|
let sticked = 'none';
|
|
769
837
|
if (originSize < minSize1 / 2) {
|
|
@@ -787,7 +855,8 @@
|
|
|
787
855
|
ghostNode.className =
|
|
788
856
|
ghostNode.className.replace(ghostClass, '') + ' ' + ghostClass;
|
|
789
857
|
}
|
|
790
|
-
|
|
858
|
+
let ghostParent = ghostTo ? (is.isString(ghostTo) ? document.querySelector(ghostTo) : ghostTo) : currentTarget.parentNode;
|
|
859
|
+
ghostParent.appendChild(ghostNode);
|
|
791
860
|
onClone && onClone({ clone: ghostNode }, ev);
|
|
792
861
|
}
|
|
793
862
|
}
|
|
@@ -829,10 +898,10 @@
|
|
|
829
898
|
anotherSize = blockSize - ds1 - splitterSize;
|
|
830
899
|
if (ghostNode) {
|
|
831
900
|
if (dir === 'v') {
|
|
832
|
-
ghostNode.style.top = startPos + ds1 -
|
|
901
|
+
ghostNode.style.top = startPos + ds1 - splitterSize / 2 + 'px';
|
|
833
902
|
}
|
|
834
903
|
else {
|
|
835
|
-
ghostNode.style.left = startPos + ds1 -
|
|
904
|
+
ghostNode.style.left = startPos + ds1 - splitterSize / 2 + 'px';
|
|
836
905
|
}
|
|
837
906
|
}
|
|
838
907
|
else {
|
|
@@ -847,16 +916,16 @@
|
|
|
847
916
|
onSticky && onSticky({ size1: ds1, size2: anotherSize, position: sticked }, ev);
|
|
848
917
|
}
|
|
849
918
|
if (dir === 'v') {
|
|
850
|
-
currentStyle.top = dom2.offsetTop -
|
|
919
|
+
currentStyle.top = dom2.offsetTop - splitterSize / 2 + 'px';
|
|
851
920
|
}
|
|
852
921
|
else {
|
|
853
|
-
currentStyle.left = dom2.offsetLeft -
|
|
922
|
+
currentStyle.left = dom2.offsetLeft - splitterSize / 2 + 'px';
|
|
854
923
|
}
|
|
855
924
|
}
|
|
856
925
|
onSplit && onSplit({ size1: ds1, size2: anotherSize }, ev);
|
|
857
926
|
});
|
|
858
927
|
onPointerEnd((args) => {
|
|
859
|
-
var _a
|
|
928
|
+
var _a;
|
|
860
929
|
const { ev, currentStyle } = args;
|
|
861
930
|
switch (dir) {
|
|
862
931
|
case 'v':
|
|
@@ -878,17 +947,17 @@
|
|
|
878
947
|
dom2Style.setProperty(updateProp, anotherSize + 'px', 'important');
|
|
879
948
|
}
|
|
880
949
|
if (dir === 'v') {
|
|
881
|
-
currentStyle.top = startPos + ds1 -
|
|
950
|
+
currentStyle.top = startPos + ds1 - splitterSize / 2 + 'px';
|
|
882
951
|
}
|
|
883
952
|
else {
|
|
884
|
-
currentStyle.left = startPos + ds1 -
|
|
953
|
+
currentStyle.left = startPos + ds1 - splitterSize / 2 + 'px';
|
|
885
954
|
}
|
|
886
|
-
(
|
|
955
|
+
(_a = ghostNode.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(ghostNode);
|
|
887
956
|
}
|
|
888
957
|
onEnd && onEnd({ size1: originSize, size2: originSize1 }, ev);
|
|
889
958
|
});
|
|
890
959
|
}, {
|
|
891
|
-
threshold: THRESHOLD
|
|
960
|
+
threshold: THRESHOLD,
|
|
892
961
|
lockPage: true
|
|
893
962
|
});
|
|
894
963
|
};
|
|
@@ -896,7 +965,6 @@
|
|
|
896
965
|
return new Splittable(container, opts);
|
|
897
966
|
}
|
|
898
967
|
|
|
899
|
-
const THRESHOLD$3 = 2;
|
|
900
968
|
const CLASS_RESIZABLE_HANDLE = "uii-resizable-handle";
|
|
901
969
|
const CLASS_RESIZABLE_HANDLE_DIR = "uii-resizable-handle-";
|
|
902
970
|
const CLASS_RESIZABLE_HANDLE_ACTIVE = "uii-resizable-handle-active";
|
|
@@ -932,14 +1000,12 @@
|
|
|
932
1000
|
const onPointerDown = opts.onPointerDown;
|
|
933
1001
|
if (onPointerDown && onPointerDown(ev) === false)
|
|
934
1002
|
return true;
|
|
935
|
-
let container = panel
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
let setOrigin = !(panel instanceof SVGGraphicsElement);
|
|
939
|
-
let matrixInfo = getMatrixInfo(panel);
|
|
940
|
-
const offset = getRectInContainer(panel, container);
|
|
1003
|
+
let container = panel.parentElement;
|
|
1004
|
+
let matrixInfo = getMatrixInfo(panel, true);
|
|
1005
|
+
const offset = getRectInContainer(panel, container, matrixInfo);
|
|
941
1006
|
const offsetParentRect = container.getBoundingClientRect();
|
|
942
1007
|
const offsetParentCStyle = window.getComputedStyle(container);
|
|
1008
|
+
let setOrigin = !(panel instanceof SVGGraphicsElement) && matrixInfo.angle != 0;
|
|
943
1009
|
const { w, h } = getStyleSize(panel);
|
|
944
1010
|
const originW = w;
|
|
945
1011
|
const originH = h;
|
|
@@ -983,10 +1049,10 @@
|
|
|
983
1049
|
toTransformOrigin = "0 0";
|
|
984
1050
|
break;
|
|
985
1051
|
}
|
|
986
|
-
let minWidth;
|
|
987
|
-
let minHeight;
|
|
988
|
-
let maxWidth;
|
|
989
|
-
let maxHeight;
|
|
1052
|
+
let minWidth = 1;
|
|
1053
|
+
let minHeight = 1;
|
|
1054
|
+
let maxWidth = 9999;
|
|
1055
|
+
let maxHeight = 9999;
|
|
990
1056
|
if (is.isArray(opts.minSize)) {
|
|
991
1057
|
minWidth = opts.minSize[0];
|
|
992
1058
|
minHeight = opts.minSize[1];
|
|
@@ -1018,9 +1084,8 @@
|
|
|
1018
1084
|
let currentVertex;
|
|
1019
1085
|
let refPoint;
|
|
1020
1086
|
let k1;
|
|
1021
|
-
let startOx = 0;
|
|
1022
|
-
let startOy = 0;
|
|
1023
1087
|
let sX = 0, sY = 0;
|
|
1088
|
+
let startPointXy;
|
|
1024
1089
|
onPointerStart(function (args) {
|
|
1025
1090
|
var _a;
|
|
1026
1091
|
const { ev } = args;
|
|
@@ -1054,16 +1119,17 @@
|
|
|
1054
1119
|
const w = parseFloat(cStyle.width);
|
|
1055
1120
|
const h = parseFloat(cStyle.height);
|
|
1056
1121
|
const oxy = parseOxy(opts.ox, opts.oy, w, h);
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
const
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
let
|
|
1122
|
+
oxy.originX;
|
|
1123
|
+
oxy.originY;
|
|
1124
|
+
const panelRect = getRectInContainer(panel, panel.parentElement, matrixInfo);
|
|
1125
|
+
let centerX = Math.round(panelRect.x + panelRect.w / 2);
|
|
1126
|
+
let centerY = Math.round(panelRect.y + panelRect.h / 2);
|
|
1127
|
+
let sx = Math.round(centerX - originW / 2);
|
|
1128
|
+
let sy = Math.round(centerY - originH / 2);
|
|
1129
|
+
transform.x = sx;
|
|
1130
|
+
transform.y = sy;
|
|
1063
1131
|
const deg = matrixInfo.angle * ONE_ANG;
|
|
1064
|
-
currentVertex =
|
|
1065
|
-
vertexBeforeTransform =
|
|
1066
|
-
calcVertex(originW, originH, centerX, centerY, sx, sy, deg);
|
|
1132
|
+
currentVertex = vertexBeforeTransform = calcVertex(originW, originH, centerX, centerY, sx, sy, deg);
|
|
1067
1133
|
switch (dir) {
|
|
1068
1134
|
case "s":
|
|
1069
1135
|
case "e":
|
|
@@ -1092,26 +1158,27 @@
|
|
|
1092
1158
|
style.transformOrigin = toTransformOrigin;
|
|
1093
1159
|
}
|
|
1094
1160
|
else {
|
|
1095
|
-
style.transformOrigin = `${centerX -
|
|
1161
|
+
style.transformOrigin = `${centerX - sx}px ${centerY - sy}px`;
|
|
1096
1162
|
}
|
|
1097
1163
|
}
|
|
1098
1164
|
if (panel instanceof SVGGraphicsElement) {
|
|
1099
1165
|
sX = matrixInfo.x - currentVertex[0].x;
|
|
1100
1166
|
sY = matrixInfo.y - currentVertex[0].y;
|
|
1101
1167
|
}
|
|
1102
|
-
|
|
1168
|
+
startPointXy = getPointInContainer(ev, container, offsetParentRect, offsetParentCStyle, matrixInfo);
|
|
1169
|
+
onStart &&
|
|
1170
|
+
onStart.call(uiik, { w: originW, h: originH, transform }, ev);
|
|
1103
1171
|
});
|
|
1104
1172
|
onPointerMove((args) => {
|
|
1105
|
-
const { ev } = args;
|
|
1106
|
-
|
|
1107
|
-
let
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
let hyLen = Math.sqrt((newX -
|
|
1112
|
-
(newY - refPoint.y) * (newY - refPoint.y));
|
|
1173
|
+
const { ev, offX, offY } = args;
|
|
1174
|
+
let newX = startPointXy.x + offX;
|
|
1175
|
+
let newY = startPointXy.y + offY;
|
|
1176
|
+
const rpx = refPoint.x;
|
|
1177
|
+
const rpy = refPoint.y;
|
|
1178
|
+
let angle = Math.atan2(newY - rpy, newX - rpx) * ONE_RAD - matrixInfo.angle;
|
|
1179
|
+
let hyLen = Math.sqrt((newX - rpx) * (newX - rpx) + (newY - rpy) * (newY - rpy));
|
|
1113
1180
|
let pl1 = Math.abs(k1 === Infinity
|
|
1114
|
-
? newY - refPoint.y
|
|
1181
|
+
? newY - refPoint.y / matrixInfo.scale
|
|
1115
1182
|
: hyLen * Math.cos(angle * ONE_ANG));
|
|
1116
1183
|
let pl2 = Math.sqrt(hyLen * hyLen - pl1 * pl1);
|
|
1117
1184
|
let w = originW;
|
|
@@ -1119,6 +1186,18 @@
|
|
|
1119
1186
|
let y = originY;
|
|
1120
1187
|
let x = originX;
|
|
1121
1188
|
let angl = 0;
|
|
1189
|
+
switch (dir) {
|
|
1190
|
+
case "w":
|
|
1191
|
+
case "sw":
|
|
1192
|
+
angl =
|
|
1193
|
+
Math.atan2(currentVertex[0].y - currentVertex[1].y, currentVertex[0].x - currentVertex[1].x) * ONE_RAD;
|
|
1194
|
+
break;
|
|
1195
|
+
case "n":
|
|
1196
|
+
case "ne":
|
|
1197
|
+
case "nw":
|
|
1198
|
+
angl =
|
|
1199
|
+
Math.atan2(currentVertex[0].y - currentVertex[2].y, currentVertex[0].x - currentVertex[2].x) * ONE_RAD;
|
|
1200
|
+
}
|
|
1122
1201
|
switch (dir) {
|
|
1123
1202
|
case "s":
|
|
1124
1203
|
h = pl2;
|
|
@@ -1126,17 +1205,63 @@
|
|
|
1126
1205
|
case "e":
|
|
1127
1206
|
w = pl1;
|
|
1128
1207
|
break;
|
|
1208
|
+
case "n":
|
|
1209
|
+
h = pl2;
|
|
1210
|
+
if (angl === 90) {
|
|
1211
|
+
h = newY - currentVertex[2].y;
|
|
1212
|
+
}
|
|
1213
|
+
break;
|
|
1214
|
+
case "w":
|
|
1215
|
+
w = pl1;
|
|
1216
|
+
if (angl === 0) {
|
|
1217
|
+
w = newX - currentVertex[1].x;
|
|
1218
|
+
}
|
|
1219
|
+
break;
|
|
1220
|
+
case "nw":
|
|
1221
|
+
w = pl1;
|
|
1222
|
+
h = pl2;
|
|
1223
|
+
if (matrixInfo.angle === 180) {
|
|
1224
|
+
w = newX - currentVertex[3].x;
|
|
1225
|
+
h = newY - currentVertex[3].y;
|
|
1226
|
+
}
|
|
1227
|
+
break;
|
|
1129
1228
|
case "se":
|
|
1229
|
+
case "sw":
|
|
1230
|
+
case "ne":
|
|
1130
1231
|
w = pl1;
|
|
1131
1232
|
h = pl2;
|
|
1132
1233
|
break;
|
|
1234
|
+
}
|
|
1235
|
+
if (minHeight && h < minHeight)
|
|
1236
|
+
h = minHeight;
|
|
1237
|
+
if (maxHeight && h > maxHeight)
|
|
1238
|
+
h = maxHeight;
|
|
1239
|
+
if (minWidth && w < minWidth) {
|
|
1240
|
+
w = minWidth;
|
|
1241
|
+
}
|
|
1242
|
+
if (maxWidth && w > maxWidth)
|
|
1243
|
+
w = maxWidth;
|
|
1244
|
+
let hLine, wLine;
|
|
1245
|
+
switch (dir) {
|
|
1246
|
+
case "s":
|
|
1247
|
+
hLine = { p1: currentVertex[1], p2: currentVertex[0] };
|
|
1248
|
+
h = limitWH(newX, newY, hLine, h, minHeight);
|
|
1249
|
+
break;
|
|
1250
|
+
case "e":
|
|
1251
|
+
wLine = { p1: currentVertex[0], p2: currentVertex[2] };
|
|
1252
|
+
w = limitWH(newX, newY, wLine, w, minWidth);
|
|
1253
|
+
break;
|
|
1254
|
+
case "se":
|
|
1255
|
+
wLine = { p1: currentVertex[0], p2: currentVertex[2] };
|
|
1256
|
+
hLine = { p1: currentVertex[1], p2: currentVertex[0] };
|
|
1257
|
+
w = limitWH(newX, newY, wLine, w, minWidth);
|
|
1258
|
+
h = limitWH(newX, newY, hLine, h, minHeight);
|
|
1259
|
+
break;
|
|
1133
1260
|
case "n":
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
Math.atan2(currentVertex[0].y - currentVertex[2].y, currentVertex[0].x - currentVertex[2].x) * ONE_RAD;
|
|
1261
|
+
hLine = { p1: currentVertex[2], p2: currentVertex[3] };
|
|
1262
|
+
h = limitWH(newX, newY, hLine, h, minHeight);
|
|
1137
1263
|
let plh;
|
|
1138
1264
|
if (angl === 90) {
|
|
1139
|
-
h = newY - currentVertex[2].y;
|
|
1140
1265
|
x = currentVertex[2].x;
|
|
1141
1266
|
y = newY;
|
|
1142
1267
|
}
|
|
@@ -1152,12 +1277,10 @@
|
|
|
1152
1277
|
}
|
|
1153
1278
|
break;
|
|
1154
1279
|
case "w":
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
Math.atan2(currentVertex[0].y - currentVertex[1].y, currentVertex[0].x - currentVertex[1].x) * ONE_RAD;
|
|
1280
|
+
wLine = { p1: currentVertex[3], p2: currentVertex[1] };
|
|
1281
|
+
w = limitWH(newX, newY, wLine, w, minWidth);
|
|
1158
1282
|
let plw;
|
|
1159
1283
|
if (angl === 0) {
|
|
1160
|
-
w = newX - currentVertex[1].x;
|
|
1161
1284
|
x = newX;
|
|
1162
1285
|
y = currentVertex[1].y;
|
|
1163
1286
|
}
|
|
@@ -1173,20 +1296,59 @@
|
|
|
1173
1296
|
}
|
|
1174
1297
|
break;
|
|
1175
1298
|
case "nw":
|
|
1176
|
-
|
|
1177
|
-
|
|
1299
|
+
wLine = { p1: currentVertex[3], p2: currentVertex[1] };
|
|
1300
|
+
hLine = { p1: currentVertex[2], p2: currentVertex[3] };
|
|
1301
|
+
w = limitWH(newX, newY, wLine, w, minWidth);
|
|
1302
|
+
h = limitWH(newX, newY, hLine, h, minHeight);
|
|
1178
1303
|
x = newX;
|
|
1179
1304
|
y = newY;
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1305
|
+
let cv2x = currentVertex[2].x;
|
|
1306
|
+
let cv2y = currentVertex[2].y;
|
|
1307
|
+
let cv1x = currentVertex[1].x;
|
|
1308
|
+
let cv1y = currentVertex[1].y;
|
|
1309
|
+
let v32n = normalizeVector(cv2x - currentVertex[3].x, cv2y - currentVertex[3].y);
|
|
1310
|
+
v32n.x *= minWidth;
|
|
1311
|
+
v32n.y *= minWidth;
|
|
1312
|
+
let v10n = normalizeVector(currentVertex[0].x - cv1x, currentVertex[0].y - cv1y);
|
|
1313
|
+
v10n.x *= minWidth;
|
|
1314
|
+
v10n.y *= minWidth;
|
|
1315
|
+
let wp1 = { x: wLine.p1.x + v32n.x, y: wLine.p1.y + v32n.y };
|
|
1316
|
+
let wp2 = { x: wLine.p2.x + v10n.x, y: wLine.p2.y + v10n.y };
|
|
1317
|
+
let invalid = (wp2.x - wp1.x) * (newY - wp1.y) -
|
|
1318
|
+
(wp2.y - wp1.y) * (newX - wp1.x) >
|
|
1319
|
+
0;
|
|
1320
|
+
if (invalid) {
|
|
1321
|
+
let v20n = normalizeVector(currentVertex[0].x - cv2x, currentVertex[0].y - cv2y);
|
|
1322
|
+
v20n.x *= h;
|
|
1323
|
+
v20n.y *= h;
|
|
1324
|
+
x = wp1.x + v20n.x;
|
|
1325
|
+
y = wp1.y + v20n.y;
|
|
1326
|
+
}
|
|
1327
|
+
let v31n = normalizeVector(cv1x - currentVertex[3].x, cv1y - currentVertex[3].y);
|
|
1328
|
+
v31n.x *= minHeight;
|
|
1329
|
+
v31n.y *= minHeight;
|
|
1330
|
+
let v20n = normalizeVector(currentVertex[0].x - cv2x, currentVertex[0].y - cv2y);
|
|
1331
|
+
v20n.x *= minHeight;
|
|
1332
|
+
v20n.y *= minHeight;
|
|
1333
|
+
let hp1 = { x: hLine.p1.x + v31n.x, y: hLine.p1.y + v31n.y };
|
|
1334
|
+
let hp2 = { x: hLine.p2.x + v20n.x, y: hLine.p2.y + v20n.y };
|
|
1335
|
+
invalid =
|
|
1336
|
+
(hp2.x - hp1.x) * (newY - hp1.y) -
|
|
1337
|
+
(hp2.y - hp1.y) * (newX - hp1.x) >
|
|
1338
|
+
0;
|
|
1339
|
+
if (invalid) {
|
|
1340
|
+
let v10n = normalizeVector(currentVertex[0].x - cv1x, currentVertex[0].y - cv1y);
|
|
1341
|
+
v10n.x *= w;
|
|
1342
|
+
v10n.y *= w;
|
|
1343
|
+
x = hp2.x + v10n.x;
|
|
1344
|
+
y = hp2.y + v10n.y;
|
|
1183
1345
|
}
|
|
1184
1346
|
break;
|
|
1185
1347
|
case "sw":
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1348
|
+
wLine = { p1: currentVertex[3], p2: currentVertex[1] };
|
|
1349
|
+
hLine = { p1: currentVertex[1], p2: currentVertex[0] };
|
|
1350
|
+
w = limitWH(newX, newY, wLine, w, minWidth);
|
|
1351
|
+
h = limitWH(newX, newY, hLine, h, minHeight);
|
|
1190
1352
|
let plw1;
|
|
1191
1353
|
if (angl === 0) {
|
|
1192
1354
|
x = newX;
|
|
@@ -1204,10 +1366,10 @@
|
|
|
1204
1366
|
}
|
|
1205
1367
|
break;
|
|
1206
1368
|
case "ne":
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1369
|
+
wLine = { p1: currentVertex[0], p2: currentVertex[2] };
|
|
1370
|
+
hLine = { p1: currentVertex[2], p2: currentVertex[3] };
|
|
1371
|
+
w = limitWH(newX, newY, wLine, w, minWidth);
|
|
1372
|
+
h = limitWH(newX, newY, hLine, h, minHeight);
|
|
1211
1373
|
let plne;
|
|
1212
1374
|
if (angl === 0) {
|
|
1213
1375
|
x = newX;
|
|
@@ -1225,18 +1387,6 @@
|
|
|
1225
1387
|
}
|
|
1226
1388
|
break;
|
|
1227
1389
|
}
|
|
1228
|
-
if (changeW) {
|
|
1229
|
-
if (minWidth && w < minWidth)
|
|
1230
|
-
w = minWidth;
|
|
1231
|
-
if (maxWidth && w > maxWidth)
|
|
1232
|
-
w = maxWidth;
|
|
1233
|
-
}
|
|
1234
|
-
if (changeH) {
|
|
1235
|
-
if (minHeight && h < minHeight)
|
|
1236
|
-
h = minHeight;
|
|
1237
|
-
if (maxHeight && h > maxHeight)
|
|
1238
|
-
h = maxHeight;
|
|
1239
|
-
}
|
|
1240
1390
|
if (aspectRatio) {
|
|
1241
1391
|
if (changeW) {
|
|
1242
1392
|
style.width = w + "px";
|
|
@@ -1261,19 +1411,22 @@
|
|
|
1261
1411
|
}
|
|
1262
1412
|
}
|
|
1263
1413
|
if (changeY) {
|
|
1264
|
-
transform.
|
|
1414
|
+
transform.moveTo(x, y + sY);
|
|
1265
1415
|
}
|
|
1266
1416
|
if (changeX) {
|
|
1267
|
-
transform.
|
|
1417
|
+
transform.moveTo(x + sX, y);
|
|
1268
1418
|
}
|
|
1269
1419
|
lastX = x;
|
|
1270
1420
|
lastY = y;
|
|
1271
1421
|
currentW = w;
|
|
1272
1422
|
currentH = h;
|
|
1273
1423
|
if (onResize && onResize.call) {
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1424
|
+
onResize.call;
|
|
1425
|
+
const panelRect = getRectInContainer(panel, panel.parentElement, matrixInfo);
|
|
1426
|
+
let centerX = Math.round(panelRect.x + panelRect.w / 2);
|
|
1427
|
+
let centerY = Math.round(panelRect.y + panelRect.h / 2);
|
|
1428
|
+
let sx = Math.round(centerX - originW / 2);
|
|
1429
|
+
let sy = Math.round(centerY - originH / 2);
|
|
1277
1430
|
onResize.call(uiik, {
|
|
1278
1431
|
w,
|
|
1279
1432
|
h,
|
|
@@ -1285,7 +1438,7 @@
|
|
|
1285
1438
|
sx: sx,
|
|
1286
1439
|
sy: sy,
|
|
1287
1440
|
deg: matrixInfo.angle,
|
|
1288
|
-
transform
|
|
1441
|
+
transform,
|
|
1289
1442
|
}, ev);
|
|
1290
1443
|
}
|
|
1291
1444
|
});
|
|
@@ -1300,37 +1453,31 @@
|
|
|
1300
1453
|
moveTo(panel, lastX / matrixInfo.scale, lastY / matrixInfo.scale);
|
|
1301
1454
|
resize(transform, panelStyle, parseFloat(ghostNode.style.width), parseFloat(ghostNode.style.height));
|
|
1302
1455
|
}
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
let
|
|
1456
|
+
if (setOrigin)
|
|
1457
|
+
panel.style.transformOrigin = originalTransformOrigin;
|
|
1458
|
+
let { x: centerX, y: centerY } = getRectCenter(panel, matrixInfo);
|
|
1459
|
+
let sx = Math.round(centerX - currentW / 2);
|
|
1460
|
+
let sy = Math.round(centerY - currentH / 2);
|
|
1308
1461
|
const deg = matrixInfo.angle * ONE_ANG;
|
|
1309
1462
|
const currentVertex = calcVertex(currentW, currentH, centerX, centerY, sx, sy, deg);
|
|
1310
|
-
if (
|
|
1311
|
-
if (
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
if (changeX || changeY) {
|
|
1321
|
-
transform.moveTo(transform.x - (currentVertex[0].x - lastX), transform.y - (currentVertex[0].y - lastY));
|
|
1322
|
-
}
|
|
1323
|
-
else {
|
|
1324
|
-
transform.moveTo(transform.x -
|
|
1325
|
-
(currentVertex[0].x - vertexBeforeTransform[0].x), transform.y -
|
|
1326
|
-
(currentVertex[0].y - vertexBeforeTransform[0].y));
|
|
1463
|
+
if (setOrigin) {
|
|
1464
|
+
if (panel instanceof HTMLElement) {
|
|
1465
|
+
if (changeX || changeY) {
|
|
1466
|
+
transform.moveTo(transform.x - (currentVertex[0].x - lastX), transform.y - (currentVertex[0].y - lastY));
|
|
1467
|
+
}
|
|
1468
|
+
else {
|
|
1469
|
+
transform.moveTo(transform.x -
|
|
1470
|
+
(currentVertex[0].x - vertexBeforeTransform[0].x), transform.y -
|
|
1471
|
+
(currentVertex[0].y - vertexBeforeTransform[0].y));
|
|
1472
|
+
}
|
|
1327
1473
|
}
|
|
1328
1474
|
}
|
|
1329
1475
|
handle.classList.remove(CLASS_RESIZABLE_HANDLE_ACTIVE);
|
|
1330
|
-
onEnd &&
|
|
1476
|
+
onEnd &&
|
|
1477
|
+
onEnd.call(uiik, { w: currentW, h: currentH, transform }, ev);
|
|
1331
1478
|
});
|
|
1332
1479
|
}, {
|
|
1333
|
-
threshold: THRESHOLD
|
|
1480
|
+
threshold: THRESHOLD,
|
|
1334
1481
|
lockPage: true,
|
|
1335
1482
|
});
|
|
1336
1483
|
}
|
|
@@ -1364,6 +1511,15 @@
|
|
|
1364
1511
|
});
|
|
1365
1512
|
}
|
|
1366
1513
|
}
|
|
1514
|
+
function limitWH(newX, newY, line, value, minValue) {
|
|
1515
|
+
let p1 = line.p1;
|
|
1516
|
+
let p2 = line.p2;
|
|
1517
|
+
let invalid = (p2.x - p1.x) * (newY - p1.y) - (p2.y - p1.y) * (newX - p1.x) > 0;
|
|
1518
|
+
if (invalid) {
|
|
1519
|
+
return minValue;
|
|
1520
|
+
}
|
|
1521
|
+
return value;
|
|
1522
|
+
}
|
|
1367
1523
|
function resize(transform, style, w, h) {
|
|
1368
1524
|
if (transform.el instanceof SVGGraphicsElement) {
|
|
1369
1525
|
if (is.isDefined(w))
|
|
@@ -1393,14 +1549,15 @@
|
|
|
1393
1549
|
super(els, object.assign({
|
|
1394
1550
|
containment: false,
|
|
1395
1551
|
watch: true,
|
|
1396
|
-
threshold:
|
|
1552
|
+
threshold: THRESHOLD,
|
|
1397
1553
|
ghost: false,
|
|
1398
1554
|
direction: "",
|
|
1399
1555
|
scroll: true,
|
|
1556
|
+
useTransform: true,
|
|
1400
1557
|
snapOptions: {
|
|
1401
1558
|
tolerance: 10,
|
|
1402
1559
|
},
|
|
1403
|
-
self: false
|
|
1560
|
+
self: false,
|
|
1404
1561
|
}, opts));
|
|
1405
1562
|
_Draggable_instances.add(this);
|
|
1406
1563
|
_Draggable_handleMap.set(this, new WeakMap());
|
|
@@ -1455,7 +1612,7 @@
|
|
|
1455
1612
|
let draggableList = this.ele;
|
|
1456
1613
|
const eleString = this.eleString;
|
|
1457
1614
|
const initStyle = __classPrivateFieldGet(this, _Draggable_instances, "m", _Draggable_initStyle).bind(this);
|
|
1458
|
-
this.addPointerDown(bindTarget, ({ ev,
|
|
1615
|
+
this.addPointerDown(bindTarget, ({ ev, currentCStyle, onPointerStart, onPointerMove, onPointerEnd, }) => {
|
|
1459
1616
|
var _a;
|
|
1460
1617
|
let t = ev.target;
|
|
1461
1618
|
if (!t)
|
|
@@ -1464,7 +1621,7 @@
|
|
|
1464
1621
|
draggableList = bindTarget.querySelectorAll(eleString);
|
|
1465
1622
|
initStyle(draggableList);
|
|
1466
1623
|
}
|
|
1467
|
-
let findRs = tree.closest(t, node => collection.includes(draggableList, node),
|
|
1624
|
+
let findRs = tree.closest(t, (node) => collection.includes(draggableList, node), "parentNode");
|
|
1468
1625
|
if (!findRs)
|
|
1469
1626
|
return true;
|
|
1470
1627
|
const dragDom = findRs;
|
|
@@ -1475,28 +1632,23 @@
|
|
|
1475
1632
|
if (opts.self && dragDom !== t)
|
|
1476
1633
|
return true;
|
|
1477
1634
|
const onPointerDown = opts.onPointerDown;
|
|
1478
|
-
if (onPointerDown &&
|
|
1635
|
+
if (onPointerDown &&
|
|
1636
|
+
onPointerDown({ draggable: dragDom }, ev) === false)
|
|
1479
1637
|
return true;
|
|
1480
1638
|
const filter = opts.filter;
|
|
1481
1639
|
if (filter) {
|
|
1482
|
-
if (collection.some(dragDom.querySelectorAll(filter), ele => ele.contains(t)))
|
|
1640
|
+
if (collection.some(dragDom.querySelectorAll(filter), (ele) => ele.contains(t)))
|
|
1483
1641
|
return true;
|
|
1484
1642
|
}
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
let
|
|
1490
|
-
let offsetPointY = offsetXy.y;
|
|
1491
|
-
const matrixInfo = getMatrixInfo(dragDom, true);
|
|
1492
|
-
const currentXy = getPointInContainer(ev, offsetParent, offsetParentRect, offsetParentCStyle);
|
|
1493
|
-
if (matrixInfo.angle != 0) {
|
|
1494
|
-
offsetPointX = currentXy.x - matrixInfo.x;
|
|
1495
|
-
offsetPointY = currentXy.y - matrixInfo.y;
|
|
1496
|
-
}
|
|
1643
|
+
let offsetParent;
|
|
1644
|
+
let offsetParentRect;
|
|
1645
|
+
let offsetParentCStyle;
|
|
1646
|
+
let offsetPointX = 0;
|
|
1647
|
+
let offsetPointY = 0;
|
|
1497
1648
|
const inContainer = !!container;
|
|
1498
1649
|
const ghost = opts.ghost;
|
|
1499
1650
|
const ghostClass = opts.ghostClass;
|
|
1651
|
+
const ghostTo = opts.ghostTo;
|
|
1500
1652
|
const direction = opts.direction;
|
|
1501
1653
|
const onStart = opts.onStart;
|
|
1502
1654
|
const onDrag = opts.onDrag;
|
|
@@ -1504,64 +1656,25 @@
|
|
|
1504
1656
|
const onClone = opts.onClone;
|
|
1505
1657
|
const originalZIndex = currentCStyle.zIndex;
|
|
1506
1658
|
let zIndex = opts.zIndex || originalZIndex;
|
|
1507
|
-
const classes = opts.classes ||
|
|
1659
|
+
const classes = opts.classes || "";
|
|
1508
1660
|
const group = opts.group;
|
|
1509
|
-
if (group) {
|
|
1510
|
-
let i = -1;
|
|
1511
|
-
collection.each(DRAGGER_GROUPS[group], el => {
|
|
1512
|
-
const z = parseInt(currentCStyle.zIndex) || 0;
|
|
1513
|
-
if (z > i)
|
|
1514
|
-
i = z;
|
|
1515
|
-
});
|
|
1516
|
-
zIndex = i + 1;
|
|
1517
|
-
}
|
|
1518
1661
|
const scroll = opts.scroll;
|
|
1519
1662
|
const scrollSpeed = opts.scrollSpeed || 10;
|
|
1520
1663
|
let gridX, gridY;
|
|
1521
|
-
const grid = opts.grid;
|
|
1522
|
-
if (is.isArray(grid)) {
|
|
1523
|
-
gridX = grid[0];
|
|
1524
|
-
gridY = grid[1];
|
|
1525
|
-
}
|
|
1526
|
-
else if (is.isNumber(grid)) {
|
|
1527
|
-
gridX = gridY = grid;
|
|
1528
|
-
}
|
|
1529
1664
|
const snapOn = opts.snap;
|
|
1530
1665
|
let snappable;
|
|
1531
1666
|
const snapTolerance = ((_a = opts.snapOptions) === null || _a === void 0 ? void 0 : _a.tolerance) || 10;
|
|
1532
1667
|
const onSnap = opts.onSnap;
|
|
1533
1668
|
let lastSnapDirY = "", lastSnapDirX = "";
|
|
1534
1669
|
let lastSnapping = "";
|
|
1535
|
-
if (snapOn) {
|
|
1536
|
-
snappable = collection.map((container || document).querySelectorAll(snapOn), (el) => {
|
|
1537
|
-
const { x, y, w, h } = getRectInContainer(el, offsetParent);
|
|
1538
|
-
return {
|
|
1539
|
-
x1: x,
|
|
1540
|
-
y1: y,
|
|
1541
|
-
x2: x + w,
|
|
1542
|
-
y2: y + h,
|
|
1543
|
-
el: el,
|
|
1544
|
-
};
|
|
1545
|
-
});
|
|
1546
|
-
}
|
|
1547
1670
|
const dragDomRect = dragDom.getBoundingClientRect();
|
|
1548
|
-
|
|
1549
|
-
|
|
1671
|
+
let originW;
|
|
1672
|
+
let originH;
|
|
1550
1673
|
let minX = 0;
|
|
1551
1674
|
let minY = 0;
|
|
1552
1675
|
let maxX = 0;
|
|
1553
1676
|
let maxY = 0;
|
|
1554
|
-
let
|
|
1555
|
-
let originOffY = 0;
|
|
1556
|
-
if (inContainer) {
|
|
1557
|
-
maxX = container.scrollWidth - originW;
|
|
1558
|
-
maxY = container.scrollHeight - originH;
|
|
1559
|
-
}
|
|
1560
|
-
if (maxX < 0)
|
|
1561
|
-
maxX = 0;
|
|
1562
|
-
if (maxY < 0)
|
|
1563
|
-
maxY = 0;
|
|
1564
|
-
let copyNode;
|
|
1677
|
+
let ghostNode;
|
|
1565
1678
|
let transform;
|
|
1566
1679
|
let timer = null;
|
|
1567
1680
|
let toLeft = false;
|
|
@@ -1569,45 +1682,114 @@
|
|
|
1569
1682
|
let toRight = false;
|
|
1570
1683
|
let toBottom = false;
|
|
1571
1684
|
let endX = 0, endY = 0;
|
|
1685
|
+
let startMatrixInfo;
|
|
1686
|
+
let startPointXy;
|
|
1572
1687
|
onPointerStart(function (args) {
|
|
1573
|
-
var _a;
|
|
1574
1688
|
const { ev } = args;
|
|
1689
|
+
offsetParent =
|
|
1690
|
+
dragDom instanceof HTMLElement
|
|
1691
|
+
? dragDom.offsetParent || document.body
|
|
1692
|
+
: dragDom.ownerSVGElement;
|
|
1693
|
+
offsetParentRect = offsetParent.getBoundingClientRect();
|
|
1694
|
+
offsetParentCStyle = window.getComputedStyle(offsetParent);
|
|
1695
|
+
startMatrixInfo = getMatrixInfo(dragDom, true);
|
|
1696
|
+
const offsetXy = getPointInContainer(ev, dragDom, undefined, undefined, startMatrixInfo);
|
|
1697
|
+
offsetPointX = offsetXy.x;
|
|
1698
|
+
offsetPointY = offsetXy.y;
|
|
1699
|
+
startPointXy = getPointInContainer(ev, offsetParent, offsetParentRect, offsetParentCStyle, startMatrixInfo);
|
|
1700
|
+
originW =
|
|
1701
|
+
dragDomRect.width;
|
|
1702
|
+
originH =
|
|
1703
|
+
dragDomRect.height;
|
|
1704
|
+
if (dragDom instanceof SVGGElement || dragDom instanceof SVGSVGElement) {
|
|
1705
|
+
let bbox = dragDom.getBBox();
|
|
1706
|
+
offsetPointX += bbox.x;
|
|
1707
|
+
offsetPointY += bbox.y;
|
|
1708
|
+
}
|
|
1709
|
+
if (startMatrixInfo.angle != 0) {
|
|
1710
|
+
let { sx, sy } = getCenterXy(dragDom);
|
|
1711
|
+
offsetPointX = startPointXy.x - sx;
|
|
1712
|
+
offsetPointY = startPointXy.y - sy;
|
|
1713
|
+
}
|
|
1714
|
+
if (group) {
|
|
1715
|
+
let i = -1;
|
|
1716
|
+
collection.each(DRAGGER_GROUPS[group], (el) => {
|
|
1717
|
+
const z = parseInt(currentCStyle.zIndex) || 0;
|
|
1718
|
+
if (z > i)
|
|
1719
|
+
i = z;
|
|
1720
|
+
});
|
|
1721
|
+
zIndex = i + 1;
|
|
1722
|
+
}
|
|
1723
|
+
const grid = opts.grid;
|
|
1724
|
+
if (is.isArray(grid)) {
|
|
1725
|
+
gridX = grid[0];
|
|
1726
|
+
gridY = grid[1];
|
|
1727
|
+
}
|
|
1728
|
+
else if (is.isNumber(grid)) {
|
|
1729
|
+
gridX = gridY = grid;
|
|
1730
|
+
}
|
|
1731
|
+
if (snapOn) {
|
|
1732
|
+
snappable = collection.map((container || document).querySelectorAll(snapOn), (el) => {
|
|
1733
|
+
const { x, y, w, h } = getRectInContainer(el, offsetParent);
|
|
1734
|
+
return {
|
|
1735
|
+
x1: x,
|
|
1736
|
+
y1: y,
|
|
1737
|
+
x2: x + w,
|
|
1738
|
+
y2: y + h,
|
|
1739
|
+
el: el,
|
|
1740
|
+
};
|
|
1741
|
+
});
|
|
1742
|
+
}
|
|
1743
|
+
if (inContainer) {
|
|
1744
|
+
maxX =
|
|
1745
|
+
container.scrollWidth - originW / startMatrixInfo.scale;
|
|
1746
|
+
maxY =
|
|
1747
|
+
container.scrollHeight - originH / startMatrixInfo.scale;
|
|
1748
|
+
}
|
|
1749
|
+
if (maxX < 0)
|
|
1750
|
+
maxX = 0;
|
|
1751
|
+
if (maxY < 0)
|
|
1752
|
+
maxY = 0;
|
|
1575
1753
|
if (ghost) {
|
|
1576
1754
|
if (is.isFunction(ghost)) {
|
|
1577
|
-
|
|
1755
|
+
ghostNode = ghost(dragDom);
|
|
1578
1756
|
}
|
|
1579
1757
|
else {
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1758
|
+
ghostNode = dragDom.cloneNode(true);
|
|
1759
|
+
ghostNode.style.opacity = "0.3";
|
|
1760
|
+
ghostNode.style.pointerEvents = "none";
|
|
1761
|
+
ghostNode.style.position = "absolute";
|
|
1584
1762
|
}
|
|
1585
|
-
|
|
1763
|
+
ghostNode.style.zIndex = zIndex + "";
|
|
1586
1764
|
if (ghostClass) {
|
|
1587
|
-
|
|
1765
|
+
ghostNode.classList.add(...array.compact(string.split(ghostClass, " ")));
|
|
1588
1766
|
}
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1767
|
+
ghostNode.classList.add(...array.compact(string.split(classes, " ")));
|
|
1768
|
+
ghostNode.classList.toggle(CLASS_DRAGGABLE_GHOST, true);
|
|
1769
|
+
let ghostParent = ghostTo ? (is.isString(ghostTo) ? document.querySelector(ghostTo) : ghostTo) : dragDom.parentNode;
|
|
1770
|
+
ghostParent === null || ghostParent === void 0 ? void 0 : ghostParent.appendChild(ghostNode);
|
|
1771
|
+
transform = wrapper(ghostNode, opts.useTransform);
|
|
1772
|
+
onClone && onClone({ clone: ghostNode }, ev);
|
|
1594
1773
|
}
|
|
1595
1774
|
else {
|
|
1596
|
-
transform = wrapper(dragDom);
|
|
1775
|
+
transform = wrapper(dragDom, opts.useTransform);
|
|
1597
1776
|
}
|
|
1598
|
-
dragDom.classList.add(...array.compact(string.split(classes,
|
|
1599
|
-
if (!
|
|
1600
|
-
dragDom.style.zIndex = zIndex +
|
|
1777
|
+
dragDom.classList.add(...array.compact(string.split(classes, " ")));
|
|
1778
|
+
if (!ghostNode)
|
|
1779
|
+
dragDom.style.zIndex = zIndex + "";
|
|
1601
1780
|
dragDom.classList.toggle(CLASS_DRAGGABLE_ACTIVE, true);
|
|
1602
|
-
onStart &&
|
|
1603
|
-
|
|
1781
|
+
onStart &&
|
|
1782
|
+
onStart({ draggable: dragDom, x: startPointXy.x, y: startPointXy.y, transform }, ev);
|
|
1783
|
+
const customEv = new Event("uii-dragactive", {
|
|
1784
|
+
bubbles: true,
|
|
1785
|
+
cancelable: false,
|
|
1786
|
+
});
|
|
1604
1787
|
dragDom.dispatchEvent(customEv);
|
|
1605
1788
|
});
|
|
1606
1789
|
onPointerMove((args) => {
|
|
1607
1790
|
const { ev, pointX, pointY, offX, offY } = args;
|
|
1608
|
-
|
|
1609
|
-
let
|
|
1610
|
-
let newY = currentXy.y;
|
|
1791
|
+
let newX = startPointXy.x + offX;
|
|
1792
|
+
let newY = startPointXy.y + offY;
|
|
1611
1793
|
if (scroll) {
|
|
1612
1794
|
const lX = pointX - offsetParentRect.x;
|
|
1613
1795
|
const lY = pointY - offsetParentRect.y;
|
|
@@ -1617,9 +1799,7 @@
|
|
|
1617
1799
|
toTop = lY < EDGE_THRESHOLD;
|
|
1618
1800
|
toRight = rX < EDGE_THRESHOLD;
|
|
1619
1801
|
toBottom = rY < EDGE_THRESHOLD;
|
|
1620
|
-
if (toLeft || toTop
|
|
1621
|
-
||
|
|
1622
|
-
toRight || toBottom) {
|
|
1802
|
+
if (toLeft || toTop || toRight || toBottom) {
|
|
1623
1803
|
if (!timer) {
|
|
1624
1804
|
timer = setInterval(() => {
|
|
1625
1805
|
if (toLeft) {
|
|
@@ -1651,17 +1831,17 @@
|
|
|
1651
1831
|
y = ((y / gridY) >> 0) * gridY;
|
|
1652
1832
|
}
|
|
1653
1833
|
if (inContainer) {
|
|
1654
|
-
if (
|
|
1655
|
-
x =
|
|
1834
|
+
if (x < minX) {
|
|
1835
|
+
x = 0;
|
|
1656
1836
|
}
|
|
1657
|
-
if (
|
|
1658
|
-
y =
|
|
1837
|
+
if (y < minY) {
|
|
1838
|
+
y = 0;
|
|
1659
1839
|
}
|
|
1660
|
-
if (
|
|
1661
|
-
x = maxX
|
|
1840
|
+
if (x > maxX) {
|
|
1841
|
+
x = maxX;
|
|
1662
1842
|
}
|
|
1663
|
-
if (
|
|
1664
|
-
y = maxY
|
|
1843
|
+
if (y > maxY) {
|
|
1844
|
+
y = maxY;
|
|
1665
1845
|
}
|
|
1666
1846
|
}
|
|
1667
1847
|
let canDrag = true;
|
|
@@ -1734,7 +1914,7 @@
|
|
|
1734
1914
|
if (onSnap && lastSnapping !== lastSnapDirX + "" + lastSnapDirY) {
|
|
1735
1915
|
setTimeout(() => {
|
|
1736
1916
|
onSnap({
|
|
1737
|
-
el:
|
|
1917
|
+
el: ghostNode || dragDom,
|
|
1738
1918
|
targetH: targetX,
|
|
1739
1919
|
targetV: targetY,
|
|
1740
1920
|
dirH: snapDirX,
|
|
@@ -1756,7 +1936,7 @@
|
|
|
1756
1936
|
oy: offY,
|
|
1757
1937
|
x: x,
|
|
1758
1938
|
y: y,
|
|
1759
|
-
transform
|
|
1939
|
+
transform,
|
|
1760
1940
|
}, ev) === false) {
|
|
1761
1941
|
canDrag = false;
|
|
1762
1942
|
endX = x;
|
|
@@ -1778,7 +1958,7 @@
|
|
|
1778
1958
|
}
|
|
1779
1959
|
});
|
|
1780
1960
|
onPointerEnd((args) => {
|
|
1781
|
-
var _a
|
|
1961
|
+
var _a;
|
|
1782
1962
|
const { ev, currentStyle } = args;
|
|
1783
1963
|
if (scroll) {
|
|
1784
1964
|
if (timer) {
|
|
@@ -1786,25 +1966,32 @@
|
|
|
1786
1966
|
timer = null;
|
|
1787
1967
|
}
|
|
1788
1968
|
}
|
|
1789
|
-
dragDom.classList.remove(...array.compact(string.split(classes,
|
|
1969
|
+
dragDom.classList.remove(...array.compact(string.split(classes, " ")));
|
|
1790
1970
|
currentStyle.zIndex = originalZIndex;
|
|
1791
1971
|
dragDom.classList.remove(CLASS_DRAGGABLE_ACTIVE);
|
|
1792
1972
|
let moveToGhost = true;
|
|
1793
1973
|
if (onEnd) {
|
|
1794
|
-
moveToGhost =
|
|
1974
|
+
moveToGhost =
|
|
1975
|
+
onEnd({ draggable: dragDom, x: endX, y: endY, transform }, ev) ===
|
|
1976
|
+
false
|
|
1977
|
+
? false
|
|
1978
|
+
: true;
|
|
1795
1979
|
}
|
|
1796
|
-
const customEv = new Event("uii-dragdeactive", {
|
|
1980
|
+
const customEv = new Event("uii-dragdeactive", {
|
|
1981
|
+
bubbles: true,
|
|
1982
|
+
cancelable: false,
|
|
1983
|
+
});
|
|
1797
1984
|
dragDom.dispatchEvent(customEv);
|
|
1798
1985
|
if (ghost) {
|
|
1799
|
-
(
|
|
1986
|
+
(_a = ghostNode.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(ghostNode);
|
|
1800
1987
|
if (moveToGhost !== false) {
|
|
1801
|
-
wrapper(dragDom).moveTo(transform.x, transform.y);
|
|
1988
|
+
wrapper(dragDom, opts.useTransform).moveTo(transform.x, transform.y);
|
|
1802
1989
|
}
|
|
1803
1990
|
}
|
|
1804
1991
|
});
|
|
1805
1992
|
}, {
|
|
1806
1993
|
threshold: this.opts.threshold || 0,
|
|
1807
|
-
lockPage: true
|
|
1994
|
+
lockPage: true,
|
|
1808
1995
|
});
|
|
1809
1996
|
}
|
|
1810
1997
|
onOptionChanged(opts) {
|
|
@@ -1833,10 +2020,10 @@
|
|
|
1833
2020
|
const ee = __classPrivateFieldGet(this, _Draggable_handleMap, "f").get(el) || el;
|
|
1834
2021
|
ee.classList.toggle(CLASS_DRAGGABLE_HANDLE, true);
|
|
1835
2022
|
if (!is.isUndefined(this.opts.cursor)) {
|
|
1836
|
-
el.style.cursor = this.opts.cursor.default ||
|
|
2023
|
+
el.style.cursor = this.opts.cursor.default || "move";
|
|
1837
2024
|
if (is.isDefined(this.opts.cursor.over)) {
|
|
1838
2025
|
el.dataset.cursorOver = this.opts.cursor.over;
|
|
1839
|
-
el.dataset.cursorActive = this.opts.cursor.active ||
|
|
2026
|
+
el.dataset.cursorActive = this.opts.cursor.active || "move";
|
|
1840
2027
|
}
|
|
1841
2028
|
}
|
|
1842
2029
|
});
|
|
@@ -1968,7 +2155,6 @@
|
|
|
1968
2155
|
return new Droppable(els, opts);
|
|
1969
2156
|
}
|
|
1970
2157
|
|
|
1971
|
-
const THRESHOLD$2 = 2;
|
|
1972
2158
|
const CLASS_ROTATABLE = "uii-rotatable";
|
|
1973
2159
|
const CLASS_ROTATABLE_HANDLE = "uii-rotatable-handle";
|
|
1974
2160
|
const CLASS_ROTATABLE_ACTIVE = "uii-rotatable-active";
|
|
@@ -2020,23 +2206,20 @@
|
|
|
2020
2206
|
let startOy = 0;
|
|
2021
2207
|
let startDeg = 0;
|
|
2022
2208
|
let container;
|
|
2209
|
+
let startPointXy;
|
|
2023
2210
|
onPointerStart(function (args) {
|
|
2024
2211
|
const { ev } = args;
|
|
2025
2212
|
const { w, h } = getStyleSize(el);
|
|
2026
|
-
const { originX, originY } = parseOxy(opts.ox, opts.oy, w, h);
|
|
2213
|
+
const { originX, originY } = parseOxy(opts.ox, opts.oy, w, h, el);
|
|
2027
2214
|
startOx = originX;
|
|
2028
2215
|
startOy = originY;
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
container =
|
|
2035
|
-
el instanceof SVGGraphicsElement
|
|
2036
|
-
? el.ownerSVGElement : el.parentElement;
|
|
2037
|
-
const currentXy = getPointInContainer(ev, container);
|
|
2216
|
+
let centerXy = getRectCenter(el);
|
|
2217
|
+
centerX = centerXy.x;
|
|
2218
|
+
centerY = centerXy.y;
|
|
2219
|
+
container = el.parentElement;
|
|
2220
|
+
startPointXy = getPointInContainer(ev, container);
|
|
2038
2221
|
startDeg =
|
|
2039
|
-
Math.atan2(
|
|
2222
|
+
Math.atan2(startPointXy.y - centerY, startPointXy.x - centerX) * ONE_RAD +
|
|
2040
2223
|
90;
|
|
2041
2224
|
if (startDeg < 0)
|
|
2042
2225
|
startDeg = 360 + startDeg;
|
|
@@ -2046,10 +2229,11 @@
|
|
|
2046
2229
|
onStart && onStart({ deg, cx: centerX, cy: centerY }, ev);
|
|
2047
2230
|
});
|
|
2048
2231
|
onPointerMove((args) => {
|
|
2049
|
-
const { ev } = args;
|
|
2050
|
-
|
|
2232
|
+
const { ev, offX, offY } = args;
|
|
2233
|
+
let newX = startPointXy.x + offX;
|
|
2234
|
+
let newY = startPointXy.y + offY;
|
|
2051
2235
|
deg =
|
|
2052
|
-
Math.atan2(
|
|
2236
|
+
Math.atan2(newY - centerY, newX - centerX) * ONE_RAD +
|
|
2053
2237
|
90 -
|
|
2054
2238
|
startDeg;
|
|
2055
2239
|
onRotate &&
|
|
@@ -2069,7 +2253,7 @@
|
|
|
2069
2253
|
onEnd && onEnd({ deg }, ev);
|
|
2070
2254
|
});
|
|
2071
2255
|
}, {
|
|
2072
|
-
threshold: THRESHOLD
|
|
2256
|
+
threshold: THRESHOLD,
|
|
2073
2257
|
lockPage: true,
|
|
2074
2258
|
});
|
|
2075
2259
|
}
|
|
@@ -2175,7 +2359,6 @@
|
|
|
2175
2359
|
const CLASS_SELECTOR = "uii-selector";
|
|
2176
2360
|
const CLASS_SELECTING = "uii-selecting";
|
|
2177
2361
|
const CLASS_SELECTED = "uii-selected";
|
|
2178
|
-
const THRESHOLD$1 = 2;
|
|
2179
2362
|
class Selectable extends Uii {
|
|
2180
2363
|
constructor(container, opts) {
|
|
2181
2364
|
super(container, object.assign({
|
|
@@ -2240,10 +2423,9 @@
|
|
|
2240
2423
|
if (onPointerDown && onPointerDown(ev) === false)
|
|
2241
2424
|
return true;
|
|
2242
2425
|
let originPos = "";
|
|
2243
|
-
let
|
|
2244
|
-
|
|
2245
|
-
let
|
|
2246
|
-
let hitPosY = startxy.y;
|
|
2426
|
+
let startPointXy = getPointInContainer(ev, con, currentRect, currentCStyle);
|
|
2427
|
+
let hitPosX = startPointXy.x;
|
|
2428
|
+
let hitPosY = startPointXy.y;
|
|
2247
2429
|
const style = selector.style;
|
|
2248
2430
|
let selection = [];
|
|
2249
2431
|
let lastSelection = [];
|
|
@@ -2267,13 +2449,9 @@
|
|
|
2267
2449
|
style.display = 'block';
|
|
2268
2450
|
onStart && onStart({ selection: __classPrivateFieldGet(that, _Selectable__lastSelected, "f"), selectable: con }, ev);
|
|
2269
2451
|
});
|
|
2270
|
-
onPointerMove((
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
let pointX = currentXy.x;
|
|
2274
|
-
let pointY = currentXy.y;
|
|
2275
|
-
let offX = pointX - hitPosX;
|
|
2276
|
-
let offY = pointY - hitPosY;
|
|
2452
|
+
onPointerMove(({ ev, offX, offY }) => {
|
|
2453
|
+
let pointX = startPointXy.x + offX;
|
|
2454
|
+
let pointY = startPointXy.y + offY;
|
|
2277
2455
|
if (scroll) {
|
|
2278
2456
|
const ltX = ev.clientX - currentRect.x;
|
|
2279
2457
|
const ltY = ev.clientY - currentRect.y;
|
|
@@ -2378,7 +2556,7 @@
|
|
|
2378
2556
|
onEnd({ selection, selectable: con }, ev);
|
|
2379
2557
|
});
|
|
2380
2558
|
}, {
|
|
2381
|
-
threshold: THRESHOLD
|
|
2559
|
+
threshold: THRESHOLD,
|
|
2382
2560
|
lockPage: true
|
|
2383
2561
|
});
|
|
2384
2562
|
};
|
|
@@ -2392,7 +2570,6 @@
|
|
|
2392
2570
|
const CLASS_SORTABLE_GHOST = "uii-sortable-ghost";
|
|
2393
2571
|
const CLASS_SORTABLE_ACTIVE = "uii-sortable-active";
|
|
2394
2572
|
const ATTR_SORTABLE_ACTIVE = "uii-sortable-active";
|
|
2395
|
-
const THRESHOLD = 2;
|
|
2396
2573
|
class Sortable extends Uii {
|
|
2397
2574
|
constructor(container, opts) {
|
|
2398
2575
|
super(container, object.merge({
|
|
@@ -2768,7 +2945,7 @@
|
|
|
2768
2945
|
return new Sortable(container, opts);
|
|
2769
2946
|
}
|
|
2770
2947
|
|
|
2771
|
-
var version = "1.3.
|
|
2948
|
+
var version = "1.3.3";
|
|
2772
2949
|
var repository = {
|
|
2773
2950
|
type: "git",
|
|
2774
2951
|
url: "https://github.com/holyhigh2/uiik"
|
|
@@ -2813,6 +2990,7 @@
|
|
|
2813
2990
|
exports.Selectable = Selectable;
|
|
2814
2991
|
exports.Sortable = Sortable;
|
|
2815
2992
|
exports.Splittable = Splittable;
|
|
2993
|
+
exports.THRESHOLD = THRESHOLD;
|
|
2816
2994
|
exports.Uii = Uii;
|
|
2817
2995
|
exports.UiiTransform = UiiTransform;
|
|
2818
2996
|
exports.VERSION = VERSION;
|
|
@@ -2824,12 +3002,14 @@
|
|
|
2824
3002
|
exports.getMatrixInfo = getMatrixInfo;
|
|
2825
3003
|
exports.getPointInContainer = getPointInContainer;
|
|
2826
3004
|
exports.getPointOffset = getPointOffset;
|
|
3005
|
+
exports.getRectCenter = getRectCenter;
|
|
2827
3006
|
exports.getRectInContainer = getRectInContainer;
|
|
2828
3007
|
exports.getStyleSize = getStyleSize;
|
|
2829
3008
|
exports.getStyleXy = getStyleXy;
|
|
2830
3009
|
exports.getTranslate = getTranslate;
|
|
2831
3010
|
exports.getVertex = getVertex;
|
|
2832
3011
|
exports.isSVGEl = isSVGEl;
|
|
3012
|
+
exports.isVisible = isVisible;
|
|
2833
3013
|
exports.lockPage = lockPage;
|
|
2834
3014
|
exports.moveBy = moveBy;
|
|
2835
3015
|
exports.moveTo = moveTo;
|
|
@@ -2841,11 +3021,13 @@
|
|
|
2841
3021
|
exports.newSelectable = newSelectable;
|
|
2842
3022
|
exports.newSortable = newSortable;
|
|
2843
3023
|
exports.newSplittable = newSplittable;
|
|
3024
|
+
exports.normalizeVector = normalizeVector;
|
|
2844
3025
|
exports.parseOxy = parseOxy;
|
|
2845
3026
|
exports.restoreCursor = restoreCursor;
|
|
2846
3027
|
exports.rotateTo = rotateTo;
|
|
2847
3028
|
exports.saveCursor = saveCursor;
|
|
2848
3029
|
exports.setCursor = setCursor;
|
|
3030
|
+
exports.transformMoveTo = transformMoveTo;
|
|
2849
3031
|
exports.unlockPage = unlockPage;
|
|
2850
3032
|
exports.wrapper = wrapper;
|
|
2851
3033
|
|