@frybynite/image-cloud 0.7.4 → 0.7.5
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 +981 -896
- package/dist/image-cloud-auto-init.js.map +1 -1
- package/dist/image-cloud.js +701 -616
- package/dist/image-cloud.js.map +1 -1
- package/dist/image-cloud.umd.js +3 -3
- package/dist/image-cloud.umd.js.map +1 -1
- package/dist/index.d.ts +16 -5
- package/dist/react.d.ts +16 -5
- package/dist/react.js +694 -609
- package/dist/react.js.map +1 -1
- package/dist/vue.d.ts +16 -5
- package/dist/vue.js +696 -611
- package/dist/vue.js.map +1 -1
- package/dist/web-component.d.ts +16 -5
- package/dist/web-component.js +648 -563
- package/dist/web-component.js.map +1 -1
- package/package.json +1 -1
package/dist/react.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { forwardRef as Pt, useRef as
|
|
3
|
-
const
|
|
1
|
+
import { jsx as Ot } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as Pt, useRef as xt, useImperativeHandle as Ut, useEffect as _t } from "react";
|
|
3
|
+
const gt = Object.freeze({
|
|
4
4
|
none: "none",
|
|
5
5
|
sm: "0 2px 4px rgba(0,0,0,0.1)",
|
|
6
6
|
md: "0 4px 16px rgba(0,0,0,0.4)",
|
|
7
7
|
lg: "0 8px 32px rgba(0,0,0,0.5)",
|
|
8
8
|
glow: "0 0 30px rgba(255,255,255,0.6)"
|
|
9
|
-
}),
|
|
9
|
+
}), Et = Object.freeze({
|
|
10
10
|
energetic: Object.freeze({ overshoot: 0.25, bounces: 2, decayRatio: 0.5 }),
|
|
11
11
|
playful: Object.freeze({ overshoot: 0.15, bounces: 1, decayRatio: 0.5 }),
|
|
12
12
|
subtle: Object.freeze({ overshoot: 0.08, bounces: 1, decayRatio: 0.5 })
|
|
@@ -15,18 +15,18 @@ const ft = Object.freeze({
|
|
|
15
15
|
bouncy: Object.freeze({ stiffness: 300, damping: 15, mass: 1, oscillations: 4 }),
|
|
16
16
|
wobbly: Object.freeze({ stiffness: 180, damping: 12, mass: 1.5, oscillations: 5 }),
|
|
17
17
|
snappy: Object.freeze({ stiffness: 400, damping: 25, mass: 0.8, oscillations: 2 })
|
|
18
|
-
}),
|
|
18
|
+
}), It = Object.freeze({
|
|
19
19
|
gentle: Object.freeze({ amplitude: 30, frequency: 1.5, decay: !0, decayRate: 0.9, phase: 0 }),
|
|
20
20
|
playful: Object.freeze({ amplitude: 50, frequency: 2.5, decay: !0, decayRate: 0.7, phase: 0 }),
|
|
21
21
|
serpentine: Object.freeze({ amplitude: 60, frequency: 3, decay: !1, decayRate: 1, phase: 0 }),
|
|
22
22
|
flutter: Object.freeze({ amplitude: 20, frequency: 4, decay: !0, decayRate: 0.5, phase: 0 })
|
|
23
23
|
}), pt = Object.freeze({
|
|
24
24
|
type: "linear"
|
|
25
|
-
}), bt = Object.freeze({
|
|
26
|
-
mode: "none"
|
|
27
25
|
}), yt = Object.freeze({
|
|
28
26
|
mode: "none"
|
|
29
|
-
}),
|
|
27
|
+
}), bt = Object.freeze({
|
|
28
|
+
mode: "none"
|
|
29
|
+
}), Rt = Object.freeze({
|
|
30
30
|
default: Object.freeze({
|
|
31
31
|
border: Object.freeze({
|
|
32
32
|
width: 0,
|
|
@@ -80,28 +80,28 @@ const ft = Object.freeze({
|
|
|
80
80
|
min: -15,
|
|
81
81
|
max: 15
|
|
82
82
|
})
|
|
83
|
-
}),
|
|
83
|
+
}), Mt = Object.freeze({
|
|
84
84
|
sizing: jt,
|
|
85
85
|
rotation: kt
|
|
86
|
-
}),
|
|
86
|
+
}), Lt = Object.freeze({
|
|
87
87
|
validateUrls: !0,
|
|
88
88
|
validationTimeout: 5e3,
|
|
89
89
|
validationMethod: "head",
|
|
90
90
|
allowedExtensions: ["jpg", "jpeg", "png", "gif", "webp", "bmp"]
|
|
91
|
-
}),
|
|
91
|
+
}), zt = Object.freeze({
|
|
92
92
|
enabled: !1,
|
|
93
93
|
centers: !1,
|
|
94
94
|
loaders: !1
|
|
95
|
-
}),
|
|
95
|
+
}), b = Object.freeze({
|
|
96
96
|
// Loader configuration (always an array, composite behavior is implicit)
|
|
97
97
|
loaders: [],
|
|
98
98
|
// Shared loader settings and debug config
|
|
99
99
|
config: Object.freeze({
|
|
100
|
-
loaders:
|
|
101
|
-
debug:
|
|
100
|
+
loaders: Lt,
|
|
101
|
+
debug: zt
|
|
102
102
|
}),
|
|
103
103
|
// Image sizing and rotation configuration
|
|
104
|
-
image:
|
|
104
|
+
image: Mt,
|
|
105
105
|
// Pattern-based layout configuration
|
|
106
106
|
layout: Object.freeze({
|
|
107
107
|
algorithm: "radial",
|
|
@@ -164,8 +164,8 @@ const ft = Object.freeze({
|
|
|
164
164
|
easing: "cubic-bezier(0.25, 1, 0.5, 1)",
|
|
165
165
|
// smooth deceleration
|
|
166
166
|
path: pt,
|
|
167
|
-
rotation:
|
|
168
|
-
scale:
|
|
167
|
+
rotation: yt,
|
|
168
|
+
scale: bt
|
|
169
169
|
})
|
|
170
170
|
}),
|
|
171
171
|
// Pattern-based interaction configuration
|
|
@@ -218,7 +218,7 @@ const ft = Object.freeze({
|
|
|
218
218
|
})
|
|
219
219
|
}),
|
|
220
220
|
// Image styling
|
|
221
|
-
styling:
|
|
221
|
+
styling: Rt
|
|
222
222
|
});
|
|
223
223
|
function Z(n, t) {
|
|
224
224
|
if (!n) return t || {};
|
|
@@ -248,15 +248,15 @@ function Gt(n, t) {
|
|
|
248
248
|
...n.sizing,
|
|
249
249
|
...t.sizing
|
|
250
250
|
}, t.sizing.variance)) {
|
|
251
|
-
const i = t.sizing.variance, o = i.min !== void 0 && i.min >= 0.25 && i.min <= 1 ? i.min : n.sizing?.variance?.min ?? 1,
|
|
252
|
-
e.sizing.variance = { min: o, max:
|
|
251
|
+
const i = t.sizing.variance, o = i.min !== void 0 && i.min >= 0.25 && i.min <= 1 ? i.min : n.sizing?.variance?.min ?? 1, a = i.max !== void 0 && i.max >= 1 && i.max <= 1.75 ? i.max : n.sizing?.variance?.max ?? 1;
|
|
252
|
+
e.sizing.variance = { min: o, max: a };
|
|
253
253
|
}
|
|
254
254
|
if (t.rotation !== void 0 && (e.rotation = {
|
|
255
255
|
...n.rotation,
|
|
256
256
|
...t.rotation
|
|
257
257
|
}, t.rotation.range)) {
|
|
258
|
-
const i = t.rotation.range, o = i.min !== void 0 && i.min >= -180 && i.min <= 0 ? i.min : n.rotation?.range?.min ?? -15,
|
|
259
|
-
e.rotation.range = { min: o, max:
|
|
258
|
+
const i = t.rotation.range, o = i.min !== void 0 && i.min >= -180 && i.min <= 0 ? i.min : n.rotation?.range?.min ?? -15, a = i.max !== void 0 && i.max >= 0 && i.max <= 180 ? i.max : n.rotation?.range?.max ?? 15;
|
|
259
|
+
e.rotation.range = { min: o, max: a };
|
|
260
260
|
}
|
|
261
261
|
return e;
|
|
262
262
|
}
|
|
@@ -300,92 +300,92 @@ function Xt(n = {}) {
|
|
|
300
300
|
});
|
|
301
301
|
const r = {
|
|
302
302
|
loaders: {
|
|
303
|
-
...
|
|
303
|
+
...Lt,
|
|
304
304
|
...n.config?.loaders ?? {}
|
|
305
305
|
}
|
|
306
|
-
},
|
|
306
|
+
}, s = {
|
|
307
307
|
loaders: o,
|
|
308
308
|
config: r,
|
|
309
|
-
image: Gt(
|
|
310
|
-
layout: { ...
|
|
311
|
-
animation: { ...
|
|
312
|
-
interaction: { ...
|
|
313
|
-
rendering: { ...
|
|
314
|
-
styling: Wt(
|
|
309
|
+
image: Gt(Mt, i),
|
|
310
|
+
layout: { ...b.layout },
|
|
311
|
+
animation: { ...b.animation },
|
|
312
|
+
interaction: { ...b.interaction },
|
|
313
|
+
rendering: { ...b.rendering },
|
|
314
|
+
styling: Wt(Rt, n.styling)
|
|
315
315
|
};
|
|
316
|
-
return n.layout && (
|
|
317
|
-
...
|
|
316
|
+
return n.layout && (s.layout = {
|
|
317
|
+
...b.layout,
|
|
318
318
|
...n.layout
|
|
319
|
-
}, n.layout.responsive && (
|
|
320
|
-
...
|
|
321
|
-
mobile: n.layout.responsive.mobile ? { ...
|
|
322
|
-
tablet: n.layout.responsive.tablet ? { ...
|
|
323
|
-
}), n.layout.spacing && (
|
|
324
|
-
...
|
|
319
|
+
}, n.layout.responsive && (s.layout.responsive = {
|
|
320
|
+
...b.layout.responsive,
|
|
321
|
+
mobile: n.layout.responsive.mobile ? { ...b.layout.responsive.mobile, ...n.layout.responsive.mobile } : b.layout.responsive.mobile,
|
|
322
|
+
tablet: n.layout.responsive.tablet ? { ...b.layout.responsive.tablet, ...n.layout.responsive.tablet } : b.layout.responsive.tablet
|
|
323
|
+
}), n.layout.spacing && (s.layout.spacing = {
|
|
324
|
+
...b.layout.spacing,
|
|
325
325
|
...n.layout.spacing
|
|
326
|
-
})), n.animation && (
|
|
327
|
-
...
|
|
326
|
+
})), n.animation && (s.animation = {
|
|
327
|
+
...b.animation,
|
|
328
328
|
...n.animation
|
|
329
|
-
}, n.animation.easing && (
|
|
330
|
-
...
|
|
329
|
+
}, n.animation.easing && (s.animation.easing = {
|
|
330
|
+
...b.animation.easing,
|
|
331
331
|
...n.animation.easing
|
|
332
|
-
}), n.animation.queue && (
|
|
333
|
-
...
|
|
332
|
+
}), n.animation.queue && (s.animation.queue = {
|
|
333
|
+
...b.animation.queue,
|
|
334
334
|
...n.animation.queue
|
|
335
|
-
}), n.animation.performance && (
|
|
336
|
-
...
|
|
335
|
+
}), n.animation.performance && (s.animation.performance = {
|
|
336
|
+
...b.animation.performance,
|
|
337
337
|
...n.animation.performance
|
|
338
|
-
}), n.animation.entry && (
|
|
339
|
-
...
|
|
338
|
+
}), n.animation.entry && (s.animation.entry = {
|
|
339
|
+
...b.animation.entry,
|
|
340
340
|
...n.animation.entry,
|
|
341
341
|
start: n.animation.entry.start ? {
|
|
342
|
-
...
|
|
342
|
+
...b.animation.entry.start,
|
|
343
343
|
...n.animation.entry.start,
|
|
344
|
-
circular: n.animation.entry.start.circular ? { ...
|
|
345
|
-
} :
|
|
346
|
-
timing: n.animation.entry.timing ? { ...
|
|
347
|
-
path: n.animation.entry.path ? { ...pt, ...n.animation.entry.path } :
|
|
348
|
-
rotation: n.animation.entry.rotation ? { ...
|
|
349
|
-
scale: n.animation.entry.scale ? { ...
|
|
350
|
-
})), n.interaction && (
|
|
351
|
-
...
|
|
344
|
+
circular: n.animation.entry.start.circular ? { ...b.animation.entry.start.circular, ...n.animation.entry.start.circular } : b.animation.entry.start.circular
|
|
345
|
+
} : b.animation.entry.start,
|
|
346
|
+
timing: n.animation.entry.timing ? { ...b.animation.entry.timing, ...n.animation.entry.timing } : b.animation.entry.timing,
|
|
347
|
+
path: n.animation.entry.path ? { ...pt, ...n.animation.entry.path } : b.animation.entry.path,
|
|
348
|
+
rotation: n.animation.entry.rotation ? { ...yt, ...n.animation.entry.rotation } : b.animation.entry.rotation,
|
|
349
|
+
scale: n.animation.entry.scale ? { ...bt, ...n.animation.entry.scale } : b.animation.entry.scale
|
|
350
|
+
})), n.interaction && (s.interaction = {
|
|
351
|
+
...b.interaction,
|
|
352
352
|
...n.interaction
|
|
353
|
-
}, n.interaction.focus && (
|
|
354
|
-
...
|
|
353
|
+
}, n.interaction.focus && (s.interaction.focus = {
|
|
354
|
+
...b.interaction.focus,
|
|
355
355
|
...n.interaction.focus
|
|
356
|
-
}), n.interaction.navigation && (
|
|
357
|
-
...
|
|
356
|
+
}), n.interaction.navigation && (s.interaction.navigation = {
|
|
357
|
+
...b.interaction.navigation,
|
|
358
358
|
...n.interaction.navigation
|
|
359
|
-
}), n.interaction.gestures && (
|
|
360
|
-
...
|
|
359
|
+
}), n.interaction.gestures && (s.interaction.gestures = {
|
|
360
|
+
...b.interaction.gestures,
|
|
361
361
|
...n.interaction.gestures
|
|
362
|
-
})), n.rendering && (
|
|
363
|
-
...
|
|
362
|
+
})), n.rendering && (s.rendering = {
|
|
363
|
+
...b.rendering,
|
|
364
364
|
...n.rendering
|
|
365
|
-
}, n.rendering.responsive && (
|
|
366
|
-
...
|
|
365
|
+
}, n.rendering.responsive && (s.rendering.responsive = {
|
|
366
|
+
...b.rendering.responsive,
|
|
367
367
|
...n.rendering.responsive,
|
|
368
|
-
breakpoints: n.rendering.responsive.breakpoints ? { ...
|
|
369
|
-
mobileDetection: n.rendering.responsive.mobileDetection ? n.rendering.responsive.mobileDetection :
|
|
370
|
-
}), n.rendering.ui && (
|
|
371
|
-
...
|
|
368
|
+
breakpoints: n.rendering.responsive.breakpoints ? { ...b.rendering.responsive.breakpoints, ...n.rendering.responsive.breakpoints } : b.rendering.responsive.breakpoints,
|
|
369
|
+
mobileDetection: n.rendering.responsive.mobileDetection ? n.rendering.responsive.mobileDetection : b.rendering.responsive.mobileDetection
|
|
370
|
+
}), n.rendering.ui && (s.rendering.ui = {
|
|
371
|
+
...b.rendering.ui,
|
|
372
372
|
...n.rendering.ui
|
|
373
|
-
}), n.rendering.performance && (
|
|
374
|
-
...
|
|
373
|
+
}), n.rendering.performance && (s.rendering.performance = {
|
|
374
|
+
...b.rendering.performance,
|
|
375
375
|
...n.rendering.performance
|
|
376
|
-
})),
|
|
377
|
-
...
|
|
376
|
+
})), s.config.debug = {
|
|
377
|
+
...zt,
|
|
378
378
|
...n.config?.debug ?? {}
|
|
379
|
-
},
|
|
379
|
+
}, s;
|
|
380
380
|
}
|
|
381
381
|
function Bt(n, t) {
|
|
382
|
-
return { ...n ?
|
|
382
|
+
return { ...n ? Et[n] : Et.playful, ...t };
|
|
383
383
|
}
|
|
384
384
|
function Jt(n, t) {
|
|
385
385
|
return { ...n ? St[n] : St.gentle, ...t };
|
|
386
386
|
}
|
|
387
387
|
function Vt(n, t) {
|
|
388
|
-
return { ...n ?
|
|
388
|
+
return { ...n ? It[n] : It.gentle, ...t };
|
|
389
389
|
}
|
|
390
390
|
class Kt {
|
|
391
391
|
constructor(t) {
|
|
@@ -412,31 +412,31 @@ class Kt {
|
|
|
412
412
|
* @param easing - CSS easing function (optional)
|
|
413
413
|
* @returns AnimationHandle that can be used to cancel or query the animation
|
|
414
414
|
*/
|
|
415
|
-
animateTransformCancellable(t, e, i, o = null,
|
|
415
|
+
animateTransformCancellable(t, e, i, o = null, a = null) {
|
|
416
416
|
this.cancelAllAnimations(t);
|
|
417
|
-
const r = o ?? this.config.duration,
|
|
417
|
+
const r = o ?? this.config.duration, s = a ?? this.config.easing.default, h = this.buildTransformString(e), c = this.buildTransformString(i);
|
|
418
418
|
t.style.transition = "none";
|
|
419
|
-
const
|
|
419
|
+
const d = t.animate(
|
|
420
420
|
[
|
|
421
421
|
{ transform: h },
|
|
422
422
|
{ transform: c }
|
|
423
423
|
],
|
|
424
424
|
{
|
|
425
425
|
duration: r,
|
|
426
|
-
easing:
|
|
426
|
+
easing: s,
|
|
427
427
|
fill: "forwards"
|
|
428
428
|
// Keep final state after animation
|
|
429
429
|
}
|
|
430
430
|
), l = {
|
|
431
431
|
id: `anim-${++this.animationIdCounter}`,
|
|
432
432
|
element: t,
|
|
433
|
-
animation:
|
|
433
|
+
animation: d,
|
|
434
434
|
fromState: e,
|
|
435
435
|
toState: i,
|
|
436
436
|
startTime: performance.now(),
|
|
437
437
|
duration: r
|
|
438
438
|
};
|
|
439
|
-
return this.activeAnimations.set(t, l),
|
|
439
|
+
return this.activeAnimations.set(t, l), d.finished.then(() => {
|
|
440
440
|
t.style.transform = c, this.activeAnimations.delete(t);
|
|
441
441
|
}).catch(() => {
|
|
442
442
|
this.activeAnimations.delete(t);
|
|
@@ -483,8 +483,8 @@ class Kt {
|
|
|
483
483
|
const i = getComputedStyle(t).transform;
|
|
484
484
|
if (i === "none" || !i)
|
|
485
485
|
return { x: 0, y: 0, rotation: 0, scale: 1 };
|
|
486
|
-
const o = new DOMMatrix(i),
|
|
487
|
-
return { x:
|
|
486
|
+
const o = new DOMMatrix(i), a = Math.sqrt(o.a * o.a + o.b * o.b), r = Math.atan2(o.b, o.a) * (180 / Math.PI), s = o.e, h = o.f;
|
|
487
|
+
return { x: s, y: h, rotation: r, scale: a };
|
|
488
488
|
}
|
|
489
489
|
/**
|
|
490
490
|
* Check if an element has an active animation
|
|
@@ -511,10 +511,10 @@ class Kt {
|
|
|
511
511
|
* @returns Promise that resolves when animation completes
|
|
512
512
|
*/
|
|
513
513
|
animateTransform(t, e, i = null, o = null) {
|
|
514
|
-
return new Promise((
|
|
515
|
-
const r = i ?? this.config.duration,
|
|
516
|
-
t.style.transition = `transform ${r}ms ${
|
|
517
|
-
|
|
514
|
+
return new Promise((a) => {
|
|
515
|
+
const r = i ?? this.config.duration, s = o ?? this.config.easing.default;
|
|
516
|
+
t.style.transition = `transform ${r}ms ${s}, box-shadow ${r}ms ${s}`, t.style.transform = this.buildTransformString(e), setTimeout(() => {
|
|
517
|
+
a();
|
|
518
518
|
}, r);
|
|
519
519
|
});
|
|
520
520
|
}
|
|
@@ -547,27 +547,27 @@ function V(n, t, e) {
|
|
|
547
547
|
return n + (t - n) * e;
|
|
548
548
|
}
|
|
549
549
|
function Zt(n, t, e, i) {
|
|
550
|
-
const { overshoot: o, bounces:
|
|
551
|
-
let
|
|
552
|
-
for (let
|
|
553
|
-
if (n <= c[
|
|
554
|
-
l =
|
|
550
|
+
const { overshoot: o, bounces: a, decayRatio: r } = i, s = e.x - t.x, h = e.y - t.y, c = Qt(a, r);
|
|
551
|
+
let d = 0, l = 0, u = 1, g = o, p = !1;
|
|
552
|
+
for (let f = 0; f < c.length; f++)
|
|
553
|
+
if (n <= c[f].time) {
|
|
554
|
+
l = f === 0 ? 0 : c[f - 1].time, u = c[f].time, g = c[f].overshoot, p = c[f].isOvershoot;
|
|
555
555
|
break;
|
|
556
556
|
}
|
|
557
|
-
const
|
|
558
|
-
if (
|
|
559
|
-
|
|
557
|
+
const y = (n - l) / (u - l);
|
|
558
|
+
if (p)
|
|
559
|
+
d = 1 + g * it(y);
|
|
560
560
|
else if (l === 0)
|
|
561
|
-
|
|
561
|
+
d = it(y);
|
|
562
562
|
else {
|
|
563
563
|
const m = 1 + (c.find(
|
|
564
|
-
(
|
|
565
|
-
)?.overshoot ||
|
|
566
|
-
|
|
564
|
+
(E, v) => E.time > l && v > 0 && c[v - 1].isOvershoot
|
|
565
|
+
)?.overshoot || g);
|
|
566
|
+
d = V(m, 1, it(y));
|
|
567
567
|
}
|
|
568
568
|
return {
|
|
569
|
-
x: t.x +
|
|
570
|
-
y: t.y + h *
|
|
569
|
+
x: t.x + s * d,
|
|
570
|
+
y: t.y + h * d
|
|
571
571
|
};
|
|
572
572
|
}
|
|
573
573
|
function Qt(n, t) {
|
|
@@ -576,56 +576,56 @@ function Qt(n, t) {
|
|
|
576
576
|
e.push({ time: i, overshoot: 0, isOvershoot: !1 });
|
|
577
577
|
let o = 0.15;
|
|
578
578
|
const r = 0.4 / (n * 2);
|
|
579
|
-
for (let
|
|
579
|
+
for (let s = 0; s < n; s++)
|
|
580
580
|
i += r, e.push({ time: i, overshoot: o, isOvershoot: !0 }), i += r, e.push({ time: i, overshoot: o * t, isOvershoot: !1 }), o *= t;
|
|
581
581
|
return e.push({ time: 1, overshoot: 0, isOvershoot: !1 }), e;
|
|
582
582
|
}
|
|
583
583
|
function te(n, t, e, i) {
|
|
584
|
-
const { stiffness: o, damping:
|
|
585
|
-
let
|
|
584
|
+
const { stiffness: o, damping: a, mass: r, oscillations: s } = i, h = e.x - t.x, c = e.y - t.y, d = Math.sqrt(o / r), l = a / (2 * Math.sqrt(o * r));
|
|
585
|
+
let u;
|
|
586
586
|
if (l < 1) {
|
|
587
|
-
const
|
|
588
|
-
|
|
587
|
+
const g = d * Math.sqrt(1 - l * l), p = Math.exp(-l * d * n * 3), y = Math.cos(g * n * s * Math.PI);
|
|
588
|
+
u = 1 - p * y;
|
|
589
589
|
} else
|
|
590
|
-
|
|
591
|
-
return
|
|
592
|
-
x: t.x + h *
|
|
593
|
-
y: t.y + c *
|
|
590
|
+
u = 1 - Math.exp(-d * n * 3);
|
|
591
|
+
return u = Math.max(0, Math.min(u, 1.3)), {
|
|
592
|
+
x: t.x + h * u,
|
|
593
|
+
y: t.y + c * u
|
|
594
594
|
};
|
|
595
595
|
}
|
|
596
596
|
function ee(n, t, e, i) {
|
|
597
|
-
const { amplitude: o, frequency:
|
|
597
|
+
const { amplitude: o, frequency: a, decay: r, decayRate: s, phase: h } = i, c = e.x - t.x, d = e.y - t.y, l = Math.sqrt(c * c + d * d), u = l > 0 ? -d / l : 0, g = l > 0 ? c / l : 1, p = a * Math.PI * 2 * n + h, y = r ? Math.pow(1 - n, s) : 1, f = o * Math.sin(p) * y, m = ie(n);
|
|
598
598
|
return {
|
|
599
|
-
x: V(t.x, e.x, m) +
|
|
600
|
-
y: V(t.y, e.y, m) +
|
|
599
|
+
x: V(t.x, e.x, m) + f * u,
|
|
600
|
+
y: V(t.y, e.y, m) + f * g
|
|
601
601
|
};
|
|
602
602
|
}
|
|
603
|
-
function
|
|
603
|
+
function it(n) {
|
|
604
604
|
return 1 - (1 - n) * (1 - n);
|
|
605
605
|
}
|
|
606
606
|
function ie(n) {
|
|
607
607
|
return 1 - Math.pow(1 - n, 3);
|
|
608
608
|
}
|
|
609
609
|
function ne(n, t, e) {
|
|
610
|
-
const { amplitude: i, frequency: o, decay:
|
|
610
|
+
const { amplitude: i, frequency: o, decay: a } = e, r = Math.sin(n * o * Math.PI * 2), s = a ? Math.pow(1 - n, 2) : 1, h = i * r * s;
|
|
611
611
|
return t + h;
|
|
612
612
|
}
|
|
613
613
|
function oe(n, t, e) {
|
|
614
|
-
const { overshoot: i, bounces: o } = e,
|
|
615
|
-
|
|
614
|
+
const { overshoot: i, bounces: o } = e, a = [];
|
|
615
|
+
a.push({ time: 0.5, scale: i });
|
|
616
616
|
let r = i;
|
|
617
|
-
const
|
|
618
|
-
let
|
|
619
|
-
for (let
|
|
620
|
-
const
|
|
621
|
-
|
|
617
|
+
const s = 0.5, c = 0.5 / (o * 2);
|
|
618
|
+
let d = 0.5;
|
|
619
|
+
for (let u = 0; u < o; u++) {
|
|
620
|
+
const g = 1 - (r - 1) * s;
|
|
621
|
+
d += c, a.push({ time: d, scale: g }), r = 1 + (r - 1) * s * s, d += c, u < o - 1 && a.push({ time: d, scale: r });
|
|
622
622
|
}
|
|
623
|
-
|
|
623
|
+
a.push({ time: 1, scale: 1 });
|
|
624
624
|
let l = 1;
|
|
625
|
-
for (let
|
|
626
|
-
if (n <=
|
|
627
|
-
const
|
|
628
|
-
l =
|
|
625
|
+
for (let u = 0; u < a.length; u++)
|
|
626
|
+
if (n <= a[u].time) {
|
|
627
|
+
const g = u === 0 ? 0 : a[u - 1].time, p = u === 0 ? 1 : a[u - 1].scale, y = (n - g) / (a[u].time - g), f = it(y);
|
|
628
|
+
l = p + (a[u].scale - p) * f;
|
|
629
629
|
break;
|
|
630
630
|
}
|
|
631
631
|
return l * t;
|
|
@@ -636,61 +636,61 @@ function se(n) {
|
|
|
636
636
|
startPosition: e,
|
|
637
637
|
endPosition: i,
|
|
638
638
|
pathConfig: o,
|
|
639
|
-
duration:
|
|
639
|
+
duration: a,
|
|
640
640
|
imageWidth: r,
|
|
641
|
-
imageHeight:
|
|
641
|
+
imageHeight: s,
|
|
642
642
|
rotation: h,
|
|
643
643
|
scale: c,
|
|
644
|
-
onComplete:
|
|
644
|
+
onComplete: d,
|
|
645
645
|
rotationConfig: l,
|
|
646
|
-
startRotation:
|
|
647
|
-
scaleConfig:
|
|
648
|
-
startScale:
|
|
649
|
-
} = n,
|
|
650
|
-
if ((
|
|
651
|
-
|
|
646
|
+
startRotation: u,
|
|
647
|
+
scaleConfig: g,
|
|
648
|
+
startScale: p
|
|
649
|
+
} = n, y = o.type, f = u !== void 0 && u !== h, m = l?.mode === "wobble", E = l?.wobble || { amplitude: 15, frequency: 3, decay: !0 }, v = f || m, w = p !== void 0 && p !== c, S = g?.mode === "pop", x = g?.pop || { overshoot: 1.2, bounces: 1 };
|
|
650
|
+
if ((y === "linear" || y === "arc") && !v && !(w || S)) {
|
|
651
|
+
d && d();
|
|
652
652
|
return;
|
|
653
653
|
}
|
|
654
|
-
const L = performance.now(), z = -r / 2, U = -
|
|
654
|
+
const L = performance.now(), z = -r / 2, U = -s / 2;
|
|
655
655
|
function _(Y) {
|
|
656
|
-
const N = Y - L,
|
|
657
|
-
let
|
|
658
|
-
switch (
|
|
656
|
+
const N = Y - L, A = Math.min(N / a, 1);
|
|
657
|
+
let $;
|
|
658
|
+
switch (y) {
|
|
659
659
|
case "bounce": {
|
|
660
|
-
const
|
|
660
|
+
const D = Bt(
|
|
661
661
|
o.bouncePreset,
|
|
662
662
|
o.bounce
|
|
663
663
|
);
|
|
664
|
-
|
|
664
|
+
$ = Zt(A, e, i, D);
|
|
665
665
|
break;
|
|
666
666
|
}
|
|
667
667
|
case "elastic": {
|
|
668
|
-
const
|
|
668
|
+
const D = Jt(
|
|
669
669
|
o.elasticPreset,
|
|
670
670
|
o.elastic
|
|
671
671
|
);
|
|
672
|
-
|
|
672
|
+
$ = te(A, e, i, D);
|
|
673
673
|
break;
|
|
674
674
|
}
|
|
675
675
|
case "wave": {
|
|
676
|
-
const
|
|
676
|
+
const D = Vt(
|
|
677
677
|
o.wavePreset,
|
|
678
678
|
o.wave
|
|
679
679
|
);
|
|
680
|
-
|
|
680
|
+
$ = ee(A, e, i, D);
|
|
681
681
|
break;
|
|
682
682
|
}
|
|
683
683
|
default:
|
|
684
|
-
|
|
685
|
-
x: V(e.x, i.x,
|
|
686
|
-
y: V(e.y, i.y,
|
|
684
|
+
$ = {
|
|
685
|
+
x: V(e.x, i.x, A),
|
|
686
|
+
y: V(e.y, i.y, A)
|
|
687
687
|
};
|
|
688
688
|
}
|
|
689
|
-
const k =
|
|
689
|
+
const k = $.x - i.x, H = $.y - i.y;
|
|
690
690
|
let R;
|
|
691
|
-
m ? R = ne(
|
|
692
|
-
let
|
|
693
|
-
|
|
691
|
+
m ? R = ne(A, h, E) : f ? R = V(u, h, A) : R = h;
|
|
692
|
+
let T;
|
|
693
|
+
S ? T = oe(A, c, x) : w ? T = V(p, c, A) : T = c, t.style.transform = `translate(${z}px, ${U}px) translate(${k}px, ${H}px) rotate(${R}deg) scale(${T})`, A < 1 ? requestAnimationFrame(_) : (t.style.transform = `translate(${z}px, ${U}px) rotate(${h}deg) scale(${c})`, d && d());
|
|
694
694
|
}
|
|
695
695
|
requestAnimationFrame(_);
|
|
696
696
|
}
|
|
@@ -707,7 +707,7 @@ const re = {
|
|
|
707
707
|
};
|
|
708
708
|
class ce {
|
|
709
709
|
constructor(t, e) {
|
|
710
|
-
this.config = t, this.layoutAlgorithm = e, this.resolvedStartPosition = this.resolveStartPosition(), this.pathConfig = t.path || pt, this.rotationConfig = t.rotation ||
|
|
710
|
+
this.config = t, this.layoutAlgorithm = e, this.resolvedStartPosition = this.resolveStartPosition(), this.pathConfig = t.path || pt, this.rotationConfig = t.rotation || yt, this.scaleConfig = t.scale || bt;
|
|
711
711
|
}
|
|
712
712
|
/**
|
|
713
713
|
* Get the effective start position, considering layout-aware defaults
|
|
@@ -718,72 +718,72 @@ class ce {
|
|
|
718
718
|
/**
|
|
719
719
|
* Calculate the starting position for an image's entry animation
|
|
720
720
|
*/
|
|
721
|
-
calculateStartPosition(t, e, i, o,
|
|
722
|
-
const r = this.resolvedStartPosition,
|
|
721
|
+
calculateStartPosition(t, e, i, o, a) {
|
|
722
|
+
const r = this.resolvedStartPosition, s = this.config.start.offset ?? 100;
|
|
723
723
|
switch (r) {
|
|
724
724
|
case "nearest-edge":
|
|
725
|
-
return this.calculateNearestEdge(t, e, i,
|
|
725
|
+
return this.calculateNearestEdge(t, e, i, s);
|
|
726
726
|
case "top":
|
|
727
|
-
return this.calculateEdgePosition("top", t, e, i,
|
|
727
|
+
return this.calculateEdgePosition("top", t, e, i, s);
|
|
728
728
|
case "bottom":
|
|
729
|
-
return this.calculateEdgePosition("bottom", t, e, i,
|
|
729
|
+
return this.calculateEdgePosition("bottom", t, e, i, s);
|
|
730
730
|
case "left":
|
|
731
|
-
return this.calculateEdgePosition("left", t, e, i,
|
|
731
|
+
return this.calculateEdgePosition("left", t, e, i, s);
|
|
732
732
|
case "right":
|
|
733
|
-
return this.calculateEdgePosition("right", t, e, i,
|
|
733
|
+
return this.calculateEdgePosition("right", t, e, i, s);
|
|
734
734
|
case "center":
|
|
735
735
|
return this.calculateCenterPosition(i, t, e);
|
|
736
736
|
case "random-edge":
|
|
737
|
-
return this.calculateRandomEdge(t, e, i,
|
|
737
|
+
return this.calculateRandomEdge(t, e, i, s);
|
|
738
738
|
case "circular":
|
|
739
739
|
return this.calculateCircularPosition(
|
|
740
740
|
t,
|
|
741
741
|
e,
|
|
742
742
|
i,
|
|
743
743
|
o,
|
|
744
|
-
|
|
744
|
+
a
|
|
745
745
|
);
|
|
746
746
|
default:
|
|
747
|
-
return this.calculateNearestEdge(t, e, i,
|
|
747
|
+
return this.calculateNearestEdge(t, e, i, s);
|
|
748
748
|
}
|
|
749
749
|
}
|
|
750
750
|
/**
|
|
751
751
|
* Calculate start position from the nearest edge (current default behavior)
|
|
752
752
|
*/
|
|
753
753
|
calculateNearestEdge(t, e, i, o) {
|
|
754
|
-
const
|
|
755
|
-
let
|
|
756
|
-
return l ===
|
|
754
|
+
const a = t.x, r = t.y, s = a, h = i.width - a, c = r, d = i.height - r, l = Math.min(s, h, c, d);
|
|
755
|
+
let u = t.x, g = t.y;
|
|
756
|
+
return l === s ? u = -(e.width + o) : l === h ? u = i.width + o : l === c ? g = -(e.height + o) : g = i.height + o, { x: u, y: g };
|
|
757
757
|
}
|
|
758
758
|
/**
|
|
759
759
|
* Calculate start position from a specific edge
|
|
760
760
|
*/
|
|
761
|
-
calculateEdgePosition(t, e, i, o,
|
|
762
|
-
let r = e.x,
|
|
761
|
+
calculateEdgePosition(t, e, i, o, a) {
|
|
762
|
+
let r = e.x, s = e.y;
|
|
763
763
|
switch (t) {
|
|
764
764
|
case "top":
|
|
765
|
-
|
|
765
|
+
s = -(i.height + a);
|
|
766
766
|
break;
|
|
767
767
|
case "bottom":
|
|
768
|
-
|
|
768
|
+
s = o.height + a;
|
|
769
769
|
break;
|
|
770
770
|
case "left":
|
|
771
|
-
r = -(i.width +
|
|
771
|
+
r = -(i.width + a);
|
|
772
772
|
break;
|
|
773
773
|
case "right":
|
|
774
|
-
r = o.width +
|
|
774
|
+
r = o.width + a;
|
|
775
775
|
break;
|
|
776
776
|
}
|
|
777
|
-
return { x: r, y:
|
|
777
|
+
return { x: r, y: s };
|
|
778
778
|
}
|
|
779
779
|
/**
|
|
780
780
|
* Calculate start position from center with scale animation
|
|
781
781
|
*/
|
|
782
782
|
calculateCenterPosition(t, e, i) {
|
|
783
|
-
const o = t.width / 2,
|
|
783
|
+
const o = t.width / 2, a = t.height / 2;
|
|
784
784
|
return {
|
|
785
785
|
x: o,
|
|
786
|
-
y:
|
|
786
|
+
y: a,
|
|
787
787
|
useScale: !0
|
|
788
788
|
// Signal to use scale animation from 0
|
|
789
789
|
};
|
|
@@ -792,27 +792,27 @@ class ce {
|
|
|
792
792
|
* Calculate start position from a random edge
|
|
793
793
|
*/
|
|
794
794
|
calculateRandomEdge(t, e, i, o) {
|
|
795
|
-
const
|
|
795
|
+
const a = ["top", "bottom", "left", "right"], r = a[Math.floor(Math.random() * a.length)];
|
|
796
796
|
return this.calculateEdgePosition(r, t, e, i, o);
|
|
797
797
|
}
|
|
798
798
|
/**
|
|
799
799
|
* Calculate start position on a circle around the container
|
|
800
800
|
*/
|
|
801
|
-
calculateCircularPosition(t, e, i, o,
|
|
802
|
-
const r = this.config.start.circular || {},
|
|
801
|
+
calculateCircularPosition(t, e, i, o, a) {
|
|
802
|
+
const r = this.config.start.circular || {}, s = r.distribution || "even";
|
|
803
803
|
let h;
|
|
804
804
|
const c = r.radius || "120%";
|
|
805
805
|
if (typeof c == "string" && c.endsWith("%")) {
|
|
806
|
-
const
|
|
806
|
+
const y = parseFloat(c) / 100;
|
|
807
807
|
h = Math.sqrt(
|
|
808
808
|
i.width ** 2 + i.height ** 2
|
|
809
|
-
) *
|
|
809
|
+
) * y / 2;
|
|
810
810
|
} else
|
|
811
811
|
h = typeof c == "number" ? c : 500;
|
|
812
|
-
let
|
|
813
|
-
|
|
814
|
-
const l = i.width / 2,
|
|
815
|
-
return { x:
|
|
812
|
+
let d;
|
|
813
|
+
s === "even" ? d = o / a * 2 * Math.PI : d = Math.random() * 2 * Math.PI;
|
|
814
|
+
const l = i.width / 2, u = i.height / 2, g = l + Math.cos(d) * h, p = u + Math.sin(d) * h;
|
|
815
|
+
return { x: g, y: p };
|
|
816
816
|
}
|
|
817
817
|
/**
|
|
818
818
|
* Get animation parameters for an image
|
|
@@ -831,9 +831,9 @@ class ce {
|
|
|
831
831
|
* Build a CSS transform string for the start position
|
|
832
832
|
* Uses pixel-based centering offset for reliable cross-browser behavior
|
|
833
833
|
*/
|
|
834
|
-
buildStartTransform(t, e, i, o,
|
|
835
|
-
const c = t.x - e.x,
|
|
836
|
-
return t.useScale ? `${
|
|
834
|
+
buildStartTransform(t, e, i, o, a, r, s, h) {
|
|
835
|
+
const c = t.x - e.x, d = t.y - e.y, l = s !== void 0 ? s : i, u = h !== void 0 ? h : o, g = a !== void 0 ? -a / 2 : 0, p = r !== void 0 ? -r / 2 : 0, y = a !== void 0 ? `translate(${g}px, ${p}px)` : "translate(-50%, -50%)";
|
|
836
|
+
return t.useScale ? `${y} translate(${c}px, ${d}px) rotate(${l}deg) scale(0)` : `${y} translate(${c}px, ${d}px) rotate(${l}deg) scale(${u})`;
|
|
837
837
|
}
|
|
838
838
|
/**
|
|
839
839
|
* Build the final CSS transform string
|
|
@@ -841,8 +841,8 @@ class ce {
|
|
|
841
841
|
*/
|
|
842
842
|
buildFinalTransform(t, e, i, o) {
|
|
843
843
|
if (i !== void 0 && o !== void 0) {
|
|
844
|
-
const
|
|
845
|
-
return `translate(${
|
|
844
|
+
const a = -i / 2, r = -o / 2;
|
|
845
|
+
return `translate(${a}px, ${r}px) rotate(${t}deg) scale(${e})`;
|
|
846
846
|
}
|
|
847
847
|
return `translate(-50%, -50%) rotate(${t}deg) scale(${e})`;
|
|
848
848
|
}
|
|
@@ -960,7 +960,7 @@ class ce {
|
|
|
960
960
|
amplitude: 15,
|
|
961
961
|
frequency: 3,
|
|
962
962
|
decay: !0
|
|
963
|
-
}, { amplitude: o, frequency:
|
|
963
|
+
}, { amplitude: o, frequency: a, decay: r } = i, s = Math.sin(t * a * Math.PI * 2), h = r ? Math.pow(1 - t, 2) : 1, c = o * s * h;
|
|
964
964
|
return e + c;
|
|
965
965
|
}
|
|
966
966
|
/**
|
|
@@ -1017,15 +1017,15 @@ class ce {
|
|
|
1017
1017
|
const i = this.scaleConfig.pop || {
|
|
1018
1018
|
overshoot: 1.2,
|
|
1019
1019
|
bounces: 1
|
|
1020
|
-
}, { overshoot: o, bounces:
|
|
1021
|
-
let
|
|
1020
|
+
}, { overshoot: o, bounces: a } = i, r = this.generateScaleBounceKeyframes(a, o);
|
|
1021
|
+
let s = e;
|
|
1022
1022
|
for (let h = 0; h < r.length; h++)
|
|
1023
1023
|
if (t <= r[h].time) {
|
|
1024
|
-
const c = h === 0 ? 0 : r[h - 1].time,
|
|
1025
|
-
|
|
1024
|
+
const c = h === 0 ? 0 : r[h - 1].time, d = h === 0 ? e : r[h - 1].scale, l = (t - c) / (r[h].time - c), u = this.easeOutQuad(l);
|
|
1025
|
+
s = d + (r[h].scale - d) * u;
|
|
1026
1026
|
break;
|
|
1027
1027
|
}
|
|
1028
|
-
return
|
|
1028
|
+
return s * e;
|
|
1029
1029
|
}
|
|
1030
1030
|
/**
|
|
1031
1031
|
* Generate keyframes for scale bounce animation
|
|
@@ -1034,11 +1034,11 @@ class ce {
|
|
|
1034
1034
|
const i = [];
|
|
1035
1035
|
i.push({ time: 0.5, scale: e });
|
|
1036
1036
|
let o = e;
|
|
1037
|
-
const
|
|
1037
|
+
const a = 0.5, s = 0.5 / (t * 2);
|
|
1038
1038
|
let h = 0.5;
|
|
1039
1039
|
for (let c = 0; c < t; c++) {
|
|
1040
|
-
const
|
|
1041
|
-
h +=
|
|
1040
|
+
const d = 1 - (o - 1) * a;
|
|
1041
|
+
h += s, i.push({ time: h, scale: d }), o = 1 + (o - 1) * a * a, h += s, c < t - 1 && i.push({ time: h, scale: o });
|
|
1042
1042
|
}
|
|
1043
1043
|
return i.push({ time: 1, scale: 1 }), i;
|
|
1044
1044
|
}
|
|
@@ -1061,11 +1061,11 @@ class le {
|
|
|
1061
1061
|
* @returns Array of layout objects with position, rotation, scale
|
|
1062
1062
|
*/
|
|
1063
1063
|
generate(t, e, i = {}) {
|
|
1064
|
-
const o = [], { width:
|
|
1064
|
+
const o = [], { width: a, height: r } = e, s = this.config.spacing.padding, h = i.fixedHeight ?? 200, c = this.imageConfig.rotation?.mode ?? "none", d = this.imageConfig.rotation?.range?.min ?? -15, l = this.imageConfig.rotation?.range?.max ?? 15, u = this.imageConfig.sizing?.variance?.min ?? 1, g = this.imageConfig.sizing?.variance?.max ?? 1, p = u !== 1 || g !== 1, f = h * 1.5 / 2, m = h / 2, E = a - s - f, v = r - s - m, w = s + f, S = s + m;
|
|
1065
1065
|
for (let x = 0; x < t; x++) {
|
|
1066
|
-
const
|
|
1066
|
+
const C = this.random(w, E), L = this.random(S, v), z = c === "random" ? this.random(d, l) : 0, U = p ? this.random(u, g) : 1, _ = h * U, Y = {
|
|
1067
1067
|
id: x,
|
|
1068
|
-
x:
|
|
1068
|
+
x: C,
|
|
1069
1069
|
y: L,
|
|
1070
1070
|
rotation: z,
|
|
1071
1071
|
scale: U,
|
|
@@ -1097,16 +1097,16 @@ class he {
|
|
|
1097
1097
|
* @returns Array of layout objects with position, rotation, scale
|
|
1098
1098
|
*/
|
|
1099
1099
|
generate(t, e, i = {}) {
|
|
1100
|
-
const o = [], { width:
|
|
1100
|
+
const o = [], { width: a, height: r } = e, s = i.fixedHeight ?? 200, h = this.imageConfig.rotation?.mode ?? "none", c = this.imageConfig.rotation?.range?.min ?? -15, d = this.imageConfig.rotation?.range?.max ?? 15, l = this.imageConfig.sizing?.variance?.min ?? 1, u = this.imageConfig.sizing?.variance?.max ?? 1, g = l !== 1 || u !== 1, p = this.config.scaleDecay ?? 0, y = i.fixedHeight ?? s, f = a / 2, m = r / 2, E = Math.ceil(Math.sqrt(t));
|
|
1101
1101
|
if (t > 0) {
|
|
1102
|
-
const
|
|
1102
|
+
const S = g ? this.random(l, u) : 1, x = y * S;
|
|
1103
1103
|
o.push({
|
|
1104
1104
|
id: 0,
|
|
1105
|
-
x:
|
|
1105
|
+
x: f,
|
|
1106
1106
|
y: m,
|
|
1107
|
-
rotation: h === "random" ? this.random(c * 0.33,
|
|
1107
|
+
rotation: h === "random" ? this.random(c * 0.33, d * 0.33) : 0,
|
|
1108
1108
|
// Less rotation for center
|
|
1109
|
-
scale:
|
|
1109
|
+
scale: S,
|
|
1110
1110
|
baseSize: x,
|
|
1111
1111
|
zIndex: 100
|
|
1112
1112
|
// Center image is highest
|
|
@@ -1114,22 +1114,22 @@ class he {
|
|
|
1114
1114
|
}
|
|
1115
1115
|
let v = 1, w = 1;
|
|
1116
1116
|
for (; v < t; ) {
|
|
1117
|
-
const
|
|
1117
|
+
const S = w / E, x = p > 0 ? 1 - S * p * 0.5 : 1, C = w * (y * 0.8), L = C * 1.5, z = Math.PI * (3 * (L + C) - Math.sqrt((3 * L + C) * (L + 3 * C))), U = this.estimateWidth(y), _ = Math.floor(z / (U * 0.7));
|
|
1118
1118
|
if (_ === 0) {
|
|
1119
1119
|
w++;
|
|
1120
1120
|
continue;
|
|
1121
1121
|
}
|
|
1122
1122
|
const Y = 2 * Math.PI / _, N = w * (20 * Math.PI / 180);
|
|
1123
|
-
for (let
|
|
1124
|
-
const
|
|
1125
|
-
let
|
|
1126
|
-
const
|
|
1127
|
-
|
|
1128
|
-
const W = h === "random" ? this.random(c,
|
|
1123
|
+
for (let A = 0; A < _ && v < t; A++) {
|
|
1124
|
+
const $ = A * Y + N, k = g ? this.random(l, u) : 1, H = x * k, R = y * H;
|
|
1125
|
+
let T = f + Math.cos($) * L, D = m + Math.sin($) * C;
|
|
1126
|
+
const O = this.config.spacing.padding ?? 50, P = R * 1.5 / 2, M = R / 2;
|
|
1127
|
+
T - P < O ? T = O + P : T + P > a - O && (T = a - O - P), D - M < O ? D = O + M : D + M > r - O && (D = r - O - M);
|
|
1128
|
+
const W = h === "random" ? this.random(c, d) : 0;
|
|
1129
1129
|
o.push({
|
|
1130
1130
|
id: v,
|
|
1131
|
-
x:
|
|
1132
|
-
y:
|
|
1131
|
+
x: T,
|
|
1132
|
+
y: D,
|
|
1133
1133
|
rotation: W,
|
|
1134
1134
|
scale: H,
|
|
1135
1135
|
baseSize: R,
|
|
@@ -1170,7 +1170,7 @@ const de = {
|
|
|
1170
1170
|
alignment: "center",
|
|
1171
1171
|
gap: 10,
|
|
1172
1172
|
overflowOffset: 0.25
|
|
1173
|
-
},
|
|
1173
|
+
}, Ct = [
|
|
1174
1174
|
{ x: 1, y: 1 },
|
|
1175
1175
|
// bottom-right
|
|
1176
1176
|
{ x: -1, y: -1 },
|
|
@@ -1200,65 +1200,65 @@ class ue {
|
|
|
1200
1200
|
* @returns Array of layout objects with position, rotation, scale
|
|
1201
1201
|
*/
|
|
1202
1202
|
generate(t, e, i = {}) {
|
|
1203
|
-
const o = [], { width:
|
|
1203
|
+
const o = [], { width: a, height: r } = e, s = { ...de, ...this.config.grid }, h = this.config.spacing.padding, c = i.fixedHeight ?? 200, d = this.imageConfig.rotation?.mode ?? "none", l = this.imageConfig.sizing?.variance?.min ?? 1, u = this.imageConfig.sizing?.variance?.max ?? 1, g = l !== 1 || u !== 1, p = a - 2 * h, y = r - 2 * h, { columns: f, rows: m } = this.calculateGridDimensions(
|
|
1204
1204
|
t,
|
|
1205
|
-
b,
|
|
1206
1205
|
p,
|
|
1206
|
+
y,
|
|
1207
1207
|
c,
|
|
1208
|
-
|
|
1209
|
-
),
|
|
1208
|
+
s
|
|
1209
|
+
), E = s.stagger === "row", v = s.stagger === "column", w = E ? f + 0.5 : f, S = v ? m + 0.5 : m, x = (p - s.gap * (f - 1)) / w, C = (y - s.gap * (m - 1)) / S, L = E ? x / 2 : 0, z = v ? C / 2 : 0, U = 1 + s.overlap, _ = Math.min(x, C) * U, Y = i.fixedHeight ? Math.min(i.fixedHeight, _) : _, N = f * x + (f - 1) * s.gap + L, A = m * C + (m - 1) * s.gap + z, $ = h + (p - N) / 2, k = h + (y - A) / 2, H = f * m, R = s.columns !== "auto" && s.rows !== "auto", T = R && t > H;
|
|
1210
1210
|
typeof window < "u" && (window.__gridOverflowDebug = {
|
|
1211
|
-
gridConfigColumns:
|
|
1212
|
-
gridConfigRows:
|
|
1213
|
-
columns:
|
|
1211
|
+
gridConfigColumns: s.columns,
|
|
1212
|
+
gridConfigRows: s.rows,
|
|
1213
|
+
columns: f,
|
|
1214
1214
|
rows: m,
|
|
1215
1215
|
cellCount: H,
|
|
1216
1216
|
hasFixedGrid: R,
|
|
1217
1217
|
imageCount: t,
|
|
1218
|
-
isOverflowMode:
|
|
1218
|
+
isOverflowMode: T
|
|
1219
1219
|
});
|
|
1220
|
-
const
|
|
1220
|
+
const D = T ? new Array(H).fill(0) : [], O = Math.min(x, C) * s.overflowOffset;
|
|
1221
1221
|
for (let F = 0; F < t; F++) {
|
|
1222
1222
|
let P, M, W = 0;
|
|
1223
|
-
if (
|
|
1223
|
+
if (T && F >= H) {
|
|
1224
1224
|
const q = F - H, j = q % H;
|
|
1225
|
-
W = Math.floor(q / H) + 1,
|
|
1225
|
+
W = Math.floor(q / H) + 1, D[j]++, s.fillDirection === "row" ? (P = j % f, M = Math.floor(j / f)) : (M = j % m, P = Math.floor(j / m));
|
|
1226
1226
|
} else
|
|
1227
|
-
|
|
1228
|
-
let G =
|
|
1229
|
-
if (
|
|
1230
|
-
const q = (W - 1) %
|
|
1231
|
-
G += j.x *
|
|
1227
|
+
s.fillDirection === "row" ? (P = F % f, M = Math.floor(F / f)) : (M = F % m, P = Math.floor(F / m));
|
|
1228
|
+
let G = $ + P * (x + s.gap) + x / 2, X = k + M * (C + s.gap) + C / 2;
|
|
1229
|
+
if (s.stagger === "row" && M % 2 === 1 ? G += x / 2 : s.stagger === "column" && P % 2 === 1 && (X += C / 2), W > 0) {
|
|
1230
|
+
const q = (W - 1) % Ct.length, j = Ct[q];
|
|
1231
|
+
G += j.x * O, X += j.y * O;
|
|
1232
1232
|
}
|
|
1233
|
-
if (
|
|
1234
|
-
const q = x / 2 *
|
|
1233
|
+
if (s.jitter > 0) {
|
|
1234
|
+
const q = x / 2 * s.jitter, j = C / 2 * s.jitter;
|
|
1235
1235
|
G += this.random(-q, q), X += this.random(-j, j);
|
|
1236
1236
|
}
|
|
1237
1237
|
let B = G, J = X;
|
|
1238
|
-
if (!
|
|
1239
|
-
const q = t %
|
|
1240
|
-
if (M === Math.floor((t - 1) /
|
|
1241
|
-
const
|
|
1242
|
-
let
|
|
1243
|
-
|
|
1238
|
+
if (!T && s.fillDirection === "row") {
|
|
1239
|
+
const q = t % f || f;
|
|
1240
|
+
if (M === Math.floor((t - 1) / f) && q < f) {
|
|
1241
|
+
const wt = q * x + (q - 1) * s.gap;
|
|
1242
|
+
let dt = 0;
|
|
1243
|
+
s.alignment === "center" ? dt = (N - wt) / 2 : s.alignment === "end" && (dt = N - wt), B += dt;
|
|
1244
1244
|
}
|
|
1245
1245
|
}
|
|
1246
|
-
const
|
|
1247
|
-
B = Math.max(
|
|
1248
|
-
let
|
|
1249
|
-
if (
|
|
1246
|
+
const st = g ? this.random(l, u) : 1, K = Y * st, tt = K * 1.5 / 2, et = K / 2, rt = h + tt, ct = a - h - tt, $t = h + et, Dt = r - h - et;
|
|
1247
|
+
B = Math.max(rt, Math.min(B, ct)), J = Math.max($t, Math.min(J, Dt));
|
|
1248
|
+
let lt = 0;
|
|
1249
|
+
if (d === "random") {
|
|
1250
1250
|
const q = this.imageConfig.rotation?.range?.min ?? -15, j = this.imageConfig.rotation?.range?.max ?? 15;
|
|
1251
|
-
|
|
1251
|
+
s.jitter > 0 ? lt = this.random(q * s.jitter, j * s.jitter) : lt = this.random(q, j);
|
|
1252
1252
|
}
|
|
1253
|
-
let
|
|
1254
|
-
|
|
1253
|
+
let ht;
|
|
1254
|
+
T && W > 0 ? ht = 50 - W : ht = T ? 100 + F : F + 1, o.push({
|
|
1255
1255
|
id: F,
|
|
1256
1256
|
x: B,
|
|
1257
1257
|
y: J,
|
|
1258
|
-
rotation:
|
|
1259
|
-
scale:
|
|
1258
|
+
rotation: lt,
|
|
1259
|
+
scale: st,
|
|
1260
1260
|
baseSize: K,
|
|
1261
|
-
zIndex:
|
|
1261
|
+
zIndex: ht
|
|
1262
1262
|
});
|
|
1263
1263
|
}
|
|
1264
1264
|
return o;
|
|
@@ -1266,20 +1266,20 @@ class ue {
|
|
|
1266
1266
|
/**
|
|
1267
1267
|
* Calculate optimal grid dimensions based on image count and container
|
|
1268
1268
|
*/
|
|
1269
|
-
calculateGridDimensions(t, e, i, o,
|
|
1270
|
-
let r,
|
|
1271
|
-
if (
|
|
1272
|
-
r =
|
|
1273
|
-
else if (
|
|
1274
|
-
r =
|
|
1275
|
-
else if (
|
|
1276
|
-
|
|
1269
|
+
calculateGridDimensions(t, e, i, o, a) {
|
|
1270
|
+
let r, s;
|
|
1271
|
+
if (a.columns !== "auto" && a.rows !== "auto")
|
|
1272
|
+
r = a.columns, s = a.rows;
|
|
1273
|
+
else if (a.columns !== "auto")
|
|
1274
|
+
r = a.columns, s = Math.ceil(t / r);
|
|
1275
|
+
else if (a.rows !== "auto")
|
|
1276
|
+
s = a.rows, r = Math.ceil(t / s);
|
|
1277
1277
|
else {
|
|
1278
1278
|
const h = e / i;
|
|
1279
|
-
for (r = Math.max(1, Math.round(Math.sqrt(t * h / 1.4))),
|
|
1279
|
+
for (r = Math.max(1, Math.round(Math.sqrt(t * h / 1.4))), s = Math.ceil(t / r); r > 1 && (r - 1) * s >= t; )
|
|
1280
1280
|
r--;
|
|
1281
1281
|
}
|
|
1282
|
-
return { columns: Math.max(1, r), rows: Math.max(1,
|
|
1282
|
+
return { columns: Math.max(1, r), rows: Math.max(1, s) };
|
|
1283
1283
|
}
|
|
1284
1284
|
/**
|
|
1285
1285
|
* Utility: Generate random number between min and max
|
|
@@ -1307,35 +1307,35 @@ class me {
|
|
|
1307
1307
|
* @returns Array of layout objects with position, rotation, scale
|
|
1308
1308
|
*/
|
|
1309
1309
|
generate(t, e, i = {}) {
|
|
1310
|
-
const o = [], { width:
|
|
1310
|
+
const o = [], { width: a, height: r } = e, s = { ...fe, ...this.config.spiral }, h = this.config.spacing.padding, c = i.fixedHeight ?? 200, d = this.imageConfig.rotation?.mode ?? "none", l = this.imageConfig.rotation?.range?.min ?? -15, u = this.imageConfig.rotation?.range?.max ?? 15, g = this.imageConfig.sizing?.variance?.min ?? 1, p = this.imageConfig.sizing?.variance?.max ?? 1, y = g !== 1 || p !== 1, f = this.config.scaleDecay ?? s.scaleDecay, m = a / 2, E = r / 2, v = Math.min(
|
|
1311
1311
|
m - h - c / 2,
|
|
1312
|
-
|
|
1313
|
-
), w =
|
|
1314
|
-
for (let
|
|
1315
|
-
let x,
|
|
1316
|
-
if (
|
|
1317
|
-
x =
|
|
1318
|
-
else if (
|
|
1319
|
-
const G =
|
|
1320
|
-
x = G * w +
|
|
1312
|
+
E - h - c / 2
|
|
1313
|
+
), w = s.direction === "clockwise" ? -1 : 1;
|
|
1314
|
+
for (let S = 0; S < t; S++) {
|
|
1315
|
+
let x, C;
|
|
1316
|
+
if (s.spiralType === "golden")
|
|
1317
|
+
x = S * ge * w + s.startAngle, C = this.calculateGoldenRadius(S, t, v, s.tightness);
|
|
1318
|
+
else if (s.spiralType === "archimedean") {
|
|
1319
|
+
const G = S * 0.5 * s.tightness;
|
|
1320
|
+
x = G * w + s.startAngle, C = this.calculateArchimedeanRadius(G, t, v, s.tightness);
|
|
1321
1321
|
} else {
|
|
1322
|
-
const G =
|
|
1323
|
-
x = G * w +
|
|
1322
|
+
const G = S * 0.3 * s.tightness;
|
|
1323
|
+
x = G * w + s.startAngle, C = this.calculateLogarithmicRadius(G, t, v, s.tightness);
|
|
1324
1324
|
}
|
|
1325
|
-
const L = m + Math.cos(x) *
|
|
1325
|
+
const L = m + Math.cos(x) * C, z = E + Math.sin(x) * C, U = C / v, _ = f > 0 ? 1 - U * f * 0.5 : 1, Y = y ? this.random(g, p) : 1, N = _ * Y, A = c * N, k = A * 1.5 / 2, H = A / 2, R = h + k, T = a - h - k, D = h + H, O = r - h - H, F = Math.max(R, Math.min(L, T)), P = Math.max(D, Math.min(z, O));
|
|
1326
1326
|
let M = 0;
|
|
1327
|
-
if (
|
|
1328
|
-
const G = x * 180 / Math.PI % 360, X = this.random(l,
|
|
1329
|
-
M =
|
|
1330
|
-
} else
|
|
1331
|
-
const W = t -
|
|
1327
|
+
if (d === "random") {
|
|
1328
|
+
const G = x * 180 / Math.PI % 360, X = this.random(l, u);
|
|
1329
|
+
M = s.spiralType === "golden" ? X : G * 0.1 + X * 0.9;
|
|
1330
|
+
} else d === "tangent" && (M = this.calculateSpiralTangent(x, C, s));
|
|
1331
|
+
const W = t - S;
|
|
1332
1332
|
o.push({
|
|
1333
|
-
id:
|
|
1333
|
+
id: S,
|
|
1334
1334
|
x: F,
|
|
1335
1335
|
y: P,
|
|
1336
1336
|
rotation: M,
|
|
1337
1337
|
scale: N,
|
|
1338
|
-
baseSize:
|
|
1338
|
+
baseSize: A,
|
|
1339
1339
|
zIndex: W
|
|
1340
1340
|
});
|
|
1341
1341
|
}
|
|
@@ -1350,11 +1350,11 @@ class me {
|
|
|
1350
1350
|
if (i.spiralType === "golden")
|
|
1351
1351
|
o = t + Math.PI / 2;
|
|
1352
1352
|
else if (i.spiralType === "archimedean") {
|
|
1353
|
-
const r = 1 / i.tightness,
|
|
1354
|
-
o = t +
|
|
1353
|
+
const r = 1 / i.tightness, s = Math.atan(e / r);
|
|
1354
|
+
o = t + s;
|
|
1355
1355
|
} else {
|
|
1356
|
-
const r = 0.15 / i.tightness,
|
|
1357
|
-
o = t +
|
|
1356
|
+
const r = 0.15 / i.tightness, s = Math.atan(1 / r);
|
|
1357
|
+
o = t + s;
|
|
1358
1358
|
}
|
|
1359
1359
|
return o * 180 / Math.PI % 360 - 90;
|
|
1360
1360
|
}
|
|
@@ -1371,16 +1371,16 @@ class me {
|
|
|
1371
1371
|
* r = a + b*θ (constant spacing between arms)
|
|
1372
1372
|
*/
|
|
1373
1373
|
calculateArchimedeanRadius(t, e, i, o) {
|
|
1374
|
-
const
|
|
1375
|
-
return t /
|
|
1374
|
+
const a = e * 0.5 * o;
|
|
1375
|
+
return t / a * i;
|
|
1376
1376
|
}
|
|
1377
1377
|
/**
|
|
1378
1378
|
* Calculate radius for logarithmic (equiangular) spiral
|
|
1379
1379
|
* r = a * e^(b*θ)
|
|
1380
1380
|
*/
|
|
1381
1381
|
calculateLogarithmicRadius(t, e, i, o) {
|
|
1382
|
-
const
|
|
1383
|
-
return
|
|
1382
|
+
const a = i * 0.05, r = 0.15 / o, s = a * Math.exp(r * t), h = e * 0.3 * o, c = a * Math.exp(r * h);
|
|
1383
|
+
return s / c * i;
|
|
1384
1384
|
}
|
|
1385
1385
|
/**
|
|
1386
1386
|
* Utility: Generate random number between min and max
|
|
@@ -1397,7 +1397,7 @@ const pe = {
|
|
|
1397
1397
|
overlap: 0.3,
|
|
1398
1398
|
distribution: "gaussian"
|
|
1399
1399
|
};
|
|
1400
|
-
class
|
|
1400
|
+
class ye {
|
|
1401
1401
|
constructor(t, e = {}) {
|
|
1402
1402
|
this.config = t, this.imageConfig = e;
|
|
1403
1403
|
}
|
|
@@ -1409,46 +1409,46 @@ class be {
|
|
|
1409
1409
|
* @returns Array of layout objects with position, rotation, scale
|
|
1410
1410
|
*/
|
|
1411
1411
|
generate(t, e, i = {}) {
|
|
1412
|
-
const o = [], { width:
|
|
1412
|
+
const o = [], { width: a, height: r } = e, s = { ...pe, ...this.config.cluster }, h = this.config.spacing.padding, c = i.fixedHeight ?? 200, d = this.imageConfig.rotation?.mode ?? "none", l = this.imageConfig.rotation?.range?.min ?? -15, u = this.imageConfig.rotation?.range?.max ?? 15, g = this.imageConfig.sizing?.variance?.min ?? 1, p = this.imageConfig.sizing?.variance?.max ?? 1, y = g !== 1 || p !== 1, f = this.calculateClusterCount(
|
|
1413
1413
|
t,
|
|
1414
|
-
|
|
1415
|
-
|
|
1414
|
+
s.clusterCount,
|
|
1415
|
+
a,
|
|
1416
1416
|
r,
|
|
1417
|
-
|
|
1417
|
+
s.clusterSpacing
|
|
1418
1418
|
), m = this.generateClusterCenters(
|
|
1419
|
-
|
|
1420
|
-
|
|
1419
|
+
f,
|
|
1420
|
+
a,
|
|
1421
1421
|
r,
|
|
1422
1422
|
h,
|
|
1423
|
-
|
|
1424
|
-
),
|
|
1423
|
+
s
|
|
1424
|
+
), E = new Array(f).fill(0);
|
|
1425
1425
|
for (let w = 0; w < t; w++)
|
|
1426
|
-
|
|
1426
|
+
E[w % f]++;
|
|
1427
1427
|
let v = 0;
|
|
1428
|
-
for (let w = 0; w <
|
|
1429
|
-
const
|
|
1430
|
-
for (let
|
|
1428
|
+
for (let w = 0; w < f; w++) {
|
|
1429
|
+
const S = m[w], x = E[w];
|
|
1430
|
+
for (let C = 0; C < x; C++) {
|
|
1431
1431
|
let L, z;
|
|
1432
|
-
if (
|
|
1433
|
-
L = this.gaussianRandom() *
|
|
1432
|
+
if (s.distribution === "gaussian")
|
|
1433
|
+
L = this.gaussianRandom() * S.spread, z = this.gaussianRandom() * S.spread;
|
|
1434
1434
|
else {
|
|
1435
|
-
const M = this.random(0, Math.PI * 2), W = this.random(0,
|
|
1435
|
+
const M = this.random(0, Math.PI * 2), W = this.random(0, S.spread);
|
|
1436
1436
|
L = Math.cos(M) * W, z = Math.sin(M) * W;
|
|
1437
1437
|
}
|
|
1438
|
-
const U = 1 +
|
|
1438
|
+
const U = 1 + s.overlap * 0.5, _ = 1 + s.overlap * 0.3;
|
|
1439
1439
|
L /= U, z /= U;
|
|
1440
|
-
const Y =
|
|
1441
|
-
let
|
|
1442
|
-
const R =
|
|
1443
|
-
|
|
1444
|
-
const
|
|
1440
|
+
const Y = y ? this.random(g, p) : 1, N = _ * Y, A = c * N;
|
|
1441
|
+
let $ = S.x + L, k = S.y + z;
|
|
1442
|
+
const R = A * 1.5 / 2, T = A / 2;
|
|
1443
|
+
$ = Math.max(h + R, Math.min($, a - h - R)), k = Math.max(h + T, Math.min(k, r - h - T));
|
|
1444
|
+
const D = d === "random" ? this.random(l, u) : 0, F = Math.sqrt(L * L + z * z) / S.spread, P = Math.round((1 - F) * 50) + 1;
|
|
1445
1445
|
o.push({
|
|
1446
1446
|
id: v,
|
|
1447
|
-
x:
|
|
1447
|
+
x: $,
|
|
1448
1448
|
y: k,
|
|
1449
|
-
rotation:
|
|
1449
|
+
rotation: D,
|
|
1450
1450
|
scale: N,
|
|
1451
|
-
baseSize:
|
|
1451
|
+
baseSize: A,
|
|
1452
1452
|
zIndex: P
|
|
1453
1453
|
}), v++;
|
|
1454
1454
|
}
|
|
@@ -1458,36 +1458,36 @@ class be {
|
|
|
1458
1458
|
/**
|
|
1459
1459
|
* Calculate optimal number of clusters based on image count and container
|
|
1460
1460
|
*/
|
|
1461
|
-
calculateClusterCount(t, e, i, o,
|
|
1461
|
+
calculateClusterCount(t, e, i, o, a) {
|
|
1462
1462
|
if (e !== "auto")
|
|
1463
1463
|
return Math.max(1, Math.min(e, t));
|
|
1464
|
-
const
|
|
1465
|
-
i /
|
|
1464
|
+
const s = Math.max(1, Math.ceil(t / 8)), h = Math.floor(
|
|
1465
|
+
i / a * (o / a) * 0.6
|
|
1466
1466
|
);
|
|
1467
|
-
return Math.max(1, Math.min(
|
|
1467
|
+
return Math.max(1, Math.min(s, h, 10));
|
|
1468
1468
|
}
|
|
1469
1469
|
/**
|
|
1470
1470
|
* Generate cluster center positions with spacing constraints
|
|
1471
1471
|
*/
|
|
1472
|
-
generateClusterCenters(t, e, i, o,
|
|
1473
|
-
const r = [], h = o +
|
|
1474
|
-
for (let
|
|
1475
|
-
let
|
|
1476
|
-
for (let
|
|
1477
|
-
const
|
|
1472
|
+
generateClusterCenters(t, e, i, o, a) {
|
|
1473
|
+
const r = [], h = o + a.clusterSpread, c = e - o - a.clusterSpread, d = o + a.clusterSpread, l = i - o - a.clusterSpread;
|
|
1474
|
+
for (let u = 0; u < t; u++) {
|
|
1475
|
+
let g = null, p = -1;
|
|
1476
|
+
for (let y = 0; y < 100; y++) {
|
|
1477
|
+
const f = {
|
|
1478
1478
|
x: this.random(h, c),
|
|
1479
|
-
y: this.random(
|
|
1480
|
-
spread: this.calculateClusterSpread(
|
|
1479
|
+
y: this.random(d, l),
|
|
1480
|
+
spread: this.calculateClusterSpread(a)
|
|
1481
1481
|
};
|
|
1482
1482
|
let m = 1 / 0;
|
|
1483
|
-
for (const
|
|
1484
|
-
const v =
|
|
1485
|
-
m = Math.min(m,
|
|
1483
|
+
for (const E of r) {
|
|
1484
|
+
const v = f.x - E.x, w = f.y - E.y, S = Math.sqrt(v * v + w * w);
|
|
1485
|
+
m = Math.min(m, S);
|
|
1486
1486
|
}
|
|
1487
|
-
if ((r.length === 0 || m >
|
|
1487
|
+
if ((r.length === 0 || m > p) && (g = f, p = m), m >= a.clusterSpacing)
|
|
1488
1488
|
break;
|
|
1489
1489
|
}
|
|
1490
|
-
|
|
1490
|
+
g && r.push(g);
|
|
1491
1491
|
}
|
|
1492
1492
|
return r;
|
|
1493
1493
|
}
|
|
@@ -1515,7 +1515,7 @@ class be {
|
|
|
1515
1515
|
return Math.random() * (e - t) + t;
|
|
1516
1516
|
}
|
|
1517
1517
|
}
|
|
1518
|
-
class
|
|
1518
|
+
class be {
|
|
1519
1519
|
constructor(t, e = {}) {
|
|
1520
1520
|
this.config = t, this.imageConfig = e;
|
|
1521
1521
|
}
|
|
@@ -1527,24 +1527,24 @@ class ye {
|
|
|
1527
1527
|
* @returns Array of layout objects with position, rotation, scale
|
|
1528
1528
|
*/
|
|
1529
1529
|
generate(t, e, i = {}) {
|
|
1530
|
-
const o = [], { width:
|
|
1530
|
+
const o = [], { width: a, height: r } = e, s = i.fixedHeight ?? 200, h = this.config.spacing.padding ?? 50, c = this.imageConfig.rotation?.mode ?? "none", d = this.imageConfig.rotation?.range?.min ?? -15, l = this.imageConfig.rotation?.range?.max ?? 15, u = this.imageConfig.sizing?.variance?.min ?? 1, g = this.imageConfig.sizing?.variance?.max ?? 1, p = u !== 1 || g !== 1, y = i.fixedHeight ?? s, f = {
|
|
1531
1531
|
...Ht,
|
|
1532
1532
|
...this.config.wave
|
|
1533
|
-
}, { rows: m, amplitude:
|
|
1533
|
+
}, { rows: m, amplitude: E, frequency: v, phaseShift: w, synchronization: S } = f, x = Math.ceil(t / m), z = y * 1.5 / 2, U = h + z, _ = a - h - z, Y = _ - U, N = x > 1 ? Y / (x - 1) : 0, A = h + E + y / 2, $ = r - h - E - y / 2, k = $ - A, H = m > 1 ? k / (m - 1) : 0;
|
|
1534
1534
|
let R = 0;
|
|
1535
|
-
for (let
|
|
1536
|
-
const
|
|
1537
|
-
let
|
|
1538
|
-
|
|
1535
|
+
for (let T = 0; T < m && R < t; T++) {
|
|
1536
|
+
const D = m === 1 ? (A + $) / 2 : A + T * H;
|
|
1537
|
+
let O = 0;
|
|
1538
|
+
S === "offset" ? O = T * w : S === "alternating" && (O = T * Math.PI);
|
|
1539
1539
|
for (let F = 0; F < x && R < t; F++) {
|
|
1540
|
-
const P = x === 1 ? (U + _) / 2 : U + F * N, M = this.calculateWaveY(P,
|
|
1540
|
+
const P = x === 1 ? (U + _) / 2 : U + F * N, M = this.calculateWaveY(P, a, E, v, O), W = P, G = D + M, X = p ? this.random(u, g) : 1, B = y * X;
|
|
1541
1541
|
let J = 0;
|
|
1542
|
-
c === "tangent" ? J = this.calculateRotation(P,
|
|
1543
|
-
const K = B * 1.5 / 2,
|
|
1542
|
+
c === "tangent" ? J = this.calculateRotation(P, a, E, v, O) : c === "random" && (J = this.random(d, l));
|
|
1543
|
+
const K = B * 1.5 / 2, at = B / 2, tt = h + K, et = a - h - K, rt = h + at, ct = r - h - at;
|
|
1544
1544
|
o.push({
|
|
1545
1545
|
id: R,
|
|
1546
|
-
x: Math.max(
|
|
1547
|
-
y: Math.max(
|
|
1546
|
+
x: Math.max(tt, Math.min(W, et)),
|
|
1547
|
+
y: Math.max(rt, Math.min(G, ct)),
|
|
1548
1548
|
rotation: J,
|
|
1549
1549
|
scale: X,
|
|
1550
1550
|
baseSize: B,
|
|
@@ -1563,9 +1563,9 @@ class ye {
|
|
|
1563
1563
|
* @param phase - Phase offset
|
|
1564
1564
|
* @returns Y displacement from baseline
|
|
1565
1565
|
*/
|
|
1566
|
-
calculateWaveY(t, e, i, o,
|
|
1566
|
+
calculateWaveY(t, e, i, o, a) {
|
|
1567
1567
|
const r = t / e;
|
|
1568
|
-
return i * Math.sin(o * r * 2 * Math.PI +
|
|
1568
|
+
return i * Math.sin(o * r * 2 * Math.PI + a);
|
|
1569
1569
|
}
|
|
1570
1570
|
/**
|
|
1571
1571
|
* Calculate rotation based on wave tangent
|
|
@@ -1576,9 +1576,9 @@ class ye {
|
|
|
1576
1576
|
* @param phase - Phase offset
|
|
1577
1577
|
* @returns Rotation angle in degrees
|
|
1578
1578
|
*/
|
|
1579
|
-
calculateRotation(t, e, i, o,
|
|
1580
|
-
const r = t / e,
|
|
1581
|
-
return Math.atan(
|
|
1579
|
+
calculateRotation(t, e, i, o, a) {
|
|
1580
|
+
const r = t / e, s = i * o * 2 * Math.PI * Math.cos(o * r * 2 * Math.PI + a) / e;
|
|
1581
|
+
return Math.atan(s) * (180 / Math.PI);
|
|
1582
1582
|
}
|
|
1583
1583
|
/**
|
|
1584
1584
|
* Estimate image width based on height
|
|
@@ -1609,9 +1609,9 @@ class ve {
|
|
|
1609
1609
|
case "spiral":
|
|
1610
1610
|
return new me(this.config, this.imageConfig);
|
|
1611
1611
|
case "cluster":
|
|
1612
|
-
return new be(this.config, this.imageConfig);
|
|
1613
|
-
case "wave":
|
|
1614
1612
|
return new ye(this.config, this.imageConfig);
|
|
1613
|
+
case "wave":
|
|
1614
|
+
return new be(this.config, this.imageConfig);
|
|
1615
1615
|
default:
|
|
1616
1616
|
return new le(this.config, this.imageConfig);
|
|
1617
1617
|
}
|
|
@@ -1625,8 +1625,8 @@ class ve {
|
|
|
1625
1625
|
*/
|
|
1626
1626
|
generateLayout(t, e, i = {}) {
|
|
1627
1627
|
const o = this.placementLayout.generate(t, e, i);
|
|
1628
|
-
return o.forEach((
|
|
1629
|
-
this.layouts.set(
|
|
1628
|
+
return o.forEach((a) => {
|
|
1629
|
+
this.layouts.set(a.id, a);
|
|
1630
1630
|
}), o;
|
|
1631
1631
|
}
|
|
1632
1632
|
/**
|
|
@@ -1680,8 +1680,8 @@ class ve {
|
|
|
1680
1680
|
return;
|
|
1681
1681
|
if (typeof i == "number")
|
|
1682
1682
|
return i;
|
|
1683
|
-
const o = i,
|
|
1684
|
-
return
|
|
1683
|
+
const o = i, a = this.resolveBreakpoint(t);
|
|
1684
|
+
return a === "mobile" ? o.mobile ?? o.tablet ?? o.screen : a === "tablet" ? o.tablet ?? o.screen ?? o.mobile : o.screen ?? o.tablet ?? o.mobile;
|
|
1685
1685
|
}
|
|
1686
1686
|
/**
|
|
1687
1687
|
* Calculate adaptive image size based on container dimensions and image count
|
|
@@ -1692,18 +1692,18 @@ class ve {
|
|
|
1692
1692
|
* @returns Calculated sizing result with height
|
|
1693
1693
|
*/
|
|
1694
1694
|
calculateAdaptiveSize(t, e, i, o) {
|
|
1695
|
-
const
|
|
1695
|
+
const a = this.imageConfig.sizing, r = this.resolveBaseHeight(o);
|
|
1696
1696
|
if (r !== void 0)
|
|
1697
1697
|
return { height: r };
|
|
1698
|
-
const
|
|
1699
|
-
let m = Math.sqrt(
|
|
1700
|
-
m *=
|
|
1701
|
-
let
|
|
1702
|
-
if (
|
|
1703
|
-
const v = Math.max(
|
|
1704
|
-
|
|
1698
|
+
const s = a?.minSize ?? 50, h = a?.maxSize ?? 400, c = this.config.targetCoverage ?? 0.6, d = this.config.densityFactor ?? 1, { width: l, height: u } = t, y = l * u * c / e;
|
|
1699
|
+
let m = Math.sqrt(y / 1.4);
|
|
1700
|
+
m *= d, m = Math.min(m, i);
|
|
1701
|
+
let E = this.clamp(m, s, h);
|
|
1702
|
+
if (E === s && m < s) {
|
|
1703
|
+
const v = Math.max(s * 0.05, 20);
|
|
1704
|
+
E = Math.max(v, m);
|
|
1705
1705
|
}
|
|
1706
|
-
return { height:
|
|
1706
|
+
return { height: E };
|
|
1707
1707
|
}
|
|
1708
1708
|
/**
|
|
1709
1709
|
* Utility: Clamp a value between min and max
|
|
@@ -1722,18 +1722,67 @@ const At = {
|
|
|
1722
1722
|
hexagon: "polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%)",
|
|
1723
1723
|
octagon: "polygon(30% 0%, 70% 0%, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0% 70%, 0% 30%)",
|
|
1724
1724
|
diamond: "polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%)"
|
|
1725
|
+
}, we = {
|
|
1726
|
+
// Circle - uses radius in pixels (refHeight of 100px = 50px radius)
|
|
1727
|
+
circle: {
|
|
1728
|
+
refHeight: 100,
|
|
1729
|
+
points: []
|
|
1730
|
+
// Special case: handled separately
|
|
1731
|
+
},
|
|
1732
|
+
// Square - maintains perfect aspect ratio (always 1:1)
|
|
1733
|
+
square: {
|
|
1734
|
+
refHeight: 100,
|
|
1735
|
+
points: [[0, 0], [100, 0], [100, 100], [0, 100]]
|
|
1736
|
+
},
|
|
1737
|
+
// Triangle - isosceles triangle
|
|
1738
|
+
triangle: {
|
|
1739
|
+
refHeight: 100,
|
|
1740
|
+
points: [[50, 0], [100, 100], [0, 100]]
|
|
1741
|
+
},
|
|
1742
|
+
// Pentagon - regular pentagon
|
|
1743
|
+
pentagon: {
|
|
1744
|
+
refHeight: 100,
|
|
1745
|
+
points: [[50, 0], [100, 38], [82, 100], [18, 100], [0, 38]]
|
|
1746
|
+
},
|
|
1747
|
+
// Hexagon - regular hexagon
|
|
1748
|
+
hexagon: {
|
|
1749
|
+
refHeight: 100,
|
|
1750
|
+
points: [[25, 0], [75, 0], [100, 50], [75, 100], [25, 100], [0, 50]]
|
|
1751
|
+
},
|
|
1752
|
+
// Octagon - regular octagon
|
|
1753
|
+
octagon: {
|
|
1754
|
+
refHeight: 100,
|
|
1755
|
+
points: [[30, 0], [70, 0], [100, 30], [100, 70], [70, 100], [30, 100], [0, 70], [0, 30]]
|
|
1756
|
+
},
|
|
1757
|
+
// Diamond - 45-degree rotated square
|
|
1758
|
+
diamond: {
|
|
1759
|
+
refHeight: 100,
|
|
1760
|
+
points: [[50, 0], [100, 50], [50, 100], [0, 50]]
|
|
1761
|
+
}
|
|
1725
1762
|
};
|
|
1726
|
-
function
|
|
1763
|
+
function xe(n) {
|
|
1727
1764
|
if (n)
|
|
1728
1765
|
return n in At ? At[n] : n;
|
|
1729
1766
|
}
|
|
1730
|
-
function
|
|
1731
|
-
|
|
1767
|
+
function Ee(n, t, e) {
|
|
1768
|
+
const i = we[n];
|
|
1769
|
+
if (!i) return "";
|
|
1770
|
+
const o = t / i.refHeight;
|
|
1771
|
+
if (n === "circle")
|
|
1772
|
+
return `circle(${Math.round(50 * o * 100) / 100}px)`;
|
|
1773
|
+
const a = i.refHeight * o, r = a / 2, s = a / 2, h = (e ?? a) / 2, c = t / 2, d = h - r, l = c - s;
|
|
1774
|
+
return `polygon(${i.points.map(([g, p]) => {
|
|
1775
|
+
const y = Math.round((g * o + d) * 100) / 100, f = Math.round((p * o + l) * 100) / 100;
|
|
1776
|
+
return `${y}px ${f}px`;
|
|
1777
|
+
}).join(", ")})`;
|
|
1732
1778
|
}
|
|
1733
1779
|
function Se(n) {
|
|
1734
|
-
return n
|
|
1780
|
+
return n in gt;
|
|
1781
|
+
}
|
|
1782
|
+
function Ie(n) {
|
|
1783
|
+
return n ? Se(n) ? gt[n] : n : gt.md;
|
|
1735
1784
|
}
|
|
1736
|
-
function
|
|
1785
|
+
function Ce(n) {
|
|
1737
1786
|
if (!n) return "";
|
|
1738
1787
|
const t = [];
|
|
1739
1788
|
if (n.grayscale !== void 0 && t.push(`grayscale(${n.grayscale})`), n.blur !== void 0 && t.push(`blur(${n.blur}px)`), n.brightness !== void 0 && t.push(`brightness(${n.brightness})`), n.contrast !== void 0 && t.push(`contrast(${n.contrast})`), n.saturate !== void 0 && t.push(`saturate(${n.saturate})`), n.opacity !== void 0 && t.push(`opacity(${n.opacity})`), n.sepia !== void 0 && t.push(`sepia(${n.sepia})`), n.hueRotate !== void 0 && t.push(`hue-rotate(${n.hueRotate}deg)`), n.invert !== void 0 && t.push(`invert(${n.invert})`), n.dropShadow !== void 0)
|
|
@@ -1751,43 +1800,54 @@ function Q(n) {
|
|
|
1751
1800
|
const t = n.width ?? 0, e = n.style ?? "solid", i = n.color ?? "#000000";
|
|
1752
1801
|
return `${t}px ${e} ${i}`;
|
|
1753
1802
|
}
|
|
1754
|
-
function
|
|
1803
|
+
function vt(n, t, e) {
|
|
1755
1804
|
if (!n) return {};
|
|
1756
|
-
const
|
|
1805
|
+
const i = {};
|
|
1757
1806
|
if (n.borderRadiusTopLeft !== void 0 || n.borderRadiusTopRight !== void 0 || n.borderRadiusBottomRight !== void 0 || n.borderRadiusBottomLeft !== void 0) {
|
|
1758
1807
|
const s = n.border?.radius ?? 0;
|
|
1759
|
-
n.borderRadiusTopLeft !== void 0 ?
|
|
1760
|
-
} else n.border?.radius !== void 0 && (
|
|
1808
|
+
n.borderRadiusTopLeft !== void 0 ? i.borderTopLeftRadius = `${n.borderRadiusTopLeft}px` : s && (i.borderTopLeftRadius = `${s}px`), n.borderRadiusTopRight !== void 0 ? i.borderTopRightRadius = `${n.borderRadiusTopRight}px` : s && (i.borderTopRightRadius = `${s}px`), n.borderRadiusBottomRight !== void 0 ? i.borderBottomRightRadius = `${n.borderRadiusBottomRight}px` : s && (i.borderBottomRightRadius = `${s}px`), n.borderRadiusBottomLeft !== void 0 ? i.borderBottomLeftRadius = `${n.borderRadiusBottomLeft}px` : s && (i.borderBottomLeftRadius = `${s}px`);
|
|
1809
|
+
} else n.border?.radius !== void 0 && (i.borderRadius = `${n.border.radius}px`);
|
|
1761
1810
|
if (n.borderTop || n.borderRight || n.borderBottom || n.borderLeft) {
|
|
1762
|
-
const s = n.border || {},
|
|
1763
|
-
|
|
1764
|
-
} else n.border && (
|
|
1765
|
-
n.shadow !== void 0 && (
|
|
1766
|
-
const
|
|
1767
|
-
if (
|
|
1768
|
-
const s = n.outline.width ?? 0,
|
|
1769
|
-
|
|
1770
|
-
}
|
|
1771
|
-
if (n.objectFit !== void 0 && (
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1811
|
+
const s = n.border || {}, h = { ...s, ...n.borderTop }, c = { ...s, ...n.borderRight }, d = { ...s, ...n.borderBottom }, l = { ...s, ...n.borderLeft };
|
|
1812
|
+
i.borderTop = Q(h), i.borderRight = Q(c), i.borderBottom = Q(d), i.borderLeft = Q(l);
|
|
1813
|
+
} else n.border && (i.border = Q(n.border));
|
|
1814
|
+
n.shadow !== void 0 && (i.boxShadow = Ie(n.shadow));
|
|
1815
|
+
const r = Ce(n.filter);
|
|
1816
|
+
if (i.filter = r || "none", n.opacity !== void 0 && (i.opacity = String(n.opacity)), n.cursor !== void 0 && (i.cursor = n.cursor), n.outline && n.outline.style !== "none" && (n.outline.width ?? 0) > 0) {
|
|
1817
|
+
const s = n.outline.width ?? 0, h = n.outline.style ?? "solid", c = n.outline.color ?? "#000000";
|
|
1818
|
+
i.outline = `${s}px ${h} ${c}`, n.outline.offset !== void 0 && (i.outlineOffset = `${n.outline.offset}px`);
|
|
1819
|
+
}
|
|
1820
|
+
if (n.objectFit !== void 0 && (i.objectFit = n.objectFit), n.aspectRatio !== void 0 && (i.aspectRatio = n.aspectRatio), n.clipPath !== void 0) {
|
|
1821
|
+
let s;
|
|
1822
|
+
const h = typeof n.clipPath == "object" && n.clipPath !== null && "shape" in n.clipPath, c = h ? n.clipPath : void 0;
|
|
1823
|
+
if (c?.mode === "height-relative" && t)
|
|
1824
|
+
s = Ee(c.shape, t, e);
|
|
1825
|
+
else {
|
|
1826
|
+
const d = h && c ? c.shape : n.clipPath;
|
|
1827
|
+
s = xe(d);
|
|
1828
|
+
}
|
|
1829
|
+
s && (s === "none" ? i.clipPath = "unset" : (i.clipPath = s, i.overflow = "hidden"));
|
|
1830
|
+
}
|
|
1831
|
+
return i;
|
|
1776
1832
|
}
|
|
1777
|
-
function
|
|
1833
|
+
function Ae(n, t) {
|
|
1778
1834
|
t.borderRadius !== void 0 && (n.style.borderRadius = t.borderRadius), t.borderTopLeftRadius !== void 0 && (n.style.borderTopLeftRadius = t.borderTopLeftRadius), t.borderTopRightRadius !== void 0 && (n.style.borderTopRightRadius = t.borderTopRightRadius), t.borderBottomRightRadius !== void 0 && (n.style.borderBottomRightRadius = t.borderBottomRightRadius), t.borderBottomLeftRadius !== void 0 && (n.style.borderBottomLeftRadius = t.borderBottomLeftRadius), t.border !== void 0 && (n.style.border = t.border), t.borderTop !== void 0 && (n.style.borderTop = t.borderTop), t.borderRight !== void 0 && (n.style.borderRight = t.borderRight), t.borderBottom !== void 0 && (n.style.borderBottom = t.borderBottom), t.borderLeft !== void 0 && (n.style.borderLeft = t.borderLeft), t.boxShadow !== void 0 && (n.style.boxShadow = t.boxShadow), t.filter !== void 0 && (n.style.filter = t.filter), t.opacity !== void 0 && (n.style.opacity = t.opacity), t.cursor !== void 0 && (n.style.cursor = t.cursor), t.outline !== void 0 && (n.style.outline = t.outline), t.outlineOffset !== void 0 && (n.style.outlineOffset = t.outlineOffset), t.objectFit !== void 0 && (n.style.objectFit = t.objectFit), t.aspectRatio !== void 0 && (n.style.aspectRatio = t.aspectRatio), t.clipPath !== void 0 && (n.style.clipPath = t.clipPath), t.overflow !== void 0 && (n.style.overflow = t.overflow);
|
|
1779
1835
|
}
|
|
1780
|
-
function
|
|
1836
|
+
function ut(n, t, e, i) {
|
|
1837
|
+
const o = vt(t, e, i);
|
|
1838
|
+
Ae(n, o);
|
|
1839
|
+
}
|
|
1840
|
+
function Ft(n) {
|
|
1781
1841
|
return n ? Array.isArray(n) ? n.join(" ") : n : "";
|
|
1782
1842
|
}
|
|
1783
|
-
function
|
|
1784
|
-
const e =
|
|
1843
|
+
function nt(n, t) {
|
|
1844
|
+
const e = Ft(t);
|
|
1785
1845
|
e && e.split(" ").forEach((i) => {
|
|
1786
1846
|
i.trim() && n.classList.add(i.trim());
|
|
1787
1847
|
});
|
|
1788
1848
|
}
|
|
1789
|
-
function
|
|
1790
|
-
const e =
|
|
1849
|
+
function ft(n, t) {
|
|
1850
|
+
const e = Ft(t);
|
|
1791
1851
|
e && e.split(" ").forEach((i) => {
|
|
1792
1852
|
i.trim() && n.classList.remove(i.trim());
|
|
1793
1853
|
});
|
|
@@ -1796,9 +1856,9 @@ const Tt = {
|
|
|
1796
1856
|
UNFOCUSING: 999,
|
|
1797
1857
|
FOCUSING: 1e3
|
|
1798
1858
|
};
|
|
1799
|
-
class
|
|
1859
|
+
class Te {
|
|
1800
1860
|
constructor(t, e, i) {
|
|
1801
|
-
this.state = I.IDLE, this.currentFocus = null, this.focusData = null, this.outgoing = null, this.incoming = null, this.focusGeneration = 0, this.config = t, this.animationEngine = e, this.
|
|
1861
|
+
this.state = I.IDLE, this.currentFocus = null, this.focusData = null, this.outgoing = null, this.incoming = null, this.focusGeneration = 0, this.config = t, this.animationEngine = e, this.styling = i, this.focusedClassName = i?.focused?.className;
|
|
1802
1862
|
}
|
|
1803
1863
|
/**
|
|
1804
1864
|
* Get current state machine state
|
|
@@ -1823,19 +1883,19 @@ class Ie {
|
|
|
1823
1883
|
* Returns actual pixel dimensions instead of scale factor for sharper rendering
|
|
1824
1884
|
*/
|
|
1825
1885
|
calculateFocusDimensions(t, e, i) {
|
|
1826
|
-
const o = this.normalizeScalePercent(this.config.scalePercent),
|
|
1827
|
-
let
|
|
1886
|
+
const o = this.normalizeScalePercent(this.config.scalePercent), a = i.height * o, r = t / e;
|
|
1887
|
+
let s = a, h = s * r;
|
|
1828
1888
|
const c = i.width * o;
|
|
1829
|
-
return h > c && (h = c,
|
|
1889
|
+
return h > c && (h = c, s = h / r), { width: h, height: s };
|
|
1830
1890
|
}
|
|
1831
1891
|
/**
|
|
1832
1892
|
* Calculate the transform needed to center an image (position only, no scale)
|
|
1833
1893
|
* Scale is handled by animating actual dimensions for sharper rendering
|
|
1834
1894
|
*/
|
|
1835
1895
|
calculateFocusTransform(t, e) {
|
|
1836
|
-
const i = t.width / 2, o = t.height / 2,
|
|
1896
|
+
const i = t.width / 2, o = t.height / 2, a = i - e.x, r = o - e.y;
|
|
1837
1897
|
return {
|
|
1838
|
-
x:
|
|
1898
|
+
x: a,
|
|
1839
1899
|
y: r,
|
|
1840
1900
|
rotation: 0,
|
|
1841
1901
|
scale: 1
|
|
@@ -1857,19 +1917,19 @@ class Ie {
|
|
|
1857
1917
|
* Create a Web Animation that animates both transform (position) and dimensions
|
|
1858
1918
|
* This provides sharper zoom by re-rendering at target size instead of scaling pixels
|
|
1859
1919
|
*/
|
|
1860
|
-
animateWithDimensions(t, e, i, o,
|
|
1861
|
-
const c = this.buildDimensionZoomTransform(e),
|
|
1920
|
+
animateWithDimensions(t, e, i, o, a, r, s, h) {
|
|
1921
|
+
const c = this.buildDimensionZoomTransform(e), d = this.buildDimensionZoomTransform(i);
|
|
1862
1922
|
return t.style.transition = "none", t.animate(
|
|
1863
1923
|
[
|
|
1864
1924
|
{
|
|
1865
1925
|
transform: c,
|
|
1866
1926
|
width: `${o}px`,
|
|
1867
|
-
height: `${
|
|
1927
|
+
height: `${a}px`
|
|
1868
1928
|
},
|
|
1869
1929
|
{
|
|
1870
|
-
transform:
|
|
1930
|
+
transform: d,
|
|
1871
1931
|
width: `${r}px`,
|
|
1872
|
-
height: `${
|
|
1932
|
+
height: `${s}px`
|
|
1873
1933
|
}
|
|
1874
1934
|
],
|
|
1875
1935
|
{
|
|
@@ -1881,15 +1941,30 @@ class Ie {
|
|
|
1881
1941
|
}
|
|
1882
1942
|
/**
|
|
1883
1943
|
* Apply focused styling to an element
|
|
1944
|
+
* Applies non-clip-path styles immediately, clip-path will be updated during animation via startClipPathAnimation
|
|
1884
1945
|
*/
|
|
1885
1946
|
applyFocusedStyling(t, e) {
|
|
1886
|
-
t.style.zIndex = String(e), t.classList.add("fbn-ic-focused"),
|
|
1947
|
+
t.style.zIndex = String(e), t.classList.add("fbn-ic-focused"), nt(t, this.focusedClassName);
|
|
1887
1948
|
}
|
|
1888
1949
|
/**
|
|
1889
1950
|
* Remove focused styling from an element
|
|
1951
|
+
* Removes classes and z-index, clip-path will be updated during animation via startClipPathAnimation
|
|
1890
1952
|
*/
|
|
1891
1953
|
removeFocusedStyling(t, e) {
|
|
1892
|
-
t.style.zIndex = e, t.classList.remove("fbn-ic-focused"),
|
|
1954
|
+
t.style.zIndex = e, t.classList.remove("fbn-ic-focused"), ft(t, this.focusedClassName);
|
|
1955
|
+
}
|
|
1956
|
+
/**
|
|
1957
|
+
* Continuously update clip-path during animation based on current element dimensions
|
|
1958
|
+
* This ensures clip-path changes smoothly as width/height animate
|
|
1959
|
+
*/
|
|
1960
|
+
startClipPathAnimation(t, e, i) {
|
|
1961
|
+
let o = i ? this.styling?.focused ?? this.styling?.default : this.styling?.default;
|
|
1962
|
+
i && this.styling?.focused && this.styling.focused.clipPath === void 0 && (o = { ...o, clipPath: void 0 });
|
|
1963
|
+
const a = () => {
|
|
1964
|
+
const r = t.offsetHeight, s = t.offsetWidth, h = vt(o, r, s);
|
|
1965
|
+
h.clipPath !== void 0 ? t.style.clipPath = h.clipPath : t.style.clipPath = "unset", h.overflow !== void 0 && (t.style.overflow = h.overflow), e.animation.playState === "running" && requestAnimationFrame(a);
|
|
1966
|
+
};
|
|
1967
|
+
requestAnimationFrame(a);
|
|
1893
1968
|
}
|
|
1894
1969
|
/**
|
|
1895
1970
|
* Start focus animation for an image using dimension-based zoom
|
|
@@ -1897,48 +1972,50 @@ class Ie {
|
|
|
1897
1972
|
* @param fromTransform - Optional starting transform (for mid-animation reversals)
|
|
1898
1973
|
* @param fromDimensions - Optional starting dimensions (for mid-animation reversals)
|
|
1899
1974
|
*/
|
|
1900
|
-
startFocusAnimation(t, e, i, o,
|
|
1901
|
-
const r = t.style.zIndex || "",
|
|
1902
|
-
this.
|
|
1903
|
-
const l =
|
|
1975
|
+
startFocusAnimation(t, e, i, o, a) {
|
|
1976
|
+
const r = t.style.zIndex || "", s = t.offsetWidth, h = t.offsetHeight, c = this.calculateFocusDimensions(s, h, e), d = this.calculateFocusTransform(e, i);
|
|
1977
|
+
this.animationEngine.cancelAllAnimations(t);
|
|
1978
|
+
const l = this.config.animationDuration ?? 600;
|
|
1979
|
+
this.applyFocusedStyling(t, Tt.FOCUSING);
|
|
1980
|
+
const u = o ?? {
|
|
1904
1981
|
x: 0,
|
|
1905
1982
|
y: 0,
|
|
1906
1983
|
rotation: i.rotation,
|
|
1907
1984
|
scale: 1
|
|
1908
1985
|
// No scale - using dimensions
|
|
1909
|
-
},
|
|
1986
|
+
}, g = a?.width ?? s, p = a?.height ?? h, y = this.animateWithDimensions(
|
|
1910
1987
|
t,
|
|
1911
|
-
l,
|
|
1912
1988
|
u,
|
|
1913
1989
|
d,
|
|
1914
|
-
|
|
1990
|
+
g,
|
|
1991
|
+
p,
|
|
1915
1992
|
c.width,
|
|
1916
1993
|
c.height,
|
|
1917
|
-
|
|
1918
|
-
),
|
|
1994
|
+
l
|
|
1995
|
+
), f = {
|
|
1919
1996
|
id: `focus-${Date.now()}`,
|
|
1920
1997
|
element: t,
|
|
1921
|
-
animation:
|
|
1922
|
-
fromState:
|
|
1923
|
-
toState:
|
|
1998
|
+
animation: y,
|
|
1999
|
+
fromState: u,
|
|
2000
|
+
toState: d,
|
|
1924
2001
|
startTime: performance.now(),
|
|
1925
|
-
duration:
|
|
2002
|
+
duration: l
|
|
1926
2003
|
};
|
|
1927
2004
|
return this.focusData = {
|
|
1928
2005
|
element: t,
|
|
1929
2006
|
originalState: i,
|
|
1930
|
-
focusTransform:
|
|
2007
|
+
focusTransform: d,
|
|
1931
2008
|
originalZIndex: r,
|
|
1932
|
-
originalWidth:
|
|
2009
|
+
originalWidth: s,
|
|
1933
2010
|
originalHeight: h,
|
|
1934
2011
|
focusWidth: c.width,
|
|
1935
2012
|
focusHeight: c.height
|
|
1936
|
-
}, {
|
|
2013
|
+
}, this.startClipPathAnimation(t, f, !0), {
|
|
1937
2014
|
element: t,
|
|
1938
2015
|
originalState: i,
|
|
1939
|
-
animationHandle:
|
|
2016
|
+
animationHandle: f,
|
|
1940
2017
|
direction: "in",
|
|
1941
|
-
originalWidth:
|
|
2018
|
+
originalWidth: s,
|
|
1942
2019
|
originalHeight: h
|
|
1943
2020
|
};
|
|
1944
2021
|
}
|
|
@@ -1949,37 +2026,39 @@ class Ie {
|
|
|
1949
2026
|
*/
|
|
1950
2027
|
startUnfocusAnimation(t, e, i, o) {
|
|
1951
2028
|
t.style.zIndex = String(Tt.UNFOCUSING), this.animationEngine.cancelAllAnimations(t);
|
|
1952
|
-
const
|
|
2029
|
+
const a = this.config.animationDuration ?? 600;
|
|
2030
|
+
t.classList.remove("fbn-ic-focused"), ft(t, this.focusedClassName);
|
|
2031
|
+
const r = i ?? this.focusData?.focusTransform ?? { x: 0, y: 0, rotation: 0, scale: 1 }, s = o?.width ?? this.focusData?.focusWidth ?? t.offsetWidth, h = o?.height ?? this.focusData?.focusHeight ?? t.offsetHeight, c = {
|
|
1953
2032
|
x: 0,
|
|
1954
2033
|
y: 0,
|
|
1955
2034
|
rotation: e.rotation,
|
|
1956
2035
|
scale: 1
|
|
1957
2036
|
// No scale - using dimensions
|
|
1958
|
-
},
|
|
2037
|
+
}, d = this.focusData?.originalWidth ?? t.offsetWidth, l = this.focusData?.originalHeight ?? t.offsetHeight, u = this.animateWithDimensions(
|
|
1959
2038
|
t,
|
|
1960
|
-
s,
|
|
1961
|
-
h,
|
|
1962
2039
|
r,
|
|
1963
|
-
a,
|
|
1964
2040
|
c,
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
2041
|
+
s,
|
|
2042
|
+
h,
|
|
2043
|
+
d,
|
|
2044
|
+
l,
|
|
2045
|
+
a
|
|
2046
|
+
), g = {
|
|
1968
2047
|
id: `unfocus-${Date.now()}`,
|
|
1969
2048
|
element: t,
|
|
1970
|
-
animation:
|
|
1971
|
-
fromState:
|
|
1972
|
-
toState:
|
|
2049
|
+
animation: u,
|
|
2050
|
+
fromState: r,
|
|
2051
|
+
toState: c,
|
|
1973
2052
|
startTime: performance.now(),
|
|
1974
|
-
duration:
|
|
2053
|
+
duration: a
|
|
1975
2054
|
};
|
|
1976
|
-
return {
|
|
2055
|
+
return this.startClipPathAnimation(t, g, !1), {
|
|
1977
2056
|
element: t,
|
|
1978
2057
|
originalState: e,
|
|
1979
|
-
animationHandle:
|
|
2058
|
+
animationHandle: g,
|
|
1980
2059
|
direction: "out",
|
|
1981
|
-
originalWidth:
|
|
1982
|
-
originalHeight:
|
|
2060
|
+
originalWidth: d,
|
|
2061
|
+
originalHeight: l
|
|
1983
2062
|
};
|
|
1984
2063
|
}
|
|
1985
2064
|
/**
|
|
@@ -1997,10 +2076,10 @@ class Ie {
|
|
|
1997
2076
|
* Caller is responsible for calling animationEngine.cancelAllAnimations() afterwards.
|
|
1998
2077
|
*/
|
|
1999
2078
|
captureMidAnimationState(t) {
|
|
2000
|
-
const e = getComputedStyle(t), i = new DOMMatrix(e.transform), o = t.offsetWidth,
|
|
2001
|
-
return t.style.width = `${o}px`, t.style.height = `${
|
|
2002
|
-
transform: { x: r, y:
|
|
2003
|
-
dimensions: { width: o, height:
|
|
2079
|
+
const e = getComputedStyle(t), i = new DOMMatrix(e.transform), o = t.offsetWidth, a = t.offsetHeight, r = i.e + o * 0.5, s = i.f + a * 0.5, h = Math.atan2(i.b, i.a) * (180 / Math.PI);
|
|
2080
|
+
return t.style.width = `${o}px`, t.style.height = `${a}px`, t.style.transform = `translate(-50%, -50%) translate(${r}px, ${s}px) rotate(${h}deg)`, t.style.transition = "none", {
|
|
2081
|
+
transform: { x: r, y: s, rotation: h, scale: 1 },
|
|
2082
|
+
dimensions: { width: o, height: a }
|
|
2004
2083
|
};
|
|
2005
2084
|
}
|
|
2006
2085
|
/**
|
|
@@ -2015,10 +2094,10 @@ class Ie {
|
|
|
2015
2094
|
/**
|
|
2016
2095
|
* Reset an element instantly to its original position and dimensions (no animation)
|
|
2017
2096
|
*/
|
|
2018
|
-
resetElementInstantly(t, e, i, o,
|
|
2097
|
+
resetElementInstantly(t, e, i, o, a) {
|
|
2019
2098
|
this.animationEngine.cancelAllAnimations(t);
|
|
2020
2099
|
const r = ["translate(-50%, -50%)"];
|
|
2021
|
-
r.push("translate(0px, 0px)"), r.push(`rotate(${e.rotation}deg)`), t.style.transition = "none", t.style.transform = r.join(" "), o !== void 0 &&
|
|
2100
|
+
r.push("translate(0px, 0px)"), r.push(`rotate(${e.rotation}deg)`), t.style.transition = "none", t.style.transform = r.join(" "), o !== void 0 && a !== void 0 && (t.style.width = `${o}px`, t.style.height = `${a}px`), this.removeFocusedStyling(t, i);
|
|
2022
2101
|
}
|
|
2023
2102
|
/**
|
|
2024
2103
|
* Focus (zoom) an image to center of container
|
|
@@ -2028,11 +2107,11 @@ class Ie {
|
|
|
2028
2107
|
if (this.currentFocus === t && this.state === I.FOCUSED)
|
|
2029
2108
|
return this.unfocusImage();
|
|
2030
2109
|
if (this.incoming?.element === t && this.state === I.FOCUSING) {
|
|
2031
|
-
const { transform:
|
|
2110
|
+
const { transform: a, dimensions: r } = this.captureMidAnimationState(t);
|
|
2032
2111
|
this.animationEngine.cancelAllAnimations(t), this.outgoing = this.startUnfocusAnimation(
|
|
2033
2112
|
t,
|
|
2034
2113
|
this.incoming.originalState,
|
|
2035
|
-
|
|
2114
|
+
a,
|
|
2036
2115
|
r
|
|
2037
2116
|
), this.incoming = null, this.state = I.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 = I.IDLE;
|
|
2038
2117
|
return;
|
|
@@ -2075,18 +2154,18 @@ class Ie {
|
|
|
2075
2154
|
if (this.incoming?.element === t)
|
|
2076
2155
|
return;
|
|
2077
2156
|
if (this.outgoing?.element === t) {
|
|
2078
|
-
const { transform:
|
|
2157
|
+
const { transform: a, dimensions: r } = this.captureMidAnimationState(t);
|
|
2079
2158
|
if (this.animationEngine.cancelAllAnimations(t), this.incoming) {
|
|
2080
|
-
const { transform:
|
|
2159
|
+
const { transform: s, dimensions: h } = this.captureMidAnimationState(this.incoming.element);
|
|
2081
2160
|
this.animationEngine.cancelAllAnimations(this.incoming.element), this.outgoing = this.startUnfocusAnimation(
|
|
2082
2161
|
this.incoming.element,
|
|
2083
2162
|
this.incoming.originalState,
|
|
2084
|
-
|
|
2163
|
+
s,
|
|
2085
2164
|
h
|
|
2086
2165
|
);
|
|
2087
2166
|
} else
|
|
2088
2167
|
this.outgoing = null;
|
|
2089
|
-
if (this.incoming = this.startFocusAnimation(t, e, i,
|
|
2168
|
+
if (this.incoming = this.startFocusAnimation(t, e, i, a, r), await Promise.all([
|
|
2090
2169
|
this.outgoing ? this.waitForAnimation(this.outgoing.animationHandle) : Promise.resolve(),
|
|
2091
2170
|
this.waitForAnimation(this.incoming.animationHandle)
|
|
2092
2171
|
]), this.focusGeneration !== o) return;
|
|
@@ -2100,11 +2179,11 @@ class Ie {
|
|
|
2100
2179
|
this.outgoing.originalWidth,
|
|
2101
2180
|
this.outgoing.originalHeight
|
|
2102
2181
|
), this.outgoing = null), this.incoming) {
|
|
2103
|
-
const { transform:
|
|
2182
|
+
const { transform: a, dimensions: r } = this.captureMidAnimationState(this.incoming.element);
|
|
2104
2183
|
this.animationEngine.cancelAllAnimations(this.incoming.element), this.outgoing = this.startUnfocusAnimation(
|
|
2105
2184
|
this.incoming.element,
|
|
2106
2185
|
this.incoming.originalState,
|
|
2107
|
-
|
|
2186
|
+
a,
|
|
2108
2187
|
r
|
|
2109
2188
|
);
|
|
2110
2189
|
}
|
|
@@ -2125,11 +2204,11 @@ class Ie {
|
|
|
2125
2204
|
const t = ++this.focusGeneration;
|
|
2126
2205
|
if (!this.currentFocus || !this.focusData) {
|
|
2127
2206
|
if (this.incoming && this.state === I.FOCUSING) {
|
|
2128
|
-
const { transform:
|
|
2207
|
+
const { transform: a, dimensions: r } = this.captureMidAnimationState(this.incoming.element);
|
|
2129
2208
|
if (this.animationEngine.cancelAllAnimations(this.incoming.element), this.outgoing = this.startUnfocusAnimation(
|
|
2130
2209
|
this.incoming.element,
|
|
2131
2210
|
this.incoming.originalState,
|
|
2132
|
-
|
|
2211
|
+
a,
|
|
2133
2212
|
r
|
|
2134
2213
|
), this.incoming = null, this.state = I.UNFOCUSING, await this.waitForAnimation(this.outgoing.animationHandle), this.focusGeneration !== t) return;
|
|
2135
2214
|
this.removeFocusedStyling(this.outgoing.element, this.focusData?.originalZIndex || ""), this.outgoing = null, this.focusData = null, this.state = I.IDLE;
|
|
@@ -2137,19 +2216,19 @@ class Ie {
|
|
|
2137
2216
|
return;
|
|
2138
2217
|
}
|
|
2139
2218
|
if (this.state === I.CROSS_ANIMATING && this.incoming) {
|
|
2140
|
-
const { transform:
|
|
2219
|
+
const { transform: a, dimensions: r } = this.captureMidAnimationState(this.incoming.element);
|
|
2141
2220
|
this.animationEngine.cancelAllAnimations(this.incoming.element);
|
|
2142
|
-
const
|
|
2221
|
+
const s = this.startUnfocusAnimation(
|
|
2143
2222
|
this.incoming.element,
|
|
2144
2223
|
this.incoming.originalState,
|
|
2145
|
-
|
|
2224
|
+
a,
|
|
2146
2225
|
r
|
|
2147
2226
|
);
|
|
2148
2227
|
if (await Promise.all([
|
|
2149
2228
|
this.outgoing ? this.waitForAnimation(this.outgoing.animationHandle) : Promise.resolve(),
|
|
2150
|
-
this.waitForAnimation(
|
|
2229
|
+
this.waitForAnimation(s.animationHandle)
|
|
2151
2230
|
]), this.focusGeneration !== t) return;
|
|
2152
|
-
this.outgoing && this.removeFocusedStyling(this.outgoing.element, this.outgoing.originalState.zIndex?.toString() || ""), this.removeFocusedStyling(
|
|
2231
|
+
this.outgoing && this.removeFocusedStyling(this.outgoing.element, this.outgoing.originalState.zIndex?.toString() || ""), this.removeFocusedStyling(s.element, this.incoming.originalState.zIndex?.toString() || ""), this.outgoing = null, this.incoming = null, this.currentFocus = null, this.focusData = null, this.state = I.IDLE;
|
|
2153
2232
|
return;
|
|
2154
2233
|
}
|
|
2155
2234
|
this.state = I.UNFOCUSING;
|
|
@@ -2194,8 +2273,8 @@ class Ie {
|
|
|
2194
2273
|
*/
|
|
2195
2274
|
setDragOffset(t) {
|
|
2196
2275
|
if (!this.currentFocus || !this.focusData || this.state !== I.FOCUSED) return;
|
|
2197
|
-
const e = this.currentFocus, i = this.focusData.focusTransform, o = ["translate(-50%, -50%)"],
|
|
2198
|
-
o.push(`translate(${
|
|
2276
|
+
const e = this.currentFocus, i = this.focusData.focusTransform, o = ["translate(-50%, -50%)"], a = (i.x ?? 0) + t, r = i.y ?? 0;
|
|
2277
|
+
o.push(`translate(${a}px, ${r}px)`), i.rotation !== void 0 && o.push(`rotate(${i.rotation}deg)`), e.style.transition = "none", e.style.transform = o.join(" ");
|
|
2199
2278
|
}
|
|
2200
2279
|
/**
|
|
2201
2280
|
* Clear the drag offset, optionally animating back to center
|
|
@@ -2204,9 +2283,9 @@ class Ie {
|
|
|
2204
2283
|
*/
|
|
2205
2284
|
clearDragOffset(t, e = 150) {
|
|
2206
2285
|
if (!this.currentFocus || !this.focusData || this.state !== I.FOCUSED) return;
|
|
2207
|
-
const i = this.currentFocus, o = this.focusData.focusTransform,
|
|
2208
|
-
|
|
2209
|
-
const h =
|
|
2286
|
+
const i = this.currentFocus, o = this.focusData.focusTransform, a = ["translate(-50%, -50%)"], r = o.x ?? 0, s = o.y ?? 0;
|
|
2287
|
+
a.push(`translate(${r}px, ${s}px)`), o.rotation !== void 0 && a.push(`rotate(${o.rotation}deg)`);
|
|
2288
|
+
const h = a.join(" ");
|
|
2210
2289
|
t ? (i.style.transition = `transform ${e}ms ease-out`, i.style.transform = h, setTimeout(() => {
|
|
2211
2290
|
this.currentFocus === i && (i.style.transition = "none");
|
|
2212
2291
|
}, e)) : (i.style.transition = "none", i.style.transform = h);
|
|
@@ -2236,7 +2315,7 @@ class Ie {
|
|
|
2236
2315
|
), this.state = I.IDLE, this.currentFocus = null, this.focusData = null, this.outgoing = null, this.incoming = null;
|
|
2237
2316
|
}
|
|
2238
2317
|
}
|
|
2239
|
-
const
|
|
2318
|
+
const Re = 50, Me = 0.5, Le = 20, ze = 0.3, Fe = 150, $e = 30, ot = class ot {
|
|
2240
2319
|
constructor(t, e) {
|
|
2241
2320
|
this.enabled = !1, this.touchState = null, this.recentTouchTimestamp = 0, this.container = t, this.callbacks = e, this.boundTouchStart = this.handleTouchStart.bind(this), this.boundTouchMove = this.handleTouchMove.bind(this), this.boundTouchEnd = this.handleTouchEnd.bind(this), this.boundTouchCancel = this.handleTouchCancel.bind(this);
|
|
2242
2321
|
}
|
|
@@ -2263,7 +2342,7 @@ const Ae = 50, Te = 0.5, Ce = 20, Re = 0.3, Me = 150, Le = 30, at = class at {
|
|
|
2263
2342
|
* Used to prevent click-outside from unfocusing immediately after touch
|
|
2264
2343
|
*/
|
|
2265
2344
|
hadRecentTouch() {
|
|
2266
|
-
return Date.now() - this.recentTouchTimestamp <
|
|
2345
|
+
return Date.now() - this.recentTouchTimestamp < ot.TOUCH_CLICK_DELAY;
|
|
2267
2346
|
}
|
|
2268
2347
|
handleTouchStart(t) {
|
|
2269
2348
|
if (t.touches.length !== 1) return;
|
|
@@ -2282,29 +2361,29 @@ const Ae = 50, Te = 0.5, Ce = 20, Re = 0.3, Me = 150, Le = 30, at = class at {
|
|
|
2282
2361
|
if (!this.touchState || t.touches.length !== 1) return;
|
|
2283
2362
|
const e = t.touches[0], i = e.clientX - this.touchState.startX, o = e.clientY - this.touchState.startY;
|
|
2284
2363
|
if (this.touchState.isHorizontalSwipe === null && Math.sqrt(i * i + o * o) > 10) {
|
|
2285
|
-
const
|
|
2286
|
-
this.touchState.isHorizontalSwipe =
|
|
2364
|
+
const s = Math.atan2(Math.abs(o), Math.abs(i)) * (180 / Math.PI);
|
|
2365
|
+
this.touchState.isHorizontalSwipe = s <= $e;
|
|
2287
2366
|
}
|
|
2288
2367
|
if (this.touchState.isHorizontalSwipe !== !1 && this.touchState.isHorizontalSwipe === !0) {
|
|
2289
2368
|
t.preventDefault(), this.touchState.isDragging = !0, this.touchState.currentX = e.clientX;
|
|
2290
|
-
const
|
|
2291
|
-
this.callbacks.onDragOffset(
|
|
2369
|
+
const a = i * ze;
|
|
2370
|
+
this.callbacks.onDragOffset(a);
|
|
2292
2371
|
}
|
|
2293
2372
|
}
|
|
2294
2373
|
handleTouchEnd(t) {
|
|
2295
2374
|
if (!this.touchState) return;
|
|
2296
2375
|
this.recentTouchTimestamp = Date.now();
|
|
2297
|
-
const e = this.touchState.currentX - this.touchState.startX, i = performance.now() - this.touchState.startTime, o = Math.abs(e) / i,
|
|
2376
|
+
const e = this.touchState.currentX - this.touchState.startX, i = performance.now() - this.touchState.startTime, o = Math.abs(e) / i, a = Math.abs(e);
|
|
2298
2377
|
let r = !1;
|
|
2299
|
-
this.touchState.isHorizontalSwipe === !0 && this.touchState.isDragging && (
|
|
2378
|
+
this.touchState.isHorizontalSwipe === !0 && this.touchState.isDragging && (a >= Re || o >= Me && a >= Le) && (r = !0, e < 0 ? this.callbacks.onNext() : this.callbacks.onPrev()), this.touchState.isDragging && this.callbacks.onDragEnd(r), this.touchState = null;
|
|
2300
2379
|
}
|
|
2301
2380
|
handleTouchCancel(t) {
|
|
2302
2381
|
this.touchState?.isDragging && this.callbacks.onDragEnd(!1), this.touchState = null;
|
|
2303
2382
|
}
|
|
2304
2383
|
};
|
|
2305
|
-
|
|
2306
|
-
let mt =
|
|
2307
|
-
class
|
|
2384
|
+
ot.TOUCH_CLICK_DELAY = 300;
|
|
2385
|
+
let mt = ot;
|
|
2386
|
+
class De {
|
|
2308
2387
|
constructor(t) {
|
|
2309
2388
|
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)
|
|
2310
2389
|
throw new Error("GoogleDriveLoader requires at least one source to be configured");
|
|
@@ -2318,8 +2397,8 @@ class ze {
|
|
|
2318
2397
|
for (const e of this.sources)
|
|
2319
2398
|
if ("folders" in e)
|
|
2320
2399
|
for (const i of e.folders) {
|
|
2321
|
-
const o = e.recursive !== void 0 ? e.recursive : !0,
|
|
2322
|
-
this._discoveredUrls.push(...
|
|
2400
|
+
const o = e.recursive !== void 0 ? e.recursive : !0, a = await this.loadFromFolder(i, t, o);
|
|
2401
|
+
this._discoveredUrls.push(...a);
|
|
2323
2402
|
}
|
|
2324
2403
|
else if ("files" in e) {
|
|
2325
2404
|
const i = await this.loadFiles(e.files, t);
|
|
@@ -2385,8 +2464,8 @@ class ze {
|
|
|
2385
2464
|
return this.loadImagesDirectly(o, e);
|
|
2386
2465
|
try {
|
|
2387
2466
|
return i ? await this.loadImagesRecursively(o, e) : await this.loadImagesFromSingleFolder(o, e);
|
|
2388
|
-
} catch (
|
|
2389
|
-
return console.error("Error loading from Google Drive API:",
|
|
2467
|
+
} catch (a) {
|
|
2468
|
+
return console.error("Error loading from Google Drive API:", a), this.loadImagesDirectly(o, e);
|
|
2390
2469
|
}
|
|
2391
2470
|
}
|
|
2392
2471
|
/**
|
|
@@ -2396,14 +2475,14 @@ class ze {
|
|
|
2396
2475
|
* @returns Promise resolving to array of image URLs
|
|
2397
2476
|
*/
|
|
2398
2477
|
async loadImagesFromSingleFolder(t, e) {
|
|
2399
|
-
const i = [], o = `'${t}' in parents and trashed=false`, r = `${this.apiEndpoint}?q=${encodeURIComponent(o)}&fields=files(id,name,mimeType,thumbnailLink)&key=${this.apiKey}`,
|
|
2400
|
-
if (!
|
|
2401
|
-
throw new Error(`API request failed: ${
|
|
2402
|
-
const c = (await
|
|
2403
|
-
(
|
|
2478
|
+
const i = [], o = `'${t}' in parents and trashed=false`, r = `${this.apiEndpoint}?q=${encodeURIComponent(o)}&fields=files(id,name,mimeType,thumbnailLink)&key=${this.apiKey}`, s = await fetch(r);
|
|
2479
|
+
if (!s.ok)
|
|
2480
|
+
throw new Error(`API request failed: ${s.status} ${s.statusText}`);
|
|
2481
|
+
const c = (await s.json()).files.filter(
|
|
2482
|
+
(d) => d.mimeType.startsWith("image/") && e.isAllowed(d.name)
|
|
2404
2483
|
);
|
|
2405
|
-
return this.log(`Found ${c.length} images in folder ${t} (non-recursive)`), c.forEach((
|
|
2406
|
-
i.push(`https://lh3.googleusercontent.com/d/${
|
|
2484
|
+
return this.log(`Found ${c.length} images in folder ${t} (non-recursive)`), c.forEach((d) => {
|
|
2485
|
+
i.push(`https://lh3.googleusercontent.com/d/${d.id}=s1600`), this.log(`Added file: ${d.name}`);
|
|
2407
2486
|
}), i;
|
|
2408
2487
|
}
|
|
2409
2488
|
/**
|
|
@@ -2415,24 +2494,24 @@ class ze {
|
|
|
2415
2494
|
async loadFiles(t, e) {
|
|
2416
2495
|
const i = [];
|
|
2417
2496
|
for (const o of t) {
|
|
2418
|
-
const
|
|
2419
|
-
if (!
|
|
2497
|
+
const a = this.extractFileId(o);
|
|
2498
|
+
if (!a) {
|
|
2420
2499
|
this.log(`Skipping invalid file URL: ${o}`);
|
|
2421
2500
|
continue;
|
|
2422
2501
|
}
|
|
2423
2502
|
if (this.apiKey && this.apiKey !== "YOUR_API_KEY_HERE")
|
|
2424
2503
|
try {
|
|
2425
|
-
const r = `${this.apiEndpoint}/${
|
|
2426
|
-
if (
|
|
2427
|
-
const h = await
|
|
2428
|
-
h.mimeType.startsWith("image/") && e.isAllowed(h.name) ? (i.push(`https://lh3.googleusercontent.com/d/${
|
|
2504
|
+
const r = `${this.apiEndpoint}/${a}?fields=name,mimeType&key=${this.apiKey}`, s = await fetch(r);
|
|
2505
|
+
if (s.ok) {
|
|
2506
|
+
const h = await s.json();
|
|
2507
|
+
h.mimeType.startsWith("image/") && e.isAllowed(h.name) ? (i.push(`https://lh3.googleusercontent.com/d/${a}=s1600`), this.log(`Added file: ${h.name}`)) : this.log(`Skipping non-image file: ${h.name} (${h.mimeType})`);
|
|
2429
2508
|
} else
|
|
2430
|
-
this.log(`Failed to fetch metadata for file ${
|
|
2509
|
+
this.log(`Failed to fetch metadata for file ${a}: ${s.status}`);
|
|
2431
2510
|
} catch (r) {
|
|
2432
|
-
this.log(`Error fetching metadata for file ${
|
|
2511
|
+
this.log(`Error fetching metadata for file ${a}:`, r);
|
|
2433
2512
|
}
|
|
2434
2513
|
else
|
|
2435
|
-
i.push(`https://lh3.googleusercontent.com/d/${
|
|
2514
|
+
i.push(`https://lh3.googleusercontent.com/d/${a}=s1600`);
|
|
2436
2515
|
}
|
|
2437
2516
|
return i;
|
|
2438
2517
|
}
|
|
@@ -2466,21 +2545,21 @@ class ze {
|
|
|
2466
2545
|
* @returns Promise resolving to array of image URLs
|
|
2467
2546
|
*/
|
|
2468
2547
|
async loadImagesRecursively(t, e) {
|
|
2469
|
-
const i = [], o = `'${t}' in parents and trashed=false`, r = `${this.apiEndpoint}?q=${encodeURIComponent(o)}&fields=files(id,name,mimeType,thumbnailLink)&key=${this.apiKey}`,
|
|
2470
|
-
if (!
|
|
2471
|
-
throw new Error(`API request failed: ${
|
|
2472
|
-
const h = await
|
|
2548
|
+
const i = [], o = `'${t}' in parents and trashed=false`, r = `${this.apiEndpoint}?q=${encodeURIComponent(o)}&fields=files(id,name,mimeType,thumbnailLink)&key=${this.apiKey}`, s = await fetch(r);
|
|
2549
|
+
if (!s.ok)
|
|
2550
|
+
throw new Error(`API request failed: ${s.status} ${s.statusText}`);
|
|
2551
|
+
const h = await s.json(), c = h.files.filter(
|
|
2473
2552
|
(l) => l.mimeType.startsWith("image/") && e.isAllowed(l.name)
|
|
2474
|
-
),
|
|
2553
|
+
), d = h.files.filter(
|
|
2475
2554
|
(l) => l.mimeType === "application/vnd.google-apps.folder"
|
|
2476
2555
|
);
|
|
2477
|
-
this.log(`Found ${h.files.length} total items in folder ${t}`), h.files.forEach((l) => this.log(` - File: ${l.name} (${l.mimeType})`)), this.log(`- ${c.length} valid files (images only)`), this.log(`- ${
|
|
2556
|
+
this.log(`Found ${h.files.length} total items in folder ${t}`), h.files.forEach((l) => this.log(` - File: ${l.name} (${l.mimeType})`)), this.log(`- ${c.length} valid files (images only)`), this.log(`- ${d.length} subfolders`), c.forEach((l) => {
|
|
2478
2557
|
i.push(`https://lh3.googleusercontent.com/d/${l.id}=s1600`), this.log(`Added file: ${l.name}`);
|
|
2479
2558
|
});
|
|
2480
|
-
for (const l of
|
|
2559
|
+
for (const l of d) {
|
|
2481
2560
|
this.log(`Loading images from subfolder: ${l.name}`);
|
|
2482
|
-
const
|
|
2483
|
-
i.push(...
|
|
2561
|
+
const u = await this.loadImagesRecursively(l.id, e);
|
|
2562
|
+
i.push(...u);
|
|
2484
2563
|
}
|
|
2485
2564
|
return i;
|
|
2486
2565
|
}
|
|
@@ -2496,9 +2575,9 @@ class ze {
|
|
|
2496
2575
|
const i = `https://drive.google.com/embeddedfolderview?id=${t}`, o = await fetch(i, { mode: "cors" });
|
|
2497
2576
|
if (!o.ok)
|
|
2498
2577
|
throw new Error("Cannot access folder directly (CORS or permissions issue)");
|
|
2499
|
-
const
|
|
2500
|
-
return [...new Set(
|
|
2501
|
-
(
|
|
2578
|
+
const a = await o.text(), r = /\/file\/d\/([a-zA-Z0-9_-]+)/g, s = [...a.matchAll(r)];
|
|
2579
|
+
return [...new Set(s.map((d) => d[1]))].map(
|
|
2580
|
+
(d) => `https://drive.google.com/uc?export=view&id=${d}`
|
|
2502
2581
|
);
|
|
2503
2582
|
} catch (i) {
|
|
2504
2583
|
throw console.error("Direct loading failed:", i), new Error(
|
|
@@ -2525,7 +2604,7 @@ class ze {
|
|
|
2525
2604
|
this.debugLogging && typeof console < "u" && console.log(...t);
|
|
2526
2605
|
}
|
|
2527
2606
|
}
|
|
2528
|
-
class
|
|
2607
|
+
class Oe {
|
|
2529
2608
|
constructor(t) {
|
|
2530
2609
|
if (this._prepared = !1, this._discoveredUrls = [], this.validateUrls = t.validateUrls !== !1, this.validationTimeout = t.validationTimeout ?? 5e3, this.validationMethod = t.validationMethod ?? "head", this.debugLogging = t.debugLogging ?? !1, this.sources = t.sources ?? [], !this.sources || this.sources.length === 0)
|
|
2531
2610
|
throw new Error("StaticImageLoader requires at least one source to be configured");
|
|
@@ -2590,8 +2669,8 @@ class Fe {
|
|
|
2590
2669
|
return console.warn("URLs must be an array:", t), [];
|
|
2591
2670
|
const i = [];
|
|
2592
2671
|
for (const o of t) {
|
|
2593
|
-
const
|
|
2594
|
-
if (!e.isAllowed(
|
|
2672
|
+
const a = o.split("/").pop() || o;
|
|
2673
|
+
if (!e.isAllowed(a)) {
|
|
2595
2674
|
this.log(`Skipping filtered URL: ${o}`);
|
|
2596
2675
|
continue;
|
|
2597
2676
|
}
|
|
@@ -2610,12 +2689,12 @@ class Fe {
|
|
|
2610
2689
|
if (!Array.isArray(e))
|
|
2611
2690
|
return console.warn("files must be an array:", e), [];
|
|
2612
2691
|
const o = [];
|
|
2613
|
-
for (const
|
|
2614
|
-
if (!i.isAllowed(
|
|
2615
|
-
this.log(`Skipping filtered file: ${
|
|
2692
|
+
for (const a of e) {
|
|
2693
|
+
if (!i.isAllowed(a)) {
|
|
2694
|
+
this.log(`Skipping filtered file: ${a}`);
|
|
2616
2695
|
continue;
|
|
2617
2696
|
}
|
|
2618
|
-
const r = this.constructUrl(t,
|
|
2697
|
+
const r = this.constructUrl(t, a);
|
|
2619
2698
|
this.validateUrls ? await this.validateUrl(r) ? o.push(r) : console.warn(`Skipping invalid/missing file: ${r}`) : o.push(r);
|
|
2620
2699
|
}
|
|
2621
2700
|
return o;
|
|
@@ -2631,15 +2710,15 @@ class Fe {
|
|
|
2631
2710
|
this.log(`Fetching JSON endpoint: ${t}`);
|
|
2632
2711
|
const i = new AbortController(), o = setTimeout(() => i.abort(), 1e4);
|
|
2633
2712
|
try {
|
|
2634
|
-
const
|
|
2635
|
-
if (clearTimeout(o), !
|
|
2636
|
-
throw new Error(`HTTP ${
|
|
2637
|
-
const r = await
|
|
2713
|
+
const a = await fetch(t, { signal: i.signal });
|
|
2714
|
+
if (clearTimeout(o), !a.ok)
|
|
2715
|
+
throw new Error(`HTTP ${a.status} fetching ${t}`);
|
|
2716
|
+
const r = await a.json();
|
|
2638
2717
|
if (!r || !Array.isArray(r.images))
|
|
2639
2718
|
throw new Error('JSON source must return JSON with shape { "images": ["url1", "url2", ...] }');
|
|
2640
2719
|
return this.log(`JSON endpoint returned ${r.images.length} image(s)`), await this.processUrls(r.images, e);
|
|
2641
|
-
} catch (
|
|
2642
|
-
throw clearTimeout(o),
|
|
2720
|
+
} catch (a) {
|
|
2721
|
+
throw clearTimeout(o), a instanceof Error && a.name === "AbortError" ? new Error(`Timeout fetching JSON endpoint: ${t}`) : a;
|
|
2643
2722
|
}
|
|
2644
2723
|
}
|
|
2645
2724
|
/**
|
|
@@ -2661,11 +2740,11 @@ class Fe {
|
|
|
2661
2740
|
if (!(t.startsWith(window.location.origin) || t.startsWith("/")))
|
|
2662
2741
|
return this.log(`Skipping validation for cross-origin URL: ${t}`), !0;
|
|
2663
2742
|
try {
|
|
2664
|
-
const i = new AbortController(), o = setTimeout(() => i.abort(), this.validationTimeout),
|
|
2743
|
+
const i = new AbortController(), o = setTimeout(() => i.abort(), this.validationTimeout), a = await fetch(t, {
|
|
2665
2744
|
method: "HEAD",
|
|
2666
2745
|
signal: i.signal
|
|
2667
2746
|
});
|
|
2668
|
-
return clearTimeout(o),
|
|
2747
|
+
return clearTimeout(o), a.ok ? !0 : (this.log(`Validation failed for ${t}: HTTP ${a.status}`), !1);
|
|
2669
2748
|
} catch (i) {
|
|
2670
2749
|
return i instanceof Error && (i.name === "AbortError" ? this.log(`Validation timeout for ${t}`) : this.log(`Validation failed for ${t}:`, i.message)), !1;
|
|
2671
2750
|
}
|
|
@@ -2705,7 +2784,7 @@ class Fe {
|
|
|
2705
2784
|
this.debugLogging && typeof console < "u" && console.log(...t);
|
|
2706
2785
|
}
|
|
2707
2786
|
}
|
|
2708
|
-
class
|
|
2787
|
+
class Pe {
|
|
2709
2788
|
constructor(t) {
|
|
2710
2789
|
if (this._prepared = !1, this._discoveredUrls = [], this.loaders = t.loaders, this.debugLogging = t.debugLogging ?? !1, !this.loaders || this.loaders.length === 0)
|
|
2711
2790
|
throw new Error("CompositeLoader requires at least one loader to be configured");
|
|
@@ -2719,8 +2798,8 @@ class De {
|
|
|
2719
2798
|
this._discoveredUrls = [], this.log(`Preparing ${this.loaders.length} loader(s) in parallel`);
|
|
2720
2799
|
const e = this.loaders.map((i, o) => i.prepare(t).then(() => {
|
|
2721
2800
|
this.log(`Loader ${o} prepared with ${i.imagesLength()} images`);
|
|
2722
|
-
}).catch((
|
|
2723
|
-
console.warn(`Loader ${o} failed to prepare:`,
|
|
2801
|
+
}).catch((a) => {
|
|
2802
|
+
console.warn(`Loader ${o} failed to prepare:`, a);
|
|
2724
2803
|
}));
|
|
2725
2804
|
await Promise.all(e);
|
|
2726
2805
|
for (const i of this.loaders)
|
|
@@ -2762,7 +2841,7 @@ class De {
|
|
|
2762
2841
|
this.debugLogging && typeof console < "u" && console.log("[CompositeLoader]", ...t);
|
|
2763
2842
|
}
|
|
2764
2843
|
}
|
|
2765
|
-
class
|
|
2844
|
+
class Ue {
|
|
2766
2845
|
/**
|
|
2767
2846
|
* Create a new ImageFilter
|
|
2768
2847
|
* @param extensions - Array of allowed file extensions (without dots)
|
|
@@ -2799,7 +2878,7 @@ class Oe {
|
|
|
2799
2878
|
// isAllowedDate(date: Date): boolean
|
|
2800
2879
|
// isAllowedDimensions(width: number, height: number): boolean
|
|
2801
2880
|
}
|
|
2802
|
-
const
|
|
2881
|
+
const _e = `
|
|
2803
2882
|
.fbn-ic-gallery {
|
|
2804
2883
|
position: relative;
|
|
2805
2884
|
width: 100%;
|
|
@@ -2849,20 +2928,20 @@ const $e = `
|
|
|
2849
2928
|
display: none !important;
|
|
2850
2929
|
}
|
|
2851
2930
|
`;
|
|
2852
|
-
function
|
|
2931
|
+
function He() {
|
|
2853
2932
|
if (typeof document > "u") return;
|
|
2854
2933
|
const n = "fbn-ic-functional-styles";
|
|
2855
2934
|
if (document.getElementById(n)) return;
|
|
2856
2935
|
const t = document.createElement("style");
|
|
2857
|
-
t.id = n, t.textContent =
|
|
2936
|
+
t.id = n, t.textContent = _e, document.head.appendChild(t);
|
|
2858
2937
|
}
|
|
2859
|
-
let
|
|
2938
|
+
let Ne = class {
|
|
2860
2939
|
constructor(t = {}) {
|
|
2861
2940
|
this.fullConfig = Xt(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 Kt(this.fullConfig.animation), this.layoutEngine = new ve({
|
|
2862
2941
|
layout: this.fullConfig.layout,
|
|
2863
2942
|
image: this.fullConfig.image
|
|
2864
|
-
}), this.zoomEngine = new
|
|
2865
|
-
const e = this.fullConfig.animation.entry ||
|
|
2943
|
+
}), this.zoomEngine = new Te(this.fullConfig.interaction.focus, this.animationEngine, this.fullConfig.styling), this.defaultStyles = vt(this.fullConfig.styling?.default), this.defaultClassName = this.fullConfig.styling?.default?.className, this.hoverClassName = this.fullConfig.styling?.hover?.className;
|
|
2944
|
+
const e = this.fullConfig.animation.entry || b.animation.entry;
|
|
2866
2945
|
this.entryAnimationEngine = new ce(
|
|
2867
2946
|
e,
|
|
2868
2947
|
this.fullConfig.layout.algorithm
|
|
@@ -2873,7 +2952,7 @@ let Ue = class {
|
|
|
2873
2952
|
*/
|
|
2874
2953
|
createImageFilter() {
|
|
2875
2954
|
const t = this.fullConfig.config.loaders?.allowedExtensions;
|
|
2876
|
-
return new
|
|
2955
|
+
return new Ue(t);
|
|
2877
2956
|
}
|
|
2878
2957
|
/**
|
|
2879
2958
|
* Create appropriate image loader based on config
|
|
@@ -2884,7 +2963,7 @@ let Ue = class {
|
|
|
2884
2963
|
if (!t || t.length === 0)
|
|
2885
2964
|
throw new Error("No loaders configured. Provide `images`, `loaders`, or both.");
|
|
2886
2965
|
const i = t.map((o) => this.createLoaderFromEntry(o, e));
|
|
2887
|
-
return i.length === 1 ? i[0] : new
|
|
2966
|
+
return i.length === 1 ? i[0] : new Pe({
|
|
2888
2967
|
loaders: i,
|
|
2889
2968
|
debugLogging: this.fullConfig.config.debug?.loaders
|
|
2890
2969
|
});
|
|
@@ -2902,14 +2981,14 @@ let Ue = class {
|
|
|
2902
2981
|
allowedExtensions: i.allowedExtensions ?? e.allowedExtensions,
|
|
2903
2982
|
debugLogging: i.debugLogging ?? this.fullConfig.config.debug?.loaders
|
|
2904
2983
|
};
|
|
2905
|
-
return new
|
|
2984
|
+
return new Oe(o);
|
|
2906
2985
|
} else if ("googleDrive" in t) {
|
|
2907
2986
|
const i = t.googleDrive, o = {
|
|
2908
2987
|
...i,
|
|
2909
2988
|
allowedExtensions: i.allowedExtensions ?? e.allowedExtensions,
|
|
2910
2989
|
debugLogging: i.debugLogging ?? this.fullConfig.config.debug?.loaders
|
|
2911
2990
|
};
|
|
2912
|
-
return new
|
|
2991
|
+
return new De(o);
|
|
2913
2992
|
} else
|
|
2914
2993
|
throw new Error(`Unknown loader entry: ${JSON.stringify(t)}`);
|
|
2915
2994
|
}
|
|
@@ -2918,7 +2997,7 @@ let Ue = class {
|
|
|
2918
2997
|
*/
|
|
2919
2998
|
async init() {
|
|
2920
2999
|
try {
|
|
2921
|
-
if (
|
|
3000
|
+
if (He(), this.containerRef)
|
|
2922
3001
|
this.containerEl = this.containerRef;
|
|
2923
3002
|
else if (this.containerEl = document.getElementById(this.containerId), !this.containerEl)
|
|
2924
3003
|
throw new Error(`Container #${this.containerId} not found`);
|
|
@@ -2927,7 +3006,7 @@ let Ue = class {
|
|
|
2927
3006
|
onPrev: () => this.navigateToPreviousImage(),
|
|
2928
3007
|
onDragOffset: (t) => this.zoomEngine.setDragOffset(t),
|
|
2929
3008
|
onDragEnd: (t) => {
|
|
2930
|
-
t ? this.zoomEngine.clearDragOffset(!1) : this.zoomEngine.clearDragOffset(!0,
|
|
3009
|
+
t ? this.zoomEngine.clearDragOffset(!1) : this.zoomEngine.clearDragOffset(!0, Fe);
|
|
2931
3010
|
}
|
|
2932
3011
|
}), this.setupUI(), this.setupEventListeners(), this.logDebug("ImageCloud initialized"), await this.loadImages();
|
|
2933
3012
|
} catch (t) {
|
|
@@ -3022,13 +3101,13 @@ let Ue = class {
|
|
|
3022
3101
|
this.showError("No images found."), this.showLoading(!1);
|
|
3023
3102
|
return;
|
|
3024
3103
|
}
|
|
3025
|
-
const i = this.getContainerBounds(), o = this.getImageHeight(),
|
|
3104
|
+
const i = this.getContainerBounds(), o = this.getImageHeight(), a = window.innerWidth;
|
|
3026
3105
|
this.logDebug(`Adaptive sizing input: container=${i.width}x${i.height}px, images=${t}, responsiveMax=${o}px`);
|
|
3027
3106
|
const r = this.layoutEngine.calculateAdaptiveSize(
|
|
3028
3107
|
i,
|
|
3029
3108
|
t,
|
|
3030
3109
|
o,
|
|
3031
|
-
|
|
3110
|
+
a
|
|
3032
3111
|
);
|
|
3033
3112
|
this.logDebug(`Adaptive sizing result: height=${r.height}px`), await this.createImageCloud(e, r.height), this.showLoading(!1), this.imagesLoaded = !0;
|
|
3034
3113
|
} catch (t) {
|
|
@@ -3045,41 +3124,41 @@ let Ue = class {
|
|
|
3045
3124
|
if (!this.containerEl) return;
|
|
3046
3125
|
const i = this.getContainerBounds();
|
|
3047
3126
|
this.currentImageHeight = e;
|
|
3048
|
-
const o = this.loadGeneration,
|
|
3049
|
-
this.imageLayouts =
|
|
3127
|
+
const o = this.loadGeneration, a = this.layoutEngine.generateLayout(t.length, i, { fixedHeight: e });
|
|
3128
|
+
this.imageLayouts = a, this.displayQueue = [];
|
|
3050
3129
|
let r = 0;
|
|
3051
|
-
const
|
|
3130
|
+
const s = (c) => {
|
|
3052
3131
|
this.containerEl && (this.containerEl.appendChild(c), this.imageElements.push(c), requestAnimationFrame(() => {
|
|
3053
3132
|
if (c.offsetWidth, c.style.opacity = this.defaultStyles.opacity ?? "1", c.dataset.startX && (this.entryAnimationEngine.requiresJSAnimation() || this.entryAnimationEngine.requiresJSRotation() || this.entryAnimationEngine.requiresJSScale() || c.dataset.startRotation !== c.dataset.rotation || c.dataset.startScale !== c.dataset.scale)) {
|
|
3054
|
-
const
|
|
3133
|
+
const u = {
|
|
3055
3134
|
x: parseFloat(c.dataset.startX),
|
|
3056
3135
|
y: parseFloat(c.dataset.startY)
|
|
3057
|
-
},
|
|
3136
|
+
}, g = {
|
|
3058
3137
|
x: parseFloat(c.dataset.endX),
|
|
3059
3138
|
y: parseFloat(c.dataset.endY)
|
|
3060
|
-
},
|
|
3139
|
+
}, p = parseFloat(c.dataset.imageWidth), y = parseFloat(c.dataset.imageHeight), f = parseFloat(c.dataset.rotation), m = parseFloat(c.dataset.scale), E = c.dataset.startRotation ? parseFloat(c.dataset.startRotation) : f, v = c.dataset.startScale ? parseFloat(c.dataset.startScale) : m, w = this.entryAnimationEngine.getTiming();
|
|
3061
3140
|
se({
|
|
3062
3141
|
element: c,
|
|
3063
|
-
startPosition:
|
|
3064
|
-
endPosition:
|
|
3142
|
+
startPosition: u,
|
|
3143
|
+
endPosition: g,
|
|
3065
3144
|
pathConfig: this.entryAnimationEngine.getPathConfig(),
|
|
3066
3145
|
duration: w.duration,
|
|
3067
|
-
imageWidth:
|
|
3068
|
-
imageHeight:
|
|
3069
|
-
rotation:
|
|
3146
|
+
imageWidth: p,
|
|
3147
|
+
imageHeight: y,
|
|
3148
|
+
rotation: f,
|
|
3070
3149
|
scale: m,
|
|
3071
3150
|
rotationConfig: this.entryAnimationEngine.getRotationConfig(),
|
|
3072
|
-
startRotation:
|
|
3151
|
+
startRotation: E,
|
|
3073
3152
|
scaleConfig: this.entryAnimationEngine.getScaleConfig(),
|
|
3074
3153
|
startScale: v
|
|
3075
3154
|
});
|
|
3076
3155
|
} else {
|
|
3077
|
-
const
|
|
3078
|
-
c.style.transform =
|
|
3156
|
+
const u = c.dataset.finalTransform || "";
|
|
3157
|
+
c.style.transform = u;
|
|
3079
3158
|
}
|
|
3080
3159
|
const l = parseInt(c.dataset.imageId || "0");
|
|
3081
3160
|
if (this.fullConfig.config.debug?.enabled && l < 3) {
|
|
3082
|
-
const
|
|
3161
|
+
const u = c.dataset.finalTransform || "";
|
|
3083
3162
|
console.log(`Image ${l} final state:`, {
|
|
3084
3163
|
left: c.style.left,
|
|
3085
3164
|
top: c.style.top,
|
|
@@ -3087,7 +3166,7 @@ let Ue = class {
|
|
|
3087
3166
|
height: c.style.height,
|
|
3088
3167
|
computedWidth: c.offsetWidth,
|
|
3089
3168
|
computedHeight: c.offsetHeight,
|
|
3090
|
-
transform:
|
|
3169
|
+
transform: u,
|
|
3091
3170
|
pathType: this.entryAnimationEngine.getPathType()
|
|
3092
3171
|
});
|
|
3093
3172
|
}
|
|
@@ -3096,7 +3175,7 @@ let Ue = class {
|
|
|
3096
3175
|
if (this.logDebug("Starting queue processing, enabled:", this.fullConfig.animation.queue.enabled), !this.fullConfig.animation.queue.enabled) {
|
|
3097
3176
|
for (; this.displayQueue.length > 0; ) {
|
|
3098
3177
|
const c = this.displayQueue.shift();
|
|
3099
|
-
c &&
|
|
3178
|
+
c && s(c);
|
|
3100
3179
|
}
|
|
3101
3180
|
return;
|
|
3102
3181
|
}
|
|
@@ -3107,70 +3186,76 @@ let Ue = class {
|
|
|
3107
3186
|
}
|
|
3108
3187
|
if (this.displayQueue.length > 0) {
|
|
3109
3188
|
const c = this.displayQueue.shift();
|
|
3110
|
-
c &&
|
|
3189
|
+
c && s(c);
|
|
3111
3190
|
}
|
|
3112
3191
|
r >= t.length && this.displayQueue.length === 0 && this.queueInterval !== null && (clearInterval(this.queueInterval), this.queueInterval = null);
|
|
3113
3192
|
}, this.fullConfig.animation.queue.interval);
|
|
3114
3193
|
};
|
|
3115
3194
|
if ("IntersectionObserver" in window && this.containerEl) {
|
|
3116
|
-
const c = new IntersectionObserver((
|
|
3117
|
-
|
|
3195
|
+
const c = new IntersectionObserver((d) => {
|
|
3196
|
+
d.forEach((l) => {
|
|
3118
3197
|
l.isIntersecting && (h(), c.disconnect());
|
|
3119
3198
|
});
|
|
3120
3199
|
}, { threshold: 0.1, rootMargin: "50px" });
|
|
3121
3200
|
c.observe(this.containerEl);
|
|
3122
3201
|
} else
|
|
3123
3202
|
h();
|
|
3124
|
-
this.fullConfig.config.debug?.centers && this.containerEl && (this.containerEl.querySelectorAll(".fbn-ic-debug-center").forEach((c) => c.remove()),
|
|
3203
|
+
this.fullConfig.config.debug?.centers && this.containerEl && (this.containerEl.querySelectorAll(".fbn-ic-debug-center").forEach((c) => c.remove()), a.forEach((c, d) => {
|
|
3125
3204
|
const l = document.createElement("div");
|
|
3126
3205
|
l.className = "fbn-ic-debug-center", l.style.position = "absolute", l.style.width = "12px", l.style.height = "12px", l.style.borderRadius = "50%", l.style.backgroundColor = "red", l.style.border = "2px solid yellow", l.style.zIndex = "9999", l.style.pointerEvents = "none";
|
|
3127
|
-
const
|
|
3128
|
-
l.style.left = `${
|
|
3129
|
-
})), t.forEach((c,
|
|
3206
|
+
const u = c.x, g = c.y;
|
|
3207
|
+
l.style.left = `${u - 6}px`, l.style.top = `${g - 6}px`, l.title = `Image ${d}: center (${Math.round(u)}, ${Math.round(g)})`, this.containerEl.appendChild(l);
|
|
3208
|
+
})), t.forEach((c, d) => {
|
|
3130
3209
|
const l = document.createElement("img");
|
|
3131
|
-
l.referrerPolicy = "no-referrer", l.classList.add("fbn-ic-image"), l.dataset.imageId = String(
|
|
3132
|
-
const
|
|
3133
|
-
l.style.position = "absolute", l.style.width = "auto", l.style.height = `${e}px`, l.style.left = `${
|
|
3134
|
-
this.hoveredImage = { element: l, layout:
|
|
3210
|
+
l.referrerPolicy = "no-referrer", l.classList.add("fbn-ic-image"), l.dataset.imageId = String(d), l.dataset.createdFlag = "true";
|
|
3211
|
+
const u = a[d];
|
|
3212
|
+
l.style.position = "absolute", l.style.width = "auto", l.style.height = `${e}px`, l.style.left = `${u.x}px`, l.style.top = `${u.y}px`, u.zIndex && (l.style.zIndex = String(u.zIndex)), nt(l, this.defaultClassName), l.addEventListener("mouseenter", () => {
|
|
3213
|
+
if (this.hoveredImage = { element: l, layout: u }, !this.zoomEngine.isInvolved(l)) {
|
|
3214
|
+
const g = l.cachedRenderedWidth;
|
|
3215
|
+
ut(l, this.fullConfig.styling?.hover, e, g), nt(l, this.hoverClassName);
|
|
3216
|
+
}
|
|
3135
3217
|
}), l.addEventListener("mouseleave", () => {
|
|
3136
|
-
this.hoveredImage = null, this.zoomEngine.isInvolved(l)
|
|
3137
|
-
|
|
3138
|
-
|
|
3218
|
+
if (this.hoveredImage = null, !this.zoomEngine.isInvolved(l)) {
|
|
3219
|
+
const g = l.cachedRenderedWidth;
|
|
3220
|
+
ut(l, this.fullConfig.styling?.default, e, g), ft(l, this.hoverClassName), nt(l, this.defaultClassName);
|
|
3221
|
+
}
|
|
3222
|
+
}), l.addEventListener("click", (g) => {
|
|
3223
|
+
g.stopPropagation(), this.handleImageClick(l, u);
|
|
3139
3224
|
}), l.style.opacity = "0", l.style.transition = this.entryAnimationEngine.getTransitionCSS(), l.onload = () => {
|
|
3140
3225
|
if (o !== this.loadGeneration)
|
|
3141
3226
|
return;
|
|
3142
|
-
const
|
|
3143
|
-
l.style.width = `${
|
|
3144
|
-
const
|
|
3145
|
-
|
|
3146
|
-
|
|
3227
|
+
const g = l.naturalWidth / l.naturalHeight, p = e * g;
|
|
3228
|
+
l.dataset.onloadCalled = "true", window.DEBUG_CLIPPATH && console.log(`[onload #${d}] Called with imageHeight=${e}, renderedWidth=${p}`), l.style.width = `${p}px`, l.cachedRenderedWidth = p, l.aspectRatio = g, ut(l, this.fullConfig.styling?.default, e, p);
|
|
3229
|
+
const y = { x: u.x, y: u.y }, f = { width: p, height: e }, m = this.entryAnimationEngine.calculateStartPosition(
|
|
3230
|
+
y,
|
|
3231
|
+
f,
|
|
3147
3232
|
i,
|
|
3148
|
-
|
|
3233
|
+
d,
|
|
3149
3234
|
t.length
|
|
3150
|
-
),
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3235
|
+
), E = this.entryAnimationEngine.calculateStartRotation(u.rotation), v = this.entryAnimationEngine.calculateStartScale(u.scale), w = this.entryAnimationEngine.buildFinalTransform(
|
|
3236
|
+
u.rotation,
|
|
3237
|
+
u.scale,
|
|
3238
|
+
p,
|
|
3154
3239
|
e
|
|
3155
|
-
),
|
|
3240
|
+
), S = this.entryAnimationEngine.buildStartTransform(
|
|
3156
3241
|
m,
|
|
3242
|
+
y,
|
|
3243
|
+
u.rotation,
|
|
3244
|
+
u.scale,
|
|
3157
3245
|
p,
|
|
3158
|
-
d.rotation,
|
|
3159
|
-
d.scale,
|
|
3160
|
-
b,
|
|
3161
3246
|
e,
|
|
3162
|
-
|
|
3247
|
+
E,
|
|
3163
3248
|
v
|
|
3164
3249
|
);
|
|
3165
|
-
this.fullConfig.config.debug?.enabled &&
|
|
3166
|
-
finalPosition:
|
|
3167
|
-
imageSize:
|
|
3168
|
-
left:
|
|
3169
|
-
top:
|
|
3250
|
+
this.fullConfig.config.debug?.enabled && d < 3 && console.log(`Image ${d}:`, {
|
|
3251
|
+
finalPosition: y,
|
|
3252
|
+
imageSize: f,
|
|
3253
|
+
left: u.x,
|
|
3254
|
+
top: u.y,
|
|
3170
3255
|
finalTransform: w,
|
|
3171
|
-
renderedWidth:
|
|
3256
|
+
renderedWidth: p,
|
|
3172
3257
|
renderedHeight: e
|
|
3173
|
-
}), l.style.transform =
|
|
3258
|
+
}), l.style.transform = S, l.dataset.finalTransform = w, (this.entryAnimationEngine.requiresJSAnimation() || this.entryAnimationEngine.requiresJSRotation() || this.entryAnimationEngine.requiresJSScale() || E !== u.rotation || v !== u.scale) && (l.dataset.startX = String(m.x), l.dataset.startY = String(m.y), l.dataset.endX = String(y.x), l.dataset.endY = String(y.y), l.dataset.imageWidth = String(p), l.dataset.imageHeight = String(e), l.dataset.rotation = String(u.rotation), l.dataset.scale = String(u.scale), l.dataset.startRotation = String(E), l.dataset.startScale = String(v)), this.displayQueue.push(l);
|
|
3174
3259
|
}, l.onerror = () => r++, l.src = c;
|
|
3175
3260
|
});
|
|
3176
3261
|
}
|
|
@@ -3183,8 +3268,8 @@ let Ue = class {
|
|
|
3183
3268
|
if (i)
|
|
3184
3269
|
await this.zoomEngine.unfocusImage(), this.currentFocusIndex = null, this.swipeEngine?.disable(), this.hideCounter();
|
|
3185
3270
|
else {
|
|
3186
|
-
const
|
|
3187
|
-
this.currentFocusIndex =
|
|
3271
|
+
const a = t.dataset.imageId;
|
|
3272
|
+
this.currentFocusIndex = a !== void 0 ? parseInt(a, 10) : null, this.swipeEngine?.enable(), await this.zoomEngine.focusImage(t, o, e), this.currentFocusIndex !== null && this.updateCounter(this.currentFocusIndex);
|
|
3188
3273
|
}
|
|
3189
3274
|
}
|
|
3190
3275
|
/**
|
|
@@ -3215,28 +3300,28 @@ let Ue = class {
|
|
|
3215
3300
|
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();
|
|
3216
3301
|
}
|
|
3217
3302
|
};
|
|
3218
|
-
const
|
|
3303
|
+
const Ge = Pt(
|
|
3219
3304
|
function({ className: t, style: e, ...i }, o) {
|
|
3220
|
-
const
|
|
3305
|
+
const a = xt(null), r = xt(null);
|
|
3221
3306
|
return Ut(o, () => ({
|
|
3222
3307
|
get instance() {
|
|
3223
3308
|
return r.current;
|
|
3224
3309
|
}
|
|
3225
3310
|
})), _t(() => {
|
|
3226
|
-
if (!
|
|
3227
|
-
const
|
|
3228
|
-
container:
|
|
3311
|
+
if (!a.current) return;
|
|
3312
|
+
const s = new Ne({
|
|
3313
|
+
container: a.current,
|
|
3229
3314
|
...i
|
|
3230
3315
|
});
|
|
3231
|
-
return r.current =
|
|
3316
|
+
return r.current = s, s.init().catch((h) => {
|
|
3232
3317
|
console.error("ImageCloud init failed:", h);
|
|
3233
3318
|
}), () => {
|
|
3234
|
-
|
|
3319
|
+
s.destroy(), r.current = null;
|
|
3235
3320
|
};
|
|
3236
|
-
}, [JSON.stringify(i)]), /* @__PURE__ */
|
|
3321
|
+
}, [JSON.stringify(i)]), /* @__PURE__ */ Ot("div", { ref: a, className: t, style: e });
|
|
3237
3322
|
}
|
|
3238
3323
|
);
|
|
3239
3324
|
export {
|
|
3240
|
-
|
|
3325
|
+
Ge as ImageCloud
|
|
3241
3326
|
};
|
|
3242
3327
|
//# sourceMappingURL=react.js.map
|