@base-framework/ui 1.0.201 → 1.0.202
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.
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
var y = Object.defineProperty;
|
|
2
|
-
var S = (i, t,
|
|
3
|
-
var
|
|
4
|
-
import { DateTime as
|
|
2
|
+
var S = (i, t, n) => t in i ? y(i, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : i[t] = n;
|
|
3
|
+
var g = (i, t, n) => S(i, typeof t != "symbol" ? t + "" : t, n);
|
|
4
|
+
import { DateTime as f, base as l } from "@base-framework/base";
|
|
5
5
|
const h = (i, t) => (typeof i == "string" && (i = [i]), Array.isArray(i) ? (i.push(t), i) : {
|
|
6
6
|
...i,
|
|
7
7
|
callBack: t
|
|
8
|
-
}),
|
|
8
|
+
}), x = (i, t = "") => i ?? t, z = {
|
|
9
9
|
/**
|
|
10
10
|
* Formats a number with commas.
|
|
11
11
|
*
|
|
@@ -14,10 +14,12 @@ const h = (i, t) => (typeof i == "string" && (i = [i]), Array.isArray(i) ? (i.pu
|
|
|
14
14
|
* @returns {object|array}
|
|
15
15
|
*/
|
|
16
16
|
number(i, t = null) {
|
|
17
|
-
return h(i, (
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
return h(i, (e) => {
|
|
18
|
+
if (!isNaN(e)) {
|
|
19
|
+
const s = /\B(?=(\d{3})+(?!\d))/g;
|
|
20
|
+
return e.toString().replace(s, ",");
|
|
21
|
+
}
|
|
22
|
+
return t || "";
|
|
21
23
|
});
|
|
22
24
|
},
|
|
23
25
|
/**
|
|
@@ -28,8 +30,8 @@ const h = (i, t) => (typeof i == "string" && (i = [i]), Array.isArray(i) ? (i.pu
|
|
|
28
30
|
* @param {string} no - Text for false values.
|
|
29
31
|
* @returns {object|array}
|
|
30
32
|
*/
|
|
31
|
-
yesno(i, t = "Yes",
|
|
32
|
-
return h(i, (s) => s ? t :
|
|
33
|
+
yesno(i, t = "Yes", n = "No") {
|
|
34
|
+
return h(i, (s) => s ? t : n);
|
|
33
35
|
},
|
|
34
36
|
/**
|
|
35
37
|
* Formats a value as money with two decimals.
|
|
@@ -39,12 +41,11 @@ const h = (i, t) => (typeof i == "string" && (i = [i]), Array.isArray(i) ? (i.pu
|
|
|
39
41
|
* @param {*} defaultValue - Value if original is invalid.
|
|
40
42
|
* @returns {object|array}
|
|
41
43
|
*/
|
|
42
|
-
money(i, t = "$",
|
|
44
|
+
money(i, t = "$", n = null) {
|
|
43
45
|
return h(i, (s) => {
|
|
44
|
-
s = p(s, e);
|
|
45
46
|
const o = parseFloat(s);
|
|
46
47
|
if (isNaN(o))
|
|
47
|
-
return
|
|
48
|
+
return n || "";
|
|
48
49
|
const r = /\B(?=(\d{3})+(?!\d))/g;
|
|
49
50
|
return t + o.toFixed(2).toString().replace(r, ",");
|
|
50
51
|
});
|
|
@@ -57,10 +58,10 @@ const h = (i, t) => (typeof i == "string" && (i = [i]), Array.isArray(i) ? (i.pu
|
|
|
57
58
|
* @returns {object|array}
|
|
58
59
|
*/
|
|
59
60
|
phone(i, t = null) {
|
|
60
|
-
return h(i, (
|
|
61
|
-
|
|
62
|
-
const s =
|
|
63
|
-
return s.length === 10 ? "(" + s.slice(0, 3) + ") " + s.slice(3, 6) + "-" + s.slice(6) :
|
|
61
|
+
return h(i, (e) => {
|
|
62
|
+
e = e || "";
|
|
63
|
+
const s = String(e.toString()).replace(/\D/g, "");
|
|
64
|
+
return s.length === 10 ? "(" + s.slice(0, 3) + ") " + s.slice(3, 6) + "-" + s.slice(6) : e || t;
|
|
64
65
|
});
|
|
65
66
|
},
|
|
66
67
|
/**
|
|
@@ -71,9 +72,9 @@ const h = (i, t) => (typeof i == "string" && (i = [i]), Array.isArray(i) ? (i.pu
|
|
|
71
72
|
* @returns {object|array}
|
|
72
73
|
*/
|
|
73
74
|
integer(i, t = null) {
|
|
74
|
-
return h(i, (
|
|
75
|
-
|
|
76
|
-
const s = parseInt(
|
|
75
|
+
return h(i, (e) => {
|
|
76
|
+
e = x(e, t);
|
|
77
|
+
const s = parseInt(e, 10);
|
|
77
78
|
return isNaN(s) ? t : s.toString();
|
|
78
79
|
});
|
|
79
80
|
},
|
|
@@ -85,7 +86,7 @@ const h = (i, t) => (typeof i == "string" && (i = [i]), Array.isArray(i) ? (i.pu
|
|
|
85
86
|
* @returns {object|array}
|
|
86
87
|
*/
|
|
87
88
|
date(i, t = null) {
|
|
88
|
-
return h(i, (
|
|
89
|
+
return h(i, (e) => e ? f.format("standard", e) : t || "");
|
|
89
90
|
},
|
|
90
91
|
/**
|
|
91
92
|
* Formats a date and time value to a standard date and time format.
|
|
@@ -95,7 +96,7 @@ const h = (i, t) => (typeof i == "string" && (i = [i]), Array.isArray(i) ? (i.pu
|
|
|
95
96
|
* @returns {object|array}
|
|
96
97
|
*/
|
|
97
98
|
dateTime(i, t = null) {
|
|
98
|
-
return h(i, (
|
|
99
|
+
return h(i, (e) => e ? f.format("standard", e) + " " + f.formatTime(e, 12) : t || "");
|
|
99
100
|
},
|
|
100
101
|
/**
|
|
101
102
|
* Formats a time value to a standard time format.
|
|
@@ -105,7 +106,7 @@ const h = (i, t) => (typeof i == "string" && (i = [i]), Array.isArray(i) ? (i.pu
|
|
|
105
106
|
* @returns {object|array}
|
|
106
107
|
*/
|
|
107
108
|
time(i, t = null) {
|
|
108
|
-
return h(i, (
|
|
109
|
+
return h(i, (e) => e ? f.formatTime(e, 12) : t || "");
|
|
109
110
|
},
|
|
110
111
|
/**
|
|
111
112
|
* Formats a value with a default value if null or undefined.
|
|
@@ -115,10 +116,10 @@ const h = (i, t) => (typeof i == "string" && (i = [i]), Array.isArray(i) ? (i.pu
|
|
|
115
116
|
* @returns {object|array}
|
|
116
117
|
*/
|
|
117
118
|
default(i, t = null) {
|
|
118
|
-
return h(i, (
|
|
119
|
+
return h(i, (e) => x(e, t));
|
|
119
120
|
}
|
|
120
121
|
};
|
|
121
|
-
class
|
|
122
|
+
class v {
|
|
122
123
|
/**
|
|
123
124
|
* Creates an instance of ElementScaler.
|
|
124
125
|
*
|
|
@@ -174,10 +175,10 @@ class D {
|
|
|
174
175
|
* @param {number} scale - Scale factor (e.g., 1.0 = 100%, 0.5 = 50%).
|
|
175
176
|
* @returns {{width: number, height: number}} The new width and height after scaling.
|
|
176
177
|
*/
|
|
177
|
-
transform(t,
|
|
178
|
+
transform(t, n, e) {
|
|
178
179
|
const s = this.element, o = s.style;
|
|
179
|
-
o.top =
|
|
180
|
-
const r = s.naturalWidth *
|
|
180
|
+
o.top = n + "px", o.left = t + "px";
|
|
181
|
+
const r = s.naturalWidth * e, c = s.naturalHeight * e;
|
|
181
182
|
return o.width = r + "px", o.height = c + "px", { width: r, height: c };
|
|
182
183
|
}
|
|
183
184
|
/**
|
|
@@ -189,7 +190,7 @@ class D {
|
|
|
189
190
|
this.setBoundingBox(), this.containerSize = this.container.getBoundingClientRect();
|
|
190
191
|
}
|
|
191
192
|
}
|
|
192
|
-
class
|
|
193
|
+
class D {
|
|
193
194
|
/**
|
|
194
195
|
* Creates an EventController instance.
|
|
195
196
|
*
|
|
@@ -197,11 +198,11 @@ class v {
|
|
|
197
198
|
* @param {object} parent - The parent object (ImageScaler) that handles actions.
|
|
198
199
|
* @param {HTMLElement} container - The DOM element to attach events to.
|
|
199
200
|
*/
|
|
200
|
-
constructor(t,
|
|
201
|
+
constructor(t, n) {
|
|
201
202
|
/**
|
|
202
203
|
* Tracks and measures distances between touches for pinch gestures.
|
|
203
204
|
*/
|
|
204
|
-
|
|
205
|
+
g(this, "pinchTracker", {
|
|
205
206
|
/** @type {number|null} */
|
|
206
207
|
previousDistance: null,
|
|
207
208
|
/** @type {number|null} */
|
|
@@ -215,9 +216,9 @@ class v {
|
|
|
215
216
|
* @param {number} y2
|
|
216
217
|
* @returns {number}
|
|
217
218
|
*/
|
|
218
|
-
distance(t,
|
|
219
|
+
distance(t, n, e, s) {
|
|
219
220
|
return Math.sqrt(
|
|
220
|
-
(t -
|
|
221
|
+
(t - e) * (t - e) + (n - s) * (n - s)
|
|
221
222
|
);
|
|
222
223
|
},
|
|
223
224
|
/**
|
|
@@ -235,8 +236,8 @@ class v {
|
|
|
235
236
|
* @param {object} touch2
|
|
236
237
|
* @returns {void}
|
|
237
238
|
*/
|
|
238
|
-
setCurrentDistance(t,
|
|
239
|
-
this.currentDistance = this.distance(t.x, t.y,
|
|
239
|
+
setCurrentDistance(t, n) {
|
|
240
|
+
this.currentDistance = this.distance(t.x, t.y, n.x, n.y);
|
|
240
241
|
},
|
|
241
242
|
/**
|
|
242
243
|
* Updates currentDistance and keeps track of the previous distance.
|
|
@@ -245,8 +246,8 @@ class v {
|
|
|
245
246
|
* @param {object} touch2
|
|
246
247
|
* @returns {number} The updated current distance.
|
|
247
248
|
*/
|
|
248
|
-
updateCurrentDistance(t,
|
|
249
|
-
return this.setPreviousDistance(), this.setCurrentDistance(t,
|
|
249
|
+
updateCurrentDistance(t, n) {
|
|
250
|
+
return this.setPreviousDistance(), this.setCurrentDistance(t, n), this.currentDistance;
|
|
250
251
|
},
|
|
251
252
|
/**
|
|
252
253
|
* Determines the scale direction (zoom in/out) based on distance changes.
|
|
@@ -255,10 +256,10 @@ class v {
|
|
|
255
256
|
* @param {object} touch2
|
|
256
257
|
* @returns {number} 1 for zoom in, -1 for zoom out, 0 if below threshold.
|
|
257
258
|
*/
|
|
258
|
-
getScale(t,
|
|
259
|
-
let
|
|
260
|
-
const s = this.updateCurrentDistance(t,
|
|
261
|
-
return o === null || Math.abs(s - o) < 2 || (s > o ?
|
|
259
|
+
getScale(t, n) {
|
|
260
|
+
let e = 0;
|
|
261
|
+
const s = this.updateCurrentDistance(t, n), o = this.previousDistance;
|
|
262
|
+
return o === null || Math.abs(s - o) < 2 || (s > o ? e = 1 : s < o && (e = -1)), e;
|
|
262
263
|
},
|
|
263
264
|
/**
|
|
264
265
|
* Resets the distance measurements.
|
|
@@ -269,7 +270,7 @@ class v {
|
|
|
269
270
|
this.previousDistance = null, this.currentDistance = null;
|
|
270
271
|
}
|
|
271
272
|
});
|
|
272
|
-
this.parent = t, this.container =
|
|
273
|
+
this.parent = t, this.container = n, this.pointer = { x: 0, y: 0, status: "up" }, this.setup();
|
|
273
274
|
}
|
|
274
275
|
/**
|
|
275
276
|
* Initializes event setup.
|
|
@@ -293,11 +294,11 @@ class v {
|
|
|
293
294
|
* @returns {void}
|
|
294
295
|
*/
|
|
295
296
|
setupEvents() {
|
|
296
|
-
const t = this.container,
|
|
297
|
+
const t = this.container, n = l.bind(this, this.pointerMove), e = l.bind(this, this.pointerUp), s = l.bind(this, this.pointerDown), o = l.bind(this, this.wheel), r = l.bind(this, this.resize);
|
|
297
298
|
this.addEvents = function() {
|
|
298
|
-
l.on(["mousemove", "touchmove"], t,
|
|
299
|
+
l.on(["mousemove", "touchmove"], t, n), l.on(["mouseup", "mouseout", "touchend", "touchcancel"], t, e), l.on(["mousedown", "touchstart"], t, s), l.onMouseWheel(o, t, !0), l.on("resize", globalThis, r);
|
|
299
300
|
}, this.addEvents(), this.removeEvents = function() {
|
|
300
|
-
l.off(["mousemove", "touchmove"], t,
|
|
301
|
+
l.off(["mousemove", "touchmove"], t, n), l.off(["mouseup", "mouseout", "touchend", "touchcancel"], t, e), l.off(["mousedown", "touchstart"], t, s), l.offMouseWheel(o, t), l.off("resize", globalThis, r);
|
|
301
302
|
};
|
|
302
303
|
}
|
|
303
304
|
/**
|
|
@@ -307,8 +308,8 @@ class v {
|
|
|
307
308
|
* @param {Event} e - The associated event.
|
|
308
309
|
* @returns {void}
|
|
309
310
|
*/
|
|
310
|
-
wheel(t,
|
|
311
|
-
this.parent.callAction("pinch",
|
|
311
|
+
wheel(t, n) {
|
|
312
|
+
this.parent.callAction("pinch", n, t);
|
|
312
313
|
}
|
|
313
314
|
/**
|
|
314
315
|
* Extracts the position from mouse or touch events and updates `this.pointer`.
|
|
@@ -317,14 +318,14 @@ class v {
|
|
|
317
318
|
* @returns {void}
|
|
318
319
|
*/
|
|
319
320
|
getEventPosition(t) {
|
|
320
|
-
let
|
|
321
|
+
let n, e;
|
|
321
322
|
const s = t.touches;
|
|
322
323
|
if (s && s.length) {
|
|
323
324
|
const o = s[0];
|
|
324
|
-
|
|
325
|
+
n = o.clientX, e = o.clientY;
|
|
325
326
|
} else
|
|
326
|
-
|
|
327
|
-
this.pointer.x =
|
|
327
|
+
n = t.clientX, e = t.clientY;
|
|
328
|
+
this.pointer.x = n, this.pointer.y = e;
|
|
328
329
|
}
|
|
329
330
|
/**
|
|
330
331
|
* Called when the pointer goes down (mouse/touch).
|
|
@@ -359,11 +360,11 @@ class v {
|
|
|
359
360
|
* @returns {Array<object>} Array of touch points.
|
|
360
361
|
*/
|
|
361
362
|
getTouches(t) {
|
|
362
|
-
const
|
|
363
|
-
if (
|
|
364
|
-
for (let s = 0; s <
|
|
365
|
-
|
|
366
|
-
return
|
|
363
|
+
const n = [], e = t.touches;
|
|
364
|
+
if (e && e.length)
|
|
365
|
+
for (let s = 0; s < e.length; s++)
|
|
366
|
+
n.push(e[s]);
|
|
367
|
+
return n;
|
|
367
368
|
}
|
|
368
369
|
/**
|
|
369
370
|
* Calculates the midpoint (center) between two sets of coordinates.
|
|
@@ -374,10 +375,10 @@ class v {
|
|
|
374
375
|
* @param {number} y2
|
|
375
376
|
* @returns {{x: number, y: number}} The center coordinates.
|
|
376
377
|
*/
|
|
377
|
-
getCenter(t,
|
|
378
|
+
getCenter(t, n, e, s) {
|
|
378
379
|
return {
|
|
379
|
-
x: (t +
|
|
380
|
-
y: (
|
|
380
|
+
x: (t + e) / 2,
|
|
381
|
+
y: (n + s) / 2
|
|
381
382
|
};
|
|
382
383
|
}
|
|
383
384
|
/**
|
|
@@ -387,11 +388,11 @@ class v {
|
|
|
387
388
|
* @returns {void}
|
|
388
389
|
*/
|
|
389
390
|
pinch(t) {
|
|
390
|
-
const
|
|
391
|
-
if (
|
|
391
|
+
const n = this.getTouches(t);
|
|
392
|
+
if (n.length === 2) {
|
|
392
393
|
this.pointer.status = "down";
|
|
393
|
-
const
|
|
394
|
-
this.centerMousePinch(
|
|
394
|
+
const e = n[0], s = n[1], o = this.getPosition(e.clientX, e.clientY), r = this.getPosition(s.clientX, s.clientY);
|
|
395
|
+
this.centerMousePinch(e, s);
|
|
395
396
|
const c = this.pinchTracker.getScale(o, r);
|
|
396
397
|
this.parent.callAction("pinch", t, c);
|
|
397
398
|
}
|
|
@@ -403,10 +404,10 @@ class v {
|
|
|
403
404
|
* @param {number} eY
|
|
404
405
|
* @returns {{x: number, y: number}}
|
|
405
406
|
*/
|
|
406
|
-
getPosition(t,
|
|
407
|
+
getPosition(t, n) {
|
|
407
408
|
return {
|
|
408
409
|
x: parseInt(String(t)),
|
|
409
|
-
y: parseInt(String(
|
|
410
|
+
y: parseInt(String(n))
|
|
410
411
|
};
|
|
411
412
|
}
|
|
412
413
|
/**
|
|
@@ -416,14 +417,14 @@ class v {
|
|
|
416
417
|
* @param {Touch} touch2
|
|
417
418
|
* @returns {void}
|
|
418
419
|
*/
|
|
419
|
-
centerMousePinch(t,
|
|
420
|
-
const
|
|
420
|
+
centerMousePinch(t, n) {
|
|
421
|
+
const e = this.getCenter(
|
|
421
422
|
t.clientX,
|
|
422
423
|
t.clientY,
|
|
423
|
-
|
|
424
|
-
|
|
424
|
+
n.clientX,
|
|
425
|
+
n.clientY
|
|
425
426
|
), s = this.pointer;
|
|
426
|
-
s.x =
|
|
427
|
+
s.x = e.x, s.y = e.y;
|
|
427
428
|
}
|
|
428
429
|
/**
|
|
429
430
|
* Called on a rotate gesture (currently not used).
|
|
@@ -441,9 +442,9 @@ class v {
|
|
|
441
442
|
* @returns {boolean} True if it was a gesture (pinch); false otherwise.
|
|
442
443
|
*/
|
|
443
444
|
isGesture(t) {
|
|
444
|
-
let
|
|
445
|
-
const
|
|
446
|
-
return
|
|
445
|
+
let n = !1;
|
|
446
|
+
const e = t.touches;
|
|
447
|
+
return e && e.length > 1 && (t.preventDefault(), this.pinch(t), n = !0), n;
|
|
447
448
|
}
|
|
448
449
|
/**
|
|
449
450
|
* Called when the pointer moves (mouse/touch) but might also detect pinch.
|
|
@@ -464,8 +465,8 @@ class E {
|
|
|
464
465
|
*/
|
|
465
466
|
constructor(t) {
|
|
466
467
|
/** @type {number} Minimum allowed scale factor. */
|
|
467
|
-
|
|
468
|
-
this.elementScaler = new
|
|
468
|
+
g(this, "minScale", 0.2);
|
|
469
|
+
this.elementScaler = new v(t), this.scale = this.getImageScale(t), this.panning = !1, this.events = null, this.start = { x: 0, y: 0 }, this.delta = { x: 0, y: 0 }, this.setup();
|
|
469
470
|
}
|
|
470
471
|
/**
|
|
471
472
|
* Initializes event handling and centers the image.
|
|
@@ -491,8 +492,8 @@ class E {
|
|
|
491
492
|
* @param {*} [data] - Additional data passed to the method.
|
|
492
493
|
* @returns {void}
|
|
493
494
|
*/
|
|
494
|
-
callAction(t,
|
|
495
|
-
this[t](
|
|
495
|
+
callAction(t, n, e) {
|
|
496
|
+
this[t](n, e);
|
|
496
497
|
}
|
|
497
498
|
/**
|
|
498
499
|
* Sets up the event controller for the image.
|
|
@@ -500,7 +501,7 @@ class E {
|
|
|
500
501
|
* @returns {void}
|
|
501
502
|
*/
|
|
502
503
|
setupEvents() {
|
|
503
|
-
this.events = new
|
|
504
|
+
this.events = new D(this, this.elementScaler.element);
|
|
504
505
|
}
|
|
505
506
|
/**
|
|
506
507
|
* Calculates an initial scale based on the element's offsetWidth vs. naturalWidth.
|
|
@@ -518,10 +519,10 @@ class E {
|
|
|
518
519
|
* @returns {{x: number, y: number}} The pointer offset without scale.
|
|
519
520
|
*/
|
|
520
521
|
getOffset(t) {
|
|
521
|
-
const
|
|
522
|
+
const n = this.scale, e = this.delta, s = this.getPointerPosition();
|
|
522
523
|
return {
|
|
523
|
-
x: (s.x -
|
|
524
|
-
y: (s.y -
|
|
524
|
+
x: (s.x - e.x) / n,
|
|
525
|
+
y: (s.y - e.y) / n
|
|
525
526
|
};
|
|
526
527
|
}
|
|
527
528
|
/**
|
|
@@ -532,8 +533,8 @@ class E {
|
|
|
532
533
|
* @param {number} scale - The scale factor.
|
|
533
534
|
* @returns {void}
|
|
534
535
|
*/
|
|
535
|
-
scaleElement(t,
|
|
536
|
-
const s = this.elementScaler.transform(t,
|
|
536
|
+
scaleElement(t, n, e) {
|
|
537
|
+
const s = this.elementScaler.transform(t, n, e);
|
|
537
538
|
this.center(s.width, s.height);
|
|
538
539
|
}
|
|
539
540
|
/**
|
|
@@ -543,28 +544,28 @@ class E {
|
|
|
543
544
|
* @param {number} [height] - Height of the scaled element.
|
|
544
545
|
* @returns {void}
|
|
545
546
|
*/
|
|
546
|
-
center(t,
|
|
547
|
-
const
|
|
548
|
-
t = t || o.width,
|
|
547
|
+
center(t, n) {
|
|
548
|
+
const e = this.elementScaler, s = e.containerSize, o = e.elementBoundingBox, r = this.delta;
|
|
549
|
+
t = t || o.width, n = n || o.height;
|
|
549
550
|
let c, a;
|
|
550
|
-
const
|
|
551
|
-
if (t <
|
|
552
|
-
c =
|
|
551
|
+
const p = s.width;
|
|
552
|
+
if (t < p)
|
|
553
|
+
c = p / 2 - t / 2, c = c > 0 ? c : 0;
|
|
553
554
|
else {
|
|
554
555
|
c = r.x;
|
|
555
556
|
const u = t + r.x;
|
|
556
|
-
u <
|
|
557
|
+
u < p && (c = u + (p - u) - t), r.x > 0 && (c = 0);
|
|
557
558
|
}
|
|
558
|
-
const
|
|
559
|
-
if (
|
|
560
|
-
a =
|
|
559
|
+
const d = s.height;
|
|
560
|
+
if (n < d)
|
|
561
|
+
a = d / 2 - n / 2, a = a > 0 ? a : 0;
|
|
561
562
|
else {
|
|
562
563
|
a = r.y;
|
|
563
|
-
const u =
|
|
564
|
-
u <
|
|
564
|
+
const u = n + r.y;
|
|
565
|
+
u < d && (a = u + (d - u) - n), r.y > 0 && (a = 0);
|
|
565
566
|
}
|
|
566
|
-
const
|
|
567
|
-
|
|
567
|
+
const m = e.element.style;
|
|
568
|
+
m.left = c + "px", m.top = a + "px", this.delta = { x: c, y: a };
|
|
568
569
|
}
|
|
569
570
|
/**
|
|
570
571
|
* Updates the current scale (zoom) value based on scroll delta.
|
|
@@ -573,8 +574,8 @@ class E {
|
|
|
573
574
|
* @returns {number} The updated scale factor.
|
|
574
575
|
*/
|
|
575
576
|
updateScale(t) {
|
|
576
|
-
let
|
|
577
|
-
return t !== 0 && (
|
|
577
|
+
let n = this.scale;
|
|
578
|
+
return t !== 0 && (n = t > 0 ? this.scale *= 1.05 : this.scale /= 1.05), n <= this.minScale && (this.scale = this.minScale), this.scale;
|
|
578
579
|
}
|
|
579
580
|
/**
|
|
580
581
|
* Returns the pointer position relative to the container.
|
|
@@ -582,10 +583,10 @@ class E {
|
|
|
582
583
|
* @returns {{x: number, y: number}} The pointer coordinates.
|
|
583
584
|
*/
|
|
584
585
|
getPointerPosition() {
|
|
585
|
-
const t = this.elementScaler.containerSize,
|
|
586
|
+
const t = this.elementScaler.containerSize, n = this.events.pointer;
|
|
586
587
|
return {
|
|
587
|
-
x:
|
|
588
|
-
y:
|
|
588
|
+
x: n.x - t.left,
|
|
589
|
+
y: n.y - t.top
|
|
589
590
|
};
|
|
590
591
|
}
|
|
591
592
|
/**
|
|
@@ -595,10 +596,10 @@ class E {
|
|
|
595
596
|
* @returns {void}
|
|
596
597
|
*/
|
|
597
598
|
pointerDown(t) {
|
|
598
|
-
const
|
|
599
|
+
const n = this.delta, e = this.getPointerPosition();
|
|
599
600
|
this.start = {
|
|
600
|
-
x:
|
|
601
|
-
y:
|
|
601
|
+
x: e.x - n.x,
|
|
602
|
+
y: e.y - n.y
|
|
602
603
|
}, this.panning = !0;
|
|
603
604
|
}
|
|
604
605
|
/**
|
|
@@ -610,8 +611,8 @@ class E {
|
|
|
610
611
|
pointerMove(t) {
|
|
611
612
|
if (t.preventDefault(), !this.panning)
|
|
612
613
|
return;
|
|
613
|
-
const
|
|
614
|
-
|
|
614
|
+
const n = this.getPointerPosition(), e = this.delta, s = this.start;
|
|
615
|
+
e.x = n.x - s.x, e.y = n.y - s.y, this.scaleElement(e.x, e.y, this.scale);
|
|
615
616
|
}
|
|
616
617
|
/**
|
|
617
618
|
* Called when the user releases the pointer (mouse/touch).
|
|
@@ -637,11 +638,11 @@ class E {
|
|
|
637
638
|
* @param {number} delta - Positive = zoom in, negative = zoom out.
|
|
638
639
|
* @returns {void}
|
|
639
640
|
*/
|
|
640
|
-
pinch(t,
|
|
641
|
-
const
|
|
641
|
+
pinch(t, n) {
|
|
642
|
+
const e = this.getOffset(t);
|
|
642
643
|
t.preventDefault();
|
|
643
|
-
const s = this.updateScale(
|
|
644
|
-
r.x = o.x -
|
|
644
|
+
const s = this.updateScale(n), o = this.getPointerPosition(), r = this.delta;
|
|
645
|
+
r.x = o.x - e.x * s, r.y = o.y - e.y * s, this.scaleElement(r.x, r.y, s);
|
|
645
646
|
}
|
|
646
647
|
}
|
|
647
648
|
export {
|
package/dist/index.es.js
CHANGED
|
@@ -10,7 +10,7 @@ import { B as De, I as Ie, M as Se, d as Be, e as Pe, g as Fe, N as Me, b as ke,
|
|
|
10
10
|
import { B as He, a as Le, C as Ae, F as we, b as Ue, c as Re, M as Ee, P as Oe, S as Ge } from "./sidebar-menu-page-BVryQj2Z.js";
|
|
11
11
|
import { A as je, F as qe, M as ze, a as Je, T as _e } from "./aside-template-McEj_Gxc.js";
|
|
12
12
|
import { B as Qe } from "./bside-template-Du2m3rsE.js";
|
|
13
|
-
import { F as Ye, I as Ze, c as $e } from "./image-scaler-
|
|
13
|
+
import { F as Ye, I as Ze, c as $e } from "./image-scaler-BQ7WdtlV.js";
|
|
14
14
|
export {
|
|
15
15
|
O as Alert,
|
|
16
16
|
je as AsideTemplate,
|
package/dist/utils.es.js
CHANGED
package/package.json
CHANGED