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