@frybynite/image-cloud 0.9.2 → 0.9.4
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/dist/image-cloud-auto-init.js +361 -311
- package/dist/image-cloud-auto-init.js.map +1 -1
- package/dist/image-cloud.js +692 -642
- package/dist/image-cloud.js.map +1 -1
- package/dist/image-cloud.umd.js +34 -3
- package/dist/image-cloud.umd.js.map +1 -1
- package/dist/index.d.ts +23 -19
- package/dist/react.d.ts +23 -19
- package/dist/react.js +698 -648
- package/dist/react.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/vue.d.ts +23 -19
- package/dist/vue.js +676 -626
- package/dist/vue.js.map +1 -1
- package/dist/web-component.d.ts +23 -19
- package/dist/web-component.js +675 -625
- package/dist/web-component.js.map +1 -1
- package/package.json +1 -1
package/dist/web-component.js
CHANGED
|
@@ -4,26 +4,26 @@ const mt = Object.freeze({
|
|
|
4
4
|
md: "0 4px 16px rgba(0,0,0,0.4)",
|
|
5
5
|
lg: "0 8px 32px rgba(0,0,0,0.5)",
|
|
6
6
|
glow: "0 0 30px rgba(255,255,255,0.6)"
|
|
7
|
-
}),
|
|
7
|
+
}), Ct = Object.freeze({
|
|
8
8
|
energetic: Object.freeze({ overshoot: 0.25, bounces: 2, decayRatio: 0.5 }),
|
|
9
9
|
playful: Object.freeze({ overshoot: 0.15, bounces: 1, decayRatio: 0.5 }),
|
|
10
10
|
subtle: Object.freeze({ overshoot: 0.08, bounces: 1, decayRatio: 0.5 })
|
|
11
|
-
}),
|
|
11
|
+
}), Rt = Object.freeze({
|
|
12
12
|
gentle: Object.freeze({ stiffness: 150, damping: 30, mass: 1, oscillations: 2 }),
|
|
13
13
|
bouncy: Object.freeze({ stiffness: 300, damping: 15, mass: 1, oscillations: 4 }),
|
|
14
14
|
wobbly: Object.freeze({ stiffness: 180, damping: 12, mass: 1.5, oscillations: 5 }),
|
|
15
15
|
snappy: Object.freeze({ stiffness: 400, damping: 25, mass: 0.8, oscillations: 2 })
|
|
16
|
-
}),
|
|
16
|
+
}), Tt = Object.freeze({
|
|
17
17
|
gentle: Object.freeze({ amplitude: 30, frequency: 1.5, decay: !0, decayRate: 0.9, phase: 0 }),
|
|
18
18
|
playful: Object.freeze({ amplitude: 50, frequency: 2.5, decay: !0, decayRate: 0.7, phase: 0 }),
|
|
19
19
|
serpentine: Object.freeze({ amplitude: 60, frequency: 3, decay: !1, decayRate: 1, phase: 0 }),
|
|
20
20
|
flutter: Object.freeze({ amplitude: 20, frequency: 4, decay: !0, decayRate: 0.5, phase: 0 })
|
|
21
21
|
}), vt = Object.freeze({
|
|
22
22
|
type: "linear"
|
|
23
|
-
}), wt = Object.freeze({
|
|
24
|
-
mode: "none"
|
|
25
23
|
}), Et = Object.freeze({
|
|
26
24
|
mode: "none"
|
|
25
|
+
}), wt = Object.freeze({
|
|
26
|
+
mode: "none"
|
|
27
27
|
}), Ot = Object.freeze({
|
|
28
28
|
default: Object.freeze({
|
|
29
29
|
border: Object.freeze({
|
|
@@ -50,21 +50,21 @@ const mt = Object.freeze({
|
|
|
50
50
|
focused: Object.freeze({
|
|
51
51
|
shadow: "none"
|
|
52
52
|
})
|
|
53
|
-
}), kt = Object.freeze({
|
|
54
|
-
tightness: 1
|
|
55
53
|
}), Nt = Object.freeze({
|
|
54
|
+
tightness: 1
|
|
55
|
+
}), kt = Object.freeze({
|
|
56
56
|
rows: 1,
|
|
57
57
|
amplitude: 100,
|
|
58
58
|
frequency: 2,
|
|
59
59
|
phaseShift: 0,
|
|
60
60
|
synchronization: "offset"
|
|
61
61
|
// Note: Image rotation along wave is now controlled via image.rotation.mode = 'tangent'
|
|
62
|
-
}),
|
|
62
|
+
}), Bt = Object.freeze({
|
|
63
63
|
spacing: 0
|
|
64
|
-
}),
|
|
64
|
+
}), jt = Object.freeze({
|
|
65
65
|
mobile: Object.freeze({ maxWidth: 767 }),
|
|
66
66
|
tablet: Object.freeze({ maxWidth: 1199 })
|
|
67
|
-
}),
|
|
67
|
+
}), Wt = Object.freeze({
|
|
68
68
|
mode: "adaptive",
|
|
69
69
|
// Default to adaptive sizing
|
|
70
70
|
minSize: 50,
|
|
@@ -76,15 +76,15 @@ const mt = Object.freeze({
|
|
|
76
76
|
// No variance by default
|
|
77
77
|
max: 1
|
|
78
78
|
})
|
|
79
|
-
}),
|
|
79
|
+
}), Gt = Object.freeze({
|
|
80
80
|
mode: "none",
|
|
81
81
|
range: Object.freeze({
|
|
82
82
|
min: -15,
|
|
83
83
|
max: 15
|
|
84
84
|
})
|
|
85
85
|
}), zt = Object.freeze({
|
|
86
|
-
sizing:
|
|
87
|
-
rotation:
|
|
86
|
+
sizing: Wt,
|
|
87
|
+
rotation: Gt
|
|
88
88
|
}), Dt = Object.freeze({
|
|
89
89
|
validateUrls: !0,
|
|
90
90
|
validationTimeout: 5e3,
|
|
@@ -94,7 +94,7 @@ const mt = Object.freeze({
|
|
|
94
94
|
enabled: !1,
|
|
95
95
|
centers: !1,
|
|
96
96
|
loaders: !1
|
|
97
|
-
}),
|
|
97
|
+
}), qt = Object.freeze({ maxAngle: 5, speed: 2e3, sync: "random" }), Xt = Object.freeze({ minScale: 0.95, maxScale: 1.05, speed: 2400, sync: "random" }), Yt = Object.freeze({ onRatio: 0.7, speed: 3e3, style: "snap" }), Jt = Object.freeze({ speed: 4e3, direction: "clockwise" }), $t = Object.freeze({ type: "none" }), A = Object.freeze({
|
|
98
98
|
// Loader configuration (always an array, composite behavior is implicit)
|
|
99
99
|
loaders: [],
|
|
100
100
|
// Shared loader settings and debug config
|
|
@@ -109,7 +109,7 @@ const mt = Object.freeze({
|
|
|
109
109
|
algorithm: "radial",
|
|
110
110
|
scaleDecay: 0,
|
|
111
111
|
// No decay by default (0-1 for radial/spiral)
|
|
112
|
-
responsive:
|
|
112
|
+
responsive: jt,
|
|
113
113
|
targetCoverage: 0.6,
|
|
114
114
|
// Target 60% of container area
|
|
115
115
|
densityFactor: 1,
|
|
@@ -156,8 +156,8 @@ const mt = Object.freeze({
|
|
|
156
156
|
easing: "cubic-bezier(0.25, 1, 0.5, 1)",
|
|
157
157
|
// smooth deceleration
|
|
158
158
|
path: vt,
|
|
159
|
-
rotation:
|
|
160
|
-
scale:
|
|
159
|
+
rotation: Et,
|
|
160
|
+
scale: wt
|
|
161
161
|
}),
|
|
162
162
|
idle: $t
|
|
163
163
|
}),
|
|
@@ -178,22 +178,12 @@ const mt = Object.freeze({
|
|
|
178
178
|
}),
|
|
179
179
|
dragging: !0
|
|
180
180
|
}),
|
|
181
|
-
//
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
// STUB: Not implemented yet
|
|
188
|
-
desktop: void 0
|
|
189
|
-
// STUB: Not implemented yet
|
|
190
|
-
}),
|
|
191
|
-
mobileDetection: () => typeof window > "u" ? !1 : window.innerWidth <= 768
|
|
192
|
-
}),
|
|
193
|
-
ui: Object.freeze({
|
|
194
|
-
showLoadingSpinner: !1,
|
|
195
|
-
showImageCounter: !1
|
|
196
|
-
})
|
|
181
|
+
// UI configuration
|
|
182
|
+
ui: Object.freeze({
|
|
183
|
+
showLoadingSpinner: !1,
|
|
184
|
+
showImageCounter: !1,
|
|
185
|
+
showNavButtons: !1,
|
|
186
|
+
showFocusOutline: !1
|
|
197
187
|
}),
|
|
198
188
|
// Image styling
|
|
199
189
|
styling: Ot
|
|
@@ -226,15 +216,15 @@ function Kt(o, t) {
|
|
|
226
216
|
...o.sizing,
|
|
227
217
|
...t.sizing
|
|
228
218
|
}, t.sizing.variance)) {
|
|
229
|
-
const e = t.sizing.variance, n = e.min !== void 0 && e.min >= 0.25 && e.min <= 1 ? e.min : o.sizing?.variance?.min ?? 1,
|
|
230
|
-
i.sizing.variance = { min: n, max:
|
|
219
|
+
const e = t.sizing.variance, n = e.min !== void 0 && e.min >= 0.25 && e.min <= 1 ? e.min : o.sizing?.variance?.min ?? 1, s = e.max !== void 0 && e.max >= 1 && e.max <= 1.75 ? e.max : o.sizing?.variance?.max ?? 1;
|
|
220
|
+
i.sizing.variance = { min: n, max: s };
|
|
231
221
|
}
|
|
232
222
|
if (t.rotation !== void 0 && (i.rotation = {
|
|
233
223
|
...o.rotation,
|
|
234
224
|
...t.rotation
|
|
235
225
|
}, t.rotation.range)) {
|
|
236
|
-
const e = t.rotation.range, n = e.min !== void 0 && e.min >= -180 && e.min <= 0 ? e.min : o.rotation?.range?.min ?? -15,
|
|
237
|
-
i.rotation.range = { min: n, max:
|
|
226
|
+
const e = t.rotation.range, n = e.min !== void 0 && e.min >= -180 && e.min <= 0 ? e.min : o.rotation?.range?.min ?? -15, s = e.max !== void 0 && e.max >= 0 && e.max <= 180 ? e.max : o.rotation?.range?.max ?? 15;
|
|
227
|
+
i.rotation.range = { min: n, max: s };
|
|
238
228
|
}
|
|
239
229
|
return i;
|
|
240
230
|
}
|
|
@@ -281,92 +271,87 @@ function te(o = {}) {
|
|
|
281
271
|
...Dt,
|
|
282
272
|
...o.config?.loaders ?? {}
|
|
283
273
|
}
|
|
284
|
-
},
|
|
274
|
+
}, a = {
|
|
285
275
|
loaders: n,
|
|
286
276
|
config: r,
|
|
287
277
|
image: Kt(zt, e),
|
|
288
|
-
layout: { ...
|
|
289
|
-
animation: { ...
|
|
290
|
-
interaction: { ...
|
|
291
|
-
|
|
278
|
+
layout: { ...A.layout },
|
|
279
|
+
animation: { ...A.animation },
|
|
280
|
+
interaction: { ...A.interaction },
|
|
281
|
+
ui: { ...A.ui },
|
|
292
282
|
styling: Vt(Ot, o.styling)
|
|
293
283
|
};
|
|
294
|
-
|
|
295
|
-
...
|
|
284
|
+
o.layout && (a.layout = {
|
|
285
|
+
...A.layout,
|
|
296
286
|
...o.layout
|
|
297
|
-
}, o.layout.responsive && (
|
|
298
|
-
...
|
|
299
|
-
mobile: o.layout.responsive.mobile ? { ...
|
|
300
|
-
tablet: o.layout.responsive.tablet ? { ...
|
|
301
|
-
}), o.layout.spacing && (
|
|
302
|
-
...
|
|
287
|
+
}, o.layout.responsive && (a.layout.responsive = {
|
|
288
|
+
...A.layout.responsive,
|
|
289
|
+
mobile: o.layout.responsive.mobile ? { ...A.layout.responsive.mobile, ...o.layout.responsive.mobile } : A.layout.responsive.mobile,
|
|
290
|
+
tablet: o.layout.responsive.tablet ? { ...A.layout.responsive.tablet, ...o.layout.responsive.tablet } : A.layout.responsive.tablet
|
|
291
|
+
}), o.layout.spacing && (a.layout.spacing = {
|
|
292
|
+
...A.layout.spacing,
|
|
303
293
|
...o.layout.spacing
|
|
304
|
-
})), o.animation && (
|
|
305
|
-
...
|
|
294
|
+
})), o.animation && (a.animation = {
|
|
295
|
+
...A.animation,
|
|
306
296
|
...o.animation
|
|
307
|
-
}, o.animation.easing && (
|
|
308
|
-
...
|
|
297
|
+
}, o.animation.easing && (a.animation.easing = {
|
|
298
|
+
...A.animation.easing,
|
|
309
299
|
...o.animation.easing
|
|
310
|
-
}), o.animation.queue && (
|
|
311
|
-
...
|
|
300
|
+
}), o.animation.queue && (a.animation.queue = {
|
|
301
|
+
...A.animation.queue,
|
|
312
302
|
...o.animation.queue
|
|
313
|
-
}), o.animation.entry && (
|
|
314
|
-
...
|
|
303
|
+
}), o.animation.entry && (a.animation.entry = {
|
|
304
|
+
...A.animation.entry,
|
|
315
305
|
...o.animation.entry,
|
|
316
306
|
start: o.animation.entry.start ? {
|
|
317
|
-
...
|
|
307
|
+
...A.animation.entry.start,
|
|
318
308
|
...o.animation.entry.start,
|
|
319
|
-
circular: o.animation.entry.start.circular ? { ...
|
|
320
|
-
} :
|
|
321
|
-
timing: o.animation.entry.timing ? { ...
|
|
322
|
-
path: o.animation.entry.path ? { ...vt, ...o.animation.entry.path } :
|
|
323
|
-
rotation: o.animation.entry.rotation ? { ...
|
|
324
|
-
scale: o.animation.entry.scale ? { ...
|
|
325
|
-
}), o.animation.idle && (
|
|
309
|
+
circular: o.animation.entry.start.circular ? { ...A.animation.entry.start.circular, ...o.animation.entry.start.circular } : A.animation.entry.start.circular
|
|
310
|
+
} : A.animation.entry.start,
|
|
311
|
+
timing: o.animation.entry.timing ? { ...A.animation.entry.timing, ...o.animation.entry.timing } : A.animation.entry.timing,
|
|
312
|
+
path: o.animation.entry.path ? { ...vt, ...o.animation.entry.path } : A.animation.entry.path,
|
|
313
|
+
rotation: o.animation.entry.rotation ? { ...Et, ...o.animation.entry.rotation } : A.animation.entry.rotation,
|
|
314
|
+
scale: o.animation.entry.scale ? { ...wt, ...o.animation.entry.scale } : A.animation.entry.scale
|
|
315
|
+
}), o.animation.idle && (a.animation.idle = {
|
|
326
316
|
...$t,
|
|
327
317
|
...o.animation.idle
|
|
328
|
-
})), o.interaction && (
|
|
329
|
-
...
|
|
318
|
+
})), o.interaction && (a.interaction = {
|
|
319
|
+
...A.interaction,
|
|
330
320
|
...o.interaction
|
|
331
|
-
}, o.interaction.focus && (
|
|
332
|
-
...
|
|
321
|
+
}, o.interaction.focus && (a.interaction.focus = {
|
|
322
|
+
...A.interaction.focus,
|
|
333
323
|
...o.interaction.focus
|
|
334
|
-
}), o.interaction.navigation && (
|
|
335
|
-
...
|
|
324
|
+
}), o.interaction.navigation && (a.interaction.navigation = {
|
|
325
|
+
...A.interaction.navigation,
|
|
336
326
|
...o.interaction.navigation
|
|
337
|
-
}))
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
...
|
|
342
|
-
...o.
|
|
343
|
-
|
|
344
|
-
mobileDetection: o.rendering.responsive.mobileDetection ? o.rendering.responsive.mobileDetection : x.rendering.responsive.mobileDetection
|
|
345
|
-
}), o.rendering.ui && (s.rendering.ui = {
|
|
346
|
-
...x.rendering.ui,
|
|
347
|
-
...o.rendering.ui
|
|
348
|
-
})), s.config.debug = {
|
|
327
|
+
}));
|
|
328
|
+
const c = o.rendering?.ui;
|
|
329
|
+
if (c && console.warn("[ImageCloud] rendering.ui is deprecated. Use top-level ui instead."), a.ui = {
|
|
330
|
+
...A.ui,
|
|
331
|
+
...c,
|
|
332
|
+
...o.ui
|
|
333
|
+
}, a.config.debug = {
|
|
349
334
|
..._t,
|
|
350
335
|
...o.config?.debug ?? {}
|
|
351
|
-
},
|
|
352
|
-
const
|
|
353
|
-
|
|
354
|
-
...
|
|
355
|
-
default: { ...
|
|
356
|
-
hover: { ...
|
|
336
|
+
}, a.layout.algorithm === "honeycomb" && a.styling) {
|
|
337
|
+
const l = { shape: "hexagon", mode: "height-relative" };
|
|
338
|
+
a.styling = {
|
|
339
|
+
...a.styling,
|
|
340
|
+
default: { ...a.styling.default, clipPath: l },
|
|
341
|
+
hover: { ...a.styling.hover, clipPath: l }
|
|
357
342
|
// focused: untouched — user config respected
|
|
358
343
|
};
|
|
359
344
|
}
|
|
360
|
-
return
|
|
345
|
+
return a;
|
|
361
346
|
}
|
|
362
347
|
function ee(o, t) {
|
|
363
|
-
return { ...o ?
|
|
348
|
+
return { ...o ? Ct[o] : Ct.playful, ...t };
|
|
364
349
|
}
|
|
365
350
|
function ie(o, t) {
|
|
366
|
-
return { ...o ?
|
|
351
|
+
return { ...o ? Rt[o] : Rt.gentle, ...t };
|
|
367
352
|
}
|
|
368
353
|
function ne(o, t) {
|
|
369
|
-
return { ...o ?
|
|
354
|
+
return { ...o ? Tt[o] : Tt.gentle, ...t };
|
|
370
355
|
}
|
|
371
356
|
class oe {
|
|
372
357
|
constructor(t) {
|
|
@@ -393,9 +378,9 @@ class oe {
|
|
|
393
378
|
* @param easing - CSS easing function (optional)
|
|
394
379
|
* @returns AnimationHandle that can be used to cancel or query the animation
|
|
395
380
|
*/
|
|
396
|
-
animateTransformCancellable(t, i, e, n = null,
|
|
381
|
+
animateTransformCancellable(t, i, e, n = null, s = null) {
|
|
397
382
|
this.cancelAllAnimations(t);
|
|
398
|
-
const r = n ?? this.config.duration,
|
|
383
|
+
const r = n ?? this.config.duration, a = s ?? this.config.easing.default, c = this.buildTransformString(i), l = this.buildTransformString(e);
|
|
399
384
|
t.style.transition = "none";
|
|
400
385
|
const u = t.animate(
|
|
401
386
|
[
|
|
@@ -404,7 +389,7 @@ class oe {
|
|
|
404
389
|
],
|
|
405
390
|
{
|
|
406
391
|
duration: r,
|
|
407
|
-
easing:
|
|
392
|
+
easing: a,
|
|
408
393
|
fill: "forwards"
|
|
409
394
|
// Keep final state after animation
|
|
410
395
|
}
|
|
@@ -464,8 +449,8 @@ class oe {
|
|
|
464
449
|
const e = getComputedStyle(t).transform;
|
|
465
450
|
if (e === "none" || !e)
|
|
466
451
|
return { x: 0, y: 0, rotation: 0, scale: 1 };
|
|
467
|
-
const n = new DOMMatrix(e),
|
|
468
|
-
return { x:
|
|
452
|
+
const n = new DOMMatrix(e), s = Math.sqrt(n.a * n.a + n.b * n.b), r = Math.atan2(n.b, n.a) * (180 / Math.PI), a = n.e, c = n.f;
|
|
453
|
+
return { x: a, y: c, rotation: r, scale: s };
|
|
469
454
|
}
|
|
470
455
|
/**
|
|
471
456
|
* Check if an element has an active animation
|
|
@@ -492,10 +477,10 @@ class oe {
|
|
|
492
477
|
* @returns Promise that resolves when animation completes
|
|
493
478
|
*/
|
|
494
479
|
animateTransform(t, i, e = null, n = null) {
|
|
495
|
-
return new Promise((
|
|
496
|
-
const r = e ?? this.config.duration,
|
|
497
|
-
t.style.transition = `transform ${r}ms ${
|
|
498
|
-
|
|
480
|
+
return new Promise((s) => {
|
|
481
|
+
const r = e ?? this.config.duration, a = n ?? this.config.easing.default;
|
|
482
|
+
t.style.transition = `transform ${r}ms ${a}, box-shadow ${r}ms ${a}`, t.style.transform = this.buildTransformString(i), setTimeout(() => {
|
|
483
|
+
s();
|
|
499
484
|
}, r);
|
|
500
485
|
});
|
|
501
486
|
}
|
|
@@ -528,26 +513,26 @@ function V(o, t, i) {
|
|
|
528
513
|
return o + (t - o) * i;
|
|
529
514
|
}
|
|
530
515
|
function se(o, t, i, e) {
|
|
531
|
-
const { overshoot: n, bounces:
|
|
532
|
-
let u = 0, h = 0, d = 1,
|
|
533
|
-
for (let
|
|
534
|
-
if (o <= l[
|
|
535
|
-
h =
|
|
516
|
+
const { overshoot: n, bounces: s, decayRatio: r } = e, a = i.x - t.x, c = i.y - t.y, l = ae(s, r);
|
|
517
|
+
let u = 0, h = 0, d = 1, g = n, b = !1;
|
|
518
|
+
for (let f = 0; f < l.length; f++)
|
|
519
|
+
if (o <= l[f].time) {
|
|
520
|
+
h = f === 0 ? 0 : l[f - 1].time, d = l[f].time, g = l[f].overshoot, b = l[f].isOvershoot;
|
|
536
521
|
break;
|
|
537
522
|
}
|
|
538
523
|
const p = (o - h) / (d - h);
|
|
539
524
|
if (b)
|
|
540
|
-
u = 1 +
|
|
525
|
+
u = 1 + g * at(p);
|
|
541
526
|
else if (h === 0)
|
|
542
|
-
u =
|
|
527
|
+
u = at(p);
|
|
543
528
|
else {
|
|
544
529
|
const m = 1 + (l.find(
|
|
545
|
-
(y,
|
|
546
|
-
)?.overshoot ||
|
|
547
|
-
u = V(m, 1,
|
|
530
|
+
(y, E) => y.time > h && E > 0 && l[E - 1].isOvershoot
|
|
531
|
+
)?.overshoot || g);
|
|
532
|
+
u = V(m, 1, at(p));
|
|
548
533
|
}
|
|
549
534
|
return {
|
|
550
|
-
x: t.x +
|
|
535
|
+
x: t.x + a * u,
|
|
551
536
|
y: t.y + c * u
|
|
552
537
|
};
|
|
553
538
|
}
|
|
@@ -557,15 +542,15 @@ function ae(o, t) {
|
|
|
557
542
|
i.push({ time: e, overshoot: 0, isOvershoot: !1 });
|
|
558
543
|
let n = 0.15;
|
|
559
544
|
const r = 0.4 / (o * 2);
|
|
560
|
-
for (let
|
|
545
|
+
for (let a = 0; a < o; a++)
|
|
561
546
|
e += r, i.push({ time: e, overshoot: n, isOvershoot: !0 }), e += r, i.push({ time: e, overshoot: n * t, isOvershoot: !1 }), n *= t;
|
|
562
547
|
return i.push({ time: 1, overshoot: 0, isOvershoot: !1 }), i;
|
|
563
548
|
}
|
|
564
549
|
function re(o, t, i, e) {
|
|
565
|
-
const { stiffness: n, damping:
|
|
550
|
+
const { stiffness: n, damping: s, mass: r, oscillations: a } = e, c = i.x - t.x, l = i.y - t.y, u = Math.sqrt(n / r), h = s / (2 * Math.sqrt(n * r));
|
|
566
551
|
let d;
|
|
567
552
|
if (h < 1) {
|
|
568
|
-
const
|
|
553
|
+
const g = u * Math.sqrt(1 - h * h), b = Math.exp(-h * u * o * 3), p = Math.cos(g * o * a * Math.PI);
|
|
569
554
|
d = 1 - b * p;
|
|
570
555
|
} else
|
|
571
556
|
d = 1 - Math.exp(-u * o * 3);
|
|
@@ -575,38 +560,38 @@ function re(o, t, i, e) {
|
|
|
575
560
|
};
|
|
576
561
|
}
|
|
577
562
|
function ce(o, t, i, e) {
|
|
578
|
-
const { amplitude: n, frequency:
|
|
563
|
+
const { amplitude: n, frequency: s, decay: r, decayRate: a, phase: c } = e, l = i.x - t.x, u = i.y - t.y, h = Math.sqrt(l * l + u * u), d = h > 0 ? -u / h : 0, g = h > 0 ? l / h : 1, b = s * Math.PI * 2 * o + c, p = r ? Math.pow(1 - o, a) : 1, f = n * Math.sin(b) * p, m = le(o);
|
|
579
564
|
return {
|
|
580
|
-
x: V(t.x, i.x, m) +
|
|
581
|
-
y: V(t.y, i.y, m) +
|
|
565
|
+
x: V(t.x, i.x, m) + f * d,
|
|
566
|
+
y: V(t.y, i.y, m) + f * g
|
|
582
567
|
};
|
|
583
568
|
}
|
|
584
|
-
function
|
|
569
|
+
function at(o) {
|
|
585
570
|
return 1 - (1 - o) * (1 - o);
|
|
586
571
|
}
|
|
587
572
|
function le(o) {
|
|
588
573
|
return 1 - Math.pow(1 - o, 3);
|
|
589
574
|
}
|
|
590
575
|
function he(o, t, i) {
|
|
591
|
-
const { amplitude: e, frequency: n, decay:
|
|
576
|
+
const { amplitude: e, frequency: n, decay: s } = i, r = Math.sin(o * n * Math.PI * 2), a = s ? Math.pow(1 - o, 2) : 1, c = e * r * a;
|
|
592
577
|
return t + c;
|
|
593
578
|
}
|
|
594
579
|
function de(o, t, i) {
|
|
595
|
-
const { overshoot: e, bounces: n } = i,
|
|
596
|
-
|
|
580
|
+
const { overshoot: e, bounces: n } = i, s = [];
|
|
581
|
+
s.push({ time: 0.5, scale: e });
|
|
597
582
|
let r = e;
|
|
598
|
-
const
|
|
583
|
+
const a = 0.5, l = 0.5 / (n * 2);
|
|
599
584
|
let u = 0.5;
|
|
600
585
|
for (let d = 0; d < n; d++) {
|
|
601
|
-
const
|
|
602
|
-
u += l,
|
|
586
|
+
const g = 1 - (r - 1) * a;
|
|
587
|
+
u += l, s.push({ time: u, scale: g }), r = 1 + (r - 1) * a * a, u += l, d < n - 1 && s.push({ time: u, scale: r });
|
|
603
588
|
}
|
|
604
|
-
|
|
589
|
+
s.push({ time: 1, scale: 1 });
|
|
605
590
|
let h = 1;
|
|
606
|
-
for (let d = 0; d <
|
|
607
|
-
if (o <=
|
|
608
|
-
const
|
|
609
|
-
h = b + (
|
|
591
|
+
for (let d = 0; d < s.length; d++)
|
|
592
|
+
if (o <= s[d].time) {
|
|
593
|
+
const g = d === 0 ? 0 : s[d - 1].time, b = d === 0 ? 1 : s[d - 1].scale, p = (o - g) / (s[d].time - g), f = at(p);
|
|
594
|
+
h = b + (s[d].scale - b) * f;
|
|
610
595
|
break;
|
|
611
596
|
}
|
|
612
597
|
return h * t;
|
|
@@ -617,68 +602,68 @@ function ue(o) {
|
|
|
617
602
|
startPosition: i,
|
|
618
603
|
endPosition: e,
|
|
619
604
|
pathConfig: n,
|
|
620
|
-
duration:
|
|
605
|
+
duration: s,
|
|
621
606
|
imageWidth: r,
|
|
622
|
-
imageHeight:
|
|
607
|
+
imageHeight: a,
|
|
623
608
|
rotation: c,
|
|
624
609
|
scale: l,
|
|
625
610
|
onComplete: u,
|
|
626
611
|
rotationConfig: h,
|
|
627
612
|
startRotation: d,
|
|
628
|
-
scaleConfig:
|
|
613
|
+
scaleConfig: g,
|
|
629
614
|
startScale: b
|
|
630
|
-
} = o, p = n.type,
|
|
631
|
-
if ((p === "linear" || p === "arc") && !
|
|
615
|
+
} = o, p = n.type, f = d !== void 0 && d !== c, m = h?.mode === "wobble", y = h?.wobble || { amplitude: 15, frequency: 3, decay: !0 }, E = f || m, v = b !== void 0 && b !== l, S = g?.mode === "pop", w = g?.pop || { overshoot: 1.2, bounces: 1 };
|
|
616
|
+
if ((p === "linear" || p === "arc") && !E && !(v || S)) {
|
|
632
617
|
u && u();
|
|
633
618
|
return;
|
|
634
619
|
}
|
|
635
|
-
const O = performance.now(), L = -r / 2, P = -
|
|
620
|
+
const O = performance.now(), L = -r / 2, P = -a / 2;
|
|
636
621
|
function z(H) {
|
|
637
|
-
const
|
|
622
|
+
const N = H - O, C = Math.min(N / s, 1);
|
|
638
623
|
let D;
|
|
639
624
|
switch (p) {
|
|
640
625
|
case "bounce": {
|
|
641
|
-
const
|
|
626
|
+
const k = ee(
|
|
642
627
|
n.bouncePreset,
|
|
643
628
|
n.bounce
|
|
644
629
|
);
|
|
645
|
-
D = se(
|
|
630
|
+
D = se(C, i, e, k);
|
|
646
631
|
break;
|
|
647
632
|
}
|
|
648
633
|
case "elastic": {
|
|
649
|
-
const
|
|
634
|
+
const k = ie(
|
|
650
635
|
n.elasticPreset,
|
|
651
636
|
n.elastic
|
|
652
637
|
);
|
|
653
|
-
D = re(
|
|
638
|
+
D = re(C, i, e, k);
|
|
654
639
|
break;
|
|
655
640
|
}
|
|
656
641
|
case "wave": {
|
|
657
|
-
const
|
|
642
|
+
const k = ne(
|
|
658
643
|
n.wavePreset,
|
|
659
644
|
n.wave
|
|
660
645
|
);
|
|
661
|
-
D = ce(
|
|
646
|
+
D = ce(C, i, e, k);
|
|
662
647
|
break;
|
|
663
648
|
}
|
|
664
649
|
default:
|
|
665
650
|
D = {
|
|
666
|
-
x: V(i.x, e.x,
|
|
667
|
-
y: V(i.y, e.y,
|
|
651
|
+
x: V(i.x, e.x, C),
|
|
652
|
+
y: V(i.y, e.y, C)
|
|
668
653
|
};
|
|
669
654
|
}
|
|
670
|
-
const
|
|
655
|
+
const W = D.x - e.x, U = D.y - e.y;
|
|
671
656
|
let M;
|
|
672
|
-
m ? M = he(
|
|
673
|
-
let
|
|
674
|
-
|
|
657
|
+
m ? M = he(C, c, y) : f ? M = V(d, c, C) : M = c;
|
|
658
|
+
let R;
|
|
659
|
+
S ? R = de(C, l, w) : v ? R = V(b, l, C) : R = l, t.style.transform = `translate(${L}px, ${P}px) translate(${W}px, ${U}px) rotate(${M}deg) scale(${R})`, C < 1 ? requestAnimationFrame(z) : (t.style.transform = `translate(${L}px, ${P}px) rotate(${c}deg) scale(${l})`, u && u());
|
|
675
660
|
}
|
|
676
661
|
requestAnimationFrame(z);
|
|
677
662
|
}
|
|
678
|
-
function
|
|
663
|
+
function fe(o) {
|
|
679
664
|
return o === "bounce" || o === "elastic" || o === "wave";
|
|
680
665
|
}
|
|
681
|
-
const
|
|
666
|
+
const ge = {
|
|
682
667
|
radial: "center",
|
|
683
668
|
spiral: "center",
|
|
684
669
|
grid: "top",
|
|
@@ -689,83 +674,83 @@ const fe = {
|
|
|
689
674
|
};
|
|
690
675
|
class me {
|
|
691
676
|
constructor(t, i) {
|
|
692
|
-
this.config = t, this.layoutAlgorithm = i, this.resolvedStartPosition = this.resolveStartPosition(), this.pathConfig = t.path || vt, this.rotationConfig = t.rotation ||
|
|
677
|
+
this.config = t, this.layoutAlgorithm = i, this.resolvedStartPosition = this.resolveStartPosition(), this.pathConfig = t.path || vt, this.rotationConfig = t.rotation || Et, this.scaleConfig = t.scale || wt;
|
|
693
678
|
}
|
|
694
679
|
/**
|
|
695
680
|
* Get the effective start position, considering layout-aware defaults
|
|
696
681
|
*/
|
|
697
682
|
resolveStartPosition() {
|
|
698
|
-
return this.config.start.position ? this.config.start.position :
|
|
683
|
+
return this.config.start.position ? this.config.start.position : ge[this.layoutAlgorithm] || "nearest-edge";
|
|
699
684
|
}
|
|
700
685
|
/**
|
|
701
686
|
* Calculate the starting position for an image's entry animation
|
|
702
687
|
*/
|
|
703
|
-
calculateStartPosition(t, i, e, n,
|
|
704
|
-
const r = this.resolvedStartPosition,
|
|
688
|
+
calculateStartPosition(t, i, e, n, s) {
|
|
689
|
+
const r = this.resolvedStartPosition, a = this.config.start.offset ?? 100;
|
|
705
690
|
switch (r) {
|
|
706
691
|
case "nearest-edge":
|
|
707
|
-
return this.calculateNearestEdge(t, i, e,
|
|
692
|
+
return this.calculateNearestEdge(t, i, e, a);
|
|
708
693
|
case "top":
|
|
709
|
-
return this.calculateEdgePosition("top", t, i, e,
|
|
694
|
+
return this.calculateEdgePosition("top", t, i, e, a);
|
|
710
695
|
case "bottom":
|
|
711
|
-
return this.calculateEdgePosition("bottom", t, i, e,
|
|
696
|
+
return this.calculateEdgePosition("bottom", t, i, e, a);
|
|
712
697
|
case "left":
|
|
713
|
-
return this.calculateEdgePosition("left", t, i, e,
|
|
698
|
+
return this.calculateEdgePosition("left", t, i, e, a);
|
|
714
699
|
case "right":
|
|
715
|
-
return this.calculateEdgePosition("right", t, i, e,
|
|
700
|
+
return this.calculateEdgePosition("right", t, i, e, a);
|
|
716
701
|
case "center":
|
|
717
702
|
return this.calculateCenterPosition(e, t, i);
|
|
718
703
|
case "random-edge":
|
|
719
|
-
return this.calculateRandomEdge(t, i, e,
|
|
704
|
+
return this.calculateRandomEdge(t, i, e, a);
|
|
720
705
|
case "circular":
|
|
721
706
|
return this.calculateCircularPosition(
|
|
722
707
|
t,
|
|
723
708
|
i,
|
|
724
709
|
e,
|
|
725
710
|
n,
|
|
726
|
-
|
|
711
|
+
s
|
|
727
712
|
);
|
|
728
713
|
default:
|
|
729
|
-
return this.calculateNearestEdge(t, i, e,
|
|
714
|
+
return this.calculateNearestEdge(t, i, e, a);
|
|
730
715
|
}
|
|
731
716
|
}
|
|
732
717
|
/**
|
|
733
718
|
* Calculate start position from the nearest edge (current default behavior)
|
|
734
719
|
*/
|
|
735
720
|
calculateNearestEdge(t, i, e, n) {
|
|
736
|
-
const
|
|
737
|
-
let d = t.x,
|
|
738
|
-
return h ===
|
|
721
|
+
const s = t.x, r = t.y, a = s, c = e.width - s, l = r, u = e.height - r, h = Math.min(a, c, l, u);
|
|
722
|
+
let d = t.x, g = t.y;
|
|
723
|
+
return h === a ? d = -(i.width + n) : h === c ? d = e.width + n : h === l ? g = -(i.height + n) : g = e.height + n, { x: d, y: g };
|
|
739
724
|
}
|
|
740
725
|
/**
|
|
741
726
|
* Calculate start position from a specific edge
|
|
742
727
|
*/
|
|
743
|
-
calculateEdgePosition(t, i, e, n,
|
|
744
|
-
let r = i.x,
|
|
728
|
+
calculateEdgePosition(t, i, e, n, s) {
|
|
729
|
+
let r = i.x, a = i.y;
|
|
745
730
|
switch (t) {
|
|
746
731
|
case "top":
|
|
747
|
-
|
|
732
|
+
a = -(e.height + s);
|
|
748
733
|
break;
|
|
749
734
|
case "bottom":
|
|
750
|
-
|
|
735
|
+
a = n.height + s;
|
|
751
736
|
break;
|
|
752
737
|
case "left":
|
|
753
|
-
r = -(e.width +
|
|
738
|
+
r = -(e.width + s);
|
|
754
739
|
break;
|
|
755
740
|
case "right":
|
|
756
|
-
r = n.width +
|
|
741
|
+
r = n.width + s;
|
|
757
742
|
break;
|
|
758
743
|
}
|
|
759
|
-
return { x: r, y:
|
|
744
|
+
return { x: r, y: a };
|
|
760
745
|
}
|
|
761
746
|
/**
|
|
762
747
|
* Calculate start position from center with scale animation
|
|
763
748
|
*/
|
|
764
749
|
calculateCenterPosition(t, i, e) {
|
|
765
|
-
const n = t.width / 2,
|
|
750
|
+
const n = t.width / 2, s = t.height / 2;
|
|
766
751
|
return {
|
|
767
752
|
x: n,
|
|
768
|
-
y:
|
|
753
|
+
y: s,
|
|
769
754
|
useScale: !0
|
|
770
755
|
// Signal to use scale animation from 0
|
|
771
756
|
};
|
|
@@ -774,14 +759,14 @@ class me {
|
|
|
774
759
|
* Calculate start position from a random edge
|
|
775
760
|
*/
|
|
776
761
|
calculateRandomEdge(t, i, e, n) {
|
|
777
|
-
const
|
|
762
|
+
const s = ["top", "bottom", "left", "right"], r = s[Math.floor(Math.random() * s.length)];
|
|
778
763
|
return this.calculateEdgePosition(r, t, i, e, n);
|
|
779
764
|
}
|
|
780
765
|
/**
|
|
781
766
|
* Calculate start position on a circle around the container
|
|
782
767
|
*/
|
|
783
|
-
calculateCircularPosition(t, i, e, n,
|
|
784
|
-
const r = this.config.start.circular || {},
|
|
768
|
+
calculateCircularPosition(t, i, e, n, s) {
|
|
769
|
+
const r = this.config.start.circular || {}, a = r.distribution || "even";
|
|
785
770
|
let c;
|
|
786
771
|
const l = r.radius || "120%";
|
|
787
772
|
if (typeof l == "string" && l.endsWith("%")) {
|
|
@@ -792,9 +777,9 @@ class me {
|
|
|
792
777
|
} else
|
|
793
778
|
c = typeof l == "number" ? l : 500;
|
|
794
779
|
let u;
|
|
795
|
-
|
|
796
|
-
const h = e.width / 2, d = e.height / 2,
|
|
797
|
-
return { x:
|
|
780
|
+
a === "even" ? u = n / s * 2 * Math.PI : u = Math.random() * 2 * Math.PI;
|
|
781
|
+
const h = e.width / 2, d = e.height / 2, g = h + Math.cos(u) * c, b = d + Math.sin(u) * c;
|
|
782
|
+
return { x: g, y: b };
|
|
798
783
|
}
|
|
799
784
|
/**
|
|
800
785
|
* Get animation parameters for an image
|
|
@@ -813,8 +798,8 @@ class me {
|
|
|
813
798
|
* Build a CSS transform string for the start position
|
|
814
799
|
* Uses pixel-based centering offset for reliable cross-browser behavior
|
|
815
800
|
*/
|
|
816
|
-
buildStartTransform(t, i, e, n,
|
|
817
|
-
const l = t.x - i.x, u = t.y - i.y, h =
|
|
801
|
+
buildStartTransform(t, i, e, n, s, r, a, c) {
|
|
802
|
+
const l = t.x - i.x, u = t.y - i.y, h = a !== void 0 ? a : e, d = c !== void 0 ? c : n, g = s !== void 0 ? -s / 2 : 0, b = r !== void 0 ? -r / 2 : 0, p = s !== void 0 ? `translate(${g}px, ${b}px)` : "translate(-50%, -50%)";
|
|
818
803
|
return t.useScale ? `${p} translate(${l}px, ${u}px) rotate(${h}deg) scale(0)` : `${p} translate(${l}px, ${u}px) rotate(${h}deg) scale(${d})`;
|
|
819
804
|
}
|
|
820
805
|
/**
|
|
@@ -823,8 +808,8 @@ class me {
|
|
|
823
808
|
*/
|
|
824
809
|
buildFinalTransform(t, i, e, n) {
|
|
825
810
|
if (e !== void 0 && n !== void 0) {
|
|
826
|
-
const
|
|
827
|
-
return `translate(${
|
|
811
|
+
const s = -e / 2, r = -n / 2;
|
|
812
|
+
return `translate(${s}px, ${r}px) rotate(${t}deg) scale(${i})`;
|
|
828
813
|
}
|
|
829
814
|
return `translate(-50%, -50%) rotate(${t}deg) scale(${i})`;
|
|
830
815
|
}
|
|
@@ -840,7 +825,7 @@ class me {
|
|
|
840
825
|
* Check if the current path type requires JavaScript animation
|
|
841
826
|
*/
|
|
842
827
|
requiresJSAnimation() {
|
|
843
|
-
return
|
|
828
|
+
return fe(this.pathConfig.type);
|
|
844
829
|
}
|
|
845
830
|
/**
|
|
846
831
|
* Get the path configuration
|
|
@@ -942,7 +927,7 @@ class me {
|
|
|
942
927
|
amplitude: 15,
|
|
943
928
|
frequency: 3,
|
|
944
929
|
decay: !0
|
|
945
|
-
}, { amplitude: n, frequency:
|
|
930
|
+
}, { amplitude: n, frequency: s, decay: r } = e, a = Math.sin(t * s * Math.PI * 2), c = r ? Math.pow(1 - t, 2) : 1, l = n * a * c;
|
|
946
931
|
return i + l;
|
|
947
932
|
}
|
|
948
933
|
/**
|
|
@@ -999,15 +984,15 @@ class me {
|
|
|
999
984
|
const e = this.scaleConfig.pop || {
|
|
1000
985
|
overshoot: 1.2,
|
|
1001
986
|
bounces: 1
|
|
1002
|
-
}, { overshoot: n, bounces:
|
|
1003
|
-
let
|
|
987
|
+
}, { overshoot: n, bounces: s } = e, r = this.generateScaleBounceKeyframes(s, n);
|
|
988
|
+
let a = i;
|
|
1004
989
|
for (let c = 0; c < r.length; c++)
|
|
1005
990
|
if (t <= r[c].time) {
|
|
1006
991
|
const l = c === 0 ? 0 : r[c - 1].time, u = c === 0 ? i : r[c - 1].scale, h = (t - l) / (r[c].time - l), d = this.easeOutQuad(h);
|
|
1007
|
-
|
|
992
|
+
a = u + (r[c].scale - u) * d;
|
|
1008
993
|
break;
|
|
1009
994
|
}
|
|
1010
|
-
return
|
|
995
|
+
return a * i;
|
|
1011
996
|
}
|
|
1012
997
|
/**
|
|
1013
998
|
* Generate keyframes for scale bounce animation
|
|
@@ -1016,11 +1001,11 @@ class me {
|
|
|
1016
1001
|
const e = [];
|
|
1017
1002
|
e.push({ time: 0.5, scale: i });
|
|
1018
1003
|
let n = i;
|
|
1019
|
-
const
|
|
1004
|
+
const s = 0.5, a = 0.5 / (t * 2);
|
|
1020
1005
|
let c = 0.5;
|
|
1021
1006
|
for (let l = 0; l < t; l++) {
|
|
1022
|
-
const u = 1 - (n - 1) *
|
|
1023
|
-
c +=
|
|
1007
|
+
const u = 1 - (n - 1) * s;
|
|
1008
|
+
c += a, e.push({ time: c, scale: u }), n = 1 + (n - 1) * s * s, c += a, l < t - 1 && e.push({ time: c, scale: n });
|
|
1024
1009
|
}
|
|
1025
1010
|
return e.push({ time: 1, scale: 1 }), e;
|
|
1026
1011
|
}
|
|
@@ -1041,7 +1026,7 @@ class pe {
|
|
|
1041
1026
|
*/
|
|
1042
1027
|
register(t, i, e, n) {
|
|
1043
1028
|
if (this.entries.has(t)) return;
|
|
1044
|
-
const
|
|
1029
|
+
const s = n ?? this.entryDurationMs, r = this.config.startDelay ?? s, a = {
|
|
1045
1030
|
element: t,
|
|
1046
1031
|
index: i,
|
|
1047
1032
|
totalImages: e,
|
|
@@ -1052,8 +1037,8 @@ class pe {
|
|
|
1052
1037
|
stopped: !1,
|
|
1053
1038
|
startTimer: null
|
|
1054
1039
|
};
|
|
1055
|
-
this.entries.set(t,
|
|
1056
|
-
|
|
1040
|
+
this.entries.set(t, a), a.startTimer = setTimeout(() => {
|
|
1041
|
+
a.startTimer = null, !a.stopped && !a.paused && this._startAnimation(a);
|
|
1057
1042
|
}, r);
|
|
1058
1043
|
}
|
|
1059
1044
|
/**
|
|
@@ -1116,7 +1101,7 @@ class pe {
|
|
|
1116
1101
|
}
|
|
1117
1102
|
}
|
|
1118
1103
|
_startWiggle(t) {
|
|
1119
|
-
const i = { ...
|
|
1104
|
+
const i = { ...qt, ...this.config.wiggle }, e = [
|
|
1120
1105
|
{ transform: "rotate(0deg)", offset: 0 },
|
|
1121
1106
|
{ transform: `rotate(${i.maxAngle}deg)`, offset: 0.25 },
|
|
1122
1107
|
{ transform: "rotate(0deg)", offset: 0.5 },
|
|
@@ -1157,8 +1142,8 @@ class pe {
|
|
|
1157
1142
|
}
|
|
1158
1143
|
_startBlink(t) {
|
|
1159
1144
|
const i = { ...Yt, ...this.config.blink }, e = -(Math.random() * i.speed), n = parseFloat(getComputedStyle(t.element).opacity) || 1;
|
|
1160
|
-
let
|
|
1161
|
-
i.style === "fade" ? (
|
|
1145
|
+
let s, r;
|
|
1146
|
+
i.style === "fade" ? (s = [
|
|
1162
1147
|
{ opacity: n, offset: 0 },
|
|
1163
1148
|
{ opacity: 0, offset: 0.5 },
|
|
1164
1149
|
{ opacity: n, offset: 1 }
|
|
@@ -1167,7 +1152,7 @@ class pe {
|
|
|
1167
1152
|
delay: e,
|
|
1168
1153
|
iterations: 1 / 0,
|
|
1169
1154
|
easing: "ease-in-out"
|
|
1170
|
-
}) : (
|
|
1155
|
+
}) : (s = [
|
|
1171
1156
|
{ opacity: n, offset: 0 },
|
|
1172
1157
|
{ opacity: n, offset: i.onRatio },
|
|
1173
1158
|
{ opacity: 0, offset: Math.min(i.onRatio + 0.01, 0.99) },
|
|
@@ -1177,7 +1162,7 @@ class pe {
|
|
|
1177
1162
|
duration: i.speed,
|
|
1178
1163
|
delay: e,
|
|
1179
1164
|
iterations: 1 / 0
|
|
1180
|
-
}), t.blinkAnimation = t.element.animate(
|
|
1165
|
+
}), t.blinkAnimation = t.element.animate(s, r);
|
|
1181
1166
|
}
|
|
1182
1167
|
_startSpin(t) {
|
|
1183
1168
|
const i = { ...Jt, ...this.config.spin }, e = i.direction === "clockwise" ? 360 : -360;
|
|
@@ -1229,11 +1214,11 @@ class be {
|
|
|
1229
1214
|
* @returns Array of layout objects with position, rotation, scale
|
|
1230
1215
|
*/
|
|
1231
1216
|
generate(t, i, e = {}) {
|
|
1232
|
-
const n = [], { width:
|
|
1233
|
-
for (let
|
|
1234
|
-
const
|
|
1235
|
-
id:
|
|
1236
|
-
x:
|
|
1217
|
+
const n = [], { width: s, height: r } = i, a = this.config.spacing.padding, c = e.fixedHeight ?? 200, l = this.imageConfig.rotation?.mode ?? "none", u = this.imageConfig.rotation?.range?.min ?? -15, h = this.imageConfig.rotation?.range?.max ?? 15, d = this.imageConfig.sizing?.variance?.min ?? 1, g = this.imageConfig.sizing?.variance?.max ?? 1, b = d !== 1 || g !== 1, f = c * 1.5 / 2, m = c / 2, y = s - a - f, E = r - a - m, v = a + f, S = a + m;
|
|
1218
|
+
for (let w = 0; w < t; w++) {
|
|
1219
|
+
const I = this.random(v, y), O = this.random(S, E), L = l === "random" ? this.random(u, h) : 0, P = b ? this.random(d, g) : 1, z = c * P, H = {
|
|
1220
|
+
id: w,
|
|
1221
|
+
x: I,
|
|
1237
1222
|
y: O,
|
|
1238
1223
|
rotation: L,
|
|
1239
1224
|
scale: P,
|
|
@@ -1265,15 +1250,15 @@ class ye {
|
|
|
1265
1250
|
* @returns Array of layout objects with position, rotation, scale
|
|
1266
1251
|
*/
|
|
1267
1252
|
generate(t, i, e = {}) {
|
|
1268
|
-
const n = [], { width:
|
|
1269
|
-
...
|
|
1253
|
+
const n = [], { width: s, height: r } = i, a = e.fixedHeight ?? 200, c = this.imageConfig.rotation?.mode ?? "none", l = this.imageConfig.rotation?.range?.min ?? -15, u = this.imageConfig.rotation?.range?.max ?? 15, h = this.imageConfig.sizing?.variance?.min ?? 1, d = this.imageConfig.sizing?.variance?.max ?? 1, g = h !== 1 || d !== 1, b = this.config.scaleDecay ?? 0, p = {
|
|
1254
|
+
...Nt,
|
|
1270
1255
|
...this.config.radial
|
|
1271
|
-
},
|
|
1272
|
-
m - v -
|
|
1273
|
-
y - v -
|
|
1256
|
+
}, f = e.fixedHeight ?? a, m = s / 2, y = r / 2, E = Math.ceil(Math.sqrt(t)), v = this.config.spacing.padding ?? 50, S = Math.max(f * 0.8, Math.min(
|
|
1257
|
+
m - v - f / 2,
|
|
1258
|
+
y - v - f / 2
|
|
1274
1259
|
));
|
|
1275
1260
|
if (t > 0) {
|
|
1276
|
-
const O =
|
|
1261
|
+
const O = g ? this.random(h, d) : 1, L = f * O;
|
|
1277
1262
|
n.push({
|
|
1278
1263
|
id: 0,
|
|
1279
1264
|
x: m,
|
|
@@ -1286,32 +1271,32 @@ class ye {
|
|
|
1286
1271
|
// Center image is highest
|
|
1287
1272
|
});
|
|
1288
1273
|
}
|
|
1289
|
-
let
|
|
1290
|
-
for (;
|
|
1291
|
-
const O =
|
|
1274
|
+
let w = 1, I = 1;
|
|
1275
|
+
for (; w < t; ) {
|
|
1276
|
+
const O = I / E, L = b > 0 ? 1 - O * b * 0.5 : 1, P = Math.max(f * 0.8, S / E * 1.5 / p.tightness), z = I * P, H = z * 1.5, N = Math.PI * (3 * (H + z) - Math.sqrt((3 * H + z) * (H + 3 * z))), C = this.estimateWidth(f), D = Math.floor(N / (C * 0.7));
|
|
1292
1277
|
if (D === 0) {
|
|
1293
|
-
|
|
1278
|
+
I++;
|
|
1294
1279
|
continue;
|
|
1295
1280
|
}
|
|
1296
|
-
const
|
|
1297
|
-
for (let M = 0; M < D &&
|
|
1298
|
-
const
|
|
1299
|
-
let _ = m + Math.cos(
|
|
1300
|
-
const $ =
|
|
1301
|
-
_ - $ < v ? _ = v + $ : _ + $ >
|
|
1281
|
+
const W = 2 * Math.PI / D, U = I * (20 * Math.PI / 180);
|
|
1282
|
+
for (let M = 0; M < D && w < t; M++) {
|
|
1283
|
+
const R = M * W + U, k = g ? this.random(h, d) : 1, q = L * k, T = f * q;
|
|
1284
|
+
let _ = m + Math.cos(R) * H, F = y + Math.sin(R) * z;
|
|
1285
|
+
const $ = T * 1.5 / 2, B = T / 2;
|
|
1286
|
+
_ - $ < v ? _ = v + $ : _ + $ > s - v && (_ = s - v - $), F - B < v ? F = v + B : F + B > r - v && (F = r - v - B);
|
|
1302
1287
|
const Y = c === "random" ? this.random(l, u) : 0;
|
|
1303
1288
|
n.push({
|
|
1304
|
-
id:
|
|
1289
|
+
id: w,
|
|
1305
1290
|
x: _,
|
|
1306
1291
|
y: F,
|
|
1307
1292
|
rotation: Y,
|
|
1308
|
-
scale:
|
|
1309
|
-
baseSize:
|
|
1310
|
-
zIndex: Math.max(1, 100 -
|
|
1293
|
+
scale: q,
|
|
1294
|
+
baseSize: T,
|
|
1295
|
+
zIndex: Math.max(1, 100 - I)
|
|
1311
1296
|
// Outer rings have lower z-index
|
|
1312
|
-
}),
|
|
1297
|
+
}), w++;
|
|
1313
1298
|
}
|
|
1314
|
-
|
|
1299
|
+
I++;
|
|
1315
1300
|
}
|
|
1316
1301
|
return n;
|
|
1317
1302
|
}
|
|
@@ -1362,7 +1347,7 @@ const ve = {
|
|
|
1362
1347
|
{ x: 0, y: 1 }
|
|
1363
1348
|
// down
|
|
1364
1349
|
];
|
|
1365
|
-
class
|
|
1350
|
+
class Ee {
|
|
1366
1351
|
constructor(t, i = {}) {
|
|
1367
1352
|
this.config = t, this.imageConfig = i;
|
|
1368
1353
|
}
|
|
@@ -1374,65 +1359,65 @@ class we {
|
|
|
1374
1359
|
* @returns Array of layout objects with position, rotation, scale
|
|
1375
1360
|
*/
|
|
1376
1361
|
generate(t, i, e = {}) {
|
|
1377
|
-
const n = [], { width:
|
|
1362
|
+
const n = [], { width: s, height: r } = i, a = { ...ve, ...this.config.grid }, c = this.config.spacing.padding, l = e.fixedHeight ?? 200, u = this.imageConfig.rotation?.mode ?? "none", h = this.imageConfig.sizing?.variance?.min ?? 1, d = this.imageConfig.sizing?.variance?.max ?? 1, g = h !== 1 || d !== 1, b = s - 2 * c, p = r - 2 * c, { columns: f, rows: m } = this.calculateGridDimensions(
|
|
1378
1363
|
t,
|
|
1379
1364
|
b,
|
|
1380
1365
|
p,
|
|
1381
1366
|
l,
|
|
1382
|
-
|
|
1383
|
-
), y =
|
|
1367
|
+
a
|
|
1368
|
+
), y = a.stagger === "row", E = a.stagger === "column", v = y ? f + 0.5 : f, S = E ? m + 0.5 : m, w = (b - a.gap * (f - 1)) / v, I = (p - a.gap * (m - 1)) / S, O = y ? w / 2 : 0, L = E ? I / 2 : 0, P = 1 + a.overlap, z = Math.min(w, I) * P, H = e.fixedHeight ? Math.min(e.fixedHeight, z) : z, N = f * w + (f - 1) * a.gap + O, C = m * I + (m - 1) * a.gap + L, D = c + (b - N) / 2, W = c + (p - C) / 2, U = f * m, M = a.columns !== "auto" && a.rows !== "auto", R = M && t > U;
|
|
1384
1369
|
typeof window < "u" && (window.__gridOverflowDebug = {
|
|
1385
|
-
gridConfigColumns:
|
|
1386
|
-
gridConfigRows:
|
|
1387
|
-
columns:
|
|
1370
|
+
gridConfigColumns: a.columns,
|
|
1371
|
+
gridConfigRows: a.rows,
|
|
1372
|
+
columns: f,
|
|
1388
1373
|
rows: m,
|
|
1389
1374
|
cellCount: U,
|
|
1390
1375
|
hasFixedGrid: M,
|
|
1391
1376
|
imageCount: t,
|
|
1392
|
-
isOverflowMode:
|
|
1377
|
+
isOverflowMode: R
|
|
1393
1378
|
});
|
|
1394
|
-
const
|
|
1395
|
-
for (let
|
|
1379
|
+
const k = R ? new Array(U).fill(0) : [], q = Math.min(w, I) * a.overflowOffset;
|
|
1380
|
+
for (let T = 0; T < t; T++) {
|
|
1396
1381
|
let _, F, X = 0;
|
|
1397
|
-
if (
|
|
1398
|
-
const
|
|
1399
|
-
X = Math.floor(
|
|
1382
|
+
if (R && T >= U) {
|
|
1383
|
+
const G = T - U, j = G % U;
|
|
1384
|
+
X = Math.floor(G / U) + 1, k[j]++, a.fillDirection === "row" ? (_ = j % f, F = Math.floor(j / f)) : (F = j % m, _ = Math.floor(j / m));
|
|
1400
1385
|
} else
|
|
1401
|
-
|
|
1402
|
-
let $ = D + _ * (
|
|
1403
|
-
if (
|
|
1404
|
-
const
|
|
1405
|
-
$ +=
|
|
1386
|
+
a.fillDirection === "row" ? (_ = T % f, F = Math.floor(T / f)) : (F = T % m, _ = Math.floor(T / m));
|
|
1387
|
+
let $ = D + _ * (w + a.gap) + w / 2, B = W + F * (I + a.gap) + I / 2;
|
|
1388
|
+
if (a.stagger === "row" && F % 2 === 1 ? $ += w / 2 : a.stagger === "column" && _ % 2 === 1 && (B += I / 2), X > 0) {
|
|
1389
|
+
const G = (X - 1) % Lt.length, j = Lt[G];
|
|
1390
|
+
$ += j.x * q, B += j.y * q;
|
|
1406
1391
|
}
|
|
1407
|
-
if (
|
|
1408
|
-
const
|
|
1409
|
-
$ += this.random(-
|
|
1392
|
+
if (a.jitter > 0) {
|
|
1393
|
+
const G = w / 2 * a.jitter, j = I / 2 * a.jitter;
|
|
1394
|
+
$ += this.random(-G, G), B += this.random(-j, j);
|
|
1410
1395
|
}
|
|
1411
|
-
let Y = $, J =
|
|
1412
|
-
if (!
|
|
1413
|
-
const
|
|
1414
|
-
if (F === Math.floor((t - 1) /
|
|
1415
|
-
const
|
|
1396
|
+
let Y = $, J = B;
|
|
1397
|
+
if (!R && a.fillDirection === "row") {
|
|
1398
|
+
const G = t % f || f;
|
|
1399
|
+
if (F === Math.floor((t - 1) / f) && G < f) {
|
|
1400
|
+
const At = G * w + (G - 1) * a.gap;
|
|
1416
1401
|
let gt = 0;
|
|
1417
|
-
|
|
1402
|
+
a.alignment === "center" ? gt = (N - At) / 2 : a.alignment === "end" && (gt = N - At), Y += gt;
|
|
1418
1403
|
}
|
|
1419
1404
|
}
|
|
1420
|
-
const
|
|
1421
|
-
Y = Math.max(
|
|
1422
|
-
let
|
|
1405
|
+
const ct = g ? this.random(h, d) : 1, K = H * ct, nt = K * 1.5 / 2, ot = K / 2, ht = c + nt, dt = s - c - nt, Ut = c + ot, Ht = r - c - ot;
|
|
1406
|
+
Y = Math.max(ht, Math.min(Y, dt)), J = Math.max(Ut, Math.min(J, Ht));
|
|
1407
|
+
let ut = 0;
|
|
1423
1408
|
if (u === "random") {
|
|
1424
|
-
const
|
|
1425
|
-
|
|
1409
|
+
const G = this.imageConfig.rotation?.range?.min ?? -15, j = this.imageConfig.rotation?.range?.max ?? 15;
|
|
1410
|
+
a.jitter > 0 ? ut = this.random(G * a.jitter, j * a.jitter) : ut = this.random(G, j);
|
|
1426
1411
|
}
|
|
1427
|
-
let
|
|
1428
|
-
|
|
1429
|
-
id:
|
|
1412
|
+
let ft;
|
|
1413
|
+
R && X > 0 ? ft = 50 - X : ft = R ? 100 + T : T + 1, n.push({
|
|
1414
|
+
id: T,
|
|
1430
1415
|
x: Y,
|
|
1431
1416
|
y: J,
|
|
1432
|
-
rotation:
|
|
1433
|
-
scale:
|
|
1417
|
+
rotation: ut,
|
|
1418
|
+
scale: ct,
|
|
1434
1419
|
baseSize: K,
|
|
1435
|
-
zIndex:
|
|
1420
|
+
zIndex: ft
|
|
1436
1421
|
});
|
|
1437
1422
|
}
|
|
1438
1423
|
return n;
|
|
@@ -1440,20 +1425,20 @@ class we {
|
|
|
1440
1425
|
/**
|
|
1441
1426
|
* Calculate optimal grid dimensions based on image count and container
|
|
1442
1427
|
*/
|
|
1443
|
-
calculateGridDimensions(t, i, e, n,
|
|
1444
|
-
let r,
|
|
1445
|
-
if (
|
|
1446
|
-
r =
|
|
1447
|
-
else if (
|
|
1448
|
-
r =
|
|
1449
|
-
else if (
|
|
1450
|
-
|
|
1428
|
+
calculateGridDimensions(t, i, e, n, s) {
|
|
1429
|
+
let r, a;
|
|
1430
|
+
if (s.columns !== "auto" && s.rows !== "auto")
|
|
1431
|
+
r = s.columns, a = s.rows;
|
|
1432
|
+
else if (s.columns !== "auto")
|
|
1433
|
+
r = s.columns, a = Math.ceil(t / r);
|
|
1434
|
+
else if (s.rows !== "auto")
|
|
1435
|
+
a = s.rows, r = Math.ceil(t / a);
|
|
1451
1436
|
else {
|
|
1452
1437
|
const c = i / e;
|
|
1453
|
-
for (r = Math.max(1, Math.round(Math.sqrt(t * c / 1.4))),
|
|
1438
|
+
for (r = Math.max(1, Math.round(Math.sqrt(t * c / 1.4))), a = Math.ceil(t / r); r > 1 && (r - 1) * a >= t; )
|
|
1454
1439
|
r--;
|
|
1455
1440
|
}
|
|
1456
|
-
return { columns: Math.max(1, r), rows: Math.max(1,
|
|
1441
|
+
return { columns: Math.max(1, r), rows: Math.max(1, a) };
|
|
1457
1442
|
}
|
|
1458
1443
|
/**
|
|
1459
1444
|
* Utility: Generate random number between min and max
|
|
@@ -1462,7 +1447,7 @@ class we {
|
|
|
1462
1447
|
return Math.random() * (i - t) + t;
|
|
1463
1448
|
}
|
|
1464
1449
|
}
|
|
1465
|
-
const
|
|
1450
|
+
const we = Math.PI * (3 - Math.sqrt(5)), xe = {
|
|
1466
1451
|
spiralType: "golden",
|
|
1467
1452
|
direction: "counterclockwise",
|
|
1468
1453
|
tightness: 1,
|
|
@@ -1481,35 +1466,35 @@ class Se {
|
|
|
1481
1466
|
* @returns Array of layout objects with position, rotation, scale
|
|
1482
1467
|
*/
|
|
1483
1468
|
generate(t, i, e = {}) {
|
|
1484
|
-
const n = [], { width:
|
|
1469
|
+
const n = [], { width: s, height: r } = i, a = { ...xe, ...this.config.spiral }, c = this.config.spacing.padding, l = e.fixedHeight ?? 200, u = this.imageConfig.rotation?.mode ?? "none", h = this.imageConfig.rotation?.range?.min ?? -15, d = this.imageConfig.rotation?.range?.max ?? 15, g = this.imageConfig.sizing?.variance?.min ?? 1, b = this.imageConfig.sizing?.variance?.max ?? 1, p = g !== 1 || b !== 1, f = this.config.scaleDecay ?? a.scaleDecay, m = s / 2, y = r / 2, E = Math.min(
|
|
1485
1470
|
m - c - l / 2,
|
|
1486
1471
|
y - c - l / 2
|
|
1487
|
-
), v =
|
|
1488
|
-
for (let
|
|
1489
|
-
let
|
|
1490
|
-
if (
|
|
1491
|
-
|
|
1492
|
-
else if (
|
|
1493
|
-
const $ =
|
|
1494
|
-
|
|
1472
|
+
), v = a.direction === "clockwise" ? -1 : 1;
|
|
1473
|
+
for (let S = 0; S < t; S++) {
|
|
1474
|
+
let w, I;
|
|
1475
|
+
if (a.spiralType === "golden")
|
|
1476
|
+
w = S * we * v + a.startAngle, I = this.calculateGoldenRadius(S, t, E, a.tightness);
|
|
1477
|
+
else if (a.spiralType === "archimedean") {
|
|
1478
|
+
const $ = S * 0.5 * a.tightness;
|
|
1479
|
+
w = $ * v + a.startAngle, I = this.calculateArchimedeanRadius($, t, E, a.tightness);
|
|
1495
1480
|
} else {
|
|
1496
|
-
const $ =
|
|
1497
|
-
|
|
1481
|
+
const $ = S * 0.3 * a.tightness;
|
|
1482
|
+
w = $ * v + a.startAngle, I = this.calculateLogarithmicRadius($, t, E, a.tightness);
|
|
1498
1483
|
}
|
|
1499
|
-
const O = m + Math.cos(
|
|
1484
|
+
const O = m + Math.cos(w) * I, L = y + Math.sin(w) * I, P = I / E, z = f > 0 ? 1 - P * f * 0.5 : 1, H = p ? this.random(g, b) : 1, N = z * H, C = l * N, W = C * 1.5 / 2, U = C / 2, M = c + W, R = s - c - W, k = c + U, q = r - c - U, T = Math.max(M, Math.min(O, R)), _ = Math.max(k, Math.min(L, q));
|
|
1500
1485
|
let F = 0;
|
|
1501
1486
|
if (u === "random") {
|
|
1502
|
-
const $ =
|
|
1503
|
-
F =
|
|
1504
|
-
} else u === "tangent" && (F = this.calculateSpiralTangent(
|
|
1505
|
-
const X = t -
|
|
1487
|
+
const $ = w * 180 / Math.PI % 360, B = this.random(h, d);
|
|
1488
|
+
F = a.spiralType === "golden" ? B : $ * 0.1 + B * 0.9;
|
|
1489
|
+
} else u === "tangent" && (F = this.calculateSpiralTangent(w, I, a));
|
|
1490
|
+
const X = t - S;
|
|
1506
1491
|
n.push({
|
|
1507
|
-
id:
|
|
1508
|
-
x:
|
|
1492
|
+
id: S,
|
|
1493
|
+
x: T,
|
|
1509
1494
|
y: _,
|
|
1510
1495
|
rotation: F,
|
|
1511
|
-
scale:
|
|
1512
|
-
baseSize:
|
|
1496
|
+
scale: N,
|
|
1497
|
+
baseSize: C,
|
|
1513
1498
|
zIndex: X
|
|
1514
1499
|
});
|
|
1515
1500
|
}
|
|
@@ -1524,11 +1509,11 @@ class Se {
|
|
|
1524
1509
|
if (e.spiralType === "golden")
|
|
1525
1510
|
n = t + Math.PI / 2;
|
|
1526
1511
|
else if (e.spiralType === "archimedean") {
|
|
1527
|
-
const r = 1 / e.tightness,
|
|
1528
|
-
n = t +
|
|
1512
|
+
const r = 1 / e.tightness, a = Math.atan(i / r);
|
|
1513
|
+
n = t + a;
|
|
1529
1514
|
} else {
|
|
1530
|
-
const r = 0.15 / e.tightness,
|
|
1531
|
-
n = t +
|
|
1515
|
+
const r = 0.15 / e.tightness, a = Math.atan(1 / r);
|
|
1516
|
+
n = t + a;
|
|
1532
1517
|
}
|
|
1533
1518
|
return n * 180 / Math.PI % 360 - 90;
|
|
1534
1519
|
}
|
|
@@ -1545,16 +1530,16 @@ class Se {
|
|
|
1545
1530
|
* r = a + b*θ (constant spacing between arms)
|
|
1546
1531
|
*/
|
|
1547
1532
|
calculateArchimedeanRadius(t, i, e, n) {
|
|
1548
|
-
const
|
|
1549
|
-
return t /
|
|
1533
|
+
const s = i * 0.5 * n;
|
|
1534
|
+
return t / s * e;
|
|
1550
1535
|
}
|
|
1551
1536
|
/**
|
|
1552
1537
|
* Calculate radius for logarithmic (equiangular) spiral
|
|
1553
1538
|
* r = a * e^(b*θ)
|
|
1554
1539
|
*/
|
|
1555
1540
|
calculateLogarithmicRadius(t, i, e, n) {
|
|
1556
|
-
const
|
|
1557
|
-
return
|
|
1541
|
+
const s = e * 0.05, r = 0.15 / n, a = s * Math.exp(r * t), c = i * 0.3 * n, l = s * Math.exp(r * c);
|
|
1542
|
+
return a / l * e;
|
|
1558
1543
|
}
|
|
1559
1544
|
/**
|
|
1560
1545
|
* Utility: Generate random number between min and max
|
|
@@ -1571,7 +1556,7 @@ const Ie = {
|
|
|
1571
1556
|
overlap: 0.3,
|
|
1572
1557
|
distribution: "gaussian"
|
|
1573
1558
|
};
|
|
1574
|
-
class
|
|
1559
|
+
class Ae {
|
|
1575
1560
|
constructor(t, i = {}) {
|
|
1576
1561
|
this.config = t, this.imageConfig = i;
|
|
1577
1562
|
}
|
|
@@ -1583,48 +1568,48 @@ class Re {
|
|
|
1583
1568
|
* @returns Array of layout objects with position, rotation, scale
|
|
1584
1569
|
*/
|
|
1585
1570
|
generate(t, i, e = {}) {
|
|
1586
|
-
const n = [], { width:
|
|
1571
|
+
const n = [], { width: s, height: r } = i, a = { ...Ie, ...this.config.cluster }, c = this.config.spacing.padding, l = e.fixedHeight ?? 200, u = this.imageConfig.rotation?.mode ?? "none", h = this.imageConfig.rotation?.range?.min ?? -15, d = this.imageConfig.rotation?.range?.max ?? 15, g = this.imageConfig.sizing?.variance?.min ?? 1, b = this.imageConfig.sizing?.variance?.max ?? 1, p = g !== 1 || b !== 1, f = this.calculateClusterCount(
|
|
1587
1572
|
t,
|
|
1588
|
-
|
|
1589
|
-
|
|
1573
|
+
a.clusterCount,
|
|
1574
|
+
s,
|
|
1590
1575
|
r,
|
|
1591
|
-
|
|
1576
|
+
a.clusterSpacing
|
|
1592
1577
|
), m = this.generateClusterCenters(
|
|
1593
|
-
|
|
1594
|
-
|
|
1578
|
+
f,
|
|
1579
|
+
s,
|
|
1595
1580
|
r,
|
|
1596
1581
|
c,
|
|
1597
|
-
|
|
1598
|
-
), y = new Array(
|
|
1582
|
+
a
|
|
1583
|
+
), y = new Array(f).fill(0);
|
|
1599
1584
|
for (let v = 0; v < t; v++)
|
|
1600
|
-
y[v %
|
|
1601
|
-
let
|
|
1602
|
-
for (let v = 0; v <
|
|
1603
|
-
const
|
|
1604
|
-
for (let
|
|
1585
|
+
y[v % f]++;
|
|
1586
|
+
let E = 0;
|
|
1587
|
+
for (let v = 0; v < f; v++) {
|
|
1588
|
+
const S = m[v], w = y[v];
|
|
1589
|
+
for (let I = 0; I < w; I++) {
|
|
1605
1590
|
let O, L;
|
|
1606
|
-
if (
|
|
1607
|
-
O = this.gaussianRandom() *
|
|
1591
|
+
if (a.distribution === "gaussian")
|
|
1592
|
+
O = this.gaussianRandom() * S.spread, L = this.gaussianRandom() * S.spread;
|
|
1608
1593
|
else {
|
|
1609
|
-
const F = this.random(0, Math.PI * 2), X = this.random(0,
|
|
1594
|
+
const F = this.random(0, Math.PI * 2), X = this.random(0, S.spread);
|
|
1610
1595
|
O = Math.cos(F) * X, L = Math.sin(F) * X;
|
|
1611
1596
|
}
|
|
1612
|
-
const P = 1 +
|
|
1597
|
+
const P = 1 + a.overlap * 0.5, z = 1 + a.overlap * 0.3;
|
|
1613
1598
|
O /= P, L /= P;
|
|
1614
|
-
const H = p ? this.random(
|
|
1615
|
-
let D =
|
|
1616
|
-
const M =
|
|
1617
|
-
D = Math.max(c + M, Math.min(D,
|
|
1618
|
-
const
|
|
1599
|
+
const H = p ? this.random(g, b) : 1, N = z * H, C = l * N;
|
|
1600
|
+
let D = S.x + O, W = S.y + L;
|
|
1601
|
+
const M = C * 1.5 / 2, R = C / 2;
|
|
1602
|
+
D = Math.max(c + M, Math.min(D, s - c - M)), W = Math.max(c + R, Math.min(W, r - c - R));
|
|
1603
|
+
const k = u === "random" ? this.random(h, d) : 0, T = Math.sqrt(O * O + L * L) / S.spread, _ = Math.round((1 - T) * 50) + 1;
|
|
1619
1604
|
n.push({
|
|
1620
|
-
id:
|
|
1605
|
+
id: E,
|
|
1621
1606
|
x: D,
|
|
1622
|
-
y:
|
|
1623
|
-
rotation:
|
|
1624
|
-
scale:
|
|
1625
|
-
baseSize:
|
|
1607
|
+
y: W,
|
|
1608
|
+
rotation: k,
|
|
1609
|
+
scale: N,
|
|
1610
|
+
baseSize: C,
|
|
1626
1611
|
zIndex: _
|
|
1627
|
-
}),
|
|
1612
|
+
}), E++;
|
|
1628
1613
|
}
|
|
1629
1614
|
}
|
|
1630
1615
|
return n;
|
|
@@ -1632,36 +1617,36 @@ class Re {
|
|
|
1632
1617
|
/**
|
|
1633
1618
|
* Calculate optimal number of clusters based on image count and container
|
|
1634
1619
|
*/
|
|
1635
|
-
calculateClusterCount(t, i, e, n,
|
|
1620
|
+
calculateClusterCount(t, i, e, n, s) {
|
|
1636
1621
|
if (i !== "auto")
|
|
1637
1622
|
return Math.max(1, Math.min(i, t));
|
|
1638
|
-
const
|
|
1639
|
-
e /
|
|
1623
|
+
const a = Math.max(1, Math.ceil(t / 8)), c = Math.floor(
|
|
1624
|
+
e / s * (n / s) * 0.6
|
|
1640
1625
|
);
|
|
1641
|
-
return Math.max(1, Math.min(
|
|
1626
|
+
return Math.max(1, Math.min(a, c, 10));
|
|
1642
1627
|
}
|
|
1643
1628
|
/**
|
|
1644
1629
|
* Generate cluster center positions with spacing constraints
|
|
1645
1630
|
*/
|
|
1646
|
-
generateClusterCenters(t, i, e, n,
|
|
1647
|
-
const r = [], c = n +
|
|
1631
|
+
generateClusterCenters(t, i, e, n, s) {
|
|
1632
|
+
const r = [], c = n + s.clusterSpread, l = i - n - s.clusterSpread, u = n + s.clusterSpread, h = e - n - s.clusterSpread;
|
|
1648
1633
|
for (let d = 0; d < t; d++) {
|
|
1649
|
-
let
|
|
1634
|
+
let g = null, b = -1;
|
|
1650
1635
|
for (let p = 0; p < 100; p++) {
|
|
1651
|
-
const
|
|
1636
|
+
const f = {
|
|
1652
1637
|
x: this.random(c, l),
|
|
1653
1638
|
y: this.random(u, h),
|
|
1654
|
-
spread: this.calculateClusterSpread(
|
|
1639
|
+
spread: this.calculateClusterSpread(s)
|
|
1655
1640
|
};
|
|
1656
1641
|
let m = 1 / 0;
|
|
1657
1642
|
for (const y of r) {
|
|
1658
|
-
const
|
|
1659
|
-
m = Math.min(m,
|
|
1643
|
+
const E = f.x - y.x, v = f.y - y.y, S = Math.sqrt(E * E + v * v);
|
|
1644
|
+
m = Math.min(m, S);
|
|
1660
1645
|
}
|
|
1661
|
-
if ((r.length === 0 || m > b) && (
|
|
1646
|
+
if ((r.length === 0 || m > b) && (g = f, b = m), m >= s.clusterSpacing)
|
|
1662
1647
|
break;
|
|
1663
1648
|
}
|
|
1664
|
-
|
|
1649
|
+
g && r.push(g);
|
|
1665
1650
|
}
|
|
1666
1651
|
return r;
|
|
1667
1652
|
}
|
|
@@ -1689,7 +1674,7 @@ class Re {
|
|
|
1689
1674
|
return Math.random() * (i - t) + t;
|
|
1690
1675
|
}
|
|
1691
1676
|
}
|
|
1692
|
-
class
|
|
1677
|
+
class Ce {
|
|
1693
1678
|
constructor(t, i = {}) {
|
|
1694
1679
|
this.config = t, this.imageConfig = i;
|
|
1695
1680
|
}
|
|
@@ -1701,26 +1686,26 @@ class Ae {
|
|
|
1701
1686
|
* @returns Array of layout objects with position, rotation, scale
|
|
1702
1687
|
*/
|
|
1703
1688
|
generate(t, i, e = {}) {
|
|
1704
|
-
const n = [], { width:
|
|
1705
|
-
...
|
|
1689
|
+
const n = [], { width: s, height: r } = i, a = e.fixedHeight ?? 200, c = this.config.spacing.padding ?? 50, l = this.imageConfig.rotation?.mode ?? "none", u = this.imageConfig.rotation?.range?.min ?? -15, h = this.imageConfig.rotation?.range?.max ?? 15, d = this.imageConfig.sizing?.variance?.min ?? 1, g = this.imageConfig.sizing?.variance?.max ?? 1, b = d !== 1 || g !== 1, p = e.fixedHeight ?? a, f = {
|
|
1690
|
+
...kt,
|
|
1706
1691
|
...this.config.wave
|
|
1707
|
-
}, { rows: m, amplitude: y, frequency:
|
|
1692
|
+
}, { rows: m, amplitude: y, frequency: E, phaseShift: v, synchronization: S } = f, w = Math.ceil(t / m), L = p * 1.5 / 2, P = c + L, z = s - c - L, H = z - P, N = w > 1 ? H / (w - 1) : 0, C = c + y + p / 2, D = r - c - y - p / 2, W = D - C, U = m > 1 ? W / (m - 1) : 0;
|
|
1708
1693
|
let M = 0;
|
|
1709
|
-
for (let
|
|
1710
|
-
const
|
|
1711
|
-
let
|
|
1712
|
-
|
|
1713
|
-
for (let
|
|
1714
|
-
const _ =
|
|
1694
|
+
for (let R = 0; R < m && M < t; R++) {
|
|
1695
|
+
const k = m === 1 ? (C + D) / 2 : C + R * U;
|
|
1696
|
+
let q = 0;
|
|
1697
|
+
S === "offset" ? q = R * v : S === "alternating" && (q = R * Math.PI);
|
|
1698
|
+
for (let T = 0; T < w && M < t; T++) {
|
|
1699
|
+
const _ = w === 1 ? (P + z) / 2 : P + T * N, F = this.calculateWaveY(_, s, y, E, q), X = _, $ = k + F, B = b ? this.random(d, g) : 1, Y = p * B;
|
|
1715
1700
|
let J = 0;
|
|
1716
|
-
l === "tangent" ? J = this.calculateRotation(_,
|
|
1717
|
-
const K = Y * 1.5 / 2,
|
|
1701
|
+
l === "tangent" ? J = this.calculateRotation(_, s, y, E, q) : l === "random" && (J = this.random(u, h));
|
|
1702
|
+
const K = Y * 1.5 / 2, lt = Y / 2, nt = c + K, ot = s - c - K, ht = c + lt, dt = r - c - lt;
|
|
1718
1703
|
n.push({
|
|
1719
1704
|
id: M,
|
|
1720
|
-
x: Math.max(
|
|
1721
|
-
y: Math.max(
|
|
1705
|
+
x: Math.max(nt, Math.min(X, ot)),
|
|
1706
|
+
y: Math.max(ht, Math.min($, dt)),
|
|
1722
1707
|
rotation: J,
|
|
1723
|
-
scale:
|
|
1708
|
+
scale: B,
|
|
1724
1709
|
baseSize: Y,
|
|
1725
1710
|
zIndex: M + 1
|
|
1726
1711
|
}), M++;
|
|
@@ -1737,9 +1722,9 @@ class Ae {
|
|
|
1737
1722
|
* @param phase - Phase offset
|
|
1738
1723
|
* @returns Y displacement from baseline
|
|
1739
1724
|
*/
|
|
1740
|
-
calculateWaveY(t, i, e, n,
|
|
1725
|
+
calculateWaveY(t, i, e, n, s) {
|
|
1741
1726
|
const r = t / i;
|
|
1742
|
-
return e * Math.sin(n * r * 2 * Math.PI +
|
|
1727
|
+
return e * Math.sin(n * r * 2 * Math.PI + s);
|
|
1743
1728
|
}
|
|
1744
1729
|
/**
|
|
1745
1730
|
* Calculate rotation based on wave tangent
|
|
@@ -1750,9 +1735,9 @@ class Ae {
|
|
|
1750
1735
|
* @param phase - Phase offset
|
|
1751
1736
|
* @returns Rotation angle in degrees
|
|
1752
1737
|
*/
|
|
1753
|
-
calculateRotation(t, i, e, n,
|
|
1754
|
-
const r = t / i,
|
|
1755
|
-
return Math.atan(
|
|
1738
|
+
calculateRotation(t, i, e, n, s) {
|
|
1739
|
+
const r = t / i, a = e * n * 2 * Math.PI * Math.cos(n * r * 2 * Math.PI + s) / i;
|
|
1740
|
+
return Math.atan(a) * (180 / Math.PI);
|
|
1756
1741
|
}
|
|
1757
1742
|
/**
|
|
1758
1743
|
* Estimate image width based on height
|
|
@@ -1779,18 +1764,18 @@ const xt = 100, Q = 100 / Math.sqrt(3), St = [
|
|
|
1779
1764
|
// lower-left
|
|
1780
1765
|
[0, 50]
|
|
1781
1766
|
// left
|
|
1782
|
-
],
|
|
1767
|
+
], Re = St[1][0] / xt, Te = St[2][1] / xt;
|
|
1783
1768
|
function Le(o) {
|
|
1784
1769
|
return {
|
|
1785
|
-
colStep:
|
|
1786
|
-
rowOffset:
|
|
1770
|
+
colStep: Re * o,
|
|
1771
|
+
rowOffset: Te * o
|
|
1787
1772
|
};
|
|
1788
1773
|
}
|
|
1789
|
-
function Me(o, t, i, e, n,
|
|
1790
|
-
const { colStep: r } = Le(
|
|
1774
|
+
function Me(o, t, i, e, n, s) {
|
|
1775
|
+
const { colStep: r } = Le(s);
|
|
1791
1776
|
return {
|
|
1792
1777
|
px: e + r * o,
|
|
1793
|
-
py: n +
|
|
1778
|
+
py: n + s * (t + o / 2)
|
|
1794
1779
|
};
|
|
1795
1780
|
}
|
|
1796
1781
|
const Fe = [
|
|
@@ -1805,9 +1790,9 @@ function Oe(o) {
|
|
|
1805
1790
|
if (o === 0) return [[0, 0, 0]];
|
|
1806
1791
|
const t = [];
|
|
1807
1792
|
let [i, e, n] = [0, -o, o];
|
|
1808
|
-
for (const [
|
|
1793
|
+
for (const [s, r, a] of Fe)
|
|
1809
1794
|
for (let c = 0; c < o; c++)
|
|
1810
|
-
t.push([i, e, n]), i +=
|
|
1795
|
+
t.push([i, e, n]), i += s, e += r, n += a;
|
|
1811
1796
|
return t;
|
|
1812
1797
|
}
|
|
1813
1798
|
class ze {
|
|
@@ -1817,26 +1802,26 @@ class ze {
|
|
|
1817
1802
|
this.config = t;
|
|
1818
1803
|
}
|
|
1819
1804
|
generate(t, i, e = {}) {
|
|
1820
|
-
const n = [], { width:
|
|
1821
|
-
...
|
|
1805
|
+
const n = [], { width: s, height: r } = i, a = s / 2, c = r / 2, l = e.fixedHeight ?? 200, h = {
|
|
1806
|
+
...Bt,
|
|
1822
1807
|
...this.config.honeycomb
|
|
1823
1808
|
}.spacing ?? 0, d = l + h;
|
|
1824
|
-
let
|
|
1825
|
-
for (;
|
|
1809
|
+
let g = 0, b = 0;
|
|
1810
|
+
for (; g < t; ) {
|
|
1826
1811
|
const p = Oe(b);
|
|
1827
|
-
for (const [
|
|
1828
|
-
if (
|
|
1829
|
-
const { px:
|
|
1812
|
+
for (const [f, m, y] of p) {
|
|
1813
|
+
if (g >= t) break;
|
|
1814
|
+
const { px: E, py: v } = Me(f, m, y, a, c, d);
|
|
1830
1815
|
n.push({
|
|
1831
|
-
id:
|
|
1832
|
-
x:
|
|
1816
|
+
id: g,
|
|
1817
|
+
x: E,
|
|
1833
1818
|
y: v,
|
|
1834
1819
|
rotation: 0,
|
|
1835
1820
|
scale: 1,
|
|
1836
1821
|
baseSize: l,
|
|
1837
1822
|
// Inner rings render above outer rings
|
|
1838
1823
|
zIndex: Math.max(1, 100 - b)
|
|
1839
|
-
}),
|
|
1824
|
+
}), g++;
|
|
1840
1825
|
}
|
|
1841
1826
|
b++;
|
|
1842
1827
|
}
|
|
@@ -1856,13 +1841,13 @@ class De {
|
|
|
1856
1841
|
case "radial":
|
|
1857
1842
|
return new ye(this.config, this.imageConfig);
|
|
1858
1843
|
case "grid":
|
|
1859
|
-
return new
|
|
1844
|
+
return new Ee(this.config, this.imageConfig);
|
|
1860
1845
|
case "spiral":
|
|
1861
1846
|
return new Se(this.config, this.imageConfig);
|
|
1862
1847
|
case "cluster":
|
|
1863
|
-
return new Re(this.config, this.imageConfig);
|
|
1864
|
-
case "wave":
|
|
1865
1848
|
return new Ae(this.config, this.imageConfig);
|
|
1849
|
+
case "wave":
|
|
1850
|
+
return new Ce(this.config, this.imageConfig);
|
|
1866
1851
|
case "honeycomb":
|
|
1867
1852
|
return new ze(this.config, this.imageConfig);
|
|
1868
1853
|
default:
|
|
@@ -1878,8 +1863,8 @@ class De {
|
|
|
1878
1863
|
*/
|
|
1879
1864
|
generateLayout(t, i, e = {}) {
|
|
1880
1865
|
const n = this.placementLayout.generate(t, i, e);
|
|
1881
|
-
return n.forEach((
|
|
1882
|
-
this.layouts.set(
|
|
1866
|
+
return n.forEach((s) => {
|
|
1867
|
+
this.layouts.set(s.id, s);
|
|
1883
1868
|
}), n;
|
|
1884
1869
|
}
|
|
1885
1870
|
/**
|
|
@@ -1933,8 +1918,8 @@ class De {
|
|
|
1933
1918
|
return;
|
|
1934
1919
|
if (typeof e == "number")
|
|
1935
1920
|
return e;
|
|
1936
|
-
const n = e,
|
|
1937
|
-
return
|
|
1921
|
+
const n = e, s = this.resolveBreakpoint(t);
|
|
1922
|
+
return s === "mobile" ? n.mobile ?? n.tablet ?? n.screen : s === "tablet" ? n.tablet ?? n.screen ?? n.mobile : n.screen ?? n.tablet ?? n.mobile;
|
|
1938
1923
|
}
|
|
1939
1924
|
/**
|
|
1940
1925
|
* Calculate adaptive image size based on container dimensions and image count
|
|
@@ -1945,16 +1930,16 @@ class De {
|
|
|
1945
1930
|
* @returns Calculated sizing result with height
|
|
1946
1931
|
*/
|
|
1947
1932
|
calculateAdaptiveSize(t, i, e, n) {
|
|
1948
|
-
const
|
|
1933
|
+
const s = this.imageConfig.sizing, r = this.resolveBaseHeight(n);
|
|
1949
1934
|
if (r !== void 0)
|
|
1950
1935
|
return { height: r };
|
|
1951
|
-
const
|
|
1936
|
+
const a = s?.minSize ?? 50, c = s?.maxSize ?? 400, l = this.config.targetCoverage ?? 0.6, u = this.config.densityFactor ?? 1, { width: h, height: d } = t, p = h * d * l / i;
|
|
1952
1937
|
let m = Math.sqrt(p / 1.4);
|
|
1953
1938
|
m *= u, m = Math.min(m, e);
|
|
1954
|
-
let y = this.clamp(m,
|
|
1955
|
-
if (y ===
|
|
1956
|
-
const
|
|
1957
|
-
y = Math.max(
|
|
1939
|
+
let y = this.clamp(m, a, c);
|
|
1940
|
+
if (y === a && m < a) {
|
|
1941
|
+
const E = Math.max(a * 0.05, 20);
|
|
1942
|
+
y = Math.max(E, m);
|
|
1958
1943
|
}
|
|
1959
1944
|
return this.config.algorithm === "honeycomb" && (y = Math.min(y, this.honeycombMaxImageHeight(i, t))), { height: y };
|
|
1960
1945
|
}
|
|
@@ -1968,7 +1953,7 @@ class De {
|
|
|
1968
1953
|
let e = 0, n = 1;
|
|
1969
1954
|
for (; n < t; )
|
|
1970
1955
|
e++, n += 6 * e;
|
|
1971
|
-
const
|
|
1956
|
+
const s = this.config.spacing?.padding ?? 50, r = this.config.honeycomb?.spacing ?? 0, a = i.width / 2, c = i.height / 2, l = Math.sqrt(3) / 2, u = 1 / Math.sqrt(3), h = (c - s - r * e) / (e + 0.5), d = (a - s - l * r * e) / (l * e + u);
|
|
1972
1957
|
return Math.max(10, Math.min(h, d));
|
|
1973
1958
|
}
|
|
1974
1959
|
/**
|
|
@@ -1978,7 +1963,7 @@ class De {
|
|
|
1978
1963
|
return Math.max(i, Math.min(e, t));
|
|
1979
1964
|
}
|
|
1980
1965
|
}
|
|
1981
|
-
var
|
|
1966
|
+
var x = /* @__PURE__ */ ((o) => (o.IDLE = "idle", o.FOCUSING = "focusing", o.FOCUSED = "focused", o.UNFOCUSING = "unfocusing", o.CROSS_ANIMATING = "cross_animating", o))(x || {});
|
|
1982
1967
|
const Mt = {
|
|
1983
1968
|
// Geometric shapes - uses percentages for responsive sizing
|
|
1984
1969
|
circle: "circle(50%)",
|
|
@@ -2036,9 +2021,9 @@ function Pe(o, t, i) {
|
|
|
2036
2021
|
const n = t / e.refHeight;
|
|
2037
2022
|
if (o === "circle")
|
|
2038
2023
|
return `circle(${Math.round(50 * n * 100) / 100}px)`;
|
|
2039
|
-
const
|
|
2040
|
-
return `polygon(${e.points.map(([p,
|
|
2041
|
-
const m = Math.round((p * n + d) * 100) / 100, y = Math.round((
|
|
2024
|
+
const s = e.points.map(([p]) => p), r = e.points.map(([, p]) => p), a = (Math.min(...s) + Math.max(...s)) / 2 * n, c = (Math.min(...r) + Math.max(...r)) / 2 * n, l = (Math.max(...s) - Math.min(...s)) * n, u = (i ?? l) / 2, h = t / 2, d = u - a, g = h - c;
|
|
2025
|
+
return `polygon(${e.points.map(([p, f]) => {
|
|
2026
|
+
const m = Math.round((p * n + d) * 100) / 100, y = Math.round((f * n + g) * 100) / 100;
|
|
2042
2027
|
return `${m}px ${y}px`;
|
|
2043
2028
|
}).join(", ")})`;
|
|
2044
2029
|
}
|
|
@@ -2048,7 +2033,7 @@ function Ue(o) {
|
|
|
2048
2033
|
function He(o) {
|
|
2049
2034
|
return o ? Ue(o) ? mt[o] : o : mt.md;
|
|
2050
2035
|
}
|
|
2051
|
-
function
|
|
2036
|
+
function Ne(o) {
|
|
2052
2037
|
if (!o) return "";
|
|
2053
2038
|
const t = [];
|
|
2054
2039
|
if (o.grayscale !== void 0 && t.push(`grayscale(${o.grayscale})`), o.blur !== void 0 && t.push(`blur(${o.blur}px)`), o.brightness !== void 0 && t.push(`brightness(${o.brightness})`), o.contrast !== void 0 && t.push(`contrast(${o.contrast})`), o.saturate !== void 0 && t.push(`saturate(${o.saturate})`), o.opacity !== void 0 && t.push(`opacity(${o.opacity})`), o.sepia !== void 0 && t.push(`sepia(${o.sepia})`), o.hueRotate !== void 0 && t.push(`hue-rotate(${o.hueRotate}deg)`), o.invert !== void 0 && t.push(`invert(${o.invert})`), o.dropShadow !== void 0)
|
|
@@ -2066,47 +2051,47 @@ function tt(o) {
|
|
|
2066
2051
|
const t = o.width ?? 0, i = o.style ?? "solid", e = o.color ?? "#000000";
|
|
2067
2052
|
return `${t}px ${i} ${e}`;
|
|
2068
2053
|
}
|
|
2069
|
-
function
|
|
2054
|
+
function it(o, t, i) {
|
|
2070
2055
|
if (!o) return {};
|
|
2071
2056
|
const e = {};
|
|
2072
2057
|
if (o.borderRadiusTopLeft !== void 0 || o.borderRadiusTopRight !== void 0 || o.borderRadiusBottomRight !== void 0 || o.borderRadiusBottomLeft !== void 0) {
|
|
2073
|
-
const
|
|
2074
|
-
o.borderRadiusTopLeft !== void 0 ? e.borderTopLeftRadius = `${o.borderRadiusTopLeft}px` :
|
|
2058
|
+
const a = o.border?.radius ?? 0;
|
|
2059
|
+
o.borderRadiusTopLeft !== void 0 ? e.borderTopLeftRadius = `${o.borderRadiusTopLeft}px` : a && (e.borderTopLeftRadius = `${a}px`), o.borderRadiusTopRight !== void 0 ? e.borderTopRightRadius = `${o.borderRadiusTopRight}px` : a && (e.borderTopRightRadius = `${a}px`), o.borderRadiusBottomRight !== void 0 ? e.borderBottomRightRadius = `${o.borderRadiusBottomRight}px` : a && (e.borderBottomRightRadius = `${a}px`), o.borderRadiusBottomLeft !== void 0 ? e.borderBottomLeftRadius = `${o.borderRadiusBottomLeft}px` : a && (e.borderBottomLeftRadius = `${a}px`);
|
|
2075
2060
|
} else o.border?.radius !== void 0 && (e.borderRadius = `${o.border.radius}px`);
|
|
2076
2061
|
if (o.borderTop || o.borderRight || o.borderBottom || o.borderLeft) {
|
|
2077
|
-
const
|
|
2062
|
+
const a = o.border || {}, c = { ...a, ...o.borderTop }, l = { ...a, ...o.borderRight }, u = { ...a, ...o.borderBottom }, h = { ...a, ...o.borderLeft };
|
|
2078
2063
|
e.borderTop = tt(c), e.borderRight = tt(l), e.borderBottom = tt(u), e.borderLeft = tt(h);
|
|
2079
2064
|
} else o.border && (e.border = tt(o.border));
|
|
2080
2065
|
o.shadow !== void 0 && (e.boxShadow = He(o.shadow));
|
|
2081
|
-
const r =
|
|
2066
|
+
const r = Ne(o.filter);
|
|
2082
2067
|
if (e.filter = r || "none", o.opacity !== void 0 && (e.opacity = String(o.opacity)), o.cursor !== void 0 && (e.cursor = o.cursor), o.outline && o.outline.style !== "none" && (o.outline.width ?? 0) > 0) {
|
|
2083
|
-
const
|
|
2084
|
-
e.outline = `${
|
|
2068
|
+
const a = o.outline.width ?? 0, c = o.outline.style ?? "solid", l = o.outline.color ?? "#000000";
|
|
2069
|
+
e.outline = `${a}px ${c} ${l}`, o.outline.offset !== void 0 && (e.outlineOffset = `${o.outline.offset}px`);
|
|
2085
2070
|
}
|
|
2086
2071
|
if (o.objectFit !== void 0 && (e.objectFit = o.objectFit), o.aspectRatio !== void 0 && (e.aspectRatio = o.aspectRatio), o.clipPath !== void 0) {
|
|
2087
|
-
let
|
|
2072
|
+
let a;
|
|
2088
2073
|
const c = typeof o.clipPath == "object" && o.clipPath !== null && "shape" in o.clipPath, l = c ? o.clipPath : void 0;
|
|
2089
2074
|
if (l?.mode === "height-relative" && t)
|
|
2090
|
-
|
|
2075
|
+
a = Pe(l.shape, t, i);
|
|
2091
2076
|
else {
|
|
2092
2077
|
const u = c && l ? l.shape : o.clipPath;
|
|
2093
|
-
|
|
2078
|
+
a = $e(u);
|
|
2094
2079
|
}
|
|
2095
|
-
|
|
2080
|
+
a && (a === "none" ? e.clipPath = "unset" : (e.clipPath = a, e.overflow = "hidden"));
|
|
2096
2081
|
}
|
|
2097
2082
|
return e;
|
|
2098
2083
|
}
|
|
2099
|
-
function
|
|
2084
|
+
function ke(o, t) {
|
|
2100
2085
|
t.borderRadius !== void 0 && (o.style.borderRadius = t.borderRadius), t.borderTopLeftRadius !== void 0 && (o.style.borderTopLeftRadius = t.borderTopLeftRadius), t.borderTopRightRadius !== void 0 && (o.style.borderTopRightRadius = t.borderTopRightRadius), t.borderBottomRightRadius !== void 0 && (o.style.borderBottomRightRadius = t.borderBottomRightRadius), t.borderBottomLeftRadius !== void 0 && (o.style.borderBottomLeftRadius = t.borderBottomLeftRadius), t.border !== void 0 && (o.style.border = t.border), t.borderTop !== void 0 && (o.style.borderTop = t.borderTop), t.borderRight !== void 0 && (o.style.borderRight = t.borderRight), t.borderBottom !== void 0 && (o.style.borderBottom = t.borderBottom), t.borderLeft !== void 0 && (o.style.borderLeft = t.borderLeft), t.boxShadow !== void 0 && (o.style.boxShadow = t.boxShadow), t.filter !== void 0 && (o.style.filter = t.filter), t.opacity !== void 0 && (o.style.opacity = t.opacity), t.cursor !== void 0 && (o.style.cursor = t.cursor), t.outline !== void 0 && (o.style.outline = t.outline), t.outlineOffset !== void 0 && (o.style.outlineOffset = t.outlineOffset), t.objectFit !== void 0 && (o.style.objectFit = t.objectFit), t.aspectRatio !== void 0 && (o.style.aspectRatio = t.aspectRatio), t.clipPath !== void 0 && (o.style.clipPath = t.clipPath), t.overflow !== void 0 && (o.style.overflow = t.overflow);
|
|
2101
2086
|
}
|
|
2102
|
-
function
|
|
2103
|
-
const n =
|
|
2104
|
-
|
|
2087
|
+
function st(o, t, i, e) {
|
|
2088
|
+
const n = it(t, i, e);
|
|
2089
|
+
ke(o, n);
|
|
2105
2090
|
}
|
|
2106
2091
|
function Pt(o) {
|
|
2107
2092
|
return o ? Array.isArray(o) ? o.join(" ") : o : "";
|
|
2108
2093
|
}
|
|
2109
|
-
function
|
|
2094
|
+
function et(o, t) {
|
|
2110
2095
|
const i = Pt(t);
|
|
2111
2096
|
i && i.split(" ").forEach((e) => {
|
|
2112
2097
|
e.trim() && o.classList.add(e.trim());
|
|
@@ -2122,9 +2107,9 @@ const Ft = {
|
|
|
2122
2107
|
UNFOCUSING: 999,
|
|
2123
2108
|
FOCUSING: 1e3
|
|
2124
2109
|
};
|
|
2125
|
-
class
|
|
2110
|
+
class Be {
|
|
2126
2111
|
constructor(t, i, e) {
|
|
2127
|
-
this.state =
|
|
2112
|
+
this.state = x.IDLE, this.currentFocus = null, this.focusData = null, this.outgoing = null, this.incoming = null, this.focusGeneration = 0, this.onUnfocusComplete = null, this.config = t, this.animationEngine = i, this.styling = e, this.focusedClassName = e?.focused?.className;
|
|
2128
2113
|
}
|
|
2129
2114
|
/**
|
|
2130
2115
|
* Set callback to be fired when an unfocus animation fully completes.
|
|
@@ -2142,7 +2127,7 @@ class je {
|
|
|
2142
2127
|
* Check if any animation is in progress
|
|
2143
2128
|
*/
|
|
2144
2129
|
isAnimating() {
|
|
2145
|
-
return this.state !==
|
|
2130
|
+
return this.state !== x.IDLE && this.state !== x.FOCUSED;
|
|
2146
2131
|
}
|
|
2147
2132
|
/**
|
|
2148
2133
|
* Normalize scalePercent value
|
|
@@ -2155,19 +2140,19 @@ class je {
|
|
|
2155
2140
|
* Returns actual pixel dimensions instead of scale factor for sharper rendering
|
|
2156
2141
|
*/
|
|
2157
2142
|
calculateFocusDimensions(t, i, e) {
|
|
2158
|
-
const n = this.normalizeScalePercent(this.config.scalePercent),
|
|
2159
|
-
let
|
|
2143
|
+
const n = this.normalizeScalePercent(this.config.scalePercent), s = e.height * n, r = t / i;
|
|
2144
|
+
let a = s, c = a * r;
|
|
2160
2145
|
const l = e.width * n;
|
|
2161
|
-
return c > l && (c = l,
|
|
2146
|
+
return c > l && (c = l, a = c / r), { width: c, height: a };
|
|
2162
2147
|
}
|
|
2163
2148
|
/**
|
|
2164
2149
|
* Calculate the transform needed to center an image (position only, no scale)
|
|
2165
2150
|
* Scale is handled by animating actual dimensions for sharper rendering
|
|
2166
2151
|
*/
|
|
2167
2152
|
calculateFocusTransform(t, i) {
|
|
2168
|
-
const e = t.width / 2, n = t.height / 2,
|
|
2153
|
+
const e = t.width / 2, n = t.height / 2, s = e - i.x, r = n - i.y;
|
|
2169
2154
|
return {
|
|
2170
|
-
x:
|
|
2155
|
+
x: s,
|
|
2171
2156
|
y: r,
|
|
2172
2157
|
rotation: 0,
|
|
2173
2158
|
scale: 1
|
|
@@ -2189,19 +2174,19 @@ class je {
|
|
|
2189
2174
|
* Create a Web Animation that animates both transform (position) and dimensions
|
|
2190
2175
|
* This provides sharper zoom by re-rendering at target size instead of scaling pixels
|
|
2191
2176
|
*/
|
|
2192
|
-
animateWithDimensions(t, i, e, n,
|
|
2177
|
+
animateWithDimensions(t, i, e, n, s, r, a, c) {
|
|
2193
2178
|
const l = this.buildDimensionZoomTransform(i), u = this.buildDimensionZoomTransform(e);
|
|
2194
2179
|
return t.style.transition = "none", t.animate(
|
|
2195
2180
|
[
|
|
2196
2181
|
{
|
|
2197
2182
|
transform: l,
|
|
2198
2183
|
width: `${n}px`,
|
|
2199
|
-
height: `${
|
|
2184
|
+
height: `${s}px`
|
|
2200
2185
|
},
|
|
2201
2186
|
{
|
|
2202
2187
|
transform: u,
|
|
2203
2188
|
width: `${r}px`,
|
|
2204
|
-
height: `${
|
|
2189
|
+
height: `${a}px`
|
|
2205
2190
|
}
|
|
2206
2191
|
],
|
|
2207
2192
|
{
|
|
@@ -2216,8 +2201,8 @@ class je {
|
|
|
2216
2201
|
* Applies all focused styling properties, classes, and z-index
|
|
2217
2202
|
*/
|
|
2218
2203
|
applyFocusedStyling(t, i) {
|
|
2219
|
-
if (t.style.zIndex = String(i), t.classList.add("fbn-ic-focused"),
|
|
2220
|
-
const e =
|
|
2204
|
+
if (t.style.zIndex = String(i), t.classList.add("fbn-ic-focused"), et(t, this.focusedClassName), this.styling?.focused) {
|
|
2205
|
+
const e = it(this.styling.focused, t.offsetHeight, t.offsetWidth);
|
|
2221
2206
|
e.borderRadius !== void 0 && (t.style.borderRadius = e.borderRadius), e.borderTopLeftRadius !== void 0 && (t.style.borderTopLeftRadius = e.borderTopLeftRadius), e.borderTopRightRadius !== void 0 && (t.style.borderTopRightRadius = e.borderTopRightRadius), e.borderBottomRightRadius !== void 0 && (t.style.borderBottomRightRadius = e.borderBottomRightRadius), e.borderBottomLeftRadius !== void 0 && (t.style.borderBottomLeftRadius = e.borderBottomLeftRadius), e.border !== void 0 && (t.style.border = e.border), e.borderTop !== void 0 && (t.style.borderTop = e.borderTop), e.borderRight !== void 0 && (t.style.borderRight = e.borderRight), e.borderBottom !== void 0 && (t.style.borderBottom = e.borderBottom), e.borderLeft !== void 0 && (t.style.borderLeft = e.borderLeft), e.boxShadow !== void 0 && (t.style.boxShadow = e.boxShadow), e.filter !== void 0 && (t.style.filter = e.filter), e.opacity !== void 0 && (t.style.opacity = e.opacity), e.cursor !== void 0 && (t.style.cursor = e.cursor), e.outline !== void 0 && (t.style.outline = e.outline), e.outlineOffset !== void 0 && (t.style.outlineOffset = e.outlineOffset), e.objectFit !== void 0 && (t.style.objectFit = e.objectFit), e.aspectRatio !== void 0 && (t.style.aspectRatio = e.aspectRatio);
|
|
2222
2207
|
}
|
|
2223
2208
|
}
|
|
@@ -2227,7 +2212,7 @@ class je {
|
|
|
2227
2212
|
*/
|
|
2228
2213
|
removeFocusedStyling(t, i) {
|
|
2229
2214
|
if (t.style.zIndex = i, t.classList.remove("fbn-ic-focused"), pt(t, this.focusedClassName), this.styling?.default) {
|
|
2230
|
-
const e =
|
|
2215
|
+
const e = it(this.styling.default, t.offsetHeight, t.offsetWidth);
|
|
2231
2216
|
e.borderRadius !== void 0 && (t.style.borderRadius = e.borderRadius), e.borderTopLeftRadius !== void 0 && (t.style.borderTopLeftRadius = e.borderTopLeftRadius), e.borderTopRightRadius !== void 0 && (t.style.borderTopRightRadius = e.borderTopRightRadius), e.borderBottomRightRadius !== void 0 && (t.style.borderBottomRightRadius = e.borderBottomRightRadius), e.borderBottomLeftRadius !== void 0 && (t.style.borderBottomLeftRadius = e.borderBottomLeftRadius), e.border !== void 0 && (t.style.border = e.border), e.borderTop !== void 0 && (t.style.borderTop = e.borderTop), e.borderRight !== void 0 && (t.style.borderRight = e.borderRight), e.borderBottom !== void 0 && (t.style.borderBottom = e.borderBottom), e.borderLeft !== void 0 && (t.style.borderLeft = e.borderLeft), e.boxShadow !== void 0 && (t.style.boxShadow = e.boxShadow), e.filter !== void 0 && (t.style.filter = e.filter), e.opacity !== void 0 && (t.style.opacity = e.opacity), e.cursor !== void 0 && (t.style.cursor = e.cursor), e.outline !== void 0 && (t.style.outline = e.outline), e.outlineOffset !== void 0 && (t.style.outlineOffset = e.outlineOffset), e.objectFit !== void 0 && (t.style.objectFit = e.objectFit), e.aspectRatio !== void 0 && (t.style.aspectRatio = e.aspectRatio);
|
|
2232
2217
|
}
|
|
2233
2218
|
}
|
|
@@ -2238,11 +2223,11 @@ class je {
|
|
|
2238
2223
|
startClipPathAnimation(t, i, e) {
|
|
2239
2224
|
let n = e ? this.styling?.focused ?? this.styling?.default : this.styling?.default;
|
|
2240
2225
|
e && this.styling?.focused && this.styling.focused.clipPath === void 0 && (n = { ...n, clipPath: void 0 });
|
|
2241
|
-
const
|
|
2242
|
-
const r = t.offsetHeight,
|
|
2243
|
-
c.clipPath !== void 0 ? t.style.clipPath = c.clipPath : t.style.clipPath = "unset", c.overflow !== void 0 && (t.style.overflow = c.overflow), i.animation.playState === "running" && requestAnimationFrame(
|
|
2226
|
+
const s = () => {
|
|
2227
|
+
const r = t.offsetHeight, a = t.offsetWidth, c = it(n, r, a);
|
|
2228
|
+
c.clipPath !== void 0 ? t.style.clipPath = c.clipPath : t.style.clipPath = "unset", c.overflow !== void 0 && (t.style.overflow = c.overflow), i.animation.playState === "running" && requestAnimationFrame(s);
|
|
2244
2229
|
};
|
|
2245
|
-
requestAnimationFrame(
|
|
2230
|
+
requestAnimationFrame(s);
|
|
2246
2231
|
}
|
|
2247
2232
|
/**
|
|
2248
2233
|
* Start focus animation for an image using dimension-based zoom
|
|
@@ -2250,8 +2235,8 @@ class je {
|
|
|
2250
2235
|
* @param fromTransform - Optional starting transform (for mid-animation reversals)
|
|
2251
2236
|
* @param fromDimensions - Optional starting dimensions (for mid-animation reversals)
|
|
2252
2237
|
*/
|
|
2253
|
-
startFocusAnimation(t, i, e, n,
|
|
2254
|
-
const r = t.style.zIndex || "",
|
|
2238
|
+
startFocusAnimation(t, i, e, n, s) {
|
|
2239
|
+
const r = t.style.zIndex || "", a = t.offsetWidth, c = t.offsetHeight, l = this.calculateFocusDimensions(a, c, i), u = this.calculateFocusTransform(i, e);
|
|
2255
2240
|
this.animationEngine.cancelAllAnimations(t);
|
|
2256
2241
|
const h = this.config.animationDuration ?? 600;
|
|
2257
2242
|
this.applyFocusedStyling(t, Ft.FOCUSING);
|
|
@@ -2261,16 +2246,16 @@ class je {
|
|
|
2261
2246
|
rotation: e.rotation,
|
|
2262
2247
|
scale: 1
|
|
2263
2248
|
// No scale - using dimensions
|
|
2264
|
-
},
|
|
2249
|
+
}, g = s?.width ?? a, b = s?.height ?? c, p = this.animateWithDimensions(
|
|
2265
2250
|
t,
|
|
2266
2251
|
d,
|
|
2267
2252
|
u,
|
|
2268
|
-
|
|
2253
|
+
g,
|
|
2269
2254
|
b,
|
|
2270
2255
|
l.width,
|
|
2271
2256
|
l.height,
|
|
2272
2257
|
h
|
|
2273
|
-
),
|
|
2258
|
+
), f = {
|
|
2274
2259
|
id: `focus-${Date.now()}`,
|
|
2275
2260
|
element: t,
|
|
2276
2261
|
animation: p,
|
|
@@ -2284,16 +2269,16 @@ class je {
|
|
|
2284
2269
|
originalState: e,
|
|
2285
2270
|
focusTransform: u,
|
|
2286
2271
|
originalZIndex: r,
|
|
2287
|
-
originalWidth:
|
|
2272
|
+
originalWidth: a,
|
|
2288
2273
|
originalHeight: c,
|
|
2289
2274
|
focusWidth: l.width,
|
|
2290
2275
|
focusHeight: l.height
|
|
2291
|
-
}, this.startClipPathAnimation(t,
|
|
2276
|
+
}, this.startClipPathAnimation(t, f, !0), {
|
|
2292
2277
|
element: t,
|
|
2293
2278
|
originalState: e,
|
|
2294
|
-
animationHandle:
|
|
2279
|
+
animationHandle: f,
|
|
2295
2280
|
direction: "in",
|
|
2296
|
-
originalWidth:
|
|
2281
|
+
originalWidth: a,
|
|
2297
2282
|
originalHeight: c
|
|
2298
2283
|
};
|
|
2299
2284
|
}
|
|
@@ -2304,9 +2289,9 @@ class je {
|
|
|
2304
2289
|
*/
|
|
2305
2290
|
startUnfocusAnimation(t, i, e, n) {
|
|
2306
2291
|
t.style.zIndex = String(Ft.UNFOCUSING), this.animationEngine.cancelAllAnimations(t);
|
|
2307
|
-
const
|
|
2292
|
+
const s = this.config.animationDuration ?? 600;
|
|
2308
2293
|
t.classList.remove("fbn-ic-focused"), pt(t, this.focusedClassName);
|
|
2309
|
-
const r = e ?? this.focusData?.focusTransform ?? { x: 0, y: 0, rotation: 0, scale: 1 },
|
|
2294
|
+
const r = e ?? this.focusData?.focusTransform ?? { x: 0, y: 0, rotation: 0, scale: 1 }, a = n?.width ?? this.focusData?.focusWidth ?? t.offsetWidth, c = n?.height ?? this.focusData?.focusHeight ?? t.offsetHeight, l = {
|
|
2310
2295
|
x: 0,
|
|
2311
2296
|
y: 0,
|
|
2312
2297
|
rotation: i.rotation,
|
|
@@ -2316,24 +2301,24 @@ class je {
|
|
|
2316
2301
|
t,
|
|
2317
2302
|
r,
|
|
2318
2303
|
l,
|
|
2319
|
-
|
|
2304
|
+
a,
|
|
2320
2305
|
c,
|
|
2321
2306
|
u,
|
|
2322
2307
|
h,
|
|
2323
|
-
|
|
2324
|
-
),
|
|
2308
|
+
s
|
|
2309
|
+
), g = {
|
|
2325
2310
|
id: `unfocus-${Date.now()}`,
|
|
2326
2311
|
element: t,
|
|
2327
2312
|
animation: d,
|
|
2328
2313
|
fromState: r,
|
|
2329
2314
|
toState: l,
|
|
2330
2315
|
startTime: performance.now(),
|
|
2331
|
-
duration:
|
|
2316
|
+
duration: s
|
|
2332
2317
|
};
|
|
2333
|
-
return this.startClipPathAnimation(t,
|
|
2318
|
+
return this.startClipPathAnimation(t, g, !1), {
|
|
2334
2319
|
element: t,
|
|
2335
2320
|
originalState: i,
|
|
2336
|
-
animationHandle:
|
|
2321
|
+
animationHandle: g,
|
|
2337
2322
|
direction: "out",
|
|
2338
2323
|
originalWidth: u,
|
|
2339
2324
|
originalHeight: h
|
|
@@ -2354,10 +2339,10 @@ class je {
|
|
|
2354
2339
|
* Caller is responsible for calling animationEngine.cancelAllAnimations() afterwards.
|
|
2355
2340
|
*/
|
|
2356
2341
|
captureMidAnimationState(t) {
|
|
2357
|
-
const i = getComputedStyle(t), e = new DOMMatrix(i.transform), n = t.offsetWidth,
|
|
2358
|
-
return t.style.width = `${n}px`, t.style.height = `${
|
|
2359
|
-
transform: { x: r, y:
|
|
2360
|
-
dimensions: { width: n, height:
|
|
2342
|
+
const i = getComputedStyle(t), e = new DOMMatrix(i.transform), n = t.offsetWidth, s = t.offsetHeight, r = e.e + n * 0.5, a = e.f + s * 0.5, c = Math.atan2(e.b, e.a) * (180 / Math.PI);
|
|
2343
|
+
return t.style.width = `${n}px`, t.style.height = `${s}px`, t.style.transform = `translate(-50%, -50%) translate(${r}px, ${a}px) rotate(${c}deg)`, t.style.transition = "none", {
|
|
2344
|
+
transform: { x: r, y: a, rotation: c, scale: 1 },
|
|
2345
|
+
dimensions: { width: n, height: s }
|
|
2361
2346
|
};
|
|
2362
2347
|
}
|
|
2363
2348
|
/**
|
|
@@ -2372,36 +2357,36 @@ class je {
|
|
|
2372
2357
|
/**
|
|
2373
2358
|
* Reset an element instantly to its original position and dimensions (no animation)
|
|
2374
2359
|
*/
|
|
2375
|
-
resetElementInstantly(t, i, e, n,
|
|
2360
|
+
resetElementInstantly(t, i, e, n, s) {
|
|
2376
2361
|
this.animationEngine.cancelAllAnimations(t);
|
|
2377
2362
|
const r = ["translate(-50%, -50%)"];
|
|
2378
|
-
r.push("translate(0px, 0px)"), r.push(`rotate(${i.rotation}deg)`), t.style.transition = "none", t.style.transform = r.join(" "), n !== void 0 &&
|
|
2363
|
+
r.push("translate(0px, 0px)"), r.push(`rotate(${i.rotation}deg)`), t.style.transition = "none", t.style.transform = r.join(" "), n !== void 0 && s !== void 0 && (t.style.width = `${n}px`, t.style.height = `${s}px`), this.removeFocusedStyling(t, e);
|
|
2379
2364
|
}
|
|
2380
2365
|
/**
|
|
2381
2366
|
* Focus (zoom) an image to center of container
|
|
2382
2367
|
* Implements cross-animation when swapping focus
|
|
2383
2368
|
*/
|
|
2384
2369
|
async focusImage(t, i, e) {
|
|
2385
|
-
if (this.currentFocus === t && this.state ===
|
|
2370
|
+
if (this.currentFocus === t && this.state === x.FOCUSED)
|
|
2386
2371
|
return this.unfocusImage();
|
|
2387
|
-
if (this.incoming?.element === t && this.state ===
|
|
2388
|
-
const { transform:
|
|
2372
|
+
if (this.incoming?.element === t && this.state === x.FOCUSING) {
|
|
2373
|
+
const { transform: s, dimensions: r } = this.captureMidAnimationState(t);
|
|
2389
2374
|
this.animationEngine.cancelAllAnimations(t), this.outgoing = this.startUnfocusAnimation(
|
|
2390
2375
|
t,
|
|
2391
2376
|
this.incoming.originalState,
|
|
2392
|
-
|
|
2377
|
+
s,
|
|
2393
2378
|
r
|
|
2394
|
-
), this.incoming = null, this.state =
|
|
2379
|
+
), this.incoming = null, this.state = x.UNFOCUSING, await this.waitForAnimation(this.outgoing.animationHandle), this.removeFocusedStyling(this.outgoing.element, this.focusData?.originalZIndex || ""), this.outgoing = null, this.currentFocus = null, this.focusData = null, this.state = x.IDLE;
|
|
2395
2380
|
return;
|
|
2396
2381
|
}
|
|
2397
2382
|
const n = ++this.focusGeneration;
|
|
2398
2383
|
switch (this.state) {
|
|
2399
|
-
case
|
|
2400
|
-
if (this.state =
|
|
2401
|
-
this.currentFocus = t, this.incoming = null, this.state =
|
|
2384
|
+
case x.IDLE:
|
|
2385
|
+
if (this.state = x.FOCUSING, this.incoming = this.startFocusAnimation(t, i, e), await this.waitForAnimation(this.incoming.animationHandle), this.focusGeneration !== n) return;
|
|
2386
|
+
this.currentFocus = t, this.incoming = null, this.state = x.FOCUSED;
|
|
2402
2387
|
break;
|
|
2403
|
-
case
|
|
2404
|
-
if (this.state =
|
|
2388
|
+
case x.FOCUSED:
|
|
2389
|
+
if (this.state = x.CROSS_ANIMATING, this.currentFocus && this.focusData && (this.outgoing = this.startUnfocusAnimation(
|
|
2405
2390
|
this.currentFocus,
|
|
2406
2391
|
this.focusData.originalState
|
|
2407
2392
|
)), this.incoming = this.startFocusAnimation(t, i, e), await Promise.all([
|
|
@@ -2410,12 +2395,12 @@ class je {
|
|
|
2410
2395
|
]), this.focusGeneration !== n)
|
|
2411
2396
|
return;
|
|
2412
2397
|
if (this.outgoing) {
|
|
2413
|
-
const
|
|
2414
|
-
this.removeFocusedStyling(
|
|
2398
|
+
const s = this.outgoing.element;
|
|
2399
|
+
this.removeFocusedStyling(s, this.outgoing.originalState.zIndex?.toString() || ""), this.outgoing = null, this.onUnfocusComplete?.(s);
|
|
2415
2400
|
}
|
|
2416
|
-
this.currentFocus = t, this.incoming = null, this.state =
|
|
2401
|
+
this.currentFocus = t, this.incoming = null, this.state = x.FOCUSED;
|
|
2417
2402
|
break;
|
|
2418
|
-
case
|
|
2403
|
+
case x.FOCUSING:
|
|
2419
2404
|
if (this.incoming && (this.animationEngine.cancelAnimation(this.incoming.animationHandle, !1), this.resetElementInstantly(
|
|
2420
2405
|
this.incoming.element,
|
|
2421
2406
|
this.incoming.originalState,
|
|
@@ -2423,43 +2408,43 @@ class je {
|
|
|
2423
2408
|
this.focusData?.originalWidth,
|
|
2424
2409
|
this.focusData?.originalHeight
|
|
2425
2410
|
), this.incoming = null), this.incoming = this.startFocusAnimation(t, i, e), await this.waitForAnimation(this.incoming.animationHandle), this.focusGeneration !== n) return;
|
|
2426
|
-
this.currentFocus = t, this.incoming = null, this.state =
|
|
2411
|
+
this.currentFocus = t, this.incoming = null, this.state = x.FOCUSED;
|
|
2427
2412
|
break;
|
|
2428
|
-
case
|
|
2429
|
-
if (this.state =
|
|
2413
|
+
case x.UNFOCUSING:
|
|
2414
|
+
if (this.state = x.CROSS_ANIMATING, this.incoming = this.startFocusAnimation(t, i, e), await Promise.all([
|
|
2430
2415
|
this.outgoing ? this.waitForAnimation(this.outgoing.animationHandle) : Promise.resolve(),
|
|
2431
2416
|
this.waitForAnimation(this.incoming.animationHandle)
|
|
2432
2417
|
]), this.focusGeneration !== n) return;
|
|
2433
2418
|
if (this.outgoing) {
|
|
2434
|
-
const
|
|
2435
|
-
this.removeFocusedStyling(
|
|
2419
|
+
const s = this.outgoing.element;
|
|
2420
|
+
this.removeFocusedStyling(s, this.outgoing.originalState.zIndex?.toString() || ""), this.outgoing = null, this.onUnfocusComplete?.(s);
|
|
2436
2421
|
}
|
|
2437
|
-
this.currentFocus = t, this.incoming = null, this.state =
|
|
2422
|
+
this.currentFocus = t, this.incoming = null, this.state = x.FOCUSED;
|
|
2438
2423
|
break;
|
|
2439
|
-
case
|
|
2424
|
+
case x.CROSS_ANIMATING:
|
|
2440
2425
|
if (this.incoming?.element === t)
|
|
2441
2426
|
return;
|
|
2442
2427
|
if (this.outgoing?.element === t) {
|
|
2443
|
-
const { transform:
|
|
2428
|
+
const { transform: s, dimensions: r } = this.captureMidAnimationState(t);
|
|
2444
2429
|
if (this.animationEngine.cancelAllAnimations(t), this.incoming) {
|
|
2445
|
-
const { transform:
|
|
2430
|
+
const { transform: a, dimensions: c } = this.captureMidAnimationState(this.incoming.element);
|
|
2446
2431
|
this.animationEngine.cancelAllAnimations(this.incoming.element), this.outgoing = this.startUnfocusAnimation(
|
|
2447
2432
|
this.incoming.element,
|
|
2448
2433
|
this.incoming.originalState,
|
|
2449
|
-
|
|
2434
|
+
a,
|
|
2450
2435
|
c
|
|
2451
2436
|
);
|
|
2452
2437
|
} else
|
|
2453
2438
|
this.outgoing = null;
|
|
2454
|
-
if (this.incoming = this.startFocusAnimation(t, i, e,
|
|
2439
|
+
if (this.incoming = this.startFocusAnimation(t, i, e, s, r), await Promise.all([
|
|
2455
2440
|
this.outgoing ? this.waitForAnimation(this.outgoing.animationHandle) : Promise.resolve(),
|
|
2456
2441
|
this.waitForAnimation(this.incoming.animationHandle)
|
|
2457
2442
|
]), this.focusGeneration !== n) return;
|
|
2458
2443
|
if (this.outgoing) {
|
|
2459
|
-
const
|
|
2460
|
-
this.removeFocusedStyling(
|
|
2444
|
+
const a = this.outgoing.element;
|
|
2445
|
+
this.removeFocusedStyling(a, this.outgoing.originalState.zIndex?.toString() || ""), this.outgoing = null, this.onUnfocusComplete?.(a);
|
|
2461
2446
|
}
|
|
2462
|
-
this.currentFocus = t, this.incoming = null, this.state =
|
|
2447
|
+
this.currentFocus = t, this.incoming = null, this.state = x.FOCUSED;
|
|
2463
2448
|
return;
|
|
2464
2449
|
}
|
|
2465
2450
|
if (this.outgoing && (this.animationEngine.cancelAnimation(this.outgoing.animationHandle, !1), this.resetElementInstantly(
|
|
@@ -2469,11 +2454,11 @@ class je {
|
|
|
2469
2454
|
this.outgoing.originalWidth,
|
|
2470
2455
|
this.outgoing.originalHeight
|
|
2471
2456
|
), this.outgoing = null), this.incoming) {
|
|
2472
|
-
const { transform:
|
|
2457
|
+
const { transform: s, dimensions: r } = this.captureMidAnimationState(this.incoming.element);
|
|
2473
2458
|
this.animationEngine.cancelAllAnimations(this.incoming.element), this.outgoing = this.startUnfocusAnimation(
|
|
2474
2459
|
this.incoming.element,
|
|
2475
2460
|
this.incoming.originalState,
|
|
2476
|
-
|
|
2461
|
+
s,
|
|
2477
2462
|
r
|
|
2478
2463
|
);
|
|
2479
2464
|
}
|
|
@@ -2482,10 +2467,10 @@ class je {
|
|
|
2482
2467
|
this.waitForAnimation(this.incoming.animationHandle)
|
|
2483
2468
|
]), this.focusGeneration !== n) return;
|
|
2484
2469
|
if (this.outgoing) {
|
|
2485
|
-
const
|
|
2486
|
-
this.removeFocusedStyling(
|
|
2470
|
+
const s = this.outgoing.element;
|
|
2471
|
+
this.removeFocusedStyling(s, this.outgoing.originalState.zIndex?.toString() || ""), this.outgoing = null, this.onUnfocusComplete?.(s);
|
|
2487
2472
|
}
|
|
2488
|
-
this.currentFocus = t, this.incoming = null, this.state =
|
|
2473
|
+
this.currentFocus = t, this.incoming = null, this.state = x.FOCUSED;
|
|
2489
2474
|
break;
|
|
2490
2475
|
}
|
|
2491
2476
|
}
|
|
@@ -2493,45 +2478,45 @@ class je {
|
|
|
2493
2478
|
* Unfocus current image, returning it to original position
|
|
2494
2479
|
*/
|
|
2495
2480
|
async unfocusImage() {
|
|
2496
|
-
if (this.state ===
|
|
2481
|
+
if (this.state === x.UNFOCUSING)
|
|
2497
2482
|
return;
|
|
2498
2483
|
const t = ++this.focusGeneration;
|
|
2499
2484
|
if (!this.currentFocus || !this.focusData) {
|
|
2500
|
-
if (this.incoming && this.state ===
|
|
2501
|
-
const { transform:
|
|
2485
|
+
if (this.incoming && this.state === x.FOCUSING) {
|
|
2486
|
+
const { transform: s, dimensions: r } = this.captureMidAnimationState(this.incoming.element);
|
|
2502
2487
|
if (this.animationEngine.cancelAllAnimations(this.incoming.element), this.outgoing = this.startUnfocusAnimation(
|
|
2503
2488
|
this.incoming.element,
|
|
2504
2489
|
this.incoming.originalState,
|
|
2505
|
-
|
|
2490
|
+
s,
|
|
2506
2491
|
r
|
|
2507
|
-
), this.incoming = null, this.state =
|
|
2508
|
-
const
|
|
2509
|
-
this.removeFocusedStyling(
|
|
2492
|
+
), this.incoming = null, this.state = x.UNFOCUSING, await this.waitForAnimation(this.outgoing.animationHandle), this.focusGeneration !== t) return;
|
|
2493
|
+
const a = this.outgoing.element;
|
|
2494
|
+
this.removeFocusedStyling(a, this.focusData?.originalZIndex || ""), this.outgoing = null, this.focusData = null, this.state = x.IDLE, this.onUnfocusComplete?.(a);
|
|
2510
2495
|
}
|
|
2511
2496
|
return;
|
|
2512
2497
|
}
|
|
2513
|
-
if (this.state ===
|
|
2514
|
-
const { transform:
|
|
2498
|
+
if (this.state === x.CROSS_ANIMATING && this.incoming) {
|
|
2499
|
+
const { transform: s, dimensions: r } = this.captureMidAnimationState(this.incoming.element);
|
|
2515
2500
|
this.animationEngine.cancelAllAnimations(this.incoming.element);
|
|
2516
|
-
const
|
|
2501
|
+
const a = this.startUnfocusAnimation(
|
|
2517
2502
|
this.incoming.element,
|
|
2518
2503
|
this.incoming.originalState,
|
|
2519
|
-
|
|
2504
|
+
s,
|
|
2520
2505
|
r
|
|
2521
2506
|
);
|
|
2522
2507
|
if (await Promise.all([
|
|
2523
2508
|
this.outgoing ? this.waitForAnimation(this.outgoing.animationHandle) : Promise.resolve(),
|
|
2524
|
-
this.waitForAnimation(
|
|
2509
|
+
this.waitForAnimation(a.animationHandle)
|
|
2525
2510
|
]), this.focusGeneration !== t) return;
|
|
2526
2511
|
let c = null;
|
|
2527
2512
|
this.outgoing && (c = this.outgoing.element, this.removeFocusedStyling(c, this.outgoing.originalState.zIndex?.toString() || ""));
|
|
2528
|
-
const l =
|
|
2529
|
-
this.removeFocusedStyling(l, this.incoming.originalState.zIndex?.toString() || ""), this.outgoing = null, this.incoming = null, this.currentFocus = null, this.focusData = null, this.state =
|
|
2513
|
+
const l = a.element;
|
|
2514
|
+
this.removeFocusedStyling(l, this.incoming.originalState.zIndex?.toString() || ""), this.outgoing = null, this.incoming = null, this.currentFocus = null, this.focusData = null, this.state = x.IDLE, c && this.onUnfocusComplete?.(c), this.onUnfocusComplete?.(l);
|
|
2530
2515
|
return;
|
|
2531
2516
|
}
|
|
2532
|
-
this.state =
|
|
2517
|
+
this.state = x.UNFOCUSING;
|
|
2533
2518
|
const i = this.currentFocus, e = this.focusData.originalState, n = this.focusData.originalZIndex;
|
|
2534
|
-
this.outgoing = this.startUnfocusAnimation(i, e), await this.waitForAnimation(this.outgoing.animationHandle), this.focusGeneration === t && (this.removeFocusedStyling(i, n), this.outgoing = null, this.currentFocus = null, this.focusData = null, this.state =
|
|
2519
|
+
this.outgoing = this.startUnfocusAnimation(i, e), await this.waitForAnimation(this.outgoing.animationHandle), this.focusGeneration === t && (this.removeFocusedStyling(i, n), this.outgoing = null, this.currentFocus = null, this.focusData = null, this.state = x.IDLE, this.onUnfocusComplete?.(i));
|
|
2535
2520
|
}
|
|
2536
2521
|
/**
|
|
2537
2522
|
* Swap focus from current image to a new one (alias for focusImage with cross-animation)
|
|
@@ -2549,7 +2534,7 @@ class je {
|
|
|
2549
2534
|
* Check if an image is currently focused (stable state)
|
|
2550
2535
|
*/
|
|
2551
2536
|
isFocused(t) {
|
|
2552
|
-
return this.currentFocus === t && this.state ===
|
|
2537
|
+
return this.currentFocus === t && this.state === x.FOCUSED;
|
|
2553
2538
|
}
|
|
2554
2539
|
/**
|
|
2555
2540
|
* Check if an image is the target of current focus animation
|
|
@@ -2570,9 +2555,9 @@ class je {
|
|
|
2570
2555
|
* Used during swipe gestures for visual feedback
|
|
2571
2556
|
*/
|
|
2572
2557
|
setDragOffset(t) {
|
|
2573
|
-
if (!this.currentFocus || !this.focusData || this.state !==
|
|
2574
|
-
const i = this.currentFocus, e = this.focusData.focusTransform, n = ["translate(-50%, -50%)"],
|
|
2575
|
-
n.push(`translate(${
|
|
2558
|
+
if (!this.currentFocus || !this.focusData || this.state !== x.FOCUSED) return;
|
|
2559
|
+
const i = this.currentFocus, e = this.focusData.focusTransform, n = ["translate(-50%, -50%)"], s = (e.x ?? 0) + t, r = e.y ?? 0;
|
|
2560
|
+
n.push(`translate(${s}px, ${r}px)`), e.rotation !== void 0 && n.push(`rotate(${e.rotation}deg)`), i.style.transition = "none", i.style.transform = n.join(" ");
|
|
2576
2561
|
}
|
|
2577
2562
|
/**
|
|
2578
2563
|
* Clear the drag offset, optionally animating back to center
|
|
@@ -2580,10 +2565,10 @@ class je {
|
|
|
2580
2565
|
* @param duration - Animation duration in ms (default 150)
|
|
2581
2566
|
*/
|
|
2582
2567
|
clearDragOffset(t, i = 150) {
|
|
2583
|
-
if (!this.currentFocus || !this.focusData || this.state !==
|
|
2584
|
-
const e = this.currentFocus, n = this.focusData.focusTransform,
|
|
2585
|
-
|
|
2586
|
-
const c =
|
|
2568
|
+
if (!this.currentFocus || !this.focusData || this.state !== x.FOCUSED) return;
|
|
2569
|
+
const e = this.currentFocus, n = this.focusData.focusTransform, s = ["translate(-50%, -50%)"], r = n.x ?? 0, a = n.y ?? 0;
|
|
2570
|
+
s.push(`translate(${r}px, ${a}px)`), n.rotation !== void 0 && s.push(`rotate(${n.rotation}deg)`);
|
|
2571
|
+
const c = s.join(" ");
|
|
2587
2572
|
t ? (e.style.transition = `transform ${i}ms ease-out`, e.style.transform = c, setTimeout(() => {
|
|
2588
2573
|
this.currentFocus === e && (e.style.transition = "none");
|
|
2589
2574
|
}, i)) : (e.style.transition = "none", e.style.transform = c);
|
|
@@ -2610,10 +2595,10 @@ class je {
|
|
|
2610
2595
|
this.focusData.originalZIndex,
|
|
2611
2596
|
this.focusData.originalWidth,
|
|
2612
2597
|
this.focusData.originalHeight
|
|
2613
|
-
), this.state =
|
|
2598
|
+
), this.state = x.IDLE, this.currentFocus = null, this.focusData = null, this.outgoing = null, this.incoming = null;
|
|
2614
2599
|
}
|
|
2615
2600
|
}
|
|
2616
|
-
const
|
|
2601
|
+
const je = 50, We = 0.5, Ge = 20, qe = 0.3, Xe = 150, Ye = 30, rt = class rt {
|
|
2617
2602
|
constructor(t, i) {
|
|
2618
2603
|
this.enabled = !1, this.touchState = null, this.recentTouchTimestamp = 0, this.container = t, this.callbacks = i, this.boundTouchStart = this.handleTouchStart.bind(this), this.boundTouchMove = this.handleTouchMove.bind(this), this.boundTouchEnd = this.handleTouchEnd.bind(this), this.boundTouchCancel = this.handleTouchCancel.bind(this);
|
|
2619
2604
|
}
|
|
@@ -2640,7 +2625,7 @@ const We = 50, Ge = 0.5, qe = 20, Be = 0.3, Xe = 150, Ye = 30, at = class at {
|
|
|
2640
2625
|
* Used to prevent click-outside from unfocusing immediately after touch
|
|
2641
2626
|
*/
|
|
2642
2627
|
hadRecentTouch() {
|
|
2643
|
-
return Date.now() - this.recentTouchTimestamp <
|
|
2628
|
+
return Date.now() - this.recentTouchTimestamp < rt.TOUCH_CLICK_DELAY;
|
|
2644
2629
|
}
|
|
2645
2630
|
handleTouchStart(t) {
|
|
2646
2631
|
if (t.touches.length !== 1) return;
|
|
@@ -2659,28 +2644,28 @@ const We = 50, Ge = 0.5, qe = 20, Be = 0.3, Xe = 150, Ye = 30, at = class at {
|
|
|
2659
2644
|
if (!this.touchState || t.touches.length !== 1) return;
|
|
2660
2645
|
const i = t.touches[0], e = i.clientX - this.touchState.startX, n = i.clientY - this.touchState.startY;
|
|
2661
2646
|
if (this.touchState.isHorizontalSwipe === null && Math.sqrt(e * e + n * n) > 10) {
|
|
2662
|
-
const
|
|
2663
|
-
this.touchState.isHorizontalSwipe =
|
|
2647
|
+
const a = Math.atan2(Math.abs(n), Math.abs(e)) * (180 / Math.PI);
|
|
2648
|
+
this.touchState.isHorizontalSwipe = a <= Ye;
|
|
2664
2649
|
}
|
|
2665
2650
|
if (this.touchState.isHorizontalSwipe !== !1 && this.touchState.isHorizontalSwipe === !0) {
|
|
2666
2651
|
t.preventDefault(), this.touchState.isDragging = !0, this.touchState.currentX = i.clientX;
|
|
2667
|
-
const
|
|
2668
|
-
this.callbacks.onDragOffset(
|
|
2652
|
+
const s = e * qe;
|
|
2653
|
+
this.callbacks.onDragOffset(s);
|
|
2669
2654
|
}
|
|
2670
2655
|
}
|
|
2671
2656
|
handleTouchEnd(t) {
|
|
2672
2657
|
if (!this.touchState) return;
|
|
2673
2658
|
this.recentTouchTimestamp = Date.now();
|
|
2674
|
-
const i = this.touchState.currentX - this.touchState.startX, e = performance.now() - this.touchState.startTime, n = Math.abs(i) / e,
|
|
2659
|
+
const i = this.touchState.currentX - this.touchState.startX, e = performance.now() - this.touchState.startTime, n = Math.abs(i) / e, s = Math.abs(i);
|
|
2675
2660
|
let r = !1;
|
|
2676
|
-
this.touchState.isHorizontalSwipe === !0 && this.touchState.isDragging && (
|
|
2661
|
+
this.touchState.isHorizontalSwipe === !0 && this.touchState.isDragging && (s >= je || n >= We && s >= Ge) && (r = !0, i < 0 ? this.callbacks.onNext() : this.callbacks.onPrev()), this.touchState.isDragging && this.callbacks.onDragEnd(r), this.touchState = null;
|
|
2677
2662
|
}
|
|
2678
2663
|
handleTouchCancel(t) {
|
|
2679
2664
|
this.touchState?.isDragging && this.callbacks.onDragEnd(!1), this.touchState = null;
|
|
2680
2665
|
}
|
|
2681
2666
|
};
|
|
2682
|
-
|
|
2683
|
-
let bt =
|
|
2667
|
+
rt.TOUCH_CLICK_DELAY = 300;
|
|
2668
|
+
let bt = rt;
|
|
2684
2669
|
class Je {
|
|
2685
2670
|
constructor(t) {
|
|
2686
2671
|
if (this._prepared = !1, this._discoveredUrls = [], this.apiKey = t.apiKey ?? "", this.apiEndpoint = t.apiEndpoint ?? "https://www.googleapis.com/drive/v3/files", this.debugLogging = t.debugLogging ?? !1, this.sources = t.sources ?? [], !this.sources || this.sources.length === 0)
|
|
@@ -2695,8 +2680,8 @@ class Je {
|
|
|
2695
2680
|
for (const i of this.sources)
|
|
2696
2681
|
if ("folders" in i)
|
|
2697
2682
|
for (const e of i.folders) {
|
|
2698
|
-
const n = i.recursive !== void 0 ? i.recursive : !0,
|
|
2699
|
-
this._discoveredUrls.push(...
|
|
2683
|
+
const n = i.recursive !== void 0 ? i.recursive : !0, s = await this.loadFromFolder(e, t, n);
|
|
2684
|
+
this._discoveredUrls.push(...s);
|
|
2700
2685
|
}
|
|
2701
2686
|
else if ("files" in i) {
|
|
2702
2687
|
const e = await this.loadFiles(i.files, t);
|
|
@@ -2762,8 +2747,8 @@ class Je {
|
|
|
2762
2747
|
return this.loadImagesDirectly(n, i);
|
|
2763
2748
|
try {
|
|
2764
2749
|
return e ? await this.loadImagesRecursively(n, i) : await this.loadImagesFromSingleFolder(n, i);
|
|
2765
|
-
} catch (
|
|
2766
|
-
return console.error("Error loading from Google Drive API:",
|
|
2750
|
+
} catch (s) {
|
|
2751
|
+
return console.error("Error loading from Google Drive API:", s), this.loadImagesDirectly(n, i);
|
|
2767
2752
|
}
|
|
2768
2753
|
}
|
|
2769
2754
|
/**
|
|
@@ -2773,10 +2758,10 @@ class Je {
|
|
|
2773
2758
|
* @returns Promise resolving to array of image URLs
|
|
2774
2759
|
*/
|
|
2775
2760
|
async loadImagesFromSingleFolder(t, i) {
|
|
2776
|
-
const e = [], n = `'${t}' in parents and trashed=false`, r = `${this.apiEndpoint}?q=${encodeURIComponent(n)}&fields=files(id,name,mimeType,thumbnailLink)&key=${this.apiKey}`,
|
|
2777
|
-
if (!
|
|
2778
|
-
throw new Error(`API request failed: ${
|
|
2779
|
-
const l = (await
|
|
2761
|
+
const e = [], n = `'${t}' in parents and trashed=false`, r = `${this.apiEndpoint}?q=${encodeURIComponent(n)}&fields=files(id,name,mimeType,thumbnailLink)&key=${this.apiKey}`, a = await fetch(r);
|
|
2762
|
+
if (!a.ok)
|
|
2763
|
+
throw new Error(`API request failed: ${a.status} ${a.statusText}`);
|
|
2764
|
+
const l = (await a.json()).files.filter(
|
|
2780
2765
|
(u) => u.mimeType.startsWith("image/") && i.isAllowed(u.name)
|
|
2781
2766
|
);
|
|
2782
2767
|
return this.log(`Found ${l.length} images in folder ${t} (non-recursive)`), l.forEach((u) => {
|
|
@@ -2792,24 +2777,24 @@ class Je {
|
|
|
2792
2777
|
async loadFiles(t, i) {
|
|
2793
2778
|
const e = [];
|
|
2794
2779
|
for (const n of t) {
|
|
2795
|
-
const
|
|
2796
|
-
if (!
|
|
2780
|
+
const s = this.extractFileId(n);
|
|
2781
|
+
if (!s) {
|
|
2797
2782
|
this.log(`Skipping invalid file URL: ${n}`);
|
|
2798
2783
|
continue;
|
|
2799
2784
|
}
|
|
2800
2785
|
if (this.apiKey && this.apiKey !== "YOUR_API_KEY_HERE")
|
|
2801
2786
|
try {
|
|
2802
|
-
const r = `${this.apiEndpoint}/${
|
|
2803
|
-
if (
|
|
2804
|
-
const c = await
|
|
2805
|
-
c.mimeType.startsWith("image/") && i.isAllowed(c.name) ? (e.push(`https://lh3.googleusercontent.com/d/${
|
|
2787
|
+
const r = `${this.apiEndpoint}/${s}?fields=name,mimeType&key=${this.apiKey}`, a = await fetch(r);
|
|
2788
|
+
if (a.ok) {
|
|
2789
|
+
const c = await a.json();
|
|
2790
|
+
c.mimeType.startsWith("image/") && i.isAllowed(c.name) ? (e.push(`https://lh3.googleusercontent.com/d/${s}=s1600`), this.log(`Added file: ${c.name}`)) : this.log(`Skipping non-image file: ${c.name} (${c.mimeType})`);
|
|
2806
2791
|
} else
|
|
2807
|
-
this.log(`Failed to fetch metadata for file ${
|
|
2792
|
+
this.log(`Failed to fetch metadata for file ${s}: ${a.status}`);
|
|
2808
2793
|
} catch (r) {
|
|
2809
|
-
this.log(`Error fetching metadata for file ${
|
|
2794
|
+
this.log(`Error fetching metadata for file ${s}:`, r);
|
|
2810
2795
|
}
|
|
2811
2796
|
else
|
|
2812
|
-
e.push(`https://lh3.googleusercontent.com/d/${
|
|
2797
|
+
e.push(`https://lh3.googleusercontent.com/d/${s}=s1600`);
|
|
2813
2798
|
}
|
|
2814
2799
|
return e;
|
|
2815
2800
|
}
|
|
@@ -2843,10 +2828,10 @@ class Je {
|
|
|
2843
2828
|
* @returns Promise resolving to array of image URLs
|
|
2844
2829
|
*/
|
|
2845
2830
|
async loadImagesRecursively(t, i) {
|
|
2846
|
-
const e = [], n = `'${t}' in parents and trashed=false`, r = `${this.apiEndpoint}?q=${encodeURIComponent(n)}&fields=files(id,name,mimeType,thumbnailLink)&key=${this.apiKey}`,
|
|
2847
|
-
if (!
|
|
2848
|
-
throw new Error(`API request failed: ${
|
|
2849
|
-
const c = await
|
|
2831
|
+
const e = [], n = `'${t}' in parents and trashed=false`, r = `${this.apiEndpoint}?q=${encodeURIComponent(n)}&fields=files(id,name,mimeType,thumbnailLink)&key=${this.apiKey}`, a = await fetch(r);
|
|
2832
|
+
if (!a.ok)
|
|
2833
|
+
throw new Error(`API request failed: ${a.status} ${a.statusText}`);
|
|
2834
|
+
const c = await a.json(), l = c.files.filter(
|
|
2850
2835
|
(h) => h.mimeType.startsWith("image/") && i.isAllowed(h.name)
|
|
2851
2836
|
), u = c.files.filter(
|
|
2852
2837
|
(h) => h.mimeType === "application/vnd.google-apps.folder"
|
|
@@ -2873,8 +2858,8 @@ class Je {
|
|
|
2873
2858
|
const e = `https://drive.google.com/embeddedfolderview?id=${t}`, n = await fetch(e, { mode: "cors" });
|
|
2874
2859
|
if (!n.ok)
|
|
2875
2860
|
throw new Error("Cannot access folder directly (CORS or permissions issue)");
|
|
2876
|
-
const
|
|
2877
|
-
return [...new Set(
|
|
2861
|
+
const s = await n.text(), r = /\/file\/d\/([a-zA-Z0-9_-]+)/g, a = [...s.matchAll(r)];
|
|
2862
|
+
return [...new Set(a.map((u) => u[1]))].map(
|
|
2878
2863
|
(u) => `https://drive.google.com/uc?export=view&id=${u}`
|
|
2879
2864
|
);
|
|
2880
2865
|
} catch (e) {
|
|
@@ -2967,8 +2952,8 @@ class Ve {
|
|
|
2967
2952
|
return console.warn("URLs must be an array:", t), [];
|
|
2968
2953
|
const e = [];
|
|
2969
2954
|
for (const n of t) {
|
|
2970
|
-
const
|
|
2971
|
-
if (!i.isAllowed(
|
|
2955
|
+
const s = n.split("/").pop() || n;
|
|
2956
|
+
if (!i.isAllowed(s)) {
|
|
2972
2957
|
this.log(`Skipping filtered URL: ${n}`);
|
|
2973
2958
|
continue;
|
|
2974
2959
|
}
|
|
@@ -2987,12 +2972,12 @@ class Ve {
|
|
|
2987
2972
|
if (!Array.isArray(i))
|
|
2988
2973
|
return console.warn("files must be an array:", i), [];
|
|
2989
2974
|
const n = [];
|
|
2990
|
-
for (const
|
|
2991
|
-
if (!e.isAllowed(
|
|
2992
|
-
this.log(`Skipping filtered file: ${
|
|
2975
|
+
for (const s of i) {
|
|
2976
|
+
if (!e.isAllowed(s)) {
|
|
2977
|
+
this.log(`Skipping filtered file: ${s}`);
|
|
2993
2978
|
continue;
|
|
2994
2979
|
}
|
|
2995
|
-
const r = this.constructUrl(t,
|
|
2980
|
+
const r = this.constructUrl(t, s);
|
|
2996
2981
|
this.validateUrls ? await this.validateUrl(r) ? n.push(r) : console.warn(`Skipping invalid/missing file: ${r}`) : n.push(r);
|
|
2997
2982
|
}
|
|
2998
2983
|
return n;
|
|
@@ -3008,15 +2993,15 @@ class Ve {
|
|
|
3008
2993
|
this.log(`Fetching JSON endpoint: ${t}`);
|
|
3009
2994
|
const e = new AbortController(), n = setTimeout(() => e.abort(), 1e4);
|
|
3010
2995
|
try {
|
|
3011
|
-
const
|
|
3012
|
-
if (clearTimeout(n), !
|
|
3013
|
-
throw new Error(`HTTP ${
|
|
3014
|
-
const r = await
|
|
2996
|
+
const s = await fetch(t, { signal: e.signal });
|
|
2997
|
+
if (clearTimeout(n), !s.ok)
|
|
2998
|
+
throw new Error(`HTTP ${s.status} fetching ${t}`);
|
|
2999
|
+
const r = await s.json();
|
|
3015
3000
|
if (!r || !Array.isArray(r.images))
|
|
3016
3001
|
throw new Error('JSON source must return JSON with shape { "images": ["url1", "url2", ...] }');
|
|
3017
3002
|
return this.log(`JSON endpoint returned ${r.images.length} image(s)`), await this.processUrls(r.images, i);
|
|
3018
|
-
} catch (
|
|
3019
|
-
throw clearTimeout(n),
|
|
3003
|
+
} catch (s) {
|
|
3004
|
+
throw clearTimeout(n), s instanceof Error && s.name === "AbortError" ? new Error(`Timeout fetching JSON endpoint: ${t}`) : s;
|
|
3020
3005
|
}
|
|
3021
3006
|
}
|
|
3022
3007
|
/**
|
|
@@ -3038,11 +3023,11 @@ class Ve {
|
|
|
3038
3023
|
if (!(t.startsWith(window.location.origin) || t.startsWith("/")))
|
|
3039
3024
|
return this.log(`Skipping validation for cross-origin URL: ${t}`), !0;
|
|
3040
3025
|
try {
|
|
3041
|
-
const e = new AbortController(), n = setTimeout(() => e.abort(), this.validationTimeout),
|
|
3026
|
+
const e = new AbortController(), n = setTimeout(() => e.abort(), this.validationTimeout), s = await fetch(t, {
|
|
3042
3027
|
method: "HEAD",
|
|
3043
3028
|
signal: e.signal
|
|
3044
3029
|
});
|
|
3045
|
-
return clearTimeout(n),
|
|
3030
|
+
return clearTimeout(n), s.ok ? !0 : (this.log(`Validation failed for ${t}: HTTP ${s.status}`), !1);
|
|
3046
3031
|
} catch (e) {
|
|
3047
3032
|
return e instanceof Error && (e.name === "AbortError" ? this.log(`Validation timeout for ${t}`) : this.log(`Validation failed for ${t}:`, e.message)), !1;
|
|
3048
3033
|
}
|
|
@@ -3096,8 +3081,8 @@ class Ke {
|
|
|
3096
3081
|
this._discoveredUrls = [], this.log(`Preparing ${this.loaders.length} loader(s) in parallel`);
|
|
3097
3082
|
const i = this.loaders.map((e, n) => e.prepare(t).then(() => {
|
|
3098
3083
|
this.log(`Loader ${n} prepared with ${e.imagesLength()} images`);
|
|
3099
|
-
}).catch((
|
|
3100
|
-
console.warn(`Loader ${n} failed to prepare:`,
|
|
3084
|
+
}).catch((s) => {
|
|
3085
|
+
console.warn(`Loader ${n} failed to prepare:`, s);
|
|
3101
3086
|
}));
|
|
3102
3087
|
await Promise.all(i);
|
|
3103
3088
|
for (const e of this.loaders)
|
|
@@ -3222,6 +3207,37 @@ const Qe = `
|
|
|
3222
3207
|
pointer-events: none;
|
|
3223
3208
|
}
|
|
3224
3209
|
|
|
3210
|
+
.fbn-ic-gallery:focus,
|
|
3211
|
+
.fbn-ic-gallery.fbn-ic-has-focus {
|
|
3212
|
+
outline: 2px solid rgba(147, 197, 253, 0.8);
|
|
3213
|
+
outline-offset: -4px;
|
|
3214
|
+
}
|
|
3215
|
+
.fbn-ic-gallery.fbn-ic-suppress-outline:focus {
|
|
3216
|
+
outline: none;
|
|
3217
|
+
}
|
|
3218
|
+
.fbn-ic-gallery.fbn-ic-suppress-outline.fbn-ic-has-focus {
|
|
3219
|
+
outline: 2px solid rgba(99, 102, 241, 0.6);
|
|
3220
|
+
outline-offset: -4px;
|
|
3221
|
+
}
|
|
3222
|
+
|
|
3223
|
+
.fbn-ic-nav-btn {
|
|
3224
|
+
position: absolute;
|
|
3225
|
+
top: 50%;
|
|
3226
|
+
transform: translateY(-50%);
|
|
3227
|
+
z-index: 10001;
|
|
3228
|
+
cursor: pointer;
|
|
3229
|
+
border: none;
|
|
3230
|
+
background: none;
|
|
3231
|
+
padding: 0;
|
|
3232
|
+
line-height: 1;
|
|
3233
|
+
}
|
|
3234
|
+
.fbn-ic-nav-btn-prev {
|
|
3235
|
+
left: 12px;
|
|
3236
|
+
}
|
|
3237
|
+
.fbn-ic-nav-btn-next {
|
|
3238
|
+
right: 12px;
|
|
3239
|
+
}
|
|
3240
|
+
|
|
3225
3241
|
.fbn-ic-hidden {
|
|
3226
3242
|
display: none !important;
|
|
3227
3243
|
}
|
|
@@ -3235,11 +3251,11 @@ function ti() {
|
|
|
3235
3251
|
}
|
|
3236
3252
|
class ei {
|
|
3237
3253
|
constructor(t = {}) {
|
|
3238
|
-
this.fullConfig = te(t), t.container instanceof HTMLElement ? (this.containerRef = t.container, this.containerId = null) : (this.containerRef = null, this.containerId = t.container || "imageCloud"), this.imagesLoaded = !1, this.imageElements = [], this.imageLayouts = [], this.currentImageHeight = 225, this.currentFocusIndex = null, this.hoveredImage = null, this.resizeTimeout = null, this.displayQueue = [], this.queueInterval = null, this.loadGeneration = 0, this.loadingElAutoCreated = !1, this.errorElAutoCreated = !1, this.counterEl = null, this.counterElAutoCreated = !1, this.animationEngine = new oe(this.fullConfig.animation), this.layoutEngine = new De({
|
|
3254
|
+
this.fullConfig = te(t), t.container instanceof HTMLElement ? (this.containerRef = t.container, this.containerId = null) : (this.containerRef = null, this.containerId = t.container || "imageCloud"), this.imagesLoaded = !1, this.imageElements = [], this.imageLayouts = [], this.currentImageHeight = 225, this.currentFocusIndex = null, this.hoveredImage = null, this.resizeTimeout = null, this.displayQueue = [], this.queueInterval = null, this.loadGeneration = 0, this.loadingElAutoCreated = !1, this.errorElAutoCreated = !1, this.counterEl = null, this.counterElAutoCreated = !1, this.prevButtonEl = null, this.nextButtonEl = null, this.prevButtonElAutoCreated = !1, this.nextButtonElAutoCreated = !1, this.animationEngine = new oe(this.fullConfig.animation), this.layoutEngine = new De({
|
|
3239
3255
|
layout: this.fullConfig.layout,
|
|
3240
3256
|
image: this.fullConfig.image
|
|
3241
|
-
}), this.zoomEngine = new
|
|
3242
|
-
const i = this.fullConfig.animation.entry ||
|
|
3257
|
+
}), this.zoomEngine = new Be(this.fullConfig.interaction.focus, this.animationEngine, this.fullConfig.styling), this.defaultStyles = it(this.fullConfig.styling?.default), this.defaultClassName = this.fullConfig.styling?.default?.className, this.hoverClassName = this.fullConfig.styling?.hover?.className;
|
|
3258
|
+
const i = this.fullConfig.animation.entry || A.animation.entry;
|
|
3243
3259
|
this.entryAnimationEngine = new me(
|
|
3244
3260
|
i,
|
|
3245
3261
|
this.fullConfig.layout.algorithm
|
|
@@ -3250,6 +3266,16 @@ class ei {
|
|
|
3250
3266
|
i.timing?.duration ?? 600
|
|
3251
3267
|
) : this.idleAnimationEngine = null, this.zoomEngine.setOnUnfocusCompleteCallback((n) => {
|
|
3252
3268
|
this.idleAnimationEngine?.resumeForImage(n);
|
|
3269
|
+
const s = n;
|
|
3270
|
+
requestAnimationFrame(() => {
|
|
3271
|
+
if (s.matches(":hover") && this.fullConfig.styling?.hover) {
|
|
3272
|
+
const r = this.imageElements.indexOf(s);
|
|
3273
|
+
if (r !== -1) {
|
|
3274
|
+
const a = s.offsetHeight, c = s.cachedRenderedWidth;
|
|
3275
|
+
st(s, this.fullConfig.styling.hover, a, c), et(s, this.hoverClassName), this.hoveredImage = { element: s, layout: this.imageLayouts[r] };
|
|
3276
|
+
}
|
|
3277
|
+
}
|
|
3278
|
+
});
|
|
3253
3279
|
}), this.swipeEngine = null, this.imageFilter = this.createImageFilter(), this.imageLoader = this.createLoader(), this.containerEl = null, this.loadingEl = null, this.errorEl = null;
|
|
3254
3280
|
}
|
|
3255
3281
|
/**
|
|
@@ -3319,8 +3345,12 @@ class ei {
|
|
|
3319
3345
|
}
|
|
3320
3346
|
}
|
|
3321
3347
|
setupUI() {
|
|
3322
|
-
const t = this.fullConfig.
|
|
3323
|
-
t.showLoadingSpinner && (t.loadingElement ? (this.loadingEl = this.resolveElement(t.loadingElement), this.loadingElAutoCreated = !1) : (this.loadingEl = this.createDefaultLoadingElement(), this.loadingElAutoCreated = !0)), t.errorElement ? (this.errorEl = this.resolveElement(t.errorElement), this.errorElAutoCreated = !1) : (this.errorEl = this.createDefaultErrorElement(), this.errorElAutoCreated = !0), t.showImageCounter && (t.counterElement ? (this.counterEl = this.resolveElement(t.counterElement), this.counterElAutoCreated = !1) : (this.counterEl = this.createDefaultCounterElement(), this.counterElAutoCreated = !0))
|
|
3348
|
+
const t = this.fullConfig.ui;
|
|
3349
|
+
t.showFocusOutline ? this.containerEl?.classList.remove("fbn-ic-suppress-outline") : this.containerEl?.classList.add("fbn-ic-suppress-outline"), t.showLoadingSpinner && (t.loadingElement ? (this.loadingEl = this.resolveElement(t.loadingElement), this.loadingElAutoCreated = !1) : (this.loadingEl = this.createDefaultLoadingElement(), this.loadingElAutoCreated = !0)), t.errorElement ? (this.errorEl = this.resolveElement(t.errorElement), this.errorElAutoCreated = !1) : (this.errorEl = this.createDefaultErrorElement(), this.errorElAutoCreated = !0), t.showImageCounter && (t.counterElement ? (this.counterEl = this.resolveElement(t.counterElement), this.counterElAutoCreated = !1) : (this.counterEl = this.createDefaultCounterElement(), this.counterElAutoCreated = !0)), t.showNavButtons && (t.prevButtonElement ? (this.prevButtonEl = this.resolveElement(t.prevButtonElement), this.prevButtonElAutoCreated = !1) : (this.prevButtonEl = this.createDefaultPrevButtonElement(), this.prevButtonElAutoCreated = !0), t.nextButtonElement ? (this.nextButtonEl = this.resolveElement(t.nextButtonElement), this.nextButtonElAutoCreated = !1) : (this.nextButtonEl = this.createDefaultNextButtonElement(), this.nextButtonElAutoCreated = !0), this.prevButtonEl?.addEventListener("click", (i) => {
|
|
3350
|
+
i.stopPropagation(), this.navigateToPreviousImage();
|
|
3351
|
+
}), this.nextButtonEl?.addEventListener("click", (i) => {
|
|
3352
|
+
i.stopPropagation(), this.navigateToNextImage();
|
|
3353
|
+
}));
|
|
3324
3354
|
}
|
|
3325
3355
|
resolveElement(t) {
|
|
3326
3356
|
return t instanceof HTMLElement ? t : document.getElementById(t);
|
|
@@ -3341,11 +3371,19 @@ class ei {
|
|
|
3341
3371
|
const t = document.createElement("div");
|
|
3342
3372
|
return t.className = "fbn-ic-counter fbn-ic-hidden", this.containerEl.appendChild(t), t;
|
|
3343
3373
|
}
|
|
3374
|
+
createDefaultPrevButtonElement() {
|
|
3375
|
+
const t = document.createElement("button");
|
|
3376
|
+
return t.className = "fbn-ic-nav-btn fbn-ic-nav-btn-prev fbn-ic-hidden", t.textContent = "‹", t.setAttribute("aria-label", "Previous image"), t.setAttribute("tabindex", "-1"), this.containerEl.appendChild(t), t;
|
|
3377
|
+
}
|
|
3378
|
+
createDefaultNextButtonElement() {
|
|
3379
|
+
const t = document.createElement("button");
|
|
3380
|
+
return t.className = "fbn-ic-nav-btn fbn-ic-nav-btn-next fbn-ic-hidden", t.textContent = "›", t.setAttribute("aria-label", "Next image"), t.setAttribute("tabindex", "-1"), this.containerEl.appendChild(t), t;
|
|
3381
|
+
}
|
|
3344
3382
|
setupEventListeners() {
|
|
3345
3383
|
this.fullConfig.interaction.navigation?.keyboard !== !1 && this.containerEl.addEventListener("keydown", (t) => {
|
|
3346
|
-
t.key === "Escape" ? (this.zoomEngine.unfocusImage(), this.currentFocusIndex = null, this.swipeEngine?.disable(), this.hideCounter()) : t.key === "ArrowRight" ? this.navigateToNextImage() : t.key === "ArrowLeft" ? this.navigateToPreviousImage() : (t.key === "Enter" || t.key === " ") && this.hoveredImage && (this.handleImageClick(this.hoveredImage.element, this.hoveredImage.layout), t.preventDefault());
|
|
3384
|
+
t.key === "Escape" ? (this.zoomEngine.unfocusImage(), this.currentFocusIndex = null, this.swipeEngine?.disable(), this.hideCounter(), this.hideNavButtons(), this.hideFocusIndicator()) : t.key === "ArrowRight" ? this.navigateToNextImage() : t.key === "ArrowLeft" ? this.navigateToPreviousImage() : (t.key === "Enter" || t.key === " ") && this.hoveredImage && (this.handleImageClick(this.hoveredImage.element, this.hoveredImage.layout), t.preventDefault());
|
|
3347
3385
|
}), document.addEventListener("click", (t) => {
|
|
3348
|
-
this.swipeEngine?.hadRecentTouch() || t.target.closest(".fbn-ic-image")
|
|
3386
|
+
this.swipeEngine?.hadRecentTouch() || !t.target.closest(".fbn-ic-image") && !t.target.closest(".fbn-ic-nav-btn") && (this.zoomEngine.unfocusImage(), this.currentFocusIndex = null, this.swipeEngine?.disable(), this.hideCounter(), this.hideNavButtons(), this.hideFocusIndicator());
|
|
3349
3387
|
}), window.addEventListener("resize", () => this.handleResize());
|
|
3350
3388
|
}
|
|
3351
3389
|
/**
|
|
@@ -3358,7 +3396,7 @@ class ei {
|
|
|
3358
3396
|
);
|
|
3359
3397
|
if (!i) return;
|
|
3360
3398
|
const e = this.imageLayouts[t];
|
|
3361
|
-
e && (this.currentFocusIndex = t, this.handleImageClick(i, e), this.updateCounter(t));
|
|
3399
|
+
e && (this.currentFocusIndex = t, this.handleImageClick(i, e), this.updateCounter(t), this.showNavButtons(), this.showFocusIndicator());
|
|
3362
3400
|
}
|
|
3363
3401
|
/**
|
|
3364
3402
|
* Navigate to the previous image (Left arrow)
|
|
@@ -3370,7 +3408,7 @@ class ei {
|
|
|
3370
3408
|
);
|
|
3371
3409
|
if (!i) return;
|
|
3372
3410
|
const e = this.imageLayouts[t];
|
|
3373
|
-
e && (this.currentFocusIndex = t, this.handleImageClick(i, e), this.updateCounter(t));
|
|
3411
|
+
e && (this.currentFocusIndex = t, this.handleImageClick(i, e), this.updateCounter(t), this.showNavButtons(), this.showFocusIndicator());
|
|
3374
3412
|
}
|
|
3375
3413
|
/**
|
|
3376
3414
|
* Navigate to a specific image by index
|
|
@@ -3406,13 +3444,13 @@ class ei {
|
|
|
3406
3444
|
this.showError("No images found."), this.showLoading(!1);
|
|
3407
3445
|
return;
|
|
3408
3446
|
}
|
|
3409
|
-
const e = this.getContainerBounds(), n = this.getImageHeight(),
|
|
3447
|
+
const e = this.getContainerBounds(), n = this.getImageHeight(), s = window.innerWidth;
|
|
3410
3448
|
this.logDebug(`Adaptive sizing input: container=${e.width}x${e.height}px, images=${t}, responsiveMax=${n}px`);
|
|
3411
3449
|
const r = this.layoutEngine.calculateAdaptiveSize(
|
|
3412
3450
|
e,
|
|
3413
3451
|
t,
|
|
3414
3452
|
n,
|
|
3415
|
-
|
|
3453
|
+
s
|
|
3416
3454
|
);
|
|
3417
3455
|
this.logDebug(`Adaptive sizing result: height=${r.height}px`), await this.createImageCloud(i, r.height), this.showLoading(!1), this.imagesLoaded = !0;
|
|
3418
3456
|
} catch (t) {
|
|
@@ -3429,33 +3467,33 @@ class ei {
|
|
|
3429
3467
|
if (!this.containerEl) return;
|
|
3430
3468
|
const e = this.getContainerBounds();
|
|
3431
3469
|
this.currentImageHeight = i;
|
|
3432
|
-
const n = this.loadGeneration,
|
|
3433
|
-
this.imageLayouts =
|
|
3470
|
+
const n = this.loadGeneration, s = this.layoutEngine.generateLayout(t.length, e, { fixedHeight: i });
|
|
3471
|
+
this.imageLayouts = s, this.displayQueue = [];
|
|
3434
3472
|
let r = 0;
|
|
3435
|
-
const
|
|
3473
|
+
const a = (l) => {
|
|
3436
3474
|
this.containerEl && (this.containerEl.appendChild(l), this.imageElements.push(l), requestAnimationFrame(() => {
|
|
3437
3475
|
if (l.offsetWidth, l.style.opacity = this.defaultStyles.opacity ?? "1", l.dataset.startX && (this.entryAnimationEngine.requiresJSAnimation() || this.entryAnimationEngine.requiresJSRotation() || this.entryAnimationEngine.requiresJSScale() || l.dataset.startRotation !== l.dataset.rotation || l.dataset.startScale !== l.dataset.scale)) {
|
|
3438
3476
|
const d = {
|
|
3439
3477
|
x: parseFloat(l.dataset.startX),
|
|
3440
3478
|
y: parseFloat(l.dataset.startY)
|
|
3441
|
-
},
|
|
3479
|
+
}, g = {
|
|
3442
3480
|
x: parseFloat(l.dataset.endX),
|
|
3443
3481
|
y: parseFloat(l.dataset.endY)
|
|
3444
|
-
}, b = parseFloat(l.dataset.imageWidth), p = parseFloat(l.dataset.imageHeight),
|
|
3482
|
+
}, b = parseFloat(l.dataset.imageWidth), p = parseFloat(l.dataset.imageHeight), f = parseFloat(l.dataset.rotation), m = parseFloat(l.dataset.scale), y = l.dataset.startRotation ? parseFloat(l.dataset.startRotation) : f, E = l.dataset.startScale ? parseFloat(l.dataset.startScale) : m, v = this.entryAnimationEngine.getTiming();
|
|
3445
3483
|
ue({
|
|
3446
3484
|
element: l,
|
|
3447
3485
|
startPosition: d,
|
|
3448
|
-
endPosition:
|
|
3486
|
+
endPosition: g,
|
|
3449
3487
|
pathConfig: this.entryAnimationEngine.getPathConfig(),
|
|
3450
3488
|
duration: v.duration,
|
|
3451
3489
|
imageWidth: b,
|
|
3452
3490
|
imageHeight: p,
|
|
3453
|
-
rotation:
|
|
3491
|
+
rotation: f,
|
|
3454
3492
|
scale: m,
|
|
3455
3493
|
rotationConfig: this.entryAnimationEngine.getRotationConfig(),
|
|
3456
3494
|
startRotation: y,
|
|
3457
3495
|
scaleConfig: this.entryAnimationEngine.getScaleConfig(),
|
|
3458
|
-
startScale:
|
|
3496
|
+
startScale: E
|
|
3459
3497
|
});
|
|
3460
3498
|
} else {
|
|
3461
3499
|
const d = l.dataset.finalTransform || "";
|
|
@@ -3484,7 +3522,7 @@ class ei {
|
|
|
3484
3522
|
if (this.logDebug("Starting queue processing, enabled:", this.fullConfig.animation.queue.enabled), !this.fullConfig.animation.queue.enabled) {
|
|
3485
3523
|
for (; this.displayQueue.length > 0; ) {
|
|
3486
3524
|
const l = this.displayQueue.shift();
|
|
3487
|
-
l &&
|
|
3525
|
+
l && a(l);
|
|
3488
3526
|
}
|
|
3489
3527
|
return;
|
|
3490
3528
|
}
|
|
@@ -3495,7 +3533,7 @@ class ei {
|
|
|
3495
3533
|
}
|
|
3496
3534
|
if (this.displayQueue.length > 0) {
|
|
3497
3535
|
const l = this.displayQueue.shift();
|
|
3498
|
-
l &&
|
|
3536
|
+
l && a(l);
|
|
3499
3537
|
}
|
|
3500
3538
|
r >= t.length && this.displayQueue.length === 0 && this.queueInterval !== null && (clearInterval(this.queueInterval), this.queueInterval = null);
|
|
3501
3539
|
}, this.fullConfig.animation.queue.interval);
|
|
@@ -3509,44 +3547,44 @@ class ei {
|
|
|
3509
3547
|
l.observe(this.containerEl);
|
|
3510
3548
|
} else
|
|
3511
3549
|
c();
|
|
3512
|
-
this.fullConfig.config.debug?.centers && this.containerEl && (this.containerEl.querySelectorAll(".fbn-ic-debug-center").forEach((l) => l.remove()),
|
|
3550
|
+
this.fullConfig.config.debug?.centers && this.containerEl && (this.containerEl.querySelectorAll(".fbn-ic-debug-center").forEach((l) => l.remove()), s.forEach((l, u) => {
|
|
3513
3551
|
const h = document.createElement("div");
|
|
3514
3552
|
h.className = "fbn-ic-debug-center", h.style.position = "absolute", h.style.width = "12px", h.style.height = "12px", h.style.borderRadius = "50%", h.style.backgroundColor = "red", h.style.border = "2px solid yellow", h.style.zIndex = "9999", h.style.pointerEvents = "none";
|
|
3515
|
-
const d = l.x,
|
|
3516
|
-
h.style.left = `${d - 6}px`, h.style.top = `${
|
|
3553
|
+
const d = l.x, g = l.y;
|
|
3554
|
+
h.style.left = `${d - 6}px`, h.style.top = `${g - 6}px`, h.title = `Image ${u}: center (${Math.round(d)}, ${Math.round(g)})`, this.containerEl.appendChild(h);
|
|
3517
3555
|
})), t.forEach((l, u) => {
|
|
3518
3556
|
const h = document.createElement("img");
|
|
3519
3557
|
h.referrerPolicy = "no-referrer", h.classList.add("fbn-ic-image"), this.fullConfig.interaction.dragging === !1 && (h.draggable = !1), h.dataset.imageId = String(u), h.dataset.createdFlag = "true";
|
|
3520
|
-
const d =
|
|
3521
|
-
h.style.position = "absolute", h.style.width = "auto", h.style.height = `${i}px`, h.style.left = `${d.x}px`, h.style.top = `${d.y}px`, d.zIndex && (h.style.zIndex = String(d.zIndex)),
|
|
3558
|
+
const d = s[u];
|
|
3559
|
+
h.style.position = "absolute", h.style.width = "auto", h.style.height = `${i}px`, h.style.left = `${d.x}px`, h.style.top = `${d.y}px`, d.zIndex && (h.style.zIndex = String(d.zIndex)), et(h, this.defaultClassName), h.addEventListener("mouseenter", () => {
|
|
3522
3560
|
if (this.hoveredImage = { element: h, layout: d }, !this.zoomEngine.isInvolved(h)) {
|
|
3523
|
-
const
|
|
3524
|
-
|
|
3561
|
+
const g = h.cachedRenderedWidth;
|
|
3562
|
+
st(h, this.fullConfig.styling?.hover, i, g), et(h, this.hoverClassName);
|
|
3525
3563
|
}
|
|
3526
3564
|
}), h.addEventListener("mouseleave", () => {
|
|
3527
3565
|
if (this.hoveredImage = null, !this.zoomEngine.isInvolved(h)) {
|
|
3528
|
-
const
|
|
3529
|
-
|
|
3566
|
+
const g = h.cachedRenderedWidth;
|
|
3567
|
+
st(h, this.fullConfig.styling?.default, i, g), pt(h, this.hoverClassName), et(h, this.defaultClassName);
|
|
3530
3568
|
}
|
|
3531
|
-
}), h.addEventListener("click", (
|
|
3532
|
-
|
|
3569
|
+
}), h.addEventListener("click", (g) => {
|
|
3570
|
+
g.stopPropagation(), this.handleImageClick(h, d);
|
|
3533
3571
|
}), h.style.opacity = "0", h.style.transition = this.entryAnimationEngine.getTransitionCSS(), h.onload = () => {
|
|
3534
3572
|
if (n !== this.loadGeneration)
|
|
3535
3573
|
return;
|
|
3536
|
-
const
|
|
3537
|
-
h.dataset.onloadCalled = "true", window.DEBUG_CLIPPATH && console.log(`[onload #${u}] Called with imageHeight=${i}, renderedWidth=${b}`), h.style.width = `${b}px`, h.cachedRenderedWidth = b, h.aspectRatio =
|
|
3538
|
-
const p = { x: d.x, y: d.y },
|
|
3574
|
+
const g = h.naturalWidth / h.naturalHeight, b = i * g;
|
|
3575
|
+
h.dataset.onloadCalled = "true", window.DEBUG_CLIPPATH && console.log(`[onload #${u}] Called with imageHeight=${i}, renderedWidth=${b}`), h.style.width = `${b}px`, h.cachedRenderedWidth = b, h.aspectRatio = g, st(h, this.fullConfig.styling?.default, i, b);
|
|
3576
|
+
const p = { x: d.x, y: d.y }, f = { width: b, height: i }, m = this.entryAnimationEngine.calculateStartPosition(
|
|
3539
3577
|
p,
|
|
3540
|
-
|
|
3578
|
+
f,
|
|
3541
3579
|
e,
|
|
3542
3580
|
u,
|
|
3543
3581
|
t.length
|
|
3544
|
-
), y = this.entryAnimationEngine.calculateStartRotation(d.rotation),
|
|
3582
|
+
), y = this.entryAnimationEngine.calculateStartRotation(d.rotation), E = this.entryAnimationEngine.calculateStartScale(d.scale), v = this.entryAnimationEngine.buildFinalTransform(
|
|
3545
3583
|
d.rotation,
|
|
3546
3584
|
d.scale,
|
|
3547
3585
|
b,
|
|
3548
3586
|
i
|
|
3549
|
-
),
|
|
3587
|
+
), S = this.entryAnimationEngine.buildStartTransform(
|
|
3550
3588
|
m,
|
|
3551
3589
|
p,
|
|
3552
3590
|
d.rotation,
|
|
@@ -3554,17 +3592,17 @@ class ei {
|
|
|
3554
3592
|
b,
|
|
3555
3593
|
i,
|
|
3556
3594
|
y,
|
|
3557
|
-
|
|
3595
|
+
E
|
|
3558
3596
|
);
|
|
3559
3597
|
this.fullConfig.config.debug?.enabled && u < 3 && console.log(`Image ${u}:`, {
|
|
3560
3598
|
finalPosition: p,
|
|
3561
|
-
imageSize:
|
|
3599
|
+
imageSize: f,
|
|
3562
3600
|
left: d.x,
|
|
3563
3601
|
top: d.y,
|
|
3564
3602
|
finalTransform: v,
|
|
3565
3603
|
renderedWidth: b,
|
|
3566
3604
|
renderedHeight: i
|
|
3567
|
-
}), h.style.transform =
|
|
3605
|
+
}), h.style.transform = S, h.dataset.finalTransform = v, (this.entryAnimationEngine.requiresJSAnimation() || this.entryAnimationEngine.requiresJSRotation() || this.entryAnimationEngine.requiresJSScale() || y !== d.rotation || E !== d.scale) && (h.dataset.startX = String(m.x), h.dataset.startY = String(m.y), h.dataset.endX = String(p.x), h.dataset.endY = String(p.y), h.dataset.imageWidth = String(b), h.dataset.imageHeight = String(i), h.dataset.rotation = String(d.rotation), h.dataset.scale = String(d.scale), h.dataset.startRotation = String(y), h.dataset.startScale = String(E)), this.displayQueue.push(h);
|
|
3568
3606
|
}, h.onerror = () => r++, h.src = l;
|
|
3569
3607
|
});
|
|
3570
3608
|
}
|
|
@@ -3575,21 +3613,21 @@ class ei {
|
|
|
3575
3613
|
height: this.containerEl.offsetHeight
|
|
3576
3614
|
};
|
|
3577
3615
|
if (e)
|
|
3578
|
-
await this.zoomEngine.unfocusImage(), this.currentFocusIndex = null, this.swipeEngine?.disable(), this.hideCounter();
|
|
3616
|
+
await this.zoomEngine.unfocusImage(), this.currentFocusIndex = null, this.swipeEngine?.disable(), this.hideCounter(), this.hideNavButtons(), this.hideFocusIndicator();
|
|
3579
3617
|
else {
|
|
3580
3618
|
this.idleAnimationEngine?.pauseForImage(t);
|
|
3581
|
-
const
|
|
3582
|
-
this.currentFocusIndex =
|
|
3619
|
+
const s = t.dataset.imageId;
|
|
3620
|
+
this.currentFocusIndex = s !== void 0 ? parseInt(s, 10) : null, this.swipeEngine?.enable(), this.containerEl?.focus({ preventScroll: !0 }), await this.zoomEngine.focusImage(t, n, i), this.currentFocusIndex !== null && this.updateCounter(this.currentFocusIndex), this.showNavButtons(), this.showFocusIndicator();
|
|
3583
3621
|
}
|
|
3584
3622
|
}
|
|
3585
3623
|
/**
|
|
3586
3624
|
* Clear the image cloud and reset state
|
|
3587
3625
|
*/
|
|
3588
3626
|
clearImageCloud() {
|
|
3589
|
-
this.queueInterval !== null && (clearInterval(this.queueInterval), this.queueInterval = null), this.loadGeneration++, this.displayQueue = [], this.containerEl && this.containerEl.querySelectorAll(".fbn-ic-image, .fbn-ic-debug-center").forEach((t) => t.remove()), this.imageElements = [], this.imageLayouts = [], this.currentFocusIndex = null, this.hoveredImage = null, this.layoutEngine.reset(), this.zoomEngine.reset(), this.idleAnimationEngine?.stopAll(), this.imagesLoaded = !1;
|
|
3627
|
+
this.queueInterval !== null && (clearInterval(this.queueInterval), this.queueInterval = null), this.loadGeneration++, this.displayQueue = [], this.hideFocusIndicator(), this.containerEl && this.containerEl.querySelectorAll(".fbn-ic-image, .fbn-ic-debug-center").forEach((t) => t.remove()), this.imageElements = [], this.imageLayouts = [], this.currentFocusIndex = null, this.hoveredImage = null, this.layoutEngine.reset(), this.zoomEngine.reset(), this.idleAnimationEngine?.stopAll(), this.imagesLoaded = !1;
|
|
3590
3628
|
}
|
|
3591
3629
|
showLoading(t) {
|
|
3592
|
-
!this.fullConfig.
|
|
3630
|
+
!this.fullConfig.ui.showLoadingSpinner || !this.loadingEl || (t ? this.loadingEl.classList.remove("fbn-ic-hidden") : this.loadingEl.classList.add("fbn-ic-hidden"));
|
|
3593
3631
|
}
|
|
3594
3632
|
showError(t) {
|
|
3595
3633
|
this.errorEl && (this.errorEl.textContent = t, this.errorEl.classList.remove("fbn-ic-hidden"));
|
|
@@ -3598,16 +3636,28 @@ class ei {
|
|
|
3598
3636
|
this.errorEl && this.errorEl.classList.add("fbn-ic-hidden");
|
|
3599
3637
|
}
|
|
3600
3638
|
updateCounter(t) {
|
|
3601
|
-
!this.fullConfig.
|
|
3639
|
+
!this.fullConfig.ui.showImageCounter || !this.counterEl || (this.counterEl.textContent = `${t + 1} of ${this.imageElements.length}`, this.counterEl.classList.remove("fbn-ic-hidden"));
|
|
3602
3640
|
}
|
|
3603
3641
|
hideCounter() {
|
|
3604
3642
|
this.counterEl && this.counterEl.classList.add("fbn-ic-hidden");
|
|
3605
3643
|
}
|
|
3644
|
+
showFocusIndicator() {
|
|
3645
|
+
this.containerEl?.classList.add("fbn-ic-has-focus");
|
|
3646
|
+
}
|
|
3647
|
+
hideFocusIndicator() {
|
|
3648
|
+
this.containerEl?.classList.remove("fbn-ic-has-focus");
|
|
3649
|
+
}
|
|
3650
|
+
showNavButtons() {
|
|
3651
|
+
this.prevButtonEl?.classList.remove("fbn-ic-hidden"), this.nextButtonEl?.classList.remove("fbn-ic-hidden");
|
|
3652
|
+
}
|
|
3653
|
+
hideNavButtons() {
|
|
3654
|
+
this.prevButtonEl?.classList.add("fbn-ic-hidden"), this.nextButtonEl?.classList.add("fbn-ic-hidden");
|
|
3655
|
+
}
|
|
3606
3656
|
/**
|
|
3607
3657
|
* Destroy the gallery and clean up resources
|
|
3608
3658
|
*/
|
|
3609
3659
|
destroy() {
|
|
3610
|
-
this.clearImageCloud(), this.loadingElAutoCreated && this.loadingEl && (this.loadingEl.remove(), this.loadingEl = null), this.errorElAutoCreated && this.errorEl && (this.errorEl.remove(), this.errorEl = null), this.counterElAutoCreated && this.counterEl && (this.counterEl.remove(), this.counterEl = null), this.resizeTimeout !== null && clearTimeout(this.resizeTimeout), this.swipeEngine?.destroy(), this.idleAnimationEngine?.stopAll(), this.idleAnimationEngine = null;
|
|
3660
|
+
this.clearImageCloud(), this.loadingElAutoCreated && this.loadingEl && (this.loadingEl.remove(), this.loadingEl = null), this.errorElAutoCreated && this.errorEl && (this.errorEl.remove(), this.errorEl = null), this.counterElAutoCreated && this.counterEl && (this.counterEl.remove(), this.counterEl = null), this.prevButtonElAutoCreated && this.prevButtonEl && (this.prevButtonEl.remove(), this.prevButtonEl = null), this.nextButtonElAutoCreated && this.nextButtonEl && (this.nextButtonEl.remove(), this.nextButtonEl = null), this.resizeTimeout !== null && clearTimeout(this.resizeTimeout), this.swipeEngine?.destroy(), this.idleAnimationEngine?.stopAll(), this.idleAnimationEngine = null;
|
|
3611
3661
|
}
|
|
3612
3662
|
}
|
|
3613
3663
|
const It = class It extends HTMLElement {
|
|
@@ -3630,17 +3680,17 @@ const It = class It extends HTMLElement {
|
|
|
3630
3680
|
const t = {}, i = this.getAttribute("config");
|
|
3631
3681
|
if (i)
|
|
3632
3682
|
try {
|
|
3633
|
-
const
|
|
3634
|
-
Object.assign(t,
|
|
3635
|
-
} catch (
|
|
3636
|
-
console.error("<image-cloud> invalid config JSON:",
|
|
3683
|
+
const s = JSON.parse(i), { container: r, ...a } = s;
|
|
3684
|
+
Object.assign(t, a);
|
|
3685
|
+
} catch (s) {
|
|
3686
|
+
console.error("<image-cloud> invalid config JSON:", s);
|
|
3637
3687
|
}
|
|
3638
3688
|
const e = this.getAttribute("images");
|
|
3639
3689
|
if (e)
|
|
3640
3690
|
try {
|
|
3641
3691
|
t.images = JSON.parse(e);
|
|
3642
|
-
} catch (
|
|
3643
|
-
console.error("<image-cloud> invalid images JSON:",
|
|
3692
|
+
} catch (s) {
|
|
3693
|
+
console.error("<image-cloud> invalid images JSON:", s);
|
|
3644
3694
|
}
|
|
3645
3695
|
const n = this.getAttribute("layout");
|
|
3646
3696
|
return n && (t.layout = {
|