uiik 1.3.0-beta.3 → 1.3.2
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 +508 -329
- package/index.js +513 -331
- package/package.json +2 -2
- package/transform.d.ts +6 -2
- package/types.d.ts +3 -0
- package/utils.d.ts +19 -3
package/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* uiik v1.3.
|
|
2
|
+
* uiik v1.3.2
|
|
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-2024 @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/is'), require('myfx/collection'), require('myfx/object'), require('myfx/string'), require('myfx/array'), require('myfx/utils')) :
|
|
9
|
-
typeof define === 'function' && define.amd ? define(['exports', 'myfx/is', 'myfx/collection', 'myfx/object', 'myfx/string', 'myfx/array', 'myfx/utils'], factory) :
|
|
10
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.uiik = {}, global.is, global.collection, global.object, global.string, global.array, global.utils));
|
|
11
|
-
})(this, (function (exports, is, collection, object, string, array, utils) { 'use strict';
|
|
8
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('myfx/is'), require('myfx/collection'), require('myfx/object'), require('myfx/string'), require('myfx/array'), require('myfx/tree'), require('myfx/utils')) :
|
|
9
|
+
typeof define === 'function' && define.amd ? define(['exports', 'myfx/is', 'myfx/collection', 'myfx/object', 'myfx/string', 'myfx/array', 'myfx/tree', 'myfx/utils'], factory) :
|
|
10
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.uiik = {}, global.is, global.collection, global.object, global.string, global.array, global.tree, global.utils));
|
|
11
|
+
})(this, (function (exports, is, collection, object, string, array, 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,43 +309,38 @@
|
|
|
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
|
-
|
|
287
|
-
|
|
288
|
-
let a = 1, b = 0
|
|
289
|
-
let
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
322
|
+
function getMatrixInfo(el, recur = false) {
|
|
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);
|
|
327
|
+
if (recur) {
|
|
328
|
+
let p = el.parentElement;
|
|
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);
|
|
333
|
+
p = p.parentElement;
|
|
295
334
|
}
|
|
296
|
-
elCStyle = window.getComputedStyle(elCStyle);
|
|
297
335
|
}
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
a = parseFloat(matched.groups.a);
|
|
306
|
-
b = parseFloat(matched.groups.b);
|
|
307
|
-
parseFloat(matched.groups.c);
|
|
308
|
-
parseFloat(matched.groups.d);
|
|
309
|
-
x = parseFloat(matched.groups.x);
|
|
310
|
-
y = parseFloat(matched.groups.y);
|
|
311
|
-
}
|
|
312
|
-
if (e && f) {
|
|
313
|
-
x = e;
|
|
314
|
-
y = f;
|
|
336
|
+
if (matrix) {
|
|
337
|
+
a = matrix.a;
|
|
338
|
+
b = matrix.b;
|
|
339
|
+
matrix.c;
|
|
340
|
+
matrix.d;
|
|
341
|
+
rs.x = matrix.e;
|
|
342
|
+
rs.y = matrix.f;
|
|
315
343
|
}
|
|
316
|
-
const rs = { scale: 1, angle: 0, x, y };
|
|
317
344
|
rs.scale = Math.sqrt(a * a + b * b);
|
|
318
345
|
rs.angle = Math.round(Math.atan2(b, a) * (180 / Math.PI));
|
|
319
346
|
return rs;
|
|
@@ -322,28 +349,29 @@
|
|
|
322
349
|
if (!elRect) {
|
|
323
350
|
elRect = el.getBoundingClientRect();
|
|
324
351
|
}
|
|
352
|
+
let rx = elRect.x, ry = elRect.y;
|
|
325
353
|
if (!elCStyle) {
|
|
326
354
|
elCStyle = window.getComputedStyle(el);
|
|
327
355
|
}
|
|
328
356
|
if (!matrixInfo) {
|
|
329
|
-
matrixInfo = getMatrixInfo(
|
|
357
|
+
matrixInfo = getMatrixInfo(el, true);
|
|
330
358
|
}
|
|
331
359
|
const scale = matrixInfo.scale;
|
|
332
360
|
let x = event.clientX -
|
|
333
|
-
|
|
361
|
+
rx -
|
|
334
362
|
(parseFloat(elCStyle.borderLeftWidth) || 0) * scale +
|
|
335
363
|
el.scrollLeft * scale;
|
|
336
364
|
let y = event.clientY -
|
|
337
|
-
|
|
365
|
+
ry -
|
|
338
366
|
(parseFloat(elCStyle.borderTopWidth) || 0) * scale +
|
|
339
367
|
el.scrollTop * scale;
|
|
340
|
-
return { x: x / scale, y: y / scale };
|
|
368
|
+
return { x: x / scale, y: y / scale, scale };
|
|
341
369
|
}
|
|
342
|
-
function getRectInContainer(el, container) {
|
|
370
|
+
function getRectInContainer(el, container, matrixInfo) {
|
|
343
371
|
const elRect = el.getBoundingClientRect();
|
|
344
372
|
const containerRect = container.getBoundingClientRect();
|
|
345
373
|
const elCStyle = window.getComputedStyle(container);
|
|
346
|
-
|
|
374
|
+
matrixInfo = matrixInfo || getMatrixInfo(container, true);
|
|
347
375
|
const scale = matrixInfo.scale;
|
|
348
376
|
let x = elRect.x -
|
|
349
377
|
containerRect.x -
|
|
@@ -360,6 +388,12 @@
|
|
|
360
388
|
h: elRect.height / scale,
|
|
361
389
|
};
|
|
362
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
|
+
}
|
|
363
397
|
function getCenterXy(el, ox, oy) {
|
|
364
398
|
const cStyle = window.getComputedStyle(el);
|
|
365
399
|
const center = cStyle.transformOrigin;
|
|
@@ -379,7 +413,19 @@
|
|
|
379
413
|
return { sx: startX, sy: startY, x: startX + ox, y: startY + oy, ox, oy };
|
|
380
414
|
}
|
|
381
415
|
function getCenterXySVG(el, ox, oy) {
|
|
382
|
-
|
|
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
|
+
}
|
|
383
429
|
return { sx: x, sy: y, x: x + ox, y: y + oy, ox, oy };
|
|
384
430
|
}
|
|
385
431
|
function getVertex(el, ox, oy) {
|
|
@@ -387,8 +433,10 @@
|
|
|
387
433
|
const w = parseFloat(cStyle.width);
|
|
388
434
|
const h = parseFloat(cStyle.height);
|
|
389
435
|
const { originX, originY } = parseOxy(ox, oy, w, h);
|
|
390
|
-
const { x, y, sx, sy } = el instanceof SVGGraphicsElement
|
|
391
|
-
|
|
436
|
+
const { x, y, sx, sy } = el instanceof SVGGraphicsElement
|
|
437
|
+
? getCenterXySVG(el, originX, originY)
|
|
438
|
+
: getCenterXy(el);
|
|
439
|
+
const { angle } = getMatrixInfo(el);
|
|
392
440
|
return calcVertex(w, h, x, y, sx, sy, angle * ONE_ANG);
|
|
393
441
|
}
|
|
394
442
|
function calcVertex(w, h, cx, cy, sx, sy, radian) {
|
|
@@ -399,28 +447,43 @@
|
|
|
399
447
|
{ x: w, y: h },
|
|
400
448
|
];
|
|
401
449
|
return collection.map(originVertex, ({ x, y }) => {
|
|
402
|
-
const nx = (x - cx + sx) * Math.cos(radian) -
|
|
403
|
-
|
|
404
|
-
const ny = (x - cx + sx) * Math.sin(radian) +
|
|
405
|
-
(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);
|
|
406
452
|
return { x: cx + nx, y: cy + ny };
|
|
407
453
|
});
|
|
408
454
|
}
|
|
409
|
-
function parseOxy(ox, oy, w, h) {
|
|
455
|
+
function parseOxy(ox, oy, w, h, el) {
|
|
410
456
|
let originX = 0, originY = 0;
|
|
457
|
+
let transformOrigin;
|
|
411
458
|
if (is.isString(ox)) {
|
|
412
459
|
originX = (parseFloat(ox) / 100) * w;
|
|
413
460
|
}
|
|
414
461
|
else if (is.isNumber(ox)) {
|
|
415
462
|
originX = ox;
|
|
416
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
|
+
}
|
|
417
470
|
if (is.isString(oy)) {
|
|
418
471
|
originY = (parseFloat(oy) / 100) * h;
|
|
419
472
|
}
|
|
420
473
|
else if (is.isNumber(oy)) {
|
|
421
474
|
originY = oy;
|
|
422
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
|
+
}
|
|
423
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 };
|
|
424
487
|
}
|
|
425
488
|
|
|
426
489
|
var _Uii_listeners;
|
|
@@ -517,9 +580,10 @@
|
|
|
517
580
|
e.preventDefault();
|
|
518
581
|
return false;
|
|
519
582
|
}
|
|
583
|
+
let matrixInfo = getMatrixInfo(el, true);
|
|
520
584
|
const pointerMove = (ev) => {
|
|
521
|
-
const offX = ev.clientX - originPosX;
|
|
522
|
-
const offY = ev.clientY - originPosY;
|
|
585
|
+
const offX = (ev.clientX - originPosX) / matrixInfo.scale;
|
|
586
|
+
const offY = (ev.clientY - originPosY) / matrixInfo.scale;
|
|
523
587
|
if (!dragging) {
|
|
524
588
|
if (Math.abs(offX) > threshold || Math.abs(offY) > threshold) {
|
|
525
589
|
dragging = true;
|
|
@@ -602,7 +666,6 @@
|
|
|
602
666
|
_Uii_listeners = new WeakMap();
|
|
603
667
|
|
|
604
668
|
var _Splittable_instances, _Splittable_checkDirection, _Splittable_bindHandle;
|
|
605
|
-
const THRESHOLD$4 = 1;
|
|
606
669
|
const CLASS_SPLITTABLE = "uii-splittable";
|
|
607
670
|
const CLASS_SPLITTABLE_HANDLE = "uii-splittable-handle";
|
|
608
671
|
const CLASS_SPLITTABLE_HANDLE_GHOST = "uii-splittable-handle-ghost";
|
|
@@ -671,8 +734,17 @@
|
|
|
671
734
|
dom2 = h.nextElementSibling;
|
|
672
735
|
}
|
|
673
736
|
else {
|
|
674
|
-
|
|
675
|
-
|
|
737
|
+
let domCon = getRootEl(h, con);
|
|
738
|
+
let domL = domCon.previousElementSibling;
|
|
739
|
+
let domR = domCon.nextElementSibling;
|
|
740
|
+
if (domL && !domL.querySelector(this.opts.handle)) {
|
|
741
|
+
dom1 = domL;
|
|
742
|
+
dom2 = domCon;
|
|
743
|
+
}
|
|
744
|
+
else {
|
|
745
|
+
dom1 = domCon;
|
|
746
|
+
dom2 = domR;
|
|
747
|
+
}
|
|
676
748
|
}
|
|
677
749
|
__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);
|
|
678
750
|
});
|
|
@@ -746,6 +818,7 @@
|
|
|
746
818
|
const dom2Style = dom2.style;
|
|
747
819
|
const ghost = opts.ghost;
|
|
748
820
|
const ghostClass = opts.ghostClass;
|
|
821
|
+
const ghostTo = opts.ghostTo;
|
|
749
822
|
let ghostNode = null;
|
|
750
823
|
let sticked = 'none';
|
|
751
824
|
if (originSize < minSize1 / 2) {
|
|
@@ -769,7 +842,8 @@
|
|
|
769
842
|
ghostNode.className =
|
|
770
843
|
ghostNode.className.replace(ghostClass, '') + ' ' + ghostClass;
|
|
771
844
|
}
|
|
772
|
-
|
|
845
|
+
let ghostParent = ghostTo ? (is.isString(ghostTo) ? document.querySelector(ghostTo) : ghostTo) : currentTarget.parentNode;
|
|
846
|
+
ghostParent.appendChild(ghostNode);
|
|
773
847
|
onClone && onClone({ clone: ghostNode }, ev);
|
|
774
848
|
}
|
|
775
849
|
}
|
|
@@ -811,10 +885,10 @@
|
|
|
811
885
|
anotherSize = blockSize - ds1 - splitterSize;
|
|
812
886
|
if (ghostNode) {
|
|
813
887
|
if (dir === 'v') {
|
|
814
|
-
ghostNode.style.top = startPos + ds1 -
|
|
888
|
+
ghostNode.style.top = startPos + ds1 - splitterSize / 2 + 'px';
|
|
815
889
|
}
|
|
816
890
|
else {
|
|
817
|
-
ghostNode.style.left = startPos + ds1 -
|
|
891
|
+
ghostNode.style.left = startPos + ds1 - splitterSize / 2 + 'px';
|
|
818
892
|
}
|
|
819
893
|
}
|
|
820
894
|
else {
|
|
@@ -829,16 +903,16 @@
|
|
|
829
903
|
onSticky && onSticky({ size1: ds1, size2: anotherSize, position: sticked }, ev);
|
|
830
904
|
}
|
|
831
905
|
if (dir === 'v') {
|
|
832
|
-
currentStyle.top = dom2.offsetTop -
|
|
906
|
+
currentStyle.top = dom2.offsetTop - splitterSize / 2 + 'px';
|
|
833
907
|
}
|
|
834
908
|
else {
|
|
835
|
-
currentStyle.left = dom2.offsetLeft -
|
|
909
|
+
currentStyle.left = dom2.offsetLeft - splitterSize / 2 + 'px';
|
|
836
910
|
}
|
|
837
911
|
}
|
|
838
912
|
onSplit && onSplit({ size1: ds1, size2: anotherSize }, ev);
|
|
839
913
|
});
|
|
840
914
|
onPointerEnd((args) => {
|
|
841
|
-
var _a
|
|
915
|
+
var _a;
|
|
842
916
|
const { ev, currentStyle } = args;
|
|
843
917
|
switch (dir) {
|
|
844
918
|
case 'v':
|
|
@@ -860,17 +934,17 @@
|
|
|
860
934
|
dom2Style.setProperty(updateProp, anotherSize + 'px', 'important');
|
|
861
935
|
}
|
|
862
936
|
if (dir === 'v') {
|
|
863
|
-
currentStyle.top = startPos + ds1 -
|
|
937
|
+
currentStyle.top = startPos + ds1 - splitterSize / 2 + 'px';
|
|
864
938
|
}
|
|
865
939
|
else {
|
|
866
|
-
currentStyle.left = startPos + ds1 -
|
|
940
|
+
currentStyle.left = startPos + ds1 - splitterSize / 2 + 'px';
|
|
867
941
|
}
|
|
868
|
-
(
|
|
942
|
+
(_a = ghostNode.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(ghostNode);
|
|
869
943
|
}
|
|
870
944
|
onEnd && onEnd({ size1: originSize, size2: originSize1 }, ev);
|
|
871
945
|
});
|
|
872
946
|
}, {
|
|
873
|
-
threshold: THRESHOLD
|
|
947
|
+
threshold: THRESHOLD,
|
|
874
948
|
lockPage: true
|
|
875
949
|
});
|
|
876
950
|
};
|
|
@@ -878,7 +952,6 @@
|
|
|
878
952
|
return new Splittable(container, opts);
|
|
879
953
|
}
|
|
880
954
|
|
|
881
|
-
const THRESHOLD$3 = 2;
|
|
882
955
|
const CLASS_RESIZABLE_HANDLE = "uii-resizable-handle";
|
|
883
956
|
const CLASS_RESIZABLE_HANDLE_DIR = "uii-resizable-handle-";
|
|
884
957
|
const CLASS_RESIZABLE_HANDLE_ACTIVE = "uii-resizable-handle-active";
|
|
@@ -914,14 +987,12 @@
|
|
|
914
987
|
const onPointerDown = opts.onPointerDown;
|
|
915
988
|
if (onPointerDown && onPointerDown(ev) === false)
|
|
916
989
|
return true;
|
|
917
|
-
let container = panel
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
let setOrigin = !(panel instanceof SVGGraphicsElement);
|
|
921
|
-
let matrixInfo = getMatrixInfo(panel);
|
|
922
|
-
const offset = getRectInContainer(panel, container);
|
|
990
|
+
let container = panel.parentElement;
|
|
991
|
+
let matrixInfo = getMatrixInfo(panel, true);
|
|
992
|
+
const offset = getRectInContainer(panel, container, matrixInfo);
|
|
923
993
|
const offsetParentRect = container.getBoundingClientRect();
|
|
924
994
|
const offsetParentCStyle = window.getComputedStyle(container);
|
|
995
|
+
let setOrigin = !(panel instanceof SVGGraphicsElement) && matrixInfo.angle != 0;
|
|
925
996
|
const { w, h } = getStyleSize(panel);
|
|
926
997
|
const originW = w;
|
|
927
998
|
const originH = h;
|
|
@@ -965,10 +1036,10 @@
|
|
|
965
1036
|
toTransformOrigin = "0 0";
|
|
966
1037
|
break;
|
|
967
1038
|
}
|
|
968
|
-
let minWidth;
|
|
969
|
-
let minHeight;
|
|
970
|
-
let maxWidth;
|
|
971
|
-
let maxHeight;
|
|
1039
|
+
let minWidth = 1;
|
|
1040
|
+
let minHeight = 1;
|
|
1041
|
+
let maxWidth = 9999;
|
|
1042
|
+
let maxHeight = 9999;
|
|
972
1043
|
if (is.isArray(opts.minSize)) {
|
|
973
1044
|
minWidth = opts.minSize[0];
|
|
974
1045
|
minHeight = opts.minSize[1];
|
|
@@ -1000,9 +1071,8 @@
|
|
|
1000
1071
|
let currentVertex;
|
|
1001
1072
|
let refPoint;
|
|
1002
1073
|
let k1;
|
|
1003
|
-
let startOx = 0;
|
|
1004
|
-
let startOy = 0;
|
|
1005
1074
|
let sX = 0, sY = 0;
|
|
1075
|
+
let startPointXy;
|
|
1006
1076
|
onPointerStart(function (args) {
|
|
1007
1077
|
var _a;
|
|
1008
1078
|
const { ev } = args;
|
|
@@ -1036,16 +1106,17 @@
|
|
|
1036
1106
|
const w = parseFloat(cStyle.width);
|
|
1037
1107
|
const h = parseFloat(cStyle.height);
|
|
1038
1108
|
const oxy = parseOxy(opts.ox, opts.oy, w, h);
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
const
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
let
|
|
1109
|
+
oxy.originX;
|
|
1110
|
+
oxy.originY;
|
|
1111
|
+
const panelRect = getRectInContainer(panel, panel.parentElement, matrixInfo);
|
|
1112
|
+
let centerX = Math.round(panelRect.x + panelRect.w / 2);
|
|
1113
|
+
let centerY = Math.round(panelRect.y + panelRect.h / 2);
|
|
1114
|
+
let sx = Math.round(centerX - originW / 2);
|
|
1115
|
+
let sy = Math.round(centerY - originH / 2);
|
|
1116
|
+
transform.x = sx;
|
|
1117
|
+
transform.y = sy;
|
|
1045
1118
|
const deg = matrixInfo.angle * ONE_ANG;
|
|
1046
|
-
currentVertex =
|
|
1047
|
-
vertexBeforeTransform =
|
|
1048
|
-
calcVertex(originW, originH, centerX, centerY, sx, sy, deg);
|
|
1119
|
+
currentVertex = vertexBeforeTransform = calcVertex(originW, originH, centerX, centerY, sx, sy, deg);
|
|
1049
1120
|
switch (dir) {
|
|
1050
1121
|
case "s":
|
|
1051
1122
|
case "e":
|
|
@@ -1074,26 +1145,27 @@
|
|
|
1074
1145
|
style.transformOrigin = toTransformOrigin;
|
|
1075
1146
|
}
|
|
1076
1147
|
else {
|
|
1077
|
-
style.transformOrigin = `${centerX -
|
|
1148
|
+
style.transformOrigin = `${centerX - sx}px ${centerY - sy}px`;
|
|
1078
1149
|
}
|
|
1079
1150
|
}
|
|
1080
1151
|
if (panel instanceof SVGGraphicsElement) {
|
|
1081
1152
|
sX = matrixInfo.x - currentVertex[0].x;
|
|
1082
1153
|
sY = matrixInfo.y - currentVertex[0].y;
|
|
1083
1154
|
}
|
|
1084
|
-
|
|
1155
|
+
startPointXy = getPointInContainer(ev, container, offsetParentRect, offsetParentCStyle, matrixInfo);
|
|
1156
|
+
onStart &&
|
|
1157
|
+
onStart.call(uiik, { w: originW, h: originH, transform }, ev);
|
|
1085
1158
|
});
|
|
1086
1159
|
onPointerMove((args) => {
|
|
1087
|
-
const { ev } = args;
|
|
1088
|
-
|
|
1089
|
-
let
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
let hyLen = Math.sqrt((newX -
|
|
1094
|
-
(newY - refPoint.y) * (newY - refPoint.y));
|
|
1160
|
+
const { ev, offX, offY } = args;
|
|
1161
|
+
let newX = startPointXy.x + offX;
|
|
1162
|
+
let newY = startPointXy.y + offY;
|
|
1163
|
+
const rpx = refPoint.x;
|
|
1164
|
+
const rpy = refPoint.y;
|
|
1165
|
+
let angle = Math.atan2(newY - rpy, newX - rpx) * ONE_RAD - matrixInfo.angle;
|
|
1166
|
+
let hyLen = Math.sqrt((newX - rpx) * (newX - rpx) + (newY - rpy) * (newY - rpy));
|
|
1095
1167
|
let pl1 = Math.abs(k1 === Infinity
|
|
1096
|
-
? newY - refPoint.y
|
|
1168
|
+
? newY - refPoint.y / matrixInfo.scale
|
|
1097
1169
|
: hyLen * Math.cos(angle * ONE_ANG));
|
|
1098
1170
|
let pl2 = Math.sqrt(hyLen * hyLen - pl1 * pl1);
|
|
1099
1171
|
let w = originW;
|
|
@@ -1101,6 +1173,18 @@
|
|
|
1101
1173
|
let y = originY;
|
|
1102
1174
|
let x = originX;
|
|
1103
1175
|
let angl = 0;
|
|
1176
|
+
switch (dir) {
|
|
1177
|
+
case "w":
|
|
1178
|
+
case "sw":
|
|
1179
|
+
angl =
|
|
1180
|
+
Math.atan2(currentVertex[0].y - currentVertex[1].y, currentVertex[0].x - currentVertex[1].x) * ONE_RAD;
|
|
1181
|
+
break;
|
|
1182
|
+
case "n":
|
|
1183
|
+
case "ne":
|
|
1184
|
+
case "nw":
|
|
1185
|
+
angl =
|
|
1186
|
+
Math.atan2(currentVertex[0].y - currentVertex[2].y, currentVertex[0].x - currentVertex[2].x) * ONE_RAD;
|
|
1187
|
+
}
|
|
1104
1188
|
switch (dir) {
|
|
1105
1189
|
case "s":
|
|
1106
1190
|
h = pl2;
|
|
@@ -1108,17 +1192,63 @@
|
|
|
1108
1192
|
case "e":
|
|
1109
1193
|
w = pl1;
|
|
1110
1194
|
break;
|
|
1195
|
+
case "n":
|
|
1196
|
+
h = pl2;
|
|
1197
|
+
if (angl === 90) {
|
|
1198
|
+
h = newY - currentVertex[2].y;
|
|
1199
|
+
}
|
|
1200
|
+
break;
|
|
1201
|
+
case "w":
|
|
1202
|
+
w = pl1;
|
|
1203
|
+
if (angl === 0) {
|
|
1204
|
+
w = newX - currentVertex[1].x;
|
|
1205
|
+
}
|
|
1206
|
+
break;
|
|
1207
|
+
case "nw":
|
|
1208
|
+
w = pl1;
|
|
1209
|
+
h = pl2;
|
|
1210
|
+
if (matrixInfo.angle === 180) {
|
|
1211
|
+
w = newX - currentVertex[3].x;
|
|
1212
|
+
h = newY - currentVertex[3].y;
|
|
1213
|
+
}
|
|
1214
|
+
break;
|
|
1111
1215
|
case "se":
|
|
1216
|
+
case "sw":
|
|
1217
|
+
case "ne":
|
|
1112
1218
|
w = pl1;
|
|
1113
1219
|
h = pl2;
|
|
1114
1220
|
break;
|
|
1221
|
+
}
|
|
1222
|
+
if (minHeight && h < minHeight)
|
|
1223
|
+
h = minHeight;
|
|
1224
|
+
if (maxHeight && h > maxHeight)
|
|
1225
|
+
h = maxHeight;
|
|
1226
|
+
if (minWidth && w < minWidth) {
|
|
1227
|
+
w = minWidth;
|
|
1228
|
+
}
|
|
1229
|
+
if (maxWidth && w > maxWidth)
|
|
1230
|
+
w = maxWidth;
|
|
1231
|
+
let hLine, wLine;
|
|
1232
|
+
switch (dir) {
|
|
1233
|
+
case "s":
|
|
1234
|
+
hLine = { p1: currentVertex[1], p2: currentVertex[0] };
|
|
1235
|
+
h = limitWH(newX, newY, hLine, h, minHeight);
|
|
1236
|
+
break;
|
|
1237
|
+
case "e":
|
|
1238
|
+
wLine = { p1: currentVertex[0], p2: currentVertex[2] };
|
|
1239
|
+
w = limitWH(newX, newY, wLine, w, minWidth);
|
|
1240
|
+
break;
|
|
1241
|
+
case "se":
|
|
1242
|
+
wLine = { p1: currentVertex[0], p2: currentVertex[2] };
|
|
1243
|
+
hLine = { p1: currentVertex[1], p2: currentVertex[0] };
|
|
1244
|
+
w = limitWH(newX, newY, wLine, w, minWidth);
|
|
1245
|
+
h = limitWH(newX, newY, hLine, h, minHeight);
|
|
1246
|
+
break;
|
|
1115
1247
|
case "n":
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
Math.atan2(currentVertex[0].y - currentVertex[2].y, currentVertex[0].x - currentVertex[2].x) * ONE_RAD;
|
|
1248
|
+
hLine = { p1: currentVertex[2], p2: currentVertex[3] };
|
|
1249
|
+
h = limitWH(newX, newY, hLine, h, minHeight);
|
|
1119
1250
|
let plh;
|
|
1120
1251
|
if (angl === 90) {
|
|
1121
|
-
h = newY - currentVertex[2].y;
|
|
1122
1252
|
x = currentVertex[2].x;
|
|
1123
1253
|
y = newY;
|
|
1124
1254
|
}
|
|
@@ -1134,12 +1264,10 @@
|
|
|
1134
1264
|
}
|
|
1135
1265
|
break;
|
|
1136
1266
|
case "w":
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
Math.atan2(currentVertex[0].y - currentVertex[1].y, currentVertex[0].x - currentVertex[1].x) * ONE_RAD;
|
|
1267
|
+
wLine = { p1: currentVertex[3], p2: currentVertex[1] };
|
|
1268
|
+
w = limitWH(newX, newY, wLine, w, minWidth);
|
|
1140
1269
|
let plw;
|
|
1141
1270
|
if (angl === 0) {
|
|
1142
|
-
w = newX - currentVertex[1].x;
|
|
1143
1271
|
x = newX;
|
|
1144
1272
|
y = currentVertex[1].y;
|
|
1145
1273
|
}
|
|
@@ -1155,20 +1283,59 @@
|
|
|
1155
1283
|
}
|
|
1156
1284
|
break;
|
|
1157
1285
|
case "nw":
|
|
1158
|
-
|
|
1159
|
-
|
|
1286
|
+
wLine = { p1: currentVertex[3], p2: currentVertex[1] };
|
|
1287
|
+
hLine = { p1: currentVertex[2], p2: currentVertex[3] };
|
|
1288
|
+
w = limitWH(newX, newY, wLine, w, minWidth);
|
|
1289
|
+
h = limitWH(newX, newY, hLine, h, minHeight);
|
|
1160
1290
|
x = newX;
|
|
1161
1291
|
y = newY;
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1292
|
+
let cv2x = currentVertex[2].x;
|
|
1293
|
+
let cv2y = currentVertex[2].y;
|
|
1294
|
+
let cv1x = currentVertex[1].x;
|
|
1295
|
+
let cv1y = currentVertex[1].y;
|
|
1296
|
+
let v32n = normalizeVector(cv2x - currentVertex[3].x, cv2y - currentVertex[3].y);
|
|
1297
|
+
v32n.x *= minWidth;
|
|
1298
|
+
v32n.y *= minWidth;
|
|
1299
|
+
let v10n = normalizeVector(currentVertex[0].x - cv1x, currentVertex[0].y - cv1y);
|
|
1300
|
+
v10n.x *= minWidth;
|
|
1301
|
+
v10n.y *= minWidth;
|
|
1302
|
+
let wp1 = { x: wLine.p1.x + v32n.x, y: wLine.p1.y + v32n.y };
|
|
1303
|
+
let wp2 = { x: wLine.p2.x + v10n.x, y: wLine.p2.y + v10n.y };
|
|
1304
|
+
let invalid = (wp2.x - wp1.x) * (newY - wp1.y) -
|
|
1305
|
+
(wp2.y - wp1.y) * (newX - wp1.x) >
|
|
1306
|
+
0;
|
|
1307
|
+
if (invalid) {
|
|
1308
|
+
let v20n = normalizeVector(currentVertex[0].x - cv2x, currentVertex[0].y - cv2y);
|
|
1309
|
+
v20n.x *= h;
|
|
1310
|
+
v20n.y *= h;
|
|
1311
|
+
x = wp1.x + v20n.x;
|
|
1312
|
+
y = wp1.y + v20n.y;
|
|
1313
|
+
}
|
|
1314
|
+
let v31n = normalizeVector(cv1x - currentVertex[3].x, cv1y - currentVertex[3].y);
|
|
1315
|
+
v31n.x *= minHeight;
|
|
1316
|
+
v31n.y *= minHeight;
|
|
1317
|
+
let v20n = normalizeVector(currentVertex[0].x - cv2x, currentVertex[0].y - cv2y);
|
|
1318
|
+
v20n.x *= minHeight;
|
|
1319
|
+
v20n.y *= minHeight;
|
|
1320
|
+
let hp1 = { x: hLine.p1.x + v31n.x, y: hLine.p1.y + v31n.y };
|
|
1321
|
+
let hp2 = { x: hLine.p2.x + v20n.x, y: hLine.p2.y + v20n.y };
|
|
1322
|
+
invalid =
|
|
1323
|
+
(hp2.x - hp1.x) * (newY - hp1.y) -
|
|
1324
|
+
(hp2.y - hp1.y) * (newX - hp1.x) >
|
|
1325
|
+
0;
|
|
1326
|
+
if (invalid) {
|
|
1327
|
+
let v10n = normalizeVector(currentVertex[0].x - cv1x, currentVertex[0].y - cv1y);
|
|
1328
|
+
v10n.x *= w;
|
|
1329
|
+
v10n.y *= w;
|
|
1330
|
+
x = hp2.x + v10n.x;
|
|
1331
|
+
y = hp2.y + v10n.y;
|
|
1165
1332
|
}
|
|
1166
1333
|
break;
|
|
1167
1334
|
case "sw":
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1335
|
+
wLine = { p1: currentVertex[3], p2: currentVertex[1] };
|
|
1336
|
+
hLine = { p1: currentVertex[1], p2: currentVertex[0] };
|
|
1337
|
+
w = limitWH(newX, newY, wLine, w, minWidth);
|
|
1338
|
+
h = limitWH(newX, newY, hLine, h, minHeight);
|
|
1172
1339
|
let plw1;
|
|
1173
1340
|
if (angl === 0) {
|
|
1174
1341
|
x = newX;
|
|
@@ -1186,10 +1353,10 @@
|
|
|
1186
1353
|
}
|
|
1187
1354
|
break;
|
|
1188
1355
|
case "ne":
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1356
|
+
wLine = { p1: currentVertex[0], p2: currentVertex[2] };
|
|
1357
|
+
hLine = { p1: currentVertex[2], p2: currentVertex[3] };
|
|
1358
|
+
w = limitWH(newX, newY, wLine, w, minWidth);
|
|
1359
|
+
h = limitWH(newX, newY, hLine, h, minHeight);
|
|
1193
1360
|
let plne;
|
|
1194
1361
|
if (angl === 0) {
|
|
1195
1362
|
x = newX;
|
|
@@ -1207,19 +1374,6 @@
|
|
|
1207
1374
|
}
|
|
1208
1375
|
break;
|
|
1209
1376
|
}
|
|
1210
|
-
if (changeW) {
|
|
1211
|
-
console.log(minWidth, 'xxxxxx', w);
|
|
1212
|
-
if (minWidth && w < minWidth)
|
|
1213
|
-
w = minWidth;
|
|
1214
|
-
if (maxWidth && w > maxWidth)
|
|
1215
|
-
w = maxWidth;
|
|
1216
|
-
}
|
|
1217
|
-
if (changeH) {
|
|
1218
|
-
if (minHeight && h < minHeight)
|
|
1219
|
-
h = minHeight;
|
|
1220
|
-
if (maxHeight && h > maxHeight)
|
|
1221
|
-
h = maxHeight;
|
|
1222
|
-
}
|
|
1223
1377
|
if (aspectRatio) {
|
|
1224
1378
|
if (changeW) {
|
|
1225
1379
|
style.width = w + "px";
|
|
@@ -1244,19 +1398,22 @@
|
|
|
1244
1398
|
}
|
|
1245
1399
|
}
|
|
1246
1400
|
if (changeY) {
|
|
1247
|
-
transform.
|
|
1401
|
+
transform.moveTo(x, y + sY);
|
|
1248
1402
|
}
|
|
1249
1403
|
if (changeX) {
|
|
1250
|
-
transform.
|
|
1404
|
+
transform.moveTo(x + sX, y);
|
|
1251
1405
|
}
|
|
1252
1406
|
lastX = x;
|
|
1253
1407
|
lastY = y;
|
|
1254
1408
|
currentW = w;
|
|
1255
1409
|
currentH = h;
|
|
1256
1410
|
if (onResize && onResize.call) {
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1411
|
+
onResize.call;
|
|
1412
|
+
const panelRect = getRectInContainer(panel, panel.parentElement, matrixInfo);
|
|
1413
|
+
let centerX = Math.round(panelRect.x + panelRect.w / 2);
|
|
1414
|
+
let centerY = Math.round(panelRect.y + panelRect.h / 2);
|
|
1415
|
+
let sx = Math.round(centerX - originW / 2);
|
|
1416
|
+
let sy = Math.round(centerY - originH / 2);
|
|
1260
1417
|
onResize.call(uiik, {
|
|
1261
1418
|
w,
|
|
1262
1419
|
h,
|
|
@@ -1268,7 +1425,7 @@
|
|
|
1268
1425
|
sx: sx,
|
|
1269
1426
|
sy: sy,
|
|
1270
1427
|
deg: matrixInfo.angle,
|
|
1271
|
-
transform
|
|
1428
|
+
transform,
|
|
1272
1429
|
}, ev);
|
|
1273
1430
|
}
|
|
1274
1431
|
});
|
|
@@ -1283,37 +1440,31 @@
|
|
|
1283
1440
|
moveTo(panel, lastX / matrixInfo.scale, lastY / matrixInfo.scale);
|
|
1284
1441
|
resize(transform, panelStyle, parseFloat(ghostNode.style.width), parseFloat(ghostNode.style.height));
|
|
1285
1442
|
}
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
let
|
|
1443
|
+
if (setOrigin)
|
|
1444
|
+
panel.style.transformOrigin = originalTransformOrigin;
|
|
1445
|
+
let { x: centerX, y: centerY } = getRectCenter(panel, matrixInfo);
|
|
1446
|
+
let sx = Math.round(centerX - currentW / 2);
|
|
1447
|
+
let sy = Math.round(centerY - currentH / 2);
|
|
1291
1448
|
const deg = matrixInfo.angle * ONE_ANG;
|
|
1292
1449
|
const currentVertex = calcVertex(currentW, currentH, centerX, centerY, sx, sy, deg);
|
|
1293
|
-
if (
|
|
1294
|
-
if (
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
if (changeX || changeY) {
|
|
1304
|
-
transform.moveTo(transform.x - (currentVertex[0].x - lastX), transform.y - (currentVertex[0].y - lastY));
|
|
1305
|
-
}
|
|
1306
|
-
else {
|
|
1307
|
-
transform.moveTo(transform.x -
|
|
1308
|
-
(currentVertex[0].x - vertexBeforeTransform[0].x), transform.y -
|
|
1309
|
-
(currentVertex[0].y - vertexBeforeTransform[0].y));
|
|
1450
|
+
if (setOrigin) {
|
|
1451
|
+
if (panel instanceof HTMLElement) {
|
|
1452
|
+
if (changeX || changeY) {
|
|
1453
|
+
transform.moveTo(transform.x - (currentVertex[0].x - lastX), transform.y - (currentVertex[0].y - lastY));
|
|
1454
|
+
}
|
|
1455
|
+
else {
|
|
1456
|
+
transform.moveTo(transform.x -
|
|
1457
|
+
(currentVertex[0].x - vertexBeforeTransform[0].x), transform.y -
|
|
1458
|
+
(currentVertex[0].y - vertexBeforeTransform[0].y));
|
|
1459
|
+
}
|
|
1310
1460
|
}
|
|
1311
1461
|
}
|
|
1312
1462
|
handle.classList.remove(CLASS_RESIZABLE_HANDLE_ACTIVE);
|
|
1313
|
-
onEnd &&
|
|
1463
|
+
onEnd &&
|
|
1464
|
+
onEnd.call(uiik, { w: currentW, h: currentH, transform }, ev);
|
|
1314
1465
|
});
|
|
1315
1466
|
}, {
|
|
1316
|
-
threshold: THRESHOLD
|
|
1467
|
+
threshold: THRESHOLD,
|
|
1317
1468
|
lockPage: true,
|
|
1318
1469
|
});
|
|
1319
1470
|
}
|
|
@@ -1347,6 +1498,15 @@
|
|
|
1347
1498
|
});
|
|
1348
1499
|
}
|
|
1349
1500
|
}
|
|
1501
|
+
function limitWH(newX, newY, line, value, minValue) {
|
|
1502
|
+
let p1 = line.p1;
|
|
1503
|
+
let p2 = line.p2;
|
|
1504
|
+
let invalid = (p2.x - p1.x) * (newY - p1.y) - (p2.y - p1.y) * (newX - p1.x) > 0;
|
|
1505
|
+
if (invalid) {
|
|
1506
|
+
return minValue;
|
|
1507
|
+
}
|
|
1508
|
+
return value;
|
|
1509
|
+
}
|
|
1350
1510
|
function resize(transform, style, w, h) {
|
|
1351
1511
|
if (transform.el instanceof SVGGraphicsElement) {
|
|
1352
1512
|
if (is.isDefined(w))
|
|
@@ -1376,14 +1536,15 @@
|
|
|
1376
1536
|
super(els, object.assign({
|
|
1377
1537
|
containment: false,
|
|
1378
1538
|
watch: true,
|
|
1379
|
-
threshold:
|
|
1539
|
+
threshold: THRESHOLD,
|
|
1380
1540
|
ghost: false,
|
|
1381
1541
|
direction: "",
|
|
1382
1542
|
scroll: true,
|
|
1543
|
+
useTransform: true,
|
|
1383
1544
|
snapOptions: {
|
|
1384
1545
|
tolerance: 10,
|
|
1385
1546
|
},
|
|
1386
|
-
self:
|
|
1547
|
+
self: false,
|
|
1387
1548
|
}, opts));
|
|
1388
1549
|
_Draggable_instances.add(this);
|
|
1389
1550
|
_Draggable_handleMap.set(this, new WeakMap());
|
|
@@ -1438,7 +1599,7 @@
|
|
|
1438
1599
|
let draggableList = this.ele;
|
|
1439
1600
|
const eleString = this.eleString;
|
|
1440
1601
|
const initStyle = __classPrivateFieldGet(this, _Draggable_instances, "m", _Draggable_initStyle).bind(this);
|
|
1441
|
-
this.addPointerDown(bindTarget, ({ ev,
|
|
1602
|
+
this.addPointerDown(bindTarget, ({ ev, currentCStyle, onPointerStart, onPointerMove, onPointerEnd, }) => {
|
|
1442
1603
|
var _a;
|
|
1443
1604
|
let t = ev.target;
|
|
1444
1605
|
if (!t)
|
|
@@ -1447,7 +1608,7 @@
|
|
|
1447
1608
|
draggableList = bindTarget.querySelectorAll(eleString);
|
|
1448
1609
|
initStyle(draggableList);
|
|
1449
1610
|
}
|
|
1450
|
-
let findRs =
|
|
1611
|
+
let findRs = tree.closest(t, (node) => collection.includes(draggableList, node), "parentNode");
|
|
1451
1612
|
if (!findRs)
|
|
1452
1613
|
return true;
|
|
1453
1614
|
const dragDom = findRs;
|
|
@@ -1456,33 +1617,25 @@
|
|
|
1456
1617
|
return true;
|
|
1457
1618
|
}
|
|
1458
1619
|
if (opts.self && dragDom !== t)
|
|
1459
|
-
return;
|
|
1620
|
+
return true;
|
|
1460
1621
|
const onPointerDown = opts.onPointerDown;
|
|
1461
|
-
if (onPointerDown &&
|
|
1622
|
+
if (onPointerDown &&
|
|
1623
|
+
onPointerDown({ draggable: dragDom }, ev) === false)
|
|
1462
1624
|
return true;
|
|
1463
1625
|
const filter = opts.filter;
|
|
1464
1626
|
if (filter) {
|
|
1465
|
-
if (collection.some(dragDom.querySelectorAll(filter), ele => ele.contains(t)))
|
|
1627
|
+
if (collection.some(dragDom.querySelectorAll(filter), (ele) => ele.contains(t)))
|
|
1466
1628
|
return true;
|
|
1467
1629
|
}
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
let
|
|
1473
|
-
let offsetPointY = offsetXy.y;
|
|
1474
|
-
const matrixInfo = getMatrixInfo(dragDom);
|
|
1475
|
-
const currentXy = getPointInContainer(ev, offsetParent, offsetParentRect, offsetParentCStyle);
|
|
1476
|
-
const matrixInfoParent = getMatrixInfo(offsetParent);
|
|
1477
|
-
offsetPointX = offsetPointX / (matrixInfo.scale * matrixInfoParent.scale);
|
|
1478
|
-
offsetPointY = offsetPointY / (matrixInfo.scale * matrixInfoParent.scale);
|
|
1479
|
-
if (matrixInfo.angle != 0) {
|
|
1480
|
-
offsetPointX = currentXy.x - matrixInfo.x;
|
|
1481
|
-
offsetPointY = currentXy.y - matrixInfo.y;
|
|
1482
|
-
}
|
|
1630
|
+
let offsetParent;
|
|
1631
|
+
let offsetParentRect;
|
|
1632
|
+
let offsetParentCStyle;
|
|
1633
|
+
let offsetPointX = 0;
|
|
1634
|
+
let offsetPointY = 0;
|
|
1483
1635
|
const inContainer = !!container;
|
|
1484
1636
|
const ghost = opts.ghost;
|
|
1485
1637
|
const ghostClass = opts.ghostClass;
|
|
1638
|
+
const ghostTo = opts.ghostTo;
|
|
1486
1639
|
const direction = opts.direction;
|
|
1487
1640
|
const onStart = opts.onStart;
|
|
1488
1641
|
const onDrag = opts.onDrag;
|
|
@@ -1490,64 +1643,25 @@
|
|
|
1490
1643
|
const onClone = opts.onClone;
|
|
1491
1644
|
const originalZIndex = currentCStyle.zIndex;
|
|
1492
1645
|
let zIndex = opts.zIndex || originalZIndex;
|
|
1493
|
-
const classes = opts.classes ||
|
|
1646
|
+
const classes = opts.classes || "";
|
|
1494
1647
|
const group = opts.group;
|
|
1495
|
-
if (group) {
|
|
1496
|
-
let i = -1;
|
|
1497
|
-
collection.each(DRAGGER_GROUPS[group], el => {
|
|
1498
|
-
const z = parseInt(currentCStyle.zIndex) || 0;
|
|
1499
|
-
if (z > i)
|
|
1500
|
-
i = z;
|
|
1501
|
-
});
|
|
1502
|
-
zIndex = i + 1;
|
|
1503
|
-
}
|
|
1504
1648
|
const scroll = opts.scroll;
|
|
1505
1649
|
const scrollSpeed = opts.scrollSpeed || 10;
|
|
1506
1650
|
let gridX, gridY;
|
|
1507
|
-
const grid = opts.grid;
|
|
1508
|
-
if (is.isArray(grid)) {
|
|
1509
|
-
gridX = grid[0];
|
|
1510
|
-
gridY = grid[1];
|
|
1511
|
-
}
|
|
1512
|
-
else if (is.isNumber(grid)) {
|
|
1513
|
-
gridX = gridY = grid;
|
|
1514
|
-
}
|
|
1515
1651
|
const snapOn = opts.snap;
|
|
1516
1652
|
let snappable;
|
|
1517
1653
|
const snapTolerance = ((_a = opts.snapOptions) === null || _a === void 0 ? void 0 : _a.tolerance) || 10;
|
|
1518
1654
|
const onSnap = opts.onSnap;
|
|
1519
1655
|
let lastSnapDirY = "", lastSnapDirX = "";
|
|
1520
1656
|
let lastSnapping = "";
|
|
1521
|
-
if (snapOn) {
|
|
1522
|
-
snappable = collection.map((container || document).querySelectorAll(snapOn), (el) => {
|
|
1523
|
-
const { x, y, w, h } = getRectInContainer(el, offsetParent);
|
|
1524
|
-
return {
|
|
1525
|
-
x1: x,
|
|
1526
|
-
y1: y,
|
|
1527
|
-
x2: x + w,
|
|
1528
|
-
y2: y + h,
|
|
1529
|
-
el: el,
|
|
1530
|
-
};
|
|
1531
|
-
});
|
|
1532
|
-
}
|
|
1533
1657
|
const dragDomRect = dragDom.getBoundingClientRect();
|
|
1534
|
-
|
|
1535
|
-
|
|
1658
|
+
let originW;
|
|
1659
|
+
let originH;
|
|
1536
1660
|
let minX = 0;
|
|
1537
1661
|
let minY = 0;
|
|
1538
1662
|
let maxX = 0;
|
|
1539
1663
|
let maxY = 0;
|
|
1540
|
-
let
|
|
1541
|
-
let originOffY = 0;
|
|
1542
|
-
if (inContainer) {
|
|
1543
|
-
maxX = container.scrollWidth - originW;
|
|
1544
|
-
maxY = container.scrollHeight - originH;
|
|
1545
|
-
}
|
|
1546
|
-
if (maxX < 0)
|
|
1547
|
-
maxX = 0;
|
|
1548
|
-
if (maxY < 0)
|
|
1549
|
-
maxY = 0;
|
|
1550
|
-
let copyNode;
|
|
1664
|
+
let ghostNode;
|
|
1551
1665
|
let transform;
|
|
1552
1666
|
let timer = null;
|
|
1553
1667
|
let toLeft = false;
|
|
@@ -1555,45 +1669,114 @@
|
|
|
1555
1669
|
let toRight = false;
|
|
1556
1670
|
let toBottom = false;
|
|
1557
1671
|
let endX = 0, endY = 0;
|
|
1672
|
+
let startMatrixInfo;
|
|
1673
|
+
let startPointXy;
|
|
1558
1674
|
onPointerStart(function (args) {
|
|
1559
|
-
var _a;
|
|
1560
1675
|
const { ev } = args;
|
|
1676
|
+
offsetParent =
|
|
1677
|
+
dragDom instanceof HTMLElement
|
|
1678
|
+
? dragDom.offsetParent || document.body
|
|
1679
|
+
: dragDom.ownerSVGElement;
|
|
1680
|
+
offsetParentRect = offsetParent.getBoundingClientRect();
|
|
1681
|
+
offsetParentCStyle = window.getComputedStyle(offsetParent);
|
|
1682
|
+
startMatrixInfo = getMatrixInfo(dragDom, true);
|
|
1683
|
+
const offsetXy = getPointInContainer(ev, dragDom, undefined, undefined, startMatrixInfo);
|
|
1684
|
+
offsetPointX = offsetXy.x;
|
|
1685
|
+
offsetPointY = offsetXy.y;
|
|
1686
|
+
startPointXy = getPointInContainer(ev, offsetParent, offsetParentRect, offsetParentCStyle, startMatrixInfo);
|
|
1687
|
+
originW =
|
|
1688
|
+
dragDomRect.width;
|
|
1689
|
+
originH =
|
|
1690
|
+
dragDomRect.height;
|
|
1691
|
+
if (dragDom instanceof SVGGElement || dragDom instanceof SVGSVGElement) {
|
|
1692
|
+
let bbox = dragDom.getBBox();
|
|
1693
|
+
offsetPointX += bbox.x;
|
|
1694
|
+
offsetPointY += bbox.y;
|
|
1695
|
+
}
|
|
1696
|
+
if (startMatrixInfo.angle != 0) {
|
|
1697
|
+
let { sx, sy } = getCenterXy(dragDom);
|
|
1698
|
+
offsetPointX = startPointXy.x - sx;
|
|
1699
|
+
offsetPointY = startPointXy.y - sy;
|
|
1700
|
+
}
|
|
1701
|
+
if (group) {
|
|
1702
|
+
let i = -1;
|
|
1703
|
+
collection.each(DRAGGER_GROUPS[group], (el) => {
|
|
1704
|
+
const z = parseInt(currentCStyle.zIndex) || 0;
|
|
1705
|
+
if (z > i)
|
|
1706
|
+
i = z;
|
|
1707
|
+
});
|
|
1708
|
+
zIndex = i + 1;
|
|
1709
|
+
}
|
|
1710
|
+
const grid = opts.grid;
|
|
1711
|
+
if (is.isArray(grid)) {
|
|
1712
|
+
gridX = grid[0];
|
|
1713
|
+
gridY = grid[1];
|
|
1714
|
+
}
|
|
1715
|
+
else if (is.isNumber(grid)) {
|
|
1716
|
+
gridX = gridY = grid;
|
|
1717
|
+
}
|
|
1718
|
+
if (snapOn) {
|
|
1719
|
+
snappable = collection.map((container || document).querySelectorAll(snapOn), (el) => {
|
|
1720
|
+
const { x, y, w, h } = getRectInContainer(el, offsetParent);
|
|
1721
|
+
return {
|
|
1722
|
+
x1: x,
|
|
1723
|
+
y1: y,
|
|
1724
|
+
x2: x + w,
|
|
1725
|
+
y2: y + h,
|
|
1726
|
+
el: el,
|
|
1727
|
+
};
|
|
1728
|
+
});
|
|
1729
|
+
}
|
|
1730
|
+
if (inContainer) {
|
|
1731
|
+
maxX =
|
|
1732
|
+
container.scrollWidth - originW / startMatrixInfo.scale;
|
|
1733
|
+
maxY =
|
|
1734
|
+
container.scrollHeight - originH / startMatrixInfo.scale;
|
|
1735
|
+
}
|
|
1736
|
+
if (maxX < 0)
|
|
1737
|
+
maxX = 0;
|
|
1738
|
+
if (maxY < 0)
|
|
1739
|
+
maxY = 0;
|
|
1561
1740
|
if (ghost) {
|
|
1562
1741
|
if (is.isFunction(ghost)) {
|
|
1563
|
-
|
|
1742
|
+
ghostNode = ghost(dragDom);
|
|
1564
1743
|
}
|
|
1565
1744
|
else {
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1745
|
+
ghostNode = dragDom.cloneNode(true);
|
|
1746
|
+
ghostNode.style.opacity = "0.3";
|
|
1747
|
+
ghostNode.style.pointerEvents = "none";
|
|
1748
|
+
ghostNode.style.position = "absolute";
|
|
1570
1749
|
}
|
|
1571
|
-
|
|
1750
|
+
ghostNode.style.zIndex = zIndex + "";
|
|
1572
1751
|
if (ghostClass) {
|
|
1573
|
-
|
|
1752
|
+
ghostNode.classList.add(...array.compact(string.split(ghostClass, " ")));
|
|
1574
1753
|
}
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1754
|
+
ghostNode.classList.add(...array.compact(string.split(classes, " ")));
|
|
1755
|
+
ghostNode.classList.toggle(CLASS_DRAGGABLE_GHOST, true);
|
|
1756
|
+
let ghostParent = ghostTo ? (is.isString(ghostTo) ? document.querySelector(ghostTo) : ghostTo) : dragDom.parentNode;
|
|
1757
|
+
ghostParent === null || ghostParent === void 0 ? void 0 : ghostParent.appendChild(ghostNode);
|
|
1758
|
+
transform = wrapper(ghostNode, opts.useTransform);
|
|
1759
|
+
onClone && onClone({ clone: ghostNode }, ev);
|
|
1580
1760
|
}
|
|
1581
1761
|
else {
|
|
1582
|
-
transform = wrapper(dragDom);
|
|
1762
|
+
transform = wrapper(dragDom, opts.useTransform);
|
|
1583
1763
|
}
|
|
1584
|
-
dragDom.classList.add(...array.compact(string.split(classes,
|
|
1585
|
-
if (!
|
|
1586
|
-
dragDom.style.zIndex = zIndex +
|
|
1764
|
+
dragDom.classList.add(...array.compact(string.split(classes, " ")));
|
|
1765
|
+
if (!ghostNode)
|
|
1766
|
+
dragDom.style.zIndex = zIndex + "";
|
|
1587
1767
|
dragDom.classList.toggle(CLASS_DRAGGABLE_ACTIVE, true);
|
|
1588
|
-
onStart &&
|
|
1589
|
-
|
|
1768
|
+
onStart &&
|
|
1769
|
+
onStart({ draggable: dragDom, x: startPointXy.x, y: startPointXy.y, transform }, ev);
|
|
1770
|
+
const customEv = new Event("uii-dragactive", {
|
|
1771
|
+
bubbles: true,
|
|
1772
|
+
cancelable: false,
|
|
1773
|
+
});
|
|
1590
1774
|
dragDom.dispatchEvent(customEv);
|
|
1591
1775
|
});
|
|
1592
1776
|
onPointerMove((args) => {
|
|
1593
1777
|
const { ev, pointX, pointY, offX, offY } = args;
|
|
1594
|
-
|
|
1595
|
-
let
|
|
1596
|
-
let newY = currentXy.y;
|
|
1778
|
+
let newX = startPointXy.x + offX;
|
|
1779
|
+
let newY = startPointXy.y + offY;
|
|
1597
1780
|
if (scroll) {
|
|
1598
1781
|
const lX = pointX - offsetParentRect.x;
|
|
1599
1782
|
const lY = pointY - offsetParentRect.y;
|
|
@@ -1603,9 +1786,7 @@
|
|
|
1603
1786
|
toTop = lY < EDGE_THRESHOLD;
|
|
1604
1787
|
toRight = rX < EDGE_THRESHOLD;
|
|
1605
1788
|
toBottom = rY < EDGE_THRESHOLD;
|
|
1606
|
-
if (toLeft || toTop
|
|
1607
|
-
||
|
|
1608
|
-
toRight || toBottom) {
|
|
1789
|
+
if (toLeft || toTop || toRight || toBottom) {
|
|
1609
1790
|
if (!timer) {
|
|
1610
1791
|
timer = setInterval(() => {
|
|
1611
1792
|
if (toLeft) {
|
|
@@ -1637,17 +1818,17 @@
|
|
|
1637
1818
|
y = ((y / gridY) >> 0) * gridY;
|
|
1638
1819
|
}
|
|
1639
1820
|
if (inContainer) {
|
|
1640
|
-
if (
|
|
1641
|
-
x =
|
|
1821
|
+
if (x < minX) {
|
|
1822
|
+
x = 0;
|
|
1642
1823
|
}
|
|
1643
|
-
if (
|
|
1644
|
-
y =
|
|
1824
|
+
if (y < minY) {
|
|
1825
|
+
y = 0;
|
|
1645
1826
|
}
|
|
1646
|
-
if (
|
|
1647
|
-
x = maxX
|
|
1827
|
+
if (x > maxX) {
|
|
1828
|
+
x = maxX;
|
|
1648
1829
|
}
|
|
1649
|
-
if (
|
|
1650
|
-
y = maxY
|
|
1830
|
+
if (y > maxY) {
|
|
1831
|
+
y = maxY;
|
|
1651
1832
|
}
|
|
1652
1833
|
}
|
|
1653
1834
|
let canDrag = true;
|
|
@@ -1720,7 +1901,7 @@
|
|
|
1720
1901
|
if (onSnap && lastSnapping !== lastSnapDirX + "" + lastSnapDirY) {
|
|
1721
1902
|
setTimeout(() => {
|
|
1722
1903
|
onSnap({
|
|
1723
|
-
el:
|
|
1904
|
+
el: ghostNode || dragDom,
|
|
1724
1905
|
targetH: targetX,
|
|
1725
1906
|
targetV: targetY,
|
|
1726
1907
|
dirH: snapDirX,
|
|
@@ -1742,7 +1923,7 @@
|
|
|
1742
1923
|
oy: offY,
|
|
1743
1924
|
x: x,
|
|
1744
1925
|
y: y,
|
|
1745
|
-
transform
|
|
1926
|
+
transform,
|
|
1746
1927
|
}, ev) === false) {
|
|
1747
1928
|
canDrag = false;
|
|
1748
1929
|
endX = x;
|
|
@@ -1764,7 +1945,7 @@
|
|
|
1764
1945
|
}
|
|
1765
1946
|
});
|
|
1766
1947
|
onPointerEnd((args) => {
|
|
1767
|
-
var _a
|
|
1948
|
+
var _a;
|
|
1768
1949
|
const { ev, currentStyle } = args;
|
|
1769
1950
|
if (scroll) {
|
|
1770
1951
|
if (timer) {
|
|
@@ -1772,25 +1953,32 @@
|
|
|
1772
1953
|
timer = null;
|
|
1773
1954
|
}
|
|
1774
1955
|
}
|
|
1775
|
-
dragDom.classList.remove(...array.compact(string.split(classes,
|
|
1956
|
+
dragDom.classList.remove(...array.compact(string.split(classes, " ")));
|
|
1776
1957
|
currentStyle.zIndex = originalZIndex;
|
|
1777
1958
|
dragDom.classList.remove(CLASS_DRAGGABLE_ACTIVE);
|
|
1778
1959
|
let moveToGhost = true;
|
|
1779
1960
|
if (onEnd) {
|
|
1780
|
-
moveToGhost =
|
|
1961
|
+
moveToGhost =
|
|
1962
|
+
onEnd({ draggable: dragDom, x: endX, y: endY, transform }, ev) ===
|
|
1963
|
+
false
|
|
1964
|
+
? false
|
|
1965
|
+
: true;
|
|
1781
1966
|
}
|
|
1782
|
-
const customEv = new Event("uii-dragdeactive", {
|
|
1967
|
+
const customEv = new Event("uii-dragdeactive", {
|
|
1968
|
+
bubbles: true,
|
|
1969
|
+
cancelable: false,
|
|
1970
|
+
});
|
|
1783
1971
|
dragDom.dispatchEvent(customEv);
|
|
1784
1972
|
if (ghost) {
|
|
1785
|
-
(
|
|
1973
|
+
(_a = ghostNode.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(ghostNode);
|
|
1786
1974
|
if (moveToGhost !== false) {
|
|
1787
|
-
wrapper(dragDom).moveTo(transform.x, transform.y);
|
|
1975
|
+
wrapper(dragDom, opts.useTransform).moveTo(transform.x, transform.y);
|
|
1788
1976
|
}
|
|
1789
1977
|
}
|
|
1790
1978
|
});
|
|
1791
1979
|
}, {
|
|
1792
1980
|
threshold: this.opts.threshold || 0,
|
|
1793
|
-
lockPage: true
|
|
1981
|
+
lockPage: true,
|
|
1794
1982
|
});
|
|
1795
1983
|
}
|
|
1796
1984
|
onOptionChanged(opts) {
|
|
@@ -1819,10 +2007,10 @@
|
|
|
1819
2007
|
const ee = __classPrivateFieldGet(this, _Draggable_handleMap, "f").get(el) || el;
|
|
1820
2008
|
ee.classList.toggle(CLASS_DRAGGABLE_HANDLE, true);
|
|
1821
2009
|
if (!is.isUndefined(this.opts.cursor)) {
|
|
1822
|
-
el.style.cursor = this.opts.cursor.default ||
|
|
2010
|
+
el.style.cursor = this.opts.cursor.default || "move";
|
|
1823
2011
|
if (is.isDefined(this.opts.cursor.over)) {
|
|
1824
2012
|
el.dataset.cursorOver = this.opts.cursor.over;
|
|
1825
|
-
el.dataset.cursorActive = this.opts.cursor.active ||
|
|
2013
|
+
el.dataset.cursorActive = this.opts.cursor.active || "move";
|
|
1826
2014
|
}
|
|
1827
2015
|
}
|
|
1828
2016
|
});
|
|
@@ -1846,7 +2034,7 @@
|
|
|
1846
2034
|
this.registerEvent(droppable, "mouseenter", (e) => {
|
|
1847
2035
|
if (!__classPrivateFieldGet(this, _Droppable_active, "f"))
|
|
1848
2036
|
return;
|
|
1849
|
-
if (
|
|
2037
|
+
if (__classPrivateFieldGet(this, _Droppable_active, "f") === droppable)
|
|
1850
2038
|
return;
|
|
1851
2039
|
if (opts.hoverClass) {
|
|
1852
2040
|
collection.each(string.split(opts.hoverClass, ' '), cls => {
|
|
@@ -1861,7 +2049,7 @@
|
|
|
1861
2049
|
this.registerEvent(droppable, "mouseleave", (e) => {
|
|
1862
2050
|
if (!__classPrivateFieldGet(this, _Droppable_active, "f"))
|
|
1863
2051
|
return;
|
|
1864
|
-
if (
|
|
2052
|
+
if (__classPrivateFieldGet(this, _Droppable_active, "f") === droppable)
|
|
1865
2053
|
return;
|
|
1866
2054
|
if (opts.hoverClass) {
|
|
1867
2055
|
collection.each(string.split(opts.hoverClass, ' '), cls => {
|
|
@@ -1876,14 +2064,14 @@
|
|
|
1876
2064
|
this.registerEvent(droppable, "mousemove", (e) => {
|
|
1877
2065
|
if (!__classPrivateFieldGet(this, _Droppable_active, "f"))
|
|
1878
2066
|
return;
|
|
1879
|
-
if (
|
|
2067
|
+
if (__classPrivateFieldGet(this, _Droppable_active, "f") === droppable)
|
|
1880
2068
|
return;
|
|
1881
2069
|
opts.onOver && opts.onOver({ draggable: __classPrivateFieldGet(this, _Droppable_active, "f"), droppable }, e);
|
|
1882
2070
|
});
|
|
1883
2071
|
this.registerEvent(droppable, "mouseup", (e) => {
|
|
1884
2072
|
if (!__classPrivateFieldGet(this, _Droppable_active, "f"))
|
|
1885
2073
|
return;
|
|
1886
|
-
if (
|
|
2074
|
+
if (__classPrivateFieldGet(this, _Droppable_active, "f") === droppable)
|
|
1887
2075
|
return;
|
|
1888
2076
|
if (opts.hoverClass) {
|
|
1889
2077
|
collection.each(string.split(opts.hoverClass, ' '), cls => {
|
|
@@ -1954,7 +2142,6 @@
|
|
|
1954
2142
|
return new Droppable(els, opts);
|
|
1955
2143
|
}
|
|
1956
2144
|
|
|
1957
|
-
const THRESHOLD$2 = 2;
|
|
1958
2145
|
const CLASS_ROTATABLE = "uii-rotatable";
|
|
1959
2146
|
const CLASS_ROTATABLE_HANDLE = "uii-rotatable-handle";
|
|
1960
2147
|
const CLASS_ROTATABLE_ACTIVE = "uii-rotatable-active";
|
|
@@ -2006,23 +2193,20 @@
|
|
|
2006
2193
|
let startOy = 0;
|
|
2007
2194
|
let startDeg = 0;
|
|
2008
2195
|
let container;
|
|
2196
|
+
let startPointXy;
|
|
2009
2197
|
onPointerStart(function (args) {
|
|
2010
2198
|
const { ev } = args;
|
|
2011
2199
|
const { w, h } = getStyleSize(el);
|
|
2012
|
-
const { originX, originY } = parseOxy(opts.ox, opts.oy, w, h);
|
|
2200
|
+
const { originX, originY } = parseOxy(opts.ox, opts.oy, w, h, el);
|
|
2013
2201
|
startOx = originX;
|
|
2014
2202
|
startOy = originY;
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
container =
|
|
2021
|
-
el instanceof SVGGraphicsElement
|
|
2022
|
-
? el.ownerSVGElement : el.parentElement;
|
|
2023
|
-
const currentXy = getPointInContainer(ev, container);
|
|
2203
|
+
let centerXy = getRectCenter(el);
|
|
2204
|
+
centerX = centerXy.x;
|
|
2205
|
+
centerY = centerXy.y;
|
|
2206
|
+
container = el.parentElement;
|
|
2207
|
+
startPointXy = getPointInContainer(ev, container);
|
|
2024
2208
|
startDeg =
|
|
2025
|
-
Math.atan2(
|
|
2209
|
+
Math.atan2(startPointXy.y - centerY, startPointXy.x - centerX) * ONE_RAD +
|
|
2026
2210
|
90;
|
|
2027
2211
|
if (startDeg < 0)
|
|
2028
2212
|
startDeg = 360 + startDeg;
|
|
@@ -2032,10 +2216,11 @@
|
|
|
2032
2216
|
onStart && onStart({ deg, cx: centerX, cy: centerY }, ev);
|
|
2033
2217
|
});
|
|
2034
2218
|
onPointerMove((args) => {
|
|
2035
|
-
const { ev } = args;
|
|
2036
|
-
|
|
2219
|
+
const { ev, offX, offY } = args;
|
|
2220
|
+
let newX = startPointXy.x + offX;
|
|
2221
|
+
let newY = startPointXy.y + offY;
|
|
2037
2222
|
deg =
|
|
2038
|
-
Math.atan2(
|
|
2223
|
+
Math.atan2(newY - centerY, newX - centerX) * ONE_RAD +
|
|
2039
2224
|
90 -
|
|
2040
2225
|
startDeg;
|
|
2041
2226
|
onRotate &&
|
|
@@ -2055,7 +2240,7 @@
|
|
|
2055
2240
|
onEnd && onEnd({ deg }, ev);
|
|
2056
2241
|
});
|
|
2057
2242
|
}, {
|
|
2058
|
-
threshold: THRESHOLD
|
|
2243
|
+
threshold: THRESHOLD,
|
|
2059
2244
|
lockPage: true,
|
|
2060
2245
|
});
|
|
2061
2246
|
}
|
|
@@ -2161,7 +2346,6 @@
|
|
|
2161
2346
|
const CLASS_SELECTOR = "uii-selector";
|
|
2162
2347
|
const CLASS_SELECTING = "uii-selecting";
|
|
2163
2348
|
const CLASS_SELECTED = "uii-selected";
|
|
2164
|
-
const THRESHOLD$1 = 2;
|
|
2165
2349
|
class Selectable extends Uii {
|
|
2166
2350
|
constructor(container, opts) {
|
|
2167
2351
|
super(container, object.assign({
|
|
@@ -2226,10 +2410,9 @@
|
|
|
2226
2410
|
if (onPointerDown && onPointerDown(ev) === false)
|
|
2227
2411
|
return true;
|
|
2228
2412
|
let originPos = "";
|
|
2229
|
-
let
|
|
2230
|
-
|
|
2231
|
-
let
|
|
2232
|
-
let hitPosY = startxy.y;
|
|
2413
|
+
let startPointXy = getPointInContainer(ev, con, currentRect, currentCStyle);
|
|
2414
|
+
let hitPosX = startPointXy.x;
|
|
2415
|
+
let hitPosY = startPointXy.y;
|
|
2233
2416
|
const style = selector.style;
|
|
2234
2417
|
let selection = [];
|
|
2235
2418
|
let lastSelection = [];
|
|
@@ -2253,13 +2436,9 @@
|
|
|
2253
2436
|
style.display = 'block';
|
|
2254
2437
|
onStart && onStart({ selection: __classPrivateFieldGet(that, _Selectable__lastSelected, "f"), selectable: con }, ev);
|
|
2255
2438
|
});
|
|
2256
|
-
onPointerMove((
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
let pointX = currentXy.x;
|
|
2260
|
-
let pointY = currentXy.y;
|
|
2261
|
-
let offX = pointX - hitPosX;
|
|
2262
|
-
let offY = pointY - hitPosY;
|
|
2439
|
+
onPointerMove(({ ev, offX, offY }) => {
|
|
2440
|
+
let pointX = startPointXy.x + offX;
|
|
2441
|
+
let pointY = startPointXy.y + offY;
|
|
2263
2442
|
if (scroll) {
|
|
2264
2443
|
const ltX = ev.clientX - currentRect.x;
|
|
2265
2444
|
const ltY = ev.clientY - currentRect.y;
|
|
@@ -2364,7 +2543,7 @@
|
|
|
2364
2543
|
onEnd({ selection, selectable: con }, ev);
|
|
2365
2544
|
});
|
|
2366
2545
|
}, {
|
|
2367
|
-
threshold: THRESHOLD
|
|
2546
|
+
threshold: THRESHOLD,
|
|
2368
2547
|
lockPage: true
|
|
2369
2548
|
});
|
|
2370
2549
|
};
|
|
@@ -2378,7 +2557,6 @@
|
|
|
2378
2557
|
const CLASS_SORTABLE_GHOST = "uii-sortable-ghost";
|
|
2379
2558
|
const CLASS_SORTABLE_ACTIVE = "uii-sortable-active";
|
|
2380
2559
|
const ATTR_SORTABLE_ACTIVE = "uii-sortable-active";
|
|
2381
|
-
const THRESHOLD = 2;
|
|
2382
2560
|
class Sortable extends Uii {
|
|
2383
2561
|
constructor(container, opts) {
|
|
2384
2562
|
super(container, object.merge({
|
|
@@ -2754,7 +2932,7 @@
|
|
|
2754
2932
|
return new Sortable(container, opts);
|
|
2755
2933
|
}
|
|
2756
2934
|
|
|
2757
|
-
var version = "1.3.
|
|
2935
|
+
var version = "1.3.2";
|
|
2758
2936
|
var repository = {
|
|
2759
2937
|
type: "git",
|
|
2760
2938
|
url: "https://github.com/holyhigh2/uiik"
|
|
@@ -2799,6 +2977,7 @@
|
|
|
2799
2977
|
exports.Selectable = Selectable;
|
|
2800
2978
|
exports.Sortable = Sortable;
|
|
2801
2979
|
exports.Splittable = Splittable;
|
|
2980
|
+
exports.THRESHOLD = THRESHOLD;
|
|
2802
2981
|
exports.Uii = Uii;
|
|
2803
2982
|
exports.UiiTransform = UiiTransform;
|
|
2804
2983
|
exports.VERSION = VERSION;
|
|
@@ -2810,6 +2989,7 @@
|
|
|
2810
2989
|
exports.getMatrixInfo = getMatrixInfo;
|
|
2811
2990
|
exports.getPointInContainer = getPointInContainer;
|
|
2812
2991
|
exports.getPointOffset = getPointOffset;
|
|
2992
|
+
exports.getRectCenter = getRectCenter;
|
|
2813
2993
|
exports.getRectInContainer = getRectInContainer;
|
|
2814
2994
|
exports.getStyleSize = getStyleSize;
|
|
2815
2995
|
exports.getStyleXy = getStyleXy;
|
|
@@ -2827,11 +3007,13 @@
|
|
|
2827
3007
|
exports.newSelectable = newSelectable;
|
|
2828
3008
|
exports.newSortable = newSortable;
|
|
2829
3009
|
exports.newSplittable = newSplittable;
|
|
3010
|
+
exports.normalizeVector = normalizeVector;
|
|
2830
3011
|
exports.parseOxy = parseOxy;
|
|
2831
3012
|
exports.restoreCursor = restoreCursor;
|
|
2832
3013
|
exports.rotateTo = rotateTo;
|
|
2833
3014
|
exports.saveCursor = saveCursor;
|
|
2834
3015
|
exports.setCursor = setCursor;
|
|
3016
|
+
exports.transformMoveTo = transformMoveTo;
|
|
2835
3017
|
exports.unlockPage = unlockPage;
|
|
2836
3018
|
exports.wrapper = wrapper;
|
|
2837
3019
|
|