@frybynite/image-cloud 0.8.2 → 0.9.0
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 +527 -299
- package/dist/image-cloud-auto-init.js.map +1 -1
- package/dist/image-cloud.js +462 -234
- 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 +53 -0
- package/dist/react.d.ts +53 -0
- package/dist/react.js +462 -234
- package/dist/react.js.map +1 -1
- package/dist/vue.d.ts +53 -0
- package/dist/vue.js +463 -235
- package/dist/vue.js.map +1 -1
- package/dist/web-component.d.ts +53 -0
- package/dist/web-component.js +820 -592
- package/dist/web-component.js.map +1 -1
- package/package.json +1 -1
package/dist/web-component.js
CHANGED
|
@@ -22,9 +22,9 @@ const mt = Object.freeze({
|
|
|
22
22
|
type: "linear"
|
|
23
23
|
}), wt = Object.freeze({
|
|
24
24
|
mode: "none"
|
|
25
|
-
}),
|
|
25
|
+
}), Et = Object.freeze({
|
|
26
26
|
mode: "none"
|
|
27
|
-
}),
|
|
27
|
+
}), Ot = Object.freeze({
|
|
28
28
|
default: Object.freeze({
|
|
29
29
|
border: Object.freeze({
|
|
30
30
|
width: 0,
|
|
@@ -50,7 +50,7 @@ const mt = Object.freeze({
|
|
|
50
50
|
focused: Object.freeze({
|
|
51
51
|
shadow: "none"
|
|
52
52
|
})
|
|
53
|
-
}),
|
|
53
|
+
}), kt = Object.freeze({
|
|
54
54
|
tightness: 1
|
|
55
55
|
}), Nt = Object.freeze({
|
|
56
56
|
rows: 1,
|
|
@@ -61,10 +61,10 @@ const mt = Object.freeze({
|
|
|
61
61
|
// Note: Image rotation along wave is now controlled via image.rotation.mode = 'tangent'
|
|
62
62
|
}), jt = Object.freeze({
|
|
63
63
|
spacing: 0
|
|
64
|
-
}),
|
|
64
|
+
}), Wt = Object.freeze({
|
|
65
65
|
mobile: Object.freeze({ maxWidth: 767 }),
|
|
66
66
|
tablet: Object.freeze({ maxWidth: 1199 })
|
|
67
|
-
}),
|
|
67
|
+
}), Gt = Object.freeze({
|
|
68
68
|
mode: "adaptive",
|
|
69
69
|
// Default to adaptive sizing
|
|
70
70
|
minSize: 50,
|
|
@@ -76,40 +76,40 @@ const mt = Object.freeze({
|
|
|
76
76
|
// No variance by default
|
|
77
77
|
max: 1
|
|
78
78
|
})
|
|
79
|
-
}),
|
|
79
|
+
}), qt = Object.freeze({
|
|
80
80
|
mode: "none",
|
|
81
81
|
range: Object.freeze({
|
|
82
82
|
min: -15,
|
|
83
83
|
max: 15
|
|
84
84
|
})
|
|
85
|
-
}),
|
|
86
|
-
sizing:
|
|
87
|
-
rotation:
|
|
85
|
+
}), zt = Object.freeze({
|
|
86
|
+
sizing: Gt,
|
|
87
|
+
rotation: qt
|
|
88
88
|
}), Dt = Object.freeze({
|
|
89
89
|
validateUrls: !0,
|
|
90
90
|
validationTimeout: 5e3,
|
|
91
91
|
validationMethod: "head",
|
|
92
92
|
allowedExtensions: ["jpg", "jpeg", "png", "gif", "webp", "bmp"]
|
|
93
|
-
}),
|
|
93
|
+
}), _t = Object.freeze({
|
|
94
94
|
enabled: !1,
|
|
95
95
|
centers: !1,
|
|
96
96
|
loaders: !1
|
|
97
|
-
}),
|
|
97
|
+
}), Bt = Object.freeze({ maxAngle: 5, speed: 2e3, sync: "random" }), Xt = Object.freeze({ minScale: 0.95, maxScale: 1.05, speed: 2400, sync: "random" }), Yt = Object.freeze({ onRatio: 0.7, speed: 3e3, style: "snap" }), Jt = Object.freeze({ speed: 4e3, direction: "clockwise" }), $t = Object.freeze({ type: "none" }), x = Object.freeze({
|
|
98
98
|
// Loader configuration (always an array, composite behavior is implicit)
|
|
99
99
|
loaders: [],
|
|
100
100
|
// Shared loader settings and debug config
|
|
101
101
|
config: Object.freeze({
|
|
102
102
|
loaders: Dt,
|
|
103
|
-
debug:
|
|
103
|
+
debug: _t
|
|
104
104
|
}),
|
|
105
105
|
// Image sizing and rotation configuration
|
|
106
|
-
image:
|
|
106
|
+
image: zt,
|
|
107
107
|
// Pattern-based layout configuration
|
|
108
108
|
layout: Object.freeze({
|
|
109
109
|
algorithm: "radial",
|
|
110
110
|
scaleDecay: 0,
|
|
111
111
|
// No decay by default (0-1 for radial/spiral)
|
|
112
|
-
responsive:
|
|
112
|
+
responsive: Wt,
|
|
113
113
|
targetCoverage: 0.6,
|
|
114
114
|
// Target 60% of container area
|
|
115
115
|
densityFactor: 1,
|
|
@@ -167,8 +167,9 @@ const mt = Object.freeze({
|
|
|
167
167
|
// smooth deceleration
|
|
168
168
|
path: vt,
|
|
169
169
|
rotation: wt,
|
|
170
|
-
scale:
|
|
171
|
-
})
|
|
170
|
+
scale: Et
|
|
171
|
+
}),
|
|
172
|
+
idle: $t
|
|
172
173
|
}),
|
|
173
174
|
// Pattern-based interaction configuration
|
|
174
175
|
interaction: Object.freeze({
|
|
@@ -212,50 +213,50 @@ const mt = Object.freeze({
|
|
|
212
213
|
})
|
|
213
214
|
}),
|
|
214
215
|
// Image styling
|
|
215
|
-
styling:
|
|
216
|
+
styling: Ot
|
|
216
217
|
});
|
|
217
|
-
function Z(
|
|
218
|
-
if (!
|
|
219
|
-
if (!t) return { ...
|
|
220
|
-
const i = { ...
|
|
221
|
-
return t.border !== void 0 && (i.border = { ...
|
|
218
|
+
function Z(o, t) {
|
|
219
|
+
if (!o) return t || {};
|
|
220
|
+
if (!t) return { ...o };
|
|
221
|
+
const i = { ...o };
|
|
222
|
+
return t.border !== void 0 && (i.border = { ...o.border, ...t.border }), t.borderTop !== void 0 && (i.borderTop = { ...o.borderTop, ...t.borderTop }), t.borderRight !== void 0 && (i.borderRight = { ...o.borderRight, ...t.borderRight }), t.borderBottom !== void 0 && (i.borderBottom = { ...o.borderBottom, ...t.borderBottom }), t.borderLeft !== void 0 && (i.borderLeft = { ...o.borderLeft, ...t.borderLeft }), t.filter !== void 0 && (i.filter = { ...o.filter, ...t.filter }), t.outline !== void 0 && (i.outline = { ...o.outline, ...t.outline }), t.shadow !== void 0 && (i.shadow = t.shadow), t.clipPath !== void 0 && (i.clipPath = t.clipPath), t.opacity !== void 0 && (i.opacity = t.opacity), t.cursor !== void 0 && (i.cursor = t.cursor), t.className !== void 0 && (i.className = t.className), t.objectFit !== void 0 && (i.objectFit = t.objectFit), t.aspectRatio !== void 0 && (i.aspectRatio = t.aspectRatio), t.borderRadiusTopLeft !== void 0 && (i.borderRadiusTopLeft = t.borderRadiusTopLeft), t.borderRadiusTopRight !== void 0 && (i.borderRadiusTopRight = t.borderRadiusTopRight), t.borderRadiusBottomRight !== void 0 && (i.borderRadiusBottomRight = t.borderRadiusBottomRight), t.borderRadiusBottomLeft !== void 0 && (i.borderRadiusBottomLeft = t.borderRadiusBottomLeft), i;
|
|
222
223
|
}
|
|
223
|
-
function
|
|
224
|
-
if (!t) return { ...
|
|
225
|
-
const i = Z(
|
|
226
|
-
Z(i,
|
|
224
|
+
function Vt(o, t) {
|
|
225
|
+
if (!t) return { ...o };
|
|
226
|
+
const i = Z(o.default, t.default), e = Z(
|
|
227
|
+
Z(i, o.hover),
|
|
227
228
|
t.hover
|
|
228
|
-
),
|
|
229
|
-
Z(i,
|
|
229
|
+
), n = Z(
|
|
230
|
+
Z(i, o.focused),
|
|
230
231
|
t.focused
|
|
231
232
|
);
|
|
232
233
|
return {
|
|
233
234
|
default: i,
|
|
234
235
|
hover: e,
|
|
235
|
-
focused:
|
|
236
|
+
focused: n
|
|
236
237
|
};
|
|
237
238
|
}
|
|
238
|
-
function
|
|
239
|
-
if (!t) return { ...
|
|
240
|
-
const i = { ...
|
|
239
|
+
function Kt(o, t) {
|
|
240
|
+
if (!t) return { ...o };
|
|
241
|
+
const i = { ...o };
|
|
241
242
|
if (t.sizing !== void 0 && (i.sizing = {
|
|
242
|
-
...
|
|
243
|
+
...o.sizing,
|
|
243
244
|
...t.sizing
|
|
244
245
|
}, t.sizing.variance)) {
|
|
245
|
-
const e = t.sizing.variance,
|
|
246
|
-
i.sizing.variance = { min:
|
|
246
|
+
const e = t.sizing.variance, n = e.min !== void 0 && e.min >= 0.25 && e.min <= 1 ? e.min : o.sizing?.variance?.min ?? 1, a = e.max !== void 0 && e.max >= 1 && e.max <= 1.75 ? e.max : o.sizing?.variance?.max ?? 1;
|
|
247
|
+
i.sizing.variance = { min: n, max: a };
|
|
247
248
|
}
|
|
248
249
|
if (t.rotation !== void 0 && (i.rotation = {
|
|
249
|
-
...
|
|
250
|
+
...o.rotation,
|
|
250
251
|
...t.rotation
|
|
251
252
|
}, t.rotation.range)) {
|
|
252
|
-
const e = t.rotation.range,
|
|
253
|
-
i.rotation.range = { min:
|
|
253
|
+
const e = t.rotation.range, n = e.min !== void 0 && e.min >= -180 && e.min <= 0 ? e.min : o.rotation?.range?.min ?? -15, a = e.max !== void 0 && e.max >= 0 && e.max <= 180 ? e.max : o.rotation?.range?.max ?? 15;
|
|
254
|
+
i.rotation.range = { min: n, max: a };
|
|
254
255
|
}
|
|
255
256
|
return i;
|
|
256
257
|
}
|
|
257
|
-
function
|
|
258
|
-
const t =
|
|
258
|
+
function Zt(o) {
|
|
259
|
+
const t = o.layout?.rotation;
|
|
259
260
|
if (t && "enabled" in t)
|
|
260
261
|
return {
|
|
261
262
|
rotation: {
|
|
@@ -264,8 +265,8 @@ function Yt(n) {
|
|
|
264
265
|
}
|
|
265
266
|
};
|
|
266
267
|
}
|
|
267
|
-
function
|
|
268
|
-
const t =
|
|
268
|
+
function Qt(o) {
|
|
269
|
+
const t = o.layout?.sizing?.variance;
|
|
269
270
|
if (t)
|
|
270
271
|
return {
|
|
271
272
|
sizing: {
|
|
@@ -275,98 +276,101 @@ function Bt(n) {
|
|
|
275
276
|
}
|
|
276
277
|
};
|
|
277
278
|
}
|
|
278
|
-
function
|
|
279
|
-
const t =
|
|
280
|
-
let e =
|
|
279
|
+
function te(o = {}) {
|
|
280
|
+
const t = Zt(o), i = Qt(o);
|
|
281
|
+
let e = o.image;
|
|
281
282
|
(t || i) && (e = {
|
|
282
283
|
...i || {},
|
|
283
284
|
...t || {},
|
|
284
285
|
...e
|
|
285
|
-
}, e.rotation && t?.rotation &&
|
|
286
|
+
}, e.rotation && t?.rotation && o.image?.rotation && (e.rotation = {
|
|
286
287
|
...t.rotation,
|
|
287
|
-
...
|
|
288
|
+
...o.image.rotation
|
|
288
289
|
}));
|
|
289
|
-
const
|
|
290
|
-
|
|
290
|
+
const n = [...o.loaders ?? []];
|
|
291
|
+
o.images && o.images.length > 0 && n.unshift({
|
|
291
292
|
static: {
|
|
292
|
-
sources: [{ urls:
|
|
293
|
+
sources: [{ urls: o.images }]
|
|
293
294
|
}
|
|
294
295
|
});
|
|
295
296
|
const r = {
|
|
296
297
|
loaders: {
|
|
297
298
|
...Dt,
|
|
298
|
-
...
|
|
299
|
+
...o.config?.loaders ?? {}
|
|
299
300
|
}
|
|
300
301
|
}, s = {
|
|
301
|
-
loaders:
|
|
302
|
+
loaders: n,
|
|
302
303
|
config: r,
|
|
303
|
-
image:
|
|
304
|
-
layout: { ...
|
|
305
|
-
animation: { ...
|
|
306
|
-
interaction: { ...
|
|
307
|
-
rendering: { ...
|
|
308
|
-
styling:
|
|
304
|
+
image: Kt(zt, e),
|
|
305
|
+
layout: { ...x.layout },
|
|
306
|
+
animation: { ...x.animation },
|
|
307
|
+
interaction: { ...x.interaction },
|
|
308
|
+
rendering: { ...x.rendering },
|
|
309
|
+
styling: Vt(Ot, o.styling)
|
|
309
310
|
};
|
|
310
|
-
if (
|
|
311
|
-
...
|
|
312
|
-
...
|
|
313
|
-
},
|
|
314
|
-
...
|
|
315
|
-
mobile:
|
|
316
|
-
tablet:
|
|
317
|
-
}),
|
|
318
|
-
...
|
|
319
|
-
...
|
|
320
|
-
})),
|
|
321
|
-
...
|
|
322
|
-
...
|
|
323
|
-
},
|
|
324
|
-
...
|
|
325
|
-
...
|
|
326
|
-
}),
|
|
327
|
-
...
|
|
328
|
-
...
|
|
329
|
-
}),
|
|
330
|
-
...
|
|
331
|
-
...
|
|
332
|
-
}),
|
|
333
|
-
...
|
|
334
|
-
...
|
|
335
|
-
start:
|
|
336
|
-
...
|
|
337
|
-
...
|
|
338
|
-
circular:
|
|
339
|
-
} :
|
|
340
|
-
timing:
|
|
341
|
-
path:
|
|
342
|
-
rotation:
|
|
343
|
-
scale:
|
|
344
|
-
})
|
|
345
|
-
...E.interaction,
|
|
346
|
-
...n.interaction
|
|
347
|
-
}, n.interaction.focus && (s.interaction.focus = {
|
|
348
|
-
...E.interaction.focus,
|
|
349
|
-
...n.interaction.focus
|
|
350
|
-
}), n.interaction.navigation && (s.interaction.navigation = {
|
|
351
|
-
...E.interaction.navigation,
|
|
352
|
-
...n.interaction.navigation
|
|
353
|
-
}), n.interaction.gestures && (s.interaction.gestures = {
|
|
354
|
-
...E.interaction.gestures,
|
|
355
|
-
...n.interaction.gestures
|
|
356
|
-
})), n.rendering && (s.rendering = {
|
|
357
|
-
...E.rendering,
|
|
358
|
-
...n.rendering
|
|
359
|
-
}, n.rendering.responsive && (s.rendering.responsive = {
|
|
360
|
-
...E.rendering.responsive,
|
|
361
|
-
...n.rendering.responsive,
|
|
362
|
-
breakpoints: n.rendering.responsive.breakpoints ? { ...E.rendering.responsive.breakpoints, ...n.rendering.responsive.breakpoints } : E.rendering.responsive.breakpoints,
|
|
363
|
-
mobileDetection: n.rendering.responsive.mobileDetection ? n.rendering.responsive.mobileDetection : E.rendering.responsive.mobileDetection
|
|
364
|
-
}), n.rendering.ui && (s.rendering.ui = {
|
|
365
|
-
...E.rendering.ui,
|
|
366
|
-
...n.rendering.ui
|
|
367
|
-
})), s.config.debug = {
|
|
311
|
+
if (o.layout && (s.layout = {
|
|
312
|
+
...x.layout,
|
|
313
|
+
...o.layout
|
|
314
|
+
}, o.layout.responsive && (s.layout.responsive = {
|
|
315
|
+
...x.layout.responsive,
|
|
316
|
+
mobile: o.layout.responsive.mobile ? { ...x.layout.responsive.mobile, ...o.layout.responsive.mobile } : x.layout.responsive.mobile,
|
|
317
|
+
tablet: o.layout.responsive.tablet ? { ...x.layout.responsive.tablet, ...o.layout.responsive.tablet } : x.layout.responsive.tablet
|
|
318
|
+
}), o.layout.spacing && (s.layout.spacing = {
|
|
319
|
+
...x.layout.spacing,
|
|
320
|
+
...o.layout.spacing
|
|
321
|
+
})), o.animation && (s.animation = {
|
|
322
|
+
...x.animation,
|
|
323
|
+
...o.animation
|
|
324
|
+
}, o.animation.easing && (s.animation.easing = {
|
|
325
|
+
...x.animation.easing,
|
|
326
|
+
...o.animation.easing
|
|
327
|
+
}), o.animation.queue && (s.animation.queue = {
|
|
328
|
+
...x.animation.queue,
|
|
329
|
+
...o.animation.queue
|
|
330
|
+
}), o.animation.performance && (s.animation.performance = {
|
|
331
|
+
...x.animation.performance,
|
|
332
|
+
...o.animation.performance
|
|
333
|
+
}), o.animation.entry && (s.animation.entry = {
|
|
334
|
+
...x.animation.entry,
|
|
335
|
+
...o.animation.entry,
|
|
336
|
+
start: o.animation.entry.start ? {
|
|
337
|
+
...x.animation.entry.start,
|
|
338
|
+
...o.animation.entry.start,
|
|
339
|
+
circular: o.animation.entry.start.circular ? { ...x.animation.entry.start.circular, ...o.animation.entry.start.circular } : x.animation.entry.start.circular
|
|
340
|
+
} : x.animation.entry.start,
|
|
341
|
+
timing: o.animation.entry.timing ? { ...x.animation.entry.timing, ...o.animation.entry.timing } : x.animation.entry.timing,
|
|
342
|
+
path: o.animation.entry.path ? { ...vt, ...o.animation.entry.path } : x.animation.entry.path,
|
|
343
|
+
rotation: o.animation.entry.rotation ? { ...wt, ...o.animation.entry.rotation } : x.animation.entry.rotation,
|
|
344
|
+
scale: o.animation.entry.scale ? { ...Et, ...o.animation.entry.scale } : x.animation.entry.scale
|
|
345
|
+
}), o.animation.idle && (s.animation.idle = {
|
|
368
346
|
...$t,
|
|
369
|
-
...
|
|
347
|
+
...o.animation.idle
|
|
348
|
+
})), o.interaction && (s.interaction = {
|
|
349
|
+
...x.interaction,
|
|
350
|
+
...o.interaction
|
|
351
|
+
}, o.interaction.focus && (s.interaction.focus = {
|
|
352
|
+
...x.interaction.focus,
|
|
353
|
+
...o.interaction.focus
|
|
354
|
+
}), o.interaction.navigation && (s.interaction.navigation = {
|
|
355
|
+
...x.interaction.navigation,
|
|
356
|
+
...o.interaction.navigation
|
|
357
|
+
}), o.interaction.gestures && (s.interaction.gestures = {
|
|
358
|
+
...x.interaction.gestures,
|
|
359
|
+
...o.interaction.gestures
|
|
360
|
+
})), o.rendering && (s.rendering = {
|
|
361
|
+
...x.rendering,
|
|
362
|
+
...o.rendering
|
|
363
|
+
}, o.rendering.responsive && (s.rendering.responsive = {
|
|
364
|
+
...x.rendering.responsive,
|
|
365
|
+
...o.rendering.responsive,
|
|
366
|
+
breakpoints: o.rendering.responsive.breakpoints ? { ...x.rendering.responsive.breakpoints, ...o.rendering.responsive.breakpoints } : x.rendering.responsive.breakpoints,
|
|
367
|
+
mobileDetection: o.rendering.responsive.mobileDetection ? o.rendering.responsive.mobileDetection : x.rendering.responsive.mobileDetection
|
|
368
|
+
}), o.rendering.ui && (s.rendering.ui = {
|
|
369
|
+
...x.rendering.ui,
|
|
370
|
+
...o.rendering.ui
|
|
371
|
+
})), s.config.debug = {
|
|
372
|
+
..._t,
|
|
373
|
+
...o.config?.debug ?? {}
|
|
370
374
|
}, s.layout.algorithm === "honeycomb" && s.styling) {
|
|
371
375
|
const c = { shape: "hexagon", mode: "height-relative" };
|
|
372
376
|
s.styling = {
|
|
@@ -378,16 +382,16 @@ function Jt(n = {}) {
|
|
|
378
382
|
}
|
|
379
383
|
return s;
|
|
380
384
|
}
|
|
381
|
-
function
|
|
382
|
-
return { ...
|
|
385
|
+
function ee(o, t) {
|
|
386
|
+
return { ...o ? Tt[o] : Tt.playful, ...t };
|
|
383
387
|
}
|
|
384
|
-
function
|
|
385
|
-
return { ...
|
|
388
|
+
function ie(o, t) {
|
|
389
|
+
return { ...o ? At[o] : At.gentle, ...t };
|
|
386
390
|
}
|
|
387
|
-
function
|
|
388
|
-
return { ...
|
|
391
|
+
function ne(o, t) {
|
|
392
|
+
return { ...o ? Ct[o] : Ct.gentle, ...t };
|
|
389
393
|
}
|
|
390
|
-
class
|
|
394
|
+
class oe {
|
|
391
395
|
constructor(t) {
|
|
392
396
|
this.activeAnimations = /* @__PURE__ */ new Map(), this.animationIdCounter = 0, this.config = t;
|
|
393
397
|
}
|
|
@@ -398,8 +402,8 @@ class Qt {
|
|
|
398
402
|
buildTransformString(t) {
|
|
399
403
|
const i = ["translate(-50%, -50%)"];
|
|
400
404
|
if (t.x !== void 0 || t.y !== void 0) {
|
|
401
|
-
const e = t.x ?? 0,
|
|
402
|
-
i.push(`translate(${e}px, ${
|
|
405
|
+
const e = t.x ?? 0, n = t.y ?? 0;
|
|
406
|
+
i.push(`translate(${e}px, ${n}px)`);
|
|
403
407
|
}
|
|
404
408
|
return t.rotation !== void 0 && i.push(`rotate(${t.rotation}deg)`), t.scale !== void 0 && i.push(`scale(${t.scale})`), i.join(" ");
|
|
405
409
|
}
|
|
@@ -412,9 +416,9 @@ class Qt {
|
|
|
412
416
|
* @param easing - CSS easing function (optional)
|
|
413
417
|
* @returns AnimationHandle that can be used to cancel or query the animation
|
|
414
418
|
*/
|
|
415
|
-
animateTransformCancellable(t, i, e,
|
|
419
|
+
animateTransformCancellable(t, i, e, n = null, a = null) {
|
|
416
420
|
this.cancelAllAnimations(t);
|
|
417
|
-
const r =
|
|
421
|
+
const r = n ?? this.config.duration, s = a ?? this.config.easing.default, c = this.buildTransformString(i), l = this.buildTransformString(e);
|
|
418
422
|
t.style.transition = "none";
|
|
419
423
|
const u = t.animate(
|
|
420
424
|
[
|
|
@@ -451,13 +455,13 @@ class Qt {
|
|
|
451
455
|
cancelAnimation(t, i = !0) {
|
|
452
456
|
const e = this.getCurrentTransform(t.element);
|
|
453
457
|
if (t.animation.cancel(), i) {
|
|
454
|
-
const
|
|
458
|
+
const n = this.buildTransformString({
|
|
455
459
|
x: e.x,
|
|
456
460
|
y: e.y,
|
|
457
461
|
rotation: e.rotation,
|
|
458
462
|
scale: e.scale
|
|
459
463
|
});
|
|
460
|
-
t.element.style.transform =
|
|
464
|
+
t.element.style.transform = n;
|
|
461
465
|
}
|
|
462
466
|
return this.activeAnimations.delete(t.element), e;
|
|
463
467
|
}
|
|
@@ -470,8 +474,8 @@ class Qt {
|
|
|
470
474
|
const i = this.activeAnimations.get(t);
|
|
471
475
|
i && this.cancelAnimation(i, !1);
|
|
472
476
|
const e = t.getAnimations();
|
|
473
|
-
for (const
|
|
474
|
-
|
|
477
|
+
for (const n of e)
|
|
478
|
+
n.cancel();
|
|
475
479
|
}
|
|
476
480
|
/**
|
|
477
481
|
* Get current transform state of an element (works mid-animation)
|
|
@@ -483,7 +487,7 @@ class Qt {
|
|
|
483
487
|
const e = getComputedStyle(t).transform;
|
|
484
488
|
if (e === "none" || !e)
|
|
485
489
|
return { x: 0, y: 0, rotation: 0, scale: 1 };
|
|
486
|
-
const
|
|
490
|
+
const n = new DOMMatrix(e), a = Math.sqrt(n.a * n.a + n.b * n.b), r = Math.atan2(n.b, n.a) * (180 / Math.PI), s = n.e, c = n.f;
|
|
487
491
|
return { x: s, y: c, rotation: r, scale: a };
|
|
488
492
|
}
|
|
489
493
|
/**
|
|
@@ -510,9 +514,9 @@ class Qt {
|
|
|
510
514
|
* @param easing - CSS easing function (optional)
|
|
511
515
|
* @returns Promise that resolves when animation completes
|
|
512
516
|
*/
|
|
513
|
-
animateTransform(t, i, e = null,
|
|
517
|
+
animateTransform(t, i, e = null, n = null) {
|
|
514
518
|
return new Promise((a) => {
|
|
515
|
-
const r = e ?? this.config.duration, s =
|
|
519
|
+
const r = e ?? this.config.duration, s = n ?? this.config.easing.default;
|
|
516
520
|
t.style.transition = `transform ${r}ms ${s}, box-shadow ${r}ms ${s}`, t.style.transform = this.buildTransformString(i), setTimeout(() => {
|
|
517
521
|
a();
|
|
518
522
|
}, r);
|
|
@@ -543,18 +547,18 @@ class Qt {
|
|
|
543
547
|
return new Promise((i) => setTimeout(i, t));
|
|
544
548
|
}
|
|
545
549
|
}
|
|
546
|
-
function V(
|
|
547
|
-
return
|
|
550
|
+
function V(o, t, i) {
|
|
551
|
+
return o + (t - o) * i;
|
|
548
552
|
}
|
|
549
|
-
function
|
|
550
|
-
const { overshoot:
|
|
551
|
-
let u = 0, h = 0, d = 1, f =
|
|
553
|
+
function se(o, t, i, e) {
|
|
554
|
+
const { overshoot: n, bounces: a, decayRatio: r } = e, s = i.x - t.x, c = i.y - t.y, l = ae(a, r);
|
|
555
|
+
let u = 0, h = 0, d = 1, f = n, b = !1;
|
|
552
556
|
for (let g = 0; g < l.length; g++)
|
|
553
|
-
if (
|
|
557
|
+
if (o <= l[g].time) {
|
|
554
558
|
h = g === 0 ? 0 : l[g - 1].time, d = l[g].time, f = l[g].overshoot, b = l[g].isOvershoot;
|
|
555
559
|
break;
|
|
556
560
|
}
|
|
557
|
-
const p = (
|
|
561
|
+
const p = (o - h) / (d - h);
|
|
558
562
|
if (b)
|
|
559
563
|
u = 1 + f * ot(p);
|
|
560
564
|
else if (h === 0)
|
|
@@ -570,72 +574,72 @@ function te(n, t, i, e) {
|
|
|
570
574
|
y: t.y + c * u
|
|
571
575
|
};
|
|
572
576
|
}
|
|
573
|
-
function
|
|
577
|
+
function ae(o, t) {
|
|
574
578
|
const i = [];
|
|
575
579
|
let e = 0.6;
|
|
576
580
|
i.push({ time: e, overshoot: 0, isOvershoot: !1 });
|
|
577
|
-
let
|
|
578
|
-
const r = 0.4 / (
|
|
579
|
-
for (let s = 0; s <
|
|
580
|
-
e += r, i.push({ time: e, overshoot:
|
|
581
|
+
let n = 0.15;
|
|
582
|
+
const r = 0.4 / (o * 2);
|
|
583
|
+
for (let s = 0; s < o; s++)
|
|
584
|
+
e += r, i.push({ time: e, overshoot: n, isOvershoot: !0 }), e += r, i.push({ time: e, overshoot: n * t, isOvershoot: !1 }), n *= t;
|
|
581
585
|
return i.push({ time: 1, overshoot: 0, isOvershoot: !1 }), i;
|
|
582
586
|
}
|
|
583
|
-
function
|
|
584
|
-
const { stiffness:
|
|
587
|
+
function re(o, t, i, e) {
|
|
588
|
+
const { stiffness: n, damping: a, mass: r, oscillations: s } = e, c = i.x - t.x, l = i.y - t.y, u = Math.sqrt(n / r), h = a / (2 * Math.sqrt(n * r));
|
|
585
589
|
let d;
|
|
586
590
|
if (h < 1) {
|
|
587
|
-
const f = u * Math.sqrt(1 - h * h), b = Math.exp(-h * u *
|
|
591
|
+
const f = u * Math.sqrt(1 - h * h), b = Math.exp(-h * u * o * 3), p = Math.cos(f * o * s * Math.PI);
|
|
588
592
|
d = 1 - b * p;
|
|
589
593
|
} else
|
|
590
|
-
d = 1 - Math.exp(-u *
|
|
594
|
+
d = 1 - Math.exp(-u * o * 3);
|
|
591
595
|
return d = Math.max(0, Math.min(d, 1.3)), {
|
|
592
596
|
x: t.x + c * d,
|
|
593
597
|
y: t.y + l * d
|
|
594
598
|
};
|
|
595
599
|
}
|
|
596
|
-
function
|
|
597
|
-
const { amplitude:
|
|
600
|
+
function ce(o, t, i, e) {
|
|
601
|
+
const { amplitude: n, frequency: a, decay: r, decayRate: s, phase: c } = e, l = i.x - t.x, u = i.y - t.y, h = Math.sqrt(l * l + u * u), d = h > 0 ? -u / h : 0, f = h > 0 ? l / h : 1, b = a * Math.PI * 2 * o + c, p = r ? Math.pow(1 - o, s) : 1, g = n * Math.sin(b) * p, m = le(o);
|
|
598
602
|
return {
|
|
599
603
|
x: V(t.x, i.x, m) + g * d,
|
|
600
604
|
y: V(t.y, i.y, m) + g * f
|
|
601
605
|
};
|
|
602
606
|
}
|
|
603
|
-
function ot(
|
|
604
|
-
return 1 - (1 -
|
|
607
|
+
function ot(o) {
|
|
608
|
+
return 1 - (1 - o) * (1 - o);
|
|
605
609
|
}
|
|
606
|
-
function
|
|
607
|
-
return 1 - Math.pow(1 -
|
|
610
|
+
function le(o) {
|
|
611
|
+
return 1 - Math.pow(1 - o, 3);
|
|
608
612
|
}
|
|
609
|
-
function
|
|
610
|
-
const { amplitude: e, frequency:
|
|
613
|
+
function he(o, t, i) {
|
|
614
|
+
const { amplitude: e, frequency: n, decay: a } = i, r = Math.sin(o * n * Math.PI * 2), s = a ? Math.pow(1 - o, 2) : 1, c = e * r * s;
|
|
611
615
|
return t + c;
|
|
612
616
|
}
|
|
613
|
-
function
|
|
614
|
-
const { overshoot: e, bounces:
|
|
617
|
+
function de(o, t, i) {
|
|
618
|
+
const { overshoot: e, bounces: n } = i, a = [];
|
|
615
619
|
a.push({ time: 0.5, scale: e });
|
|
616
620
|
let r = e;
|
|
617
|
-
const s = 0.5, l = 0.5 / (
|
|
621
|
+
const s = 0.5, l = 0.5 / (n * 2);
|
|
618
622
|
let u = 0.5;
|
|
619
|
-
for (let d = 0; d <
|
|
623
|
+
for (let d = 0; d < n; d++) {
|
|
620
624
|
const f = 1 - (r - 1) * s;
|
|
621
|
-
u += l, a.push({ time: u, scale: f }), r = 1 + (r - 1) * s * s, u += l, d <
|
|
625
|
+
u += l, a.push({ time: u, scale: f }), r = 1 + (r - 1) * s * s, u += l, d < n - 1 && a.push({ time: u, scale: r });
|
|
622
626
|
}
|
|
623
627
|
a.push({ time: 1, scale: 1 });
|
|
624
628
|
let h = 1;
|
|
625
629
|
for (let d = 0; d < a.length; d++)
|
|
626
|
-
if (
|
|
627
|
-
const f = d === 0 ? 0 : a[d - 1].time, b = d === 0 ? 1 : a[d - 1].scale, p = (
|
|
630
|
+
if (o <= a[d].time) {
|
|
631
|
+
const f = d === 0 ? 0 : a[d - 1].time, b = d === 0 ? 1 : a[d - 1].scale, p = (o - f) / (a[d].time - f), g = ot(p);
|
|
628
632
|
h = b + (a[d].scale - b) * g;
|
|
629
633
|
break;
|
|
630
634
|
}
|
|
631
635
|
return h * t;
|
|
632
636
|
}
|
|
633
|
-
function
|
|
637
|
+
function ue(o) {
|
|
634
638
|
const {
|
|
635
639
|
element: t,
|
|
636
640
|
startPosition: i,
|
|
637
641
|
endPosition: e,
|
|
638
|
-
pathConfig:
|
|
642
|
+
pathConfig: n,
|
|
639
643
|
duration: a,
|
|
640
644
|
imageWidth: r,
|
|
641
645
|
imageHeight: s,
|
|
@@ -646,38 +650,38 @@ function re(n) {
|
|
|
646
650
|
startRotation: d,
|
|
647
651
|
scaleConfig: f,
|
|
648
652
|
startScale: b
|
|
649
|
-
} =
|
|
650
|
-
if ((p === "linear" || p === "arc") && !w && !(v ||
|
|
653
|
+
} = o, p = n.type, g = d !== void 0 && d !== c, m = h?.mode === "wobble", y = h?.wobble || { amplitude: 15, frequency: 3, decay: !0 }, w = g || m, v = b !== void 0 && b !== l, I = f?.mode === "pop", E = f?.pop || { overshoot: 1.2, bounces: 1 };
|
|
654
|
+
if ((p === "linear" || p === "arc") && !w && !(v || I)) {
|
|
651
655
|
u && u();
|
|
652
656
|
return;
|
|
653
657
|
}
|
|
654
|
-
const
|
|
655
|
-
function
|
|
656
|
-
const
|
|
658
|
+
const O = performance.now(), L = -r / 2, P = -s / 2;
|
|
659
|
+
function z(H) {
|
|
660
|
+
const k = H - O, T = Math.min(k / a, 1);
|
|
657
661
|
let D;
|
|
658
662
|
switch (p) {
|
|
659
663
|
case "bounce": {
|
|
660
|
-
const
|
|
661
|
-
|
|
662
|
-
|
|
664
|
+
const N = ee(
|
|
665
|
+
n.bouncePreset,
|
|
666
|
+
n.bounce
|
|
663
667
|
);
|
|
664
|
-
D =
|
|
668
|
+
D = se(T, i, e, N);
|
|
665
669
|
break;
|
|
666
670
|
}
|
|
667
671
|
case "elastic": {
|
|
668
|
-
const
|
|
669
|
-
|
|
670
|
-
|
|
672
|
+
const N = ie(
|
|
673
|
+
n.elasticPreset,
|
|
674
|
+
n.elastic
|
|
671
675
|
);
|
|
672
|
-
D =
|
|
676
|
+
D = re(T, i, e, N);
|
|
673
677
|
break;
|
|
674
678
|
}
|
|
675
679
|
case "wave": {
|
|
676
|
-
const
|
|
677
|
-
|
|
678
|
-
|
|
680
|
+
const N = ne(
|
|
681
|
+
n.wavePreset,
|
|
682
|
+
n.wave
|
|
679
683
|
);
|
|
680
|
-
D =
|
|
684
|
+
D = ce(T, i, e, N);
|
|
681
685
|
break;
|
|
682
686
|
}
|
|
683
687
|
default:
|
|
@@ -688,16 +692,16 @@ function re(n) {
|
|
|
688
692
|
}
|
|
689
693
|
const G = D.x - e.x, U = D.y - e.y;
|
|
690
694
|
let M;
|
|
691
|
-
m ? M =
|
|
695
|
+
m ? M = he(T, c, y) : g ? M = V(d, c, T) : M = c;
|
|
692
696
|
let A;
|
|
693
|
-
|
|
697
|
+
I ? A = de(T, l, E) : v ? A = V(b, l, T) : A = l, t.style.transform = `translate(${L}px, ${P}px) translate(${G}px, ${U}px) rotate(${M}deg) scale(${A})`, T < 1 ? requestAnimationFrame(z) : (t.style.transform = `translate(${L}px, ${P}px) rotate(${c}deg) scale(${l})`, u && u());
|
|
694
698
|
}
|
|
695
|
-
requestAnimationFrame(
|
|
699
|
+
requestAnimationFrame(z);
|
|
696
700
|
}
|
|
697
|
-
function
|
|
698
|
-
return
|
|
701
|
+
function ge(o) {
|
|
702
|
+
return o === "bounce" || o === "elastic" || o === "wave";
|
|
699
703
|
}
|
|
700
|
-
const
|
|
704
|
+
const fe = {
|
|
701
705
|
radial: "center",
|
|
702
706
|
spiral: "center",
|
|
703
707
|
grid: "top",
|
|
@@ -706,20 +710,20 @@ const le = {
|
|
|
706
710
|
wave: "left",
|
|
707
711
|
honeycomb: "center"
|
|
708
712
|
};
|
|
709
|
-
class
|
|
713
|
+
class me {
|
|
710
714
|
constructor(t, i) {
|
|
711
|
-
this.config = t, this.layoutAlgorithm = i, this.resolvedStartPosition = this.resolveStartPosition(), this.pathConfig = t.path || vt, this.rotationConfig = t.rotation || wt, this.scaleConfig = t.scale ||
|
|
715
|
+
this.config = t, this.layoutAlgorithm = i, this.resolvedStartPosition = this.resolveStartPosition(), this.pathConfig = t.path || vt, this.rotationConfig = t.rotation || wt, this.scaleConfig = t.scale || Et;
|
|
712
716
|
}
|
|
713
717
|
/**
|
|
714
718
|
* Get the effective start position, considering layout-aware defaults
|
|
715
719
|
*/
|
|
716
720
|
resolveStartPosition() {
|
|
717
|
-
return this.config.start.position ? this.config.start.position :
|
|
721
|
+
return this.config.start.position ? this.config.start.position : fe[this.layoutAlgorithm] || "nearest-edge";
|
|
718
722
|
}
|
|
719
723
|
/**
|
|
720
724
|
* Calculate the starting position for an image's entry animation
|
|
721
725
|
*/
|
|
722
|
-
calculateStartPosition(t, i, e,
|
|
726
|
+
calculateStartPosition(t, i, e, n, a) {
|
|
723
727
|
const r = this.resolvedStartPosition, s = this.config.start.offset ?? 100;
|
|
724
728
|
switch (r) {
|
|
725
729
|
case "nearest-edge":
|
|
@@ -741,7 +745,7 @@ class he {
|
|
|
741
745
|
t,
|
|
742
746
|
i,
|
|
743
747
|
e,
|
|
744
|
-
|
|
748
|
+
n,
|
|
745
749
|
a
|
|
746
750
|
);
|
|
747
751
|
default:
|
|
@@ -751,28 +755,28 @@ class he {
|
|
|
751
755
|
/**
|
|
752
756
|
* Calculate start position from the nearest edge (current default behavior)
|
|
753
757
|
*/
|
|
754
|
-
calculateNearestEdge(t, i, e,
|
|
758
|
+
calculateNearestEdge(t, i, e, n) {
|
|
755
759
|
const a = t.x, r = t.y, s = a, c = e.width - a, l = r, u = e.height - r, h = Math.min(s, c, l, u);
|
|
756
760
|
let d = t.x, f = t.y;
|
|
757
|
-
return h === s ? d = -(i.width +
|
|
761
|
+
return h === s ? d = -(i.width + n) : h === c ? d = e.width + n : h === l ? f = -(i.height + n) : f = e.height + n, { x: d, y: f };
|
|
758
762
|
}
|
|
759
763
|
/**
|
|
760
764
|
* Calculate start position from a specific edge
|
|
761
765
|
*/
|
|
762
|
-
calculateEdgePosition(t, i, e,
|
|
766
|
+
calculateEdgePosition(t, i, e, n, a) {
|
|
763
767
|
let r = i.x, s = i.y;
|
|
764
768
|
switch (t) {
|
|
765
769
|
case "top":
|
|
766
770
|
s = -(e.height + a);
|
|
767
771
|
break;
|
|
768
772
|
case "bottom":
|
|
769
|
-
s =
|
|
773
|
+
s = n.height + a;
|
|
770
774
|
break;
|
|
771
775
|
case "left":
|
|
772
776
|
r = -(e.width + a);
|
|
773
777
|
break;
|
|
774
778
|
case "right":
|
|
775
|
-
r =
|
|
779
|
+
r = n.width + a;
|
|
776
780
|
break;
|
|
777
781
|
}
|
|
778
782
|
return { x: r, y: s };
|
|
@@ -781,9 +785,9 @@ class he {
|
|
|
781
785
|
* Calculate start position from center with scale animation
|
|
782
786
|
*/
|
|
783
787
|
calculateCenterPosition(t, i, e) {
|
|
784
|
-
const
|
|
788
|
+
const n = t.width / 2, a = t.height / 2;
|
|
785
789
|
return {
|
|
786
|
-
x:
|
|
790
|
+
x: n,
|
|
787
791
|
y: a,
|
|
788
792
|
useScale: !0
|
|
789
793
|
// Signal to use scale animation from 0
|
|
@@ -792,14 +796,14 @@ class he {
|
|
|
792
796
|
/**
|
|
793
797
|
* Calculate start position from a random edge
|
|
794
798
|
*/
|
|
795
|
-
calculateRandomEdge(t, i, e,
|
|
799
|
+
calculateRandomEdge(t, i, e, n) {
|
|
796
800
|
const a = ["top", "bottom", "left", "right"], r = a[Math.floor(Math.random() * a.length)];
|
|
797
|
-
return this.calculateEdgePosition(r, t, i, e,
|
|
801
|
+
return this.calculateEdgePosition(r, t, i, e, n);
|
|
798
802
|
}
|
|
799
803
|
/**
|
|
800
804
|
* Calculate start position on a circle around the container
|
|
801
805
|
*/
|
|
802
|
-
calculateCircularPosition(t, i, e,
|
|
806
|
+
calculateCircularPosition(t, i, e, n, a) {
|
|
803
807
|
const r = this.config.start.circular || {}, s = r.distribution || "even";
|
|
804
808
|
let c;
|
|
805
809
|
const l = r.radius || "120%";
|
|
@@ -811,7 +815,7 @@ class he {
|
|
|
811
815
|
} else
|
|
812
816
|
c = typeof l == "number" ? l : 500;
|
|
813
817
|
let u;
|
|
814
|
-
s === "even" ? u =
|
|
818
|
+
s === "even" ? u = n / a * 2 * Math.PI : u = Math.random() * 2 * Math.PI;
|
|
815
819
|
const h = e.width / 2, d = e.height / 2, f = h + Math.cos(u) * c, b = d + Math.sin(u) * c;
|
|
816
820
|
return { x: f, y: b };
|
|
817
821
|
}
|
|
@@ -832,17 +836,17 @@ class he {
|
|
|
832
836
|
* Build a CSS transform string for the start position
|
|
833
837
|
* Uses pixel-based centering offset for reliable cross-browser behavior
|
|
834
838
|
*/
|
|
835
|
-
buildStartTransform(t, i, e,
|
|
836
|
-
const l = t.x - i.x, u = t.y - i.y, h = s !== void 0 ? s : e, d = c !== void 0 ? c :
|
|
839
|
+
buildStartTransform(t, i, e, n, a, r, s, c) {
|
|
840
|
+
const l = t.x - i.x, u = t.y - i.y, h = s !== void 0 ? s : e, d = c !== void 0 ? c : n, f = a !== void 0 ? -a / 2 : 0, b = r !== void 0 ? -r / 2 : 0, p = a !== void 0 ? `translate(${f}px, ${b}px)` : "translate(-50%, -50%)";
|
|
837
841
|
return t.useScale ? `${p} translate(${l}px, ${u}px) rotate(${h}deg) scale(0)` : `${p} translate(${l}px, ${u}px) rotate(${h}deg) scale(${d})`;
|
|
838
842
|
}
|
|
839
843
|
/**
|
|
840
844
|
* Build the final CSS transform string
|
|
841
845
|
* Uses pixel-based centering offset for reliable cross-browser behavior
|
|
842
846
|
*/
|
|
843
|
-
buildFinalTransform(t, i, e,
|
|
844
|
-
if (e !== void 0 &&
|
|
845
|
-
const a = -e / 2, r = -
|
|
847
|
+
buildFinalTransform(t, i, e, n) {
|
|
848
|
+
if (e !== void 0 && n !== void 0) {
|
|
849
|
+
const a = -e / 2, r = -n / 2;
|
|
846
850
|
return `translate(${a}px, ${r}px) rotate(${t}deg) scale(${i})`;
|
|
847
851
|
}
|
|
848
852
|
return `translate(-50%, -50%) rotate(${t}deg) scale(${i})`;
|
|
@@ -859,7 +863,7 @@ class he {
|
|
|
859
863
|
* Check if the current path type requires JavaScript animation
|
|
860
864
|
*/
|
|
861
865
|
requiresJSAnimation() {
|
|
862
|
-
return
|
|
866
|
+
return ge(this.pathConfig.type);
|
|
863
867
|
}
|
|
864
868
|
/**
|
|
865
869
|
* Get the path configuration
|
|
@@ -908,12 +912,12 @@ class he {
|
|
|
908
912
|
return t + (Math.random() - 0.5) * 60;
|
|
909
913
|
if (typeof e == "number")
|
|
910
914
|
return e;
|
|
911
|
-
const
|
|
912
|
-
return e.min + Math.random() *
|
|
915
|
+
const n = e.max - e.min;
|
|
916
|
+
return e.min + Math.random() * n;
|
|
913
917
|
}
|
|
914
918
|
case "spin": {
|
|
915
|
-
const e = this.rotationConfig.spinCount ?? 1,
|
|
916
|
-
return t + e * 360 *
|
|
919
|
+
const e = this.rotationConfig.spinCount ?? 1, n = this.resolveSpinDirection(t);
|
|
920
|
+
return t + e * 360 * n;
|
|
917
921
|
}
|
|
918
922
|
case "random":
|
|
919
923
|
return t + (Math.random() - 0.5) * 60;
|
|
@@ -961,7 +965,7 @@ class he {
|
|
|
961
965
|
amplitude: 15,
|
|
962
966
|
frequency: 3,
|
|
963
967
|
decay: !0
|
|
964
|
-
}, { amplitude:
|
|
968
|
+
}, { amplitude: n, frequency: a, decay: r } = e, s = Math.sin(t * a * Math.PI * 2), c = r ? Math.pow(1 - t, 2) : 1, l = n * s * c;
|
|
965
969
|
return i + l;
|
|
966
970
|
}
|
|
967
971
|
/**
|
|
@@ -1018,7 +1022,7 @@ class he {
|
|
|
1018
1022
|
const e = this.scaleConfig.pop || {
|
|
1019
1023
|
overshoot: 1.2,
|
|
1020
1024
|
bounces: 1
|
|
1021
|
-
}, { overshoot:
|
|
1025
|
+
}, { overshoot: n, bounces: a } = e, r = this.generateScaleBounceKeyframes(a, n);
|
|
1022
1026
|
let s = i;
|
|
1023
1027
|
for (let c = 0; c < r.length; c++)
|
|
1024
1028
|
if (t <= r[c].time) {
|
|
@@ -1034,12 +1038,12 @@ class he {
|
|
|
1034
1038
|
generateScaleBounceKeyframes(t, i) {
|
|
1035
1039
|
const e = [];
|
|
1036
1040
|
e.push({ time: 0.5, scale: i });
|
|
1037
|
-
let
|
|
1041
|
+
let n = i;
|
|
1038
1042
|
const a = 0.5, s = 0.5 / (t * 2);
|
|
1039
1043
|
let c = 0.5;
|
|
1040
1044
|
for (let l = 0; l < t; l++) {
|
|
1041
|
-
const u = 1 - (
|
|
1042
|
-
c += s, e.push({ time: c, scale: u }),
|
|
1045
|
+
const u = 1 - (n - 1) * a;
|
|
1046
|
+
c += s, e.push({ time: c, scale: u }), n = 1 + (n - 1) * a * a, c += s, l < t - 1 && e.push({ time: c, scale: n });
|
|
1043
1047
|
}
|
|
1044
1048
|
return e.push({ time: 1, scale: 1 }), e;
|
|
1045
1049
|
}
|
|
@@ -1050,7 +1054,193 @@ class he {
|
|
|
1050
1054
|
return 1 - (1 - t) * (1 - t);
|
|
1051
1055
|
}
|
|
1052
1056
|
}
|
|
1053
|
-
class
|
|
1057
|
+
class pe {
|
|
1058
|
+
constructor(t, i = 600) {
|
|
1059
|
+
this.entries = /* @__PURE__ */ new Map(), this.togetherRafId = null, this.togetherSpeed = 0, this.config = t, this.entryDurationMs = i;
|
|
1060
|
+
}
|
|
1061
|
+
/**
|
|
1062
|
+
* Register an image element for idle animation.
|
|
1063
|
+
* Starts animation after entry duration completes.
|
|
1064
|
+
*/
|
|
1065
|
+
register(t, i, e, n) {
|
|
1066
|
+
if (this.entries.has(t)) return;
|
|
1067
|
+
const a = n ?? this.entryDurationMs, r = this.config.startDelay ?? a, s = {
|
|
1068
|
+
element: t,
|
|
1069
|
+
index: i,
|
|
1070
|
+
totalImages: e,
|
|
1071
|
+
animation: null,
|
|
1072
|
+
blinkAnimation: null,
|
|
1073
|
+
customTeardown: null,
|
|
1074
|
+
paused: !1,
|
|
1075
|
+
stopped: !1,
|
|
1076
|
+
startTimer: null
|
|
1077
|
+
};
|
|
1078
|
+
this.entries.set(t, s), s.startTimer = setTimeout(() => {
|
|
1079
|
+
s.startTimer = null, !s.stopped && !s.paused && this._startAnimation(s);
|
|
1080
|
+
}, r);
|
|
1081
|
+
}
|
|
1082
|
+
/**
|
|
1083
|
+
* Pause idle animation for a specific image (set to neutral then pause).
|
|
1084
|
+
*/
|
|
1085
|
+
pauseForImage(t) {
|
|
1086
|
+
const i = this.entries.get(t);
|
|
1087
|
+
i && (i.paused = !0, i.startTimer !== null && (clearTimeout(i.startTimer), i.startTimer = null), this._pauseEntry(i));
|
|
1088
|
+
}
|
|
1089
|
+
/**
|
|
1090
|
+
* Resume idle animation for a specific image by starting a fresh animation.
|
|
1091
|
+
* Always restarts rather than resuming, to avoid Web Animations API
|
|
1092
|
+
* quirks with negative-delay animations after pause/cancel.
|
|
1093
|
+
*/
|
|
1094
|
+
resumeForImage(t) {
|
|
1095
|
+
const i = this.entries.get(t);
|
|
1096
|
+
!i || i.stopped || (i.paused = !1, this._startAnimation(i));
|
|
1097
|
+
}
|
|
1098
|
+
/**
|
|
1099
|
+
* Stop and remove idle animation for a specific image.
|
|
1100
|
+
*/
|
|
1101
|
+
stopForImage(t) {
|
|
1102
|
+
const i = this.entries.get(t);
|
|
1103
|
+
i && (i.stopped = !0, i.startTimer !== null && (clearTimeout(i.startTimer), i.startTimer = null), this._cancelEntry(i), this.entries.delete(t));
|
|
1104
|
+
}
|
|
1105
|
+
pauseAll() {
|
|
1106
|
+
for (const t of this.entries.values())
|
|
1107
|
+
t.paused = !0, t.startTimer !== null && (clearTimeout(t.startTimer), t.startTimer = null), this._pauseEntry(t);
|
|
1108
|
+
}
|
|
1109
|
+
resumeAll() {
|
|
1110
|
+
for (const t of this.entries.values())
|
|
1111
|
+
t.stopped || (t.paused = !1, this._startAnimation(t));
|
|
1112
|
+
}
|
|
1113
|
+
stopAll() {
|
|
1114
|
+
for (const t of this.entries.values())
|
|
1115
|
+
t.stopped = !0, t.startTimer !== null && (clearTimeout(t.startTimer), t.startTimer = null), this._cancelEntry(t);
|
|
1116
|
+
this.entries.clear(), this._stopTogetherLoop();
|
|
1117
|
+
}
|
|
1118
|
+
// ──────────────────────────────────────────────────────────────────────────
|
|
1119
|
+
// Private helpers
|
|
1120
|
+
// ──────────────────────────────────────────────────────────────────────────
|
|
1121
|
+
_startAnimation(t) {
|
|
1122
|
+
const { type: i } = this.config;
|
|
1123
|
+
switch (i) {
|
|
1124
|
+
case "wiggle":
|
|
1125
|
+
this._startWiggle(t);
|
|
1126
|
+
break;
|
|
1127
|
+
case "pulse":
|
|
1128
|
+
this._startPulse(t);
|
|
1129
|
+
break;
|
|
1130
|
+
case "blink":
|
|
1131
|
+
this._startBlink(t);
|
|
1132
|
+
break;
|
|
1133
|
+
case "spin":
|
|
1134
|
+
this._startSpin(t);
|
|
1135
|
+
break;
|
|
1136
|
+
case "custom":
|
|
1137
|
+
this._startCustom(t);
|
|
1138
|
+
break;
|
|
1139
|
+
}
|
|
1140
|
+
}
|
|
1141
|
+
_startWiggle(t) {
|
|
1142
|
+
const i = { ...Bt, ...this.config.wiggle }, e = [
|
|
1143
|
+
{ transform: "rotate(0deg)", offset: 0 },
|
|
1144
|
+
{ transform: `rotate(${i.maxAngle}deg)`, offset: 0.25 },
|
|
1145
|
+
{ transform: "rotate(0deg)", offset: 0.5 },
|
|
1146
|
+
{ transform: `rotate(${-i.maxAngle}deg)`, offset: 0.75 },
|
|
1147
|
+
{ transform: "rotate(0deg)", offset: 1 }
|
|
1148
|
+
];
|
|
1149
|
+
i.sync === "together" ? (t.animation = t.element.animate(e, {
|
|
1150
|
+
duration: i.speed,
|
|
1151
|
+
iterations: 1 / 0,
|
|
1152
|
+
composite: "add",
|
|
1153
|
+
fill: "both"
|
|
1154
|
+
}), t.animation.pause(), this._startTogetherLoop(i.speed)) : t.animation = t.element.animate(e, {
|
|
1155
|
+
duration: i.speed,
|
|
1156
|
+
delay: -(Math.random() * i.speed),
|
|
1157
|
+
iterations: 1 / 0,
|
|
1158
|
+
composite: "add"
|
|
1159
|
+
});
|
|
1160
|
+
}
|
|
1161
|
+
_startPulse(t) {
|
|
1162
|
+
const i = { ...Xt, ...this.config.pulse }, e = [
|
|
1163
|
+
{ transform: "scale(1)", offset: 0 },
|
|
1164
|
+
{ transform: `scale(${i.maxScale})`, offset: 0.25 },
|
|
1165
|
+
{ transform: "scale(1)", offset: 0.5 },
|
|
1166
|
+
{ transform: `scale(${i.minScale})`, offset: 0.75 },
|
|
1167
|
+
{ transform: "scale(1)", offset: 1 }
|
|
1168
|
+
];
|
|
1169
|
+
i.sync === "together" ? (t.animation = t.element.animate(e, {
|
|
1170
|
+
duration: i.speed,
|
|
1171
|
+
iterations: 1 / 0,
|
|
1172
|
+
composite: "add",
|
|
1173
|
+
fill: "both"
|
|
1174
|
+
}), t.animation.pause(), this._startTogetherLoop(i.speed)) : t.animation = t.element.animate(e, {
|
|
1175
|
+
duration: i.speed,
|
|
1176
|
+
delay: -(Math.random() * i.speed),
|
|
1177
|
+
iterations: 1 / 0,
|
|
1178
|
+
composite: "add"
|
|
1179
|
+
});
|
|
1180
|
+
}
|
|
1181
|
+
_startBlink(t) {
|
|
1182
|
+
const i = { ...Yt, ...this.config.blink }, e = -(Math.random() * i.speed), n = parseFloat(getComputedStyle(t.element).opacity) || 1;
|
|
1183
|
+
let a, r;
|
|
1184
|
+
i.style === "fade" ? (a = [
|
|
1185
|
+
{ opacity: n, offset: 0 },
|
|
1186
|
+
{ opacity: 0, offset: 0.5 },
|
|
1187
|
+
{ opacity: n, offset: 1 }
|
|
1188
|
+
], r = {
|
|
1189
|
+
duration: i.speed,
|
|
1190
|
+
delay: e,
|
|
1191
|
+
iterations: 1 / 0,
|
|
1192
|
+
easing: "ease-in-out"
|
|
1193
|
+
}) : (a = [
|
|
1194
|
+
{ opacity: n, offset: 0 },
|
|
1195
|
+
{ opacity: n, offset: i.onRatio },
|
|
1196
|
+
{ opacity: 0, offset: Math.min(i.onRatio + 0.01, 0.99) },
|
|
1197
|
+
{ opacity: 0, offset: 0.99 },
|
|
1198
|
+
{ opacity: n, offset: 1 }
|
|
1199
|
+
], r = {
|
|
1200
|
+
duration: i.speed,
|
|
1201
|
+
delay: e,
|
|
1202
|
+
iterations: 1 / 0
|
|
1203
|
+
}), t.blinkAnimation = t.element.animate(a, r);
|
|
1204
|
+
}
|
|
1205
|
+
_startSpin(t) {
|
|
1206
|
+
const i = { ...Jt, ...this.config.spin }, e = i.direction === "clockwise" ? 360 : -360;
|
|
1207
|
+
t.animation = t.element.animate(
|
|
1208
|
+
[{ transform: "rotate(0deg)" }, { transform: `rotate(${e}deg)` }],
|
|
1209
|
+
{
|
|
1210
|
+
duration: i.speed,
|
|
1211
|
+
iterations: 1 / 0,
|
|
1212
|
+
easing: "linear",
|
|
1213
|
+
composite: "add"
|
|
1214
|
+
}
|
|
1215
|
+
);
|
|
1216
|
+
}
|
|
1217
|
+
_startCustom(t) {
|
|
1218
|
+
const i = this.config.custom;
|
|
1219
|
+
if (!i) return;
|
|
1220
|
+
const e = i({ element: t.element, index: t.index, totalImages: t.totalImages });
|
|
1221
|
+
typeof e == "function" ? t.customTeardown = e : e && typeof e.play == "function" && (t.animation = e);
|
|
1222
|
+
}
|
|
1223
|
+
_startTogetherLoop(t) {
|
|
1224
|
+
if (this.togetherSpeed = t, this.togetherRafId !== null) return;
|
|
1225
|
+
const i = () => {
|
|
1226
|
+
const e = performance.now() % this.togetherSpeed;
|
|
1227
|
+
for (const n of this.entries.values())
|
|
1228
|
+
!n.stopped && !n.paused && n.animation && (n.animation.currentTime = e);
|
|
1229
|
+
this.togetherRafId = requestAnimationFrame(i);
|
|
1230
|
+
};
|
|
1231
|
+
this.togetherRafId = requestAnimationFrame(i);
|
|
1232
|
+
}
|
|
1233
|
+
_stopTogetherLoop() {
|
|
1234
|
+
this.togetherRafId !== null && (cancelAnimationFrame(this.togetherRafId), this.togetherRafId = null);
|
|
1235
|
+
}
|
|
1236
|
+
_pauseEntry(t) {
|
|
1237
|
+
t.animation && (t.animation.cancel(), t.animation = null), t.blinkAnimation && (t.blinkAnimation.cancel(), t.blinkAnimation = null);
|
|
1238
|
+
}
|
|
1239
|
+
_cancelEntry(t) {
|
|
1240
|
+
t.animation && (t.animation.cancel(), t.animation = null), t.blinkAnimation && (t.blinkAnimation.cancel(), t.blinkAnimation = null), t.customTeardown && (t.customTeardown(), t.customTeardown = null);
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
class be {
|
|
1054
1244
|
constructor(t, i = {}) {
|
|
1055
1245
|
this.config = t, this.imageConfig = i;
|
|
1056
1246
|
}
|
|
@@ -1062,19 +1252,19 @@ class de {
|
|
|
1062
1252
|
* @returns Array of layout objects with position, rotation, scale
|
|
1063
1253
|
*/
|
|
1064
1254
|
generate(t, i, e = {}) {
|
|
1065
|
-
const
|
|
1066
|
-
for (let
|
|
1067
|
-
const
|
|
1068
|
-
id:
|
|
1069
|
-
x:
|
|
1070
|
-
y:
|
|
1255
|
+
const n = [], { width: a, height: r } = i, s = this.config.spacing.padding, c = e.fixedHeight ?? 200, l = this.imageConfig.rotation?.mode ?? "none", u = this.imageConfig.rotation?.range?.min ?? -15, h = this.imageConfig.rotation?.range?.max ?? 15, d = this.imageConfig.sizing?.variance?.min ?? 1, f = this.imageConfig.sizing?.variance?.max ?? 1, b = d !== 1 || f !== 1, g = c * 1.5 / 2, m = c / 2, y = a - s - g, w = r - s - m, v = s + g, I = s + m;
|
|
1256
|
+
for (let E = 0; E < t; E++) {
|
|
1257
|
+
const R = this.random(v, y), O = this.random(I, w), L = l === "random" ? this.random(u, h) : 0, P = b ? this.random(d, f) : 1, z = c * P, H = {
|
|
1258
|
+
id: E,
|
|
1259
|
+
x: R,
|
|
1260
|
+
y: O,
|
|
1071
1261
|
rotation: L,
|
|
1072
|
-
scale:
|
|
1073
|
-
baseSize:
|
|
1262
|
+
scale: P,
|
|
1263
|
+
baseSize: z
|
|
1074
1264
|
};
|
|
1075
|
-
|
|
1265
|
+
n.push(H);
|
|
1076
1266
|
}
|
|
1077
|
-
return
|
|
1267
|
+
return n;
|
|
1078
1268
|
}
|
|
1079
1269
|
/**
|
|
1080
1270
|
* Utility: Generate random number between min and max
|
|
@@ -1086,7 +1276,7 @@ class de {
|
|
|
1086
1276
|
return Math.random() * (i - t) + t;
|
|
1087
1277
|
}
|
|
1088
1278
|
}
|
|
1089
|
-
class
|
|
1279
|
+
class ye {
|
|
1090
1280
|
constructor(t, i = {}) {
|
|
1091
1281
|
this.config = t, this.imageConfig = i;
|
|
1092
1282
|
}
|
|
@@ -1098,55 +1288,55 @@ class ue {
|
|
|
1098
1288
|
* @returns Array of layout objects with position, rotation, scale
|
|
1099
1289
|
*/
|
|
1100
1290
|
generate(t, i, e = {}) {
|
|
1101
|
-
const
|
|
1102
|
-
...
|
|
1291
|
+
const n = [], { width: a, height: r } = i, s = e.fixedHeight ?? 200, c = this.imageConfig.rotation?.mode ?? "none", l = this.imageConfig.rotation?.range?.min ?? -15, u = this.imageConfig.rotation?.range?.max ?? 15, h = this.imageConfig.sizing?.variance?.min ?? 1, d = this.imageConfig.sizing?.variance?.max ?? 1, f = h !== 1 || d !== 1, b = this.config.scaleDecay ?? 0, p = {
|
|
1292
|
+
...kt,
|
|
1103
1293
|
...this.config.radial
|
|
1104
|
-
}, g = e.fixedHeight ?? s, m = a / 2, y = r / 2, w = Math.ceil(Math.sqrt(t)), v = this.config.spacing.padding ?? 50,
|
|
1294
|
+
}, g = e.fixedHeight ?? s, m = a / 2, y = r / 2, w = Math.ceil(Math.sqrt(t)), v = this.config.spacing.padding ?? 50, I = Math.max(g * 0.8, Math.min(
|
|
1105
1295
|
m - v - g / 2,
|
|
1106
1296
|
y - v - g / 2
|
|
1107
1297
|
));
|
|
1108
1298
|
if (t > 0) {
|
|
1109
|
-
const
|
|
1110
|
-
|
|
1299
|
+
const O = f ? this.random(h, d) : 1, L = g * O;
|
|
1300
|
+
n.push({
|
|
1111
1301
|
id: 0,
|
|
1112
1302
|
x: m,
|
|
1113
1303
|
y,
|
|
1114
1304
|
rotation: c === "random" ? this.random(l * 0.33, u * 0.33) : 0,
|
|
1115
1305
|
// Less rotation for center
|
|
1116
|
-
scale:
|
|
1306
|
+
scale: O,
|
|
1117
1307
|
baseSize: L,
|
|
1118
1308
|
zIndex: 100
|
|
1119
1309
|
// Center image is highest
|
|
1120
1310
|
});
|
|
1121
1311
|
}
|
|
1122
|
-
let
|
|
1123
|
-
for (;
|
|
1124
|
-
const
|
|
1312
|
+
let E = 1, R = 1;
|
|
1313
|
+
for (; E < t; ) {
|
|
1314
|
+
const O = R / w, L = b > 0 ? 1 - O * b * 0.5 : 1, P = Math.max(g * 0.8, I / w * 1.5 / p.tightness), z = R * P, H = z * 1.5, k = Math.PI * (3 * (H + z) - Math.sqrt((3 * H + z) * (H + 3 * z))), T = this.estimateWidth(g), D = Math.floor(k / (T * 0.7));
|
|
1125
1315
|
if (D === 0) {
|
|
1126
|
-
|
|
1316
|
+
R++;
|
|
1127
1317
|
continue;
|
|
1128
1318
|
}
|
|
1129
|
-
const G = 2 * Math.PI / D, U =
|
|
1130
|
-
for (let M = 0; M < D &&
|
|
1131
|
-
const A = M * G + U,
|
|
1132
|
-
let
|
|
1133
|
-
const
|
|
1134
|
-
|
|
1135
|
-
const
|
|
1136
|
-
|
|
1137
|
-
id:
|
|
1138
|
-
x:
|
|
1319
|
+
const G = 2 * Math.PI / D, U = R * (20 * Math.PI / 180);
|
|
1320
|
+
for (let M = 0; M < D && E < t; M++) {
|
|
1321
|
+
const A = M * G + U, N = f ? this.random(h, d) : 1, B = L * N, C = g * B;
|
|
1322
|
+
let _ = m + Math.cos(A) * H, F = y + Math.sin(A) * z;
|
|
1323
|
+
const $ = C * 1.5 / 2, j = C / 2;
|
|
1324
|
+
_ - $ < v ? _ = v + $ : _ + $ > a - v && (_ = a - v - $), F - j < v ? F = v + j : F + j > r - v && (F = r - v - j);
|
|
1325
|
+
const Y = c === "random" ? this.random(l, u) : 0;
|
|
1326
|
+
n.push({
|
|
1327
|
+
id: E,
|
|
1328
|
+
x: _,
|
|
1139
1329
|
y: F,
|
|
1140
|
-
rotation:
|
|
1141
|
-
scale:
|
|
1330
|
+
rotation: Y,
|
|
1331
|
+
scale: B,
|
|
1142
1332
|
baseSize: C,
|
|
1143
|
-
zIndex: Math.max(1, 100 -
|
|
1333
|
+
zIndex: Math.max(1, 100 - R)
|
|
1144
1334
|
// Outer rings have lower z-index
|
|
1145
|
-
}),
|
|
1335
|
+
}), E++;
|
|
1146
1336
|
}
|
|
1147
|
-
|
|
1337
|
+
R++;
|
|
1148
1338
|
}
|
|
1149
|
-
return
|
|
1339
|
+
return n;
|
|
1150
1340
|
}
|
|
1151
1341
|
/**
|
|
1152
1342
|
* Estimate image width based on height
|
|
@@ -1167,7 +1357,7 @@ class ue {
|
|
|
1167
1357
|
return Math.random() * (i - t) + t;
|
|
1168
1358
|
}
|
|
1169
1359
|
}
|
|
1170
|
-
const
|
|
1360
|
+
const ve = {
|
|
1171
1361
|
columns: "auto",
|
|
1172
1362
|
rows: "auto",
|
|
1173
1363
|
stagger: "none",
|
|
@@ -1195,7 +1385,7 @@ const ge = {
|
|
|
1195
1385
|
{ x: 0, y: 1 }
|
|
1196
1386
|
// down
|
|
1197
1387
|
];
|
|
1198
|
-
class
|
|
1388
|
+
class we {
|
|
1199
1389
|
constructor(t, i = {}) {
|
|
1200
1390
|
this.config = t, this.imageConfig = i;
|
|
1201
1391
|
}
|
|
@@ -1207,13 +1397,13 @@ class fe {
|
|
|
1207
1397
|
* @returns Array of layout objects with position, rotation, scale
|
|
1208
1398
|
*/
|
|
1209
1399
|
generate(t, i, e = {}) {
|
|
1210
|
-
const
|
|
1400
|
+
const n = [], { width: a, height: r } = i, s = { ...ve, ...this.config.grid }, c = this.config.spacing.padding, l = e.fixedHeight ?? 200, u = this.imageConfig.rotation?.mode ?? "none", h = this.imageConfig.sizing?.variance?.min ?? 1, d = this.imageConfig.sizing?.variance?.max ?? 1, f = h !== 1 || d !== 1, b = a - 2 * c, p = r - 2 * c, { columns: g, rows: m } = this.calculateGridDimensions(
|
|
1211
1401
|
t,
|
|
1212
1402
|
b,
|
|
1213
1403
|
p,
|
|
1214
1404
|
l,
|
|
1215
1405
|
s
|
|
1216
|
-
), y = s.stagger === "row", w = s.stagger === "column", v = y ? g + 0.5 : g,
|
|
1406
|
+
), y = s.stagger === "row", w = s.stagger === "column", v = y ? g + 0.5 : g, I = w ? m + 0.5 : m, E = (b - s.gap * (g - 1)) / v, R = (p - s.gap * (m - 1)) / I, O = y ? E / 2 : 0, L = w ? R / 2 : 0, P = 1 + s.overlap, z = Math.min(E, R) * P, H = e.fixedHeight ? Math.min(e.fixedHeight, z) : z, k = g * E + (g - 1) * s.gap + O, T = m * R + (m - 1) * s.gap + L, D = c + (b - k) / 2, G = c + (p - T) / 2, U = g * m, M = s.columns !== "auto" && s.rows !== "auto", A = M && t > U;
|
|
1217
1407
|
typeof window < "u" && (window.__gridOverflowDebug = {
|
|
1218
1408
|
gridConfigColumns: s.columns,
|
|
1219
1409
|
gridConfigRows: s.rows,
|
|
@@ -1224,43 +1414,43 @@ class fe {
|
|
|
1224
1414
|
imageCount: t,
|
|
1225
1415
|
isOverflowMode: A
|
|
1226
1416
|
});
|
|
1227
|
-
const
|
|
1417
|
+
const N = A ? new Array(U).fill(0) : [], B = Math.min(E, R) * s.overflowOffset;
|
|
1228
1418
|
for (let C = 0; C < t; C++) {
|
|
1229
|
-
let
|
|
1419
|
+
let _, F, X = 0;
|
|
1230
1420
|
if (A && C >= U) {
|
|
1231
1421
|
const q = C - U, W = q % U;
|
|
1232
|
-
|
|
1422
|
+
X = Math.floor(q / U) + 1, N[W]++, s.fillDirection === "row" ? (_ = W % g, F = Math.floor(W / g)) : (F = W % m, _ = Math.floor(W / m));
|
|
1233
1423
|
} else
|
|
1234
|
-
s.fillDirection === "row" ? (
|
|
1235
|
-
let
|
|
1236
|
-
if (s.stagger === "row" && F % 2 === 1 ?
|
|
1237
|
-
const q = (
|
|
1238
|
-
|
|
1424
|
+
s.fillDirection === "row" ? (_ = C % g, F = Math.floor(C / g)) : (F = C % m, _ = Math.floor(C / m));
|
|
1425
|
+
let $ = D + _ * (E + s.gap) + E / 2, j = G + F * (R + s.gap) + R / 2;
|
|
1426
|
+
if (s.stagger === "row" && F % 2 === 1 ? $ += E / 2 : s.stagger === "column" && _ % 2 === 1 && (j += R / 2), X > 0) {
|
|
1427
|
+
const q = (X - 1) % Lt.length, W = Lt[q];
|
|
1428
|
+
$ += W.x * B, j += W.y * B;
|
|
1239
1429
|
}
|
|
1240
1430
|
if (s.jitter > 0) {
|
|
1241
|
-
const q =
|
|
1242
|
-
|
|
1431
|
+
const q = E / 2 * s.jitter, W = R / 2 * s.jitter;
|
|
1432
|
+
$ += this.random(-q, q), j += this.random(-W, W);
|
|
1243
1433
|
}
|
|
1244
|
-
let
|
|
1434
|
+
let Y = $, J = j;
|
|
1245
1435
|
if (!A && s.fillDirection === "row") {
|
|
1246
1436
|
const q = t % g || g;
|
|
1247
1437
|
if (F === Math.floor((t - 1) / g) && q < g) {
|
|
1248
|
-
const
|
|
1438
|
+
const Rt = q * E + (q - 1) * s.gap;
|
|
1249
1439
|
let gt = 0;
|
|
1250
|
-
s.alignment === "center" ? gt = (
|
|
1440
|
+
s.alignment === "center" ? gt = (k - Rt) / 2 : s.alignment === "end" && (gt = k - Rt), Y += gt;
|
|
1251
1441
|
}
|
|
1252
1442
|
}
|
|
1253
|
-
const rt = f ? this.random(h, d) : 1, K = H * rt, it = K * 1.5 / 2, nt = K / 2, lt = c + it, ht = a - c - it,
|
|
1254
|
-
|
|
1443
|
+
const rt = f ? this.random(h, d) : 1, K = H * rt, it = K * 1.5 / 2, nt = K / 2, lt = c + it, ht = a - c - it, Ut = c + nt, Ht = r - c - nt;
|
|
1444
|
+
Y = Math.max(lt, Math.min(Y, ht)), J = Math.max(Ut, Math.min(J, Ht));
|
|
1255
1445
|
let dt = 0;
|
|
1256
1446
|
if (u === "random") {
|
|
1257
1447
|
const q = this.imageConfig.rotation?.range?.min ?? -15, W = this.imageConfig.rotation?.range?.max ?? 15;
|
|
1258
1448
|
s.jitter > 0 ? dt = this.random(q * s.jitter, W * s.jitter) : dt = this.random(q, W);
|
|
1259
1449
|
}
|
|
1260
1450
|
let ut;
|
|
1261
|
-
A &&
|
|
1451
|
+
A && X > 0 ? ut = 50 - X : ut = A ? 100 + C : C + 1, n.push({
|
|
1262
1452
|
id: C,
|
|
1263
|
-
x:
|
|
1453
|
+
x: Y,
|
|
1264
1454
|
y: J,
|
|
1265
1455
|
rotation: dt,
|
|
1266
1456
|
scale: rt,
|
|
@@ -1268,12 +1458,12 @@ class fe {
|
|
|
1268
1458
|
zIndex: ut
|
|
1269
1459
|
});
|
|
1270
1460
|
}
|
|
1271
|
-
return
|
|
1461
|
+
return n;
|
|
1272
1462
|
}
|
|
1273
1463
|
/**
|
|
1274
1464
|
* Calculate optimal grid dimensions based on image count and container
|
|
1275
1465
|
*/
|
|
1276
|
-
calculateGridDimensions(t, i, e,
|
|
1466
|
+
calculateGridDimensions(t, i, e, n, a) {
|
|
1277
1467
|
let r, s;
|
|
1278
1468
|
if (a.columns !== "auto" && a.rows !== "auto")
|
|
1279
1469
|
r = a.columns, s = a.rows;
|
|
@@ -1295,14 +1485,14 @@ class fe {
|
|
|
1295
1485
|
return Math.random() * (i - t) + t;
|
|
1296
1486
|
}
|
|
1297
1487
|
}
|
|
1298
|
-
const
|
|
1488
|
+
const Ee = Math.PI * (3 - Math.sqrt(5)), xe = {
|
|
1299
1489
|
spiralType: "golden",
|
|
1300
1490
|
direction: "counterclockwise",
|
|
1301
1491
|
tightness: 1,
|
|
1302
1492
|
scaleDecay: 0,
|
|
1303
1493
|
startAngle: 0
|
|
1304
1494
|
};
|
|
1305
|
-
class
|
|
1495
|
+
class Se {
|
|
1306
1496
|
constructor(t, i = {}) {
|
|
1307
1497
|
this.config = t, this.imageConfig = i;
|
|
1308
1498
|
}
|
|
@@ -1314,79 +1504,79 @@ class be {
|
|
|
1314
1504
|
* @returns Array of layout objects with position, rotation, scale
|
|
1315
1505
|
*/
|
|
1316
1506
|
generate(t, i, e = {}) {
|
|
1317
|
-
const
|
|
1507
|
+
const n = [], { width: a, height: r } = i, s = { ...xe, ...this.config.spiral }, c = this.config.spacing.padding, l = e.fixedHeight ?? 200, u = this.imageConfig.rotation?.mode ?? "none", h = this.imageConfig.rotation?.range?.min ?? -15, d = this.imageConfig.rotation?.range?.max ?? 15, f = this.imageConfig.sizing?.variance?.min ?? 1, b = this.imageConfig.sizing?.variance?.max ?? 1, p = f !== 1 || b !== 1, g = this.config.scaleDecay ?? s.scaleDecay, m = a / 2, y = r / 2, w = Math.min(
|
|
1318
1508
|
m - c - l / 2,
|
|
1319
1509
|
y - c - l / 2
|
|
1320
1510
|
), v = s.direction === "clockwise" ? -1 : 1;
|
|
1321
|
-
for (let
|
|
1322
|
-
let
|
|
1511
|
+
for (let I = 0; I < t; I++) {
|
|
1512
|
+
let E, R;
|
|
1323
1513
|
if (s.spiralType === "golden")
|
|
1324
|
-
|
|
1514
|
+
E = I * Ee * v + s.startAngle, R = this.calculateGoldenRadius(I, t, w, s.tightness);
|
|
1325
1515
|
else if (s.spiralType === "archimedean") {
|
|
1326
|
-
const
|
|
1327
|
-
|
|
1516
|
+
const $ = I * 0.5 * s.tightness;
|
|
1517
|
+
E = $ * v + s.startAngle, R = this.calculateArchimedeanRadius($, t, w, s.tightness);
|
|
1328
1518
|
} else {
|
|
1329
|
-
const
|
|
1330
|
-
|
|
1519
|
+
const $ = I * 0.3 * s.tightness;
|
|
1520
|
+
E = $ * v + s.startAngle, R = this.calculateLogarithmicRadius($, t, w, s.tightness);
|
|
1331
1521
|
}
|
|
1332
|
-
const
|
|
1522
|
+
const O = m + Math.cos(E) * R, L = y + Math.sin(E) * R, P = R / w, z = g > 0 ? 1 - P * g * 0.5 : 1, H = p ? this.random(f, b) : 1, k = z * H, T = l * k, G = T * 1.5 / 2, U = T / 2, M = c + G, A = a - c - G, N = c + U, B = r - c - U, C = Math.max(M, Math.min(O, A)), _ = Math.max(N, Math.min(L, B));
|
|
1333
1523
|
let F = 0;
|
|
1334
1524
|
if (u === "random") {
|
|
1335
|
-
const
|
|
1336
|
-
F = s.spiralType === "golden" ?
|
|
1337
|
-
} else u === "tangent" && (F = this.calculateSpiralTangent(
|
|
1338
|
-
const
|
|
1339
|
-
|
|
1340
|
-
id:
|
|
1525
|
+
const $ = E * 180 / Math.PI % 360, j = this.random(h, d);
|
|
1526
|
+
F = s.spiralType === "golden" ? j : $ * 0.1 + j * 0.9;
|
|
1527
|
+
} else u === "tangent" && (F = this.calculateSpiralTangent(E, R, s));
|
|
1528
|
+
const X = t - I;
|
|
1529
|
+
n.push({
|
|
1530
|
+
id: I,
|
|
1341
1531
|
x: C,
|
|
1342
|
-
y:
|
|
1532
|
+
y: _,
|
|
1343
1533
|
rotation: F,
|
|
1344
|
-
scale:
|
|
1534
|
+
scale: k,
|
|
1345
1535
|
baseSize: T,
|
|
1346
|
-
zIndex:
|
|
1536
|
+
zIndex: X
|
|
1347
1537
|
});
|
|
1348
1538
|
}
|
|
1349
|
-
return
|
|
1539
|
+
return n;
|
|
1350
1540
|
}
|
|
1351
1541
|
/**
|
|
1352
1542
|
* Calculate tangent angle for spiral curve at given position
|
|
1353
1543
|
* This aligns the image along the spiral's direction of travel
|
|
1354
1544
|
*/
|
|
1355
1545
|
calculateSpiralTangent(t, i, e) {
|
|
1356
|
-
let
|
|
1546
|
+
let n;
|
|
1357
1547
|
if (e.spiralType === "golden")
|
|
1358
|
-
|
|
1548
|
+
n = t + Math.PI / 2;
|
|
1359
1549
|
else if (e.spiralType === "archimedean") {
|
|
1360
1550
|
const r = 1 / e.tightness, s = Math.atan(i / r);
|
|
1361
|
-
|
|
1551
|
+
n = t + s;
|
|
1362
1552
|
} else {
|
|
1363
1553
|
const r = 0.15 / e.tightness, s = Math.atan(1 / r);
|
|
1364
|
-
|
|
1554
|
+
n = t + s;
|
|
1365
1555
|
}
|
|
1366
|
-
return
|
|
1556
|
+
return n * 180 / Math.PI % 360 - 90;
|
|
1367
1557
|
}
|
|
1368
1558
|
/**
|
|
1369
1559
|
* Calculate radius for golden spiral (Vogel's model)
|
|
1370
1560
|
* Creates even distribution like sunflower seeds
|
|
1371
1561
|
*/
|
|
1372
|
-
calculateGoldenRadius(t, i, e,
|
|
1373
|
-
const r = e / Math.sqrt(i) * Math.sqrt(t) /
|
|
1562
|
+
calculateGoldenRadius(t, i, e, n) {
|
|
1563
|
+
const r = e / Math.sqrt(i) * Math.sqrt(t) / n;
|
|
1374
1564
|
return Math.min(r, e);
|
|
1375
1565
|
}
|
|
1376
1566
|
/**
|
|
1377
1567
|
* Calculate radius for Archimedean spiral
|
|
1378
1568
|
* r = a + b*θ (constant spacing between arms)
|
|
1379
1569
|
*/
|
|
1380
|
-
calculateArchimedeanRadius(t, i, e,
|
|
1381
|
-
const a = i * 0.5 *
|
|
1570
|
+
calculateArchimedeanRadius(t, i, e, n) {
|
|
1571
|
+
const a = i * 0.5 * n;
|
|
1382
1572
|
return t / a * e;
|
|
1383
1573
|
}
|
|
1384
1574
|
/**
|
|
1385
1575
|
* Calculate radius for logarithmic (equiangular) spiral
|
|
1386
1576
|
* r = a * e^(b*θ)
|
|
1387
1577
|
*/
|
|
1388
|
-
calculateLogarithmicRadius(t, i, e,
|
|
1389
|
-
const a = e * 0.05, r = 0.15 /
|
|
1578
|
+
calculateLogarithmicRadius(t, i, e, n) {
|
|
1579
|
+
const a = e * 0.05, r = 0.15 / n, s = a * Math.exp(r * t), c = i * 0.3 * n, l = a * Math.exp(r * c);
|
|
1390
1580
|
return s / l * e;
|
|
1391
1581
|
}
|
|
1392
1582
|
/**
|
|
@@ -1396,7 +1586,7 @@ class be {
|
|
|
1396
1586
|
return Math.random() * (i - t) + t;
|
|
1397
1587
|
}
|
|
1398
1588
|
}
|
|
1399
|
-
const
|
|
1589
|
+
const Ie = {
|
|
1400
1590
|
clusterCount: "auto",
|
|
1401
1591
|
clusterSpread: 150,
|
|
1402
1592
|
clusterSpacing: 200,
|
|
@@ -1404,7 +1594,7 @@ const ye = {
|
|
|
1404
1594
|
overlap: 0.3,
|
|
1405
1595
|
distribution: "gaussian"
|
|
1406
1596
|
};
|
|
1407
|
-
class
|
|
1597
|
+
class Re {
|
|
1408
1598
|
constructor(t, i = {}) {
|
|
1409
1599
|
this.config = t, this.imageConfig = i;
|
|
1410
1600
|
}
|
|
@@ -1416,7 +1606,7 @@ class ve {
|
|
|
1416
1606
|
* @returns Array of layout objects with position, rotation, scale
|
|
1417
1607
|
*/
|
|
1418
1608
|
generate(t, i, e = {}) {
|
|
1419
|
-
const
|
|
1609
|
+
const n = [], { width: a, height: r } = i, s = { ...Ie, ...this.config.cluster }, c = this.config.spacing.padding, l = e.fixedHeight ?? 200, u = this.imageConfig.rotation?.mode ?? "none", h = this.imageConfig.rotation?.range?.min ?? -15, d = this.imageConfig.rotation?.range?.max ?? 15, f = this.imageConfig.sizing?.variance?.min ?? 1, b = this.imageConfig.sizing?.variance?.max ?? 1, p = f !== 1 || b !== 1, g = this.calculateClusterCount(
|
|
1420
1610
|
t,
|
|
1421
1611
|
s.clusterCount,
|
|
1422
1612
|
a,
|
|
@@ -1433,51 +1623,51 @@ class ve {
|
|
|
1433
1623
|
y[v % g]++;
|
|
1434
1624
|
let w = 0;
|
|
1435
1625
|
for (let v = 0; v < g; v++) {
|
|
1436
|
-
const
|
|
1437
|
-
for (let
|
|
1438
|
-
let
|
|
1626
|
+
const I = m[v], E = y[v];
|
|
1627
|
+
for (let R = 0; R < E; R++) {
|
|
1628
|
+
let O, L;
|
|
1439
1629
|
if (s.distribution === "gaussian")
|
|
1440
|
-
|
|
1630
|
+
O = this.gaussianRandom() * I.spread, L = this.gaussianRandom() * I.spread;
|
|
1441
1631
|
else {
|
|
1442
|
-
const F = this.random(0, Math.PI * 2),
|
|
1443
|
-
|
|
1632
|
+
const F = this.random(0, Math.PI * 2), X = this.random(0, I.spread);
|
|
1633
|
+
O = Math.cos(F) * X, L = Math.sin(F) * X;
|
|
1444
1634
|
}
|
|
1445
|
-
const
|
|
1446
|
-
|
|
1447
|
-
const H = p ? this.random(f, b) : 1,
|
|
1448
|
-
let D =
|
|
1635
|
+
const P = 1 + s.overlap * 0.5, z = 1 + s.overlap * 0.3;
|
|
1636
|
+
O /= P, L /= P;
|
|
1637
|
+
const H = p ? this.random(f, b) : 1, k = z * H, T = l * k;
|
|
1638
|
+
let D = I.x + O, G = I.y + L;
|
|
1449
1639
|
const M = T * 1.5 / 2, A = T / 2;
|
|
1450
1640
|
D = Math.max(c + M, Math.min(D, a - c - M)), G = Math.max(c + A, Math.min(G, r - c - A));
|
|
1451
|
-
const
|
|
1452
|
-
|
|
1641
|
+
const N = u === "random" ? this.random(h, d) : 0, C = Math.sqrt(O * O + L * L) / I.spread, _ = Math.round((1 - C) * 50) + 1;
|
|
1642
|
+
n.push({
|
|
1453
1643
|
id: w,
|
|
1454
1644
|
x: D,
|
|
1455
1645
|
y: G,
|
|
1456
|
-
rotation:
|
|
1457
|
-
scale:
|
|
1646
|
+
rotation: N,
|
|
1647
|
+
scale: k,
|
|
1458
1648
|
baseSize: T,
|
|
1459
|
-
zIndex:
|
|
1649
|
+
zIndex: _
|
|
1460
1650
|
}), w++;
|
|
1461
1651
|
}
|
|
1462
1652
|
}
|
|
1463
|
-
return
|
|
1653
|
+
return n;
|
|
1464
1654
|
}
|
|
1465
1655
|
/**
|
|
1466
1656
|
* Calculate optimal number of clusters based on image count and container
|
|
1467
1657
|
*/
|
|
1468
|
-
calculateClusterCount(t, i, e,
|
|
1658
|
+
calculateClusterCount(t, i, e, n, a) {
|
|
1469
1659
|
if (i !== "auto")
|
|
1470
1660
|
return Math.max(1, Math.min(i, t));
|
|
1471
1661
|
const s = Math.max(1, Math.ceil(t / 8)), c = Math.floor(
|
|
1472
|
-
e / a * (
|
|
1662
|
+
e / a * (n / a) * 0.6
|
|
1473
1663
|
);
|
|
1474
1664
|
return Math.max(1, Math.min(s, c, 10));
|
|
1475
1665
|
}
|
|
1476
1666
|
/**
|
|
1477
1667
|
* Generate cluster center positions with spacing constraints
|
|
1478
1668
|
*/
|
|
1479
|
-
generateClusterCenters(t, i, e,
|
|
1480
|
-
const r = [], c =
|
|
1669
|
+
generateClusterCenters(t, i, e, n, a) {
|
|
1670
|
+
const r = [], c = n + a.clusterSpread, l = i - n - a.clusterSpread, u = n + a.clusterSpread, h = e - n - a.clusterSpread;
|
|
1481
1671
|
for (let d = 0; d < t; d++) {
|
|
1482
1672
|
let f = null, b = -1;
|
|
1483
1673
|
for (let p = 0; p < 100; p++) {
|
|
@@ -1488,8 +1678,8 @@ class ve {
|
|
|
1488
1678
|
};
|
|
1489
1679
|
let m = 1 / 0;
|
|
1490
1680
|
for (const y of r) {
|
|
1491
|
-
const w = g.x - y.x, v = g.y - y.y,
|
|
1492
|
-
m = Math.min(m,
|
|
1681
|
+
const w = g.x - y.x, v = g.y - y.y, I = Math.sqrt(w * w + v * v);
|
|
1682
|
+
m = Math.min(m, I);
|
|
1493
1683
|
}
|
|
1494
1684
|
if ((r.length === 0 || m > b) && (f = g, b = m), m >= a.clusterSpacing)
|
|
1495
1685
|
break;
|
|
@@ -1522,7 +1712,7 @@ class ve {
|
|
|
1522
1712
|
return Math.random() * (i - t) + t;
|
|
1523
1713
|
}
|
|
1524
1714
|
}
|
|
1525
|
-
class
|
|
1715
|
+
class Te {
|
|
1526
1716
|
constructor(t, i = {}) {
|
|
1527
1717
|
this.config = t, this.imageConfig = i;
|
|
1528
1718
|
}
|
|
@@ -1534,32 +1724,32 @@ class we {
|
|
|
1534
1724
|
* @returns Array of layout objects with position, rotation, scale
|
|
1535
1725
|
*/
|
|
1536
1726
|
generate(t, i, e = {}) {
|
|
1537
|
-
const
|
|
1727
|
+
const n = [], { width: a, height: r } = i, s = e.fixedHeight ?? 200, c = this.config.spacing.padding ?? 50, l = this.imageConfig.rotation?.mode ?? "none", u = this.imageConfig.rotation?.range?.min ?? -15, h = this.imageConfig.rotation?.range?.max ?? 15, d = this.imageConfig.sizing?.variance?.min ?? 1, f = this.imageConfig.sizing?.variance?.max ?? 1, b = d !== 1 || f !== 1, p = e.fixedHeight ?? s, g = {
|
|
1538
1728
|
...Nt,
|
|
1539
1729
|
...this.config.wave
|
|
1540
|
-
}, { rows: m, amplitude: y, frequency: w, phaseShift: v, synchronization:
|
|
1730
|
+
}, { rows: m, amplitude: y, frequency: w, phaseShift: v, synchronization: I } = g, E = Math.ceil(t / m), L = p * 1.5 / 2, P = c + L, z = a - c - L, H = z - P, k = E > 1 ? H / (E - 1) : 0, T = c + y + p / 2, D = r - c - y - p / 2, G = D - T, U = m > 1 ? G / (m - 1) : 0;
|
|
1541
1731
|
let M = 0;
|
|
1542
1732
|
for (let A = 0; A < m && M < t; A++) {
|
|
1543
|
-
const
|
|
1544
|
-
let
|
|
1545
|
-
|
|
1546
|
-
for (let C = 0; C <
|
|
1547
|
-
const
|
|
1733
|
+
const N = m === 1 ? (T + D) / 2 : T + A * U;
|
|
1734
|
+
let B = 0;
|
|
1735
|
+
I === "offset" ? B = A * v : I === "alternating" && (B = A * Math.PI);
|
|
1736
|
+
for (let C = 0; C < E && M < t; C++) {
|
|
1737
|
+
const _ = E === 1 ? (P + z) / 2 : P + C * k, F = this.calculateWaveY(_, a, y, w, B), X = _, $ = N + F, j = b ? this.random(d, f) : 1, Y = p * j;
|
|
1548
1738
|
let J = 0;
|
|
1549
|
-
l === "tangent" ? J = this.calculateRotation(
|
|
1550
|
-
const K =
|
|
1551
|
-
|
|
1739
|
+
l === "tangent" ? J = this.calculateRotation(_, a, y, w, B) : l === "random" && (J = this.random(u, h));
|
|
1740
|
+
const K = Y * 1.5 / 2, ct = Y / 2, it = c + K, nt = a - c - K, lt = c + ct, ht = r - c - ct;
|
|
1741
|
+
n.push({
|
|
1552
1742
|
id: M,
|
|
1553
|
-
x: Math.max(it, Math.min(
|
|
1554
|
-
y: Math.max(lt, Math.min(
|
|
1743
|
+
x: Math.max(it, Math.min(X, nt)),
|
|
1744
|
+
y: Math.max(lt, Math.min($, ht)),
|
|
1555
1745
|
rotation: J,
|
|
1556
|
-
scale:
|
|
1557
|
-
baseSize:
|
|
1746
|
+
scale: j,
|
|
1747
|
+
baseSize: Y,
|
|
1558
1748
|
zIndex: M + 1
|
|
1559
1749
|
}), M++;
|
|
1560
1750
|
}
|
|
1561
1751
|
}
|
|
1562
|
-
return
|
|
1752
|
+
return n;
|
|
1563
1753
|
}
|
|
1564
1754
|
/**
|
|
1565
1755
|
* Calculate Y position displacement on wave curve
|
|
@@ -1570,9 +1760,9 @@ class we {
|
|
|
1570
1760
|
* @param phase - Phase offset
|
|
1571
1761
|
* @returns Y displacement from baseline
|
|
1572
1762
|
*/
|
|
1573
|
-
calculateWaveY(t, i, e,
|
|
1763
|
+
calculateWaveY(t, i, e, n, a) {
|
|
1574
1764
|
const r = t / i;
|
|
1575
|
-
return e * Math.sin(
|
|
1765
|
+
return e * Math.sin(n * r * 2 * Math.PI + a);
|
|
1576
1766
|
}
|
|
1577
1767
|
/**
|
|
1578
1768
|
* Calculate rotation based on wave tangent
|
|
@@ -1583,8 +1773,8 @@ class we {
|
|
|
1583
1773
|
* @param phase - Phase offset
|
|
1584
1774
|
* @returns Rotation angle in degrees
|
|
1585
1775
|
*/
|
|
1586
|
-
calculateRotation(t, i, e,
|
|
1587
|
-
const r = t / i, s = e *
|
|
1776
|
+
calculateRotation(t, i, e, n, a) {
|
|
1777
|
+
const r = t / i, s = e * n * 2 * Math.PI * Math.cos(n * r * 2 * Math.PI + a) / i;
|
|
1588
1778
|
return Math.atan(s) * (180 / Math.PI);
|
|
1589
1779
|
}
|
|
1590
1780
|
/**
|
|
@@ -1599,7 +1789,7 @@ class we {
|
|
|
1599
1789
|
return Math.random() * (i - t) + t;
|
|
1600
1790
|
}
|
|
1601
1791
|
}
|
|
1602
|
-
const
|
|
1792
|
+
const xt = 100, Q = 100 / Math.sqrt(3), St = [
|
|
1603
1793
|
[Q / 2, 0],
|
|
1604
1794
|
// upper-left
|
|
1605
1795
|
[3 * Q / 2, 0],
|
|
@@ -1612,21 +1802,21 @@ const Et = 100, Q = 100 / Math.sqrt(3), St = [
|
|
|
1612
1802
|
// lower-left
|
|
1613
1803
|
[0, 50]
|
|
1614
1804
|
// left
|
|
1615
|
-
],
|
|
1616
|
-
function
|
|
1805
|
+
], Ae = St[1][0] / xt, Ce = St[2][1] / xt;
|
|
1806
|
+
function Le(o) {
|
|
1617
1807
|
return {
|
|
1618
|
-
colStep:
|
|
1619
|
-
rowOffset:
|
|
1808
|
+
colStep: Ae * o,
|
|
1809
|
+
rowOffset: Ce * o
|
|
1620
1810
|
};
|
|
1621
1811
|
}
|
|
1622
|
-
function
|
|
1623
|
-
const { colStep: r } =
|
|
1812
|
+
function Me(o, t, i, e, n, a) {
|
|
1813
|
+
const { colStep: r } = Le(a);
|
|
1624
1814
|
return {
|
|
1625
|
-
px: e + r *
|
|
1626
|
-
py:
|
|
1815
|
+
px: e + r * o,
|
|
1816
|
+
py: n + a * (t + o / 2)
|
|
1627
1817
|
};
|
|
1628
1818
|
}
|
|
1629
|
-
const
|
|
1819
|
+
const Fe = [
|
|
1630
1820
|
[1, 0, -1],
|
|
1631
1821
|
[0, 1, -1],
|
|
1632
1822
|
[-1, 1, 0],
|
|
@@ -1634,33 +1824,33 @@ const Ie = [
|
|
|
1634
1824
|
[0, -1, 1],
|
|
1635
1825
|
[1, -1, 0]
|
|
1636
1826
|
];
|
|
1637
|
-
function
|
|
1638
|
-
if (
|
|
1827
|
+
function Oe(o) {
|
|
1828
|
+
if (o === 0) return [[0, 0, 0]];
|
|
1639
1829
|
const t = [];
|
|
1640
|
-
let [i, e,
|
|
1641
|
-
for (const [a, r, s] of
|
|
1642
|
-
for (let c = 0; c <
|
|
1643
|
-
t.push([i, e,
|
|
1830
|
+
let [i, e, n] = [0, -o, o];
|
|
1831
|
+
for (const [a, r, s] of Fe)
|
|
1832
|
+
for (let c = 0; c < o; c++)
|
|
1833
|
+
t.push([i, e, n]), i += a, e += r, n += s;
|
|
1644
1834
|
return t;
|
|
1645
1835
|
}
|
|
1646
|
-
class
|
|
1836
|
+
class ze {
|
|
1647
1837
|
// imageConfig intentionally not stored — honeycomb forces uniform sizing (rotation/variance
|
|
1648
1838
|
// would break hex tiling). Kept as parameter for interface compatibility.
|
|
1649
1839
|
constructor(t, i = {}) {
|
|
1650
1840
|
this.config = t;
|
|
1651
1841
|
}
|
|
1652
1842
|
generate(t, i, e = {}) {
|
|
1653
|
-
const
|
|
1843
|
+
const n = [], { width: a, height: r } = i, s = a / 2, c = r / 2, l = e.fixedHeight ?? 200, h = {
|
|
1654
1844
|
...jt,
|
|
1655
1845
|
...this.config.honeycomb
|
|
1656
1846
|
}.spacing ?? 0, d = l + h;
|
|
1657
1847
|
let f = 0, b = 0;
|
|
1658
1848
|
for (; f < t; ) {
|
|
1659
|
-
const p =
|
|
1849
|
+
const p = Oe(b);
|
|
1660
1850
|
for (const [g, m, y] of p) {
|
|
1661
1851
|
if (f >= t) break;
|
|
1662
|
-
const { px: w, py: v } =
|
|
1663
|
-
|
|
1852
|
+
const { px: w, py: v } = Me(g, m, y, s, c, d);
|
|
1853
|
+
n.push({
|
|
1664
1854
|
id: f,
|
|
1665
1855
|
x: w,
|
|
1666
1856
|
y: v,
|
|
@@ -1673,10 +1863,10 @@ class Ae {
|
|
|
1673
1863
|
}
|
|
1674
1864
|
b++;
|
|
1675
1865
|
}
|
|
1676
|
-
return
|
|
1866
|
+
return n;
|
|
1677
1867
|
}
|
|
1678
1868
|
}
|
|
1679
|
-
class
|
|
1869
|
+
class De {
|
|
1680
1870
|
constructor(t) {
|
|
1681
1871
|
this.config = t.layout, this.imageConfig = t.image, this.layouts = /* @__PURE__ */ new Map(), this.placementLayout = this.initLayout();
|
|
1682
1872
|
}
|
|
@@ -1687,19 +1877,19 @@ class Ce {
|
|
|
1687
1877
|
initLayout() {
|
|
1688
1878
|
switch (this.config.algorithm) {
|
|
1689
1879
|
case "radial":
|
|
1690
|
-
return new
|
|
1880
|
+
return new ye(this.config, this.imageConfig);
|
|
1691
1881
|
case "grid":
|
|
1692
|
-
return new
|
|
1882
|
+
return new we(this.config, this.imageConfig);
|
|
1693
1883
|
case "spiral":
|
|
1694
|
-
return new
|
|
1884
|
+
return new Se(this.config, this.imageConfig);
|
|
1695
1885
|
case "cluster":
|
|
1696
|
-
return new
|
|
1886
|
+
return new Re(this.config, this.imageConfig);
|
|
1697
1887
|
case "wave":
|
|
1698
|
-
return new
|
|
1888
|
+
return new Te(this.config, this.imageConfig);
|
|
1699
1889
|
case "honeycomb":
|
|
1700
|
-
return new
|
|
1890
|
+
return new ze(this.config, this.imageConfig);
|
|
1701
1891
|
default:
|
|
1702
|
-
return new
|
|
1892
|
+
return new be(this.config, this.imageConfig);
|
|
1703
1893
|
}
|
|
1704
1894
|
}
|
|
1705
1895
|
/**
|
|
@@ -1710,10 +1900,10 @@ class Ce {
|
|
|
1710
1900
|
* @returns Array of layout objects with position, rotation, scale
|
|
1711
1901
|
*/
|
|
1712
1902
|
generateLayout(t, i, e = {}) {
|
|
1713
|
-
const
|
|
1714
|
-
return
|
|
1903
|
+
const n = this.placementLayout.generate(t, i, e);
|
|
1904
|
+
return n.forEach((a) => {
|
|
1715
1905
|
this.layouts.set(a.id, a);
|
|
1716
|
-
}),
|
|
1906
|
+
}), n;
|
|
1717
1907
|
}
|
|
1718
1908
|
/**
|
|
1719
1909
|
* Get the original layout state for an image
|
|
@@ -1766,8 +1956,8 @@ class Ce {
|
|
|
1766
1956
|
return;
|
|
1767
1957
|
if (typeof e == "number")
|
|
1768
1958
|
return e;
|
|
1769
|
-
const
|
|
1770
|
-
return a === "mobile" ?
|
|
1959
|
+
const n = e, a = this.resolveBreakpoint(t);
|
|
1960
|
+
return a === "mobile" ? n.mobile ?? n.tablet ?? n.screen : a === "tablet" ? n.tablet ?? n.screen ?? n.mobile : n.screen ?? n.tablet ?? n.mobile;
|
|
1771
1961
|
}
|
|
1772
1962
|
/**
|
|
1773
1963
|
* Calculate adaptive image size based on container dimensions and image count
|
|
@@ -1777,8 +1967,8 @@ class Ce {
|
|
|
1777
1967
|
* @param viewportWidth - Current viewport width for baseHeight resolution
|
|
1778
1968
|
* @returns Calculated sizing result with height
|
|
1779
1969
|
*/
|
|
1780
|
-
calculateAdaptiveSize(t, i, e,
|
|
1781
|
-
const a = this.imageConfig.sizing, r = this.resolveBaseHeight(
|
|
1970
|
+
calculateAdaptiveSize(t, i, e, n) {
|
|
1971
|
+
const a = this.imageConfig.sizing, r = this.resolveBaseHeight(n);
|
|
1782
1972
|
if (r !== void 0)
|
|
1783
1973
|
return { height: r };
|
|
1784
1974
|
const s = a?.minSize ?? 50, c = a?.maxSize ?? 400, l = this.config.targetCoverage ?? 0.6, u = this.config.densityFactor ?? 1, { width: h, height: d } = t, p = h * d * l / i;
|
|
@@ -1798,9 +1988,9 @@ class Ce {
|
|
|
1798
1988
|
*/
|
|
1799
1989
|
honeycombMaxImageHeight(t, i) {
|
|
1800
1990
|
if (t <= 1) return 1 / 0;
|
|
1801
|
-
let e = 0,
|
|
1802
|
-
for (;
|
|
1803
|
-
e++,
|
|
1991
|
+
let e = 0, n = 1;
|
|
1992
|
+
for (; n < t; )
|
|
1993
|
+
e++, n += 6 * e;
|
|
1804
1994
|
const a = this.config.spacing?.padding ?? 50, r = this.config.honeycomb?.spacing ?? 0, s = i.width / 2, c = i.height / 2, l = Math.sqrt(3) / 2, u = 1 / Math.sqrt(3), h = (c - a - r * e) / (e + 0.5), d = (s - a - l * r * e) / (l * e + u);
|
|
1805
1995
|
return Math.max(10, Math.min(h, d));
|
|
1806
1996
|
}
|
|
@@ -1811,7 +2001,7 @@ class Ce {
|
|
|
1811
2001
|
return Math.max(i, Math.min(e, t));
|
|
1812
2002
|
}
|
|
1813
2003
|
}
|
|
1814
|
-
var S = /* @__PURE__ */ ((
|
|
2004
|
+
var S = /* @__PURE__ */ ((o) => (o.IDLE = "idle", o.FOCUSING = "focusing", o.FOCUSED = "focused", o.UNFOCUSING = "unfocusing", o.CROSS_ANIMATING = "cross_animating", o))(S || {});
|
|
1815
2005
|
const Mt = {
|
|
1816
2006
|
// Geometric shapes - uses percentages for responsive sizing
|
|
1817
2007
|
circle: "circle(50%)",
|
|
@@ -1821,7 +2011,7 @@ const Mt = {
|
|
|
1821
2011
|
hexagon: "polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%)",
|
|
1822
2012
|
octagon: "polygon(30% 0%, 70% 0%, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0% 70%, 0% 30%)",
|
|
1823
2013
|
diamond: "polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%)"
|
|
1824
|
-
},
|
|
2014
|
+
}, _e = {
|
|
1825
2015
|
// Circle - uses radius in pixels (refHeight of 100px = 50px radius)
|
|
1826
2016
|
circle: {
|
|
1827
2017
|
refHeight: 100,
|
|
@@ -1845,7 +2035,7 @@ const Mt = {
|
|
|
1845
2035
|
},
|
|
1846
2036
|
// Hexagon - regular hexagon (reference points imported from hexagonGeometry)
|
|
1847
2037
|
hexagon: {
|
|
1848
|
-
refHeight:
|
|
2038
|
+
refHeight: xt,
|
|
1849
2039
|
points: St
|
|
1850
2040
|
},
|
|
1851
2041
|
// Octagon - regular octagon
|
|
@@ -1859,105 +2049,111 @@ const Mt = {
|
|
|
1859
2049
|
points: [[50, 0], [100, 50], [50, 100], [0, 50]]
|
|
1860
2050
|
}
|
|
1861
2051
|
};
|
|
1862
|
-
function
|
|
1863
|
-
if (
|
|
1864
|
-
return
|
|
2052
|
+
function $e(o) {
|
|
2053
|
+
if (o)
|
|
2054
|
+
return o in Mt ? Mt[o] : o;
|
|
1865
2055
|
}
|
|
1866
|
-
function
|
|
1867
|
-
const e =
|
|
2056
|
+
function Pe(o, t, i) {
|
|
2057
|
+
const e = _e[o];
|
|
1868
2058
|
if (!e) return "";
|
|
1869
|
-
const
|
|
1870
|
-
if (
|
|
1871
|
-
return `circle(${Math.round(50 *
|
|
1872
|
-
const a = e.points.map(([p]) => p), r = e.points.map(([, p]) => p), s = (Math.min(...a) + Math.max(...a)) / 2 *
|
|
2059
|
+
const n = t / e.refHeight;
|
|
2060
|
+
if (o === "circle")
|
|
2061
|
+
return `circle(${Math.round(50 * n * 100) / 100}px)`;
|
|
2062
|
+
const a = e.points.map(([p]) => p), r = e.points.map(([, p]) => p), s = (Math.min(...a) + Math.max(...a)) / 2 * n, c = (Math.min(...r) + Math.max(...r)) / 2 * n, l = (Math.max(...a) - Math.min(...a)) * n, u = (i ?? l) / 2, h = t / 2, d = u - s, f = h - c;
|
|
1873
2063
|
return `polygon(${e.points.map(([p, g]) => {
|
|
1874
|
-
const m = Math.round((p *
|
|
2064
|
+
const m = Math.round((p * n + d) * 100) / 100, y = Math.round((g * n + f) * 100) / 100;
|
|
1875
2065
|
return `${m}px ${y}px`;
|
|
1876
2066
|
}).join(", ")})`;
|
|
1877
2067
|
}
|
|
1878
|
-
function
|
|
1879
|
-
return
|
|
2068
|
+
function Ue(o) {
|
|
2069
|
+
return o in mt;
|
|
1880
2070
|
}
|
|
1881
|
-
function
|
|
1882
|
-
return
|
|
2071
|
+
function He(o) {
|
|
2072
|
+
return o ? Ue(o) ? mt[o] : o : mt.md;
|
|
1883
2073
|
}
|
|
1884
|
-
function
|
|
1885
|
-
if (!
|
|
2074
|
+
function ke(o) {
|
|
2075
|
+
if (!o) return "";
|
|
1886
2076
|
const t = [];
|
|
1887
|
-
if (
|
|
1888
|
-
if (typeof
|
|
1889
|
-
t.push(`drop-shadow(${
|
|
2077
|
+
if (o.grayscale !== void 0 && t.push(`grayscale(${o.grayscale})`), o.blur !== void 0 && t.push(`blur(${o.blur}px)`), o.brightness !== void 0 && t.push(`brightness(${o.brightness})`), o.contrast !== void 0 && t.push(`contrast(${o.contrast})`), o.saturate !== void 0 && t.push(`saturate(${o.saturate})`), o.opacity !== void 0 && t.push(`opacity(${o.opacity})`), o.sepia !== void 0 && t.push(`sepia(${o.sepia})`), o.hueRotate !== void 0 && t.push(`hue-rotate(${o.hueRotate}deg)`), o.invert !== void 0 && t.push(`invert(${o.invert})`), o.dropShadow !== void 0)
|
|
2078
|
+
if (typeof o.dropShadow == "string")
|
|
2079
|
+
t.push(`drop-shadow(${o.dropShadow})`);
|
|
1890
2080
|
else {
|
|
1891
|
-
const i =
|
|
2081
|
+
const i = o.dropShadow;
|
|
1892
2082
|
t.push(`drop-shadow(${i.x}px ${i.y}px ${i.blur}px ${i.color})`);
|
|
1893
2083
|
}
|
|
1894
2084
|
return t.join(" ");
|
|
1895
2085
|
}
|
|
1896
|
-
function tt(
|
|
1897
|
-
if (!
|
|
2086
|
+
function tt(o) {
|
|
2087
|
+
if (!o || o.style === "none" || o.width === 0)
|
|
1898
2088
|
return "none";
|
|
1899
|
-
const t =
|
|
2089
|
+
const t = o.width ?? 0, i = o.style ?? "solid", e = o.color ?? "#000000";
|
|
1900
2090
|
return `${t}px ${i} ${e}`;
|
|
1901
2091
|
}
|
|
1902
|
-
function et(
|
|
1903
|
-
if (!
|
|
2092
|
+
function et(o, t, i) {
|
|
2093
|
+
if (!o) return {};
|
|
1904
2094
|
const e = {};
|
|
1905
|
-
if (
|
|
1906
|
-
const s =
|
|
1907
|
-
|
|
1908
|
-
} else
|
|
1909
|
-
if (
|
|
1910
|
-
const s =
|
|
2095
|
+
if (o.borderRadiusTopLeft !== void 0 || o.borderRadiusTopRight !== void 0 || o.borderRadiusBottomRight !== void 0 || o.borderRadiusBottomLeft !== void 0) {
|
|
2096
|
+
const s = o.border?.radius ?? 0;
|
|
2097
|
+
o.borderRadiusTopLeft !== void 0 ? e.borderTopLeftRadius = `${o.borderRadiusTopLeft}px` : s && (e.borderTopLeftRadius = `${s}px`), o.borderRadiusTopRight !== void 0 ? e.borderTopRightRadius = `${o.borderRadiusTopRight}px` : s && (e.borderTopRightRadius = `${s}px`), o.borderRadiusBottomRight !== void 0 ? e.borderBottomRightRadius = `${o.borderRadiusBottomRight}px` : s && (e.borderBottomRightRadius = `${s}px`), o.borderRadiusBottomLeft !== void 0 ? e.borderBottomLeftRadius = `${o.borderRadiusBottomLeft}px` : s && (e.borderBottomLeftRadius = `${s}px`);
|
|
2098
|
+
} else o.border?.radius !== void 0 && (e.borderRadius = `${o.border.radius}px`);
|
|
2099
|
+
if (o.borderTop || o.borderRight || o.borderBottom || o.borderLeft) {
|
|
2100
|
+
const s = o.border || {}, c = { ...s, ...o.borderTop }, l = { ...s, ...o.borderRight }, u = { ...s, ...o.borderBottom }, h = { ...s, ...o.borderLeft };
|
|
1911
2101
|
e.borderTop = tt(c), e.borderRight = tt(l), e.borderBottom = tt(u), e.borderLeft = tt(h);
|
|
1912
|
-
} else
|
|
1913
|
-
|
|
1914
|
-
const r =
|
|
1915
|
-
if (e.filter = r || "none",
|
|
1916
|
-
const s =
|
|
1917
|
-
e.outline = `${s}px ${c} ${l}`,
|
|
1918
|
-
}
|
|
1919
|
-
if (
|
|
2102
|
+
} else o.border && (e.border = tt(o.border));
|
|
2103
|
+
o.shadow !== void 0 && (e.boxShadow = He(o.shadow));
|
|
2104
|
+
const r = ke(o.filter);
|
|
2105
|
+
if (e.filter = r || "none", o.opacity !== void 0 && (e.opacity = String(o.opacity)), o.cursor !== void 0 && (e.cursor = o.cursor), o.outline && o.outline.style !== "none" && (o.outline.width ?? 0) > 0) {
|
|
2106
|
+
const s = o.outline.width ?? 0, c = o.outline.style ?? "solid", l = o.outline.color ?? "#000000";
|
|
2107
|
+
e.outline = `${s}px ${c} ${l}`, o.outline.offset !== void 0 && (e.outlineOffset = `${o.outline.offset}px`);
|
|
2108
|
+
}
|
|
2109
|
+
if (o.objectFit !== void 0 && (e.objectFit = o.objectFit), o.aspectRatio !== void 0 && (e.aspectRatio = o.aspectRatio), o.clipPath !== void 0) {
|
|
1920
2110
|
let s;
|
|
1921
|
-
const c = typeof
|
|
2111
|
+
const c = typeof o.clipPath == "object" && o.clipPath !== null && "shape" in o.clipPath, l = c ? o.clipPath : void 0;
|
|
1922
2112
|
if (l?.mode === "height-relative" && t)
|
|
1923
|
-
s =
|
|
2113
|
+
s = Pe(l.shape, t, i);
|
|
1924
2114
|
else {
|
|
1925
|
-
const u = c && l ? l.shape :
|
|
1926
|
-
s =
|
|
2115
|
+
const u = c && l ? l.shape : o.clipPath;
|
|
2116
|
+
s = $e(u);
|
|
1927
2117
|
}
|
|
1928
2118
|
s && (s === "none" ? e.clipPath = "unset" : (e.clipPath = s, e.overflow = "hidden"));
|
|
1929
2119
|
}
|
|
1930
2120
|
return e;
|
|
1931
2121
|
}
|
|
1932
|
-
function
|
|
1933
|
-
t.borderRadius !== void 0 && (
|
|
2122
|
+
function Ne(o, t) {
|
|
2123
|
+
t.borderRadius !== void 0 && (o.style.borderRadius = t.borderRadius), t.borderTopLeftRadius !== void 0 && (o.style.borderTopLeftRadius = t.borderTopLeftRadius), t.borderTopRightRadius !== void 0 && (o.style.borderTopRightRadius = t.borderTopRightRadius), t.borderBottomRightRadius !== void 0 && (o.style.borderBottomRightRadius = t.borderBottomRightRadius), t.borderBottomLeftRadius !== void 0 && (o.style.borderBottomLeftRadius = t.borderBottomLeftRadius), t.border !== void 0 && (o.style.border = t.border), t.borderTop !== void 0 && (o.style.borderTop = t.borderTop), t.borderRight !== void 0 && (o.style.borderRight = t.borderRight), t.borderBottom !== void 0 && (o.style.borderBottom = t.borderBottom), t.borderLeft !== void 0 && (o.style.borderLeft = t.borderLeft), t.boxShadow !== void 0 && (o.style.boxShadow = t.boxShadow), t.filter !== void 0 && (o.style.filter = t.filter), t.opacity !== void 0 && (o.style.opacity = t.opacity), t.cursor !== void 0 && (o.style.cursor = t.cursor), t.outline !== void 0 && (o.style.outline = t.outline), t.outlineOffset !== void 0 && (o.style.outlineOffset = t.outlineOffset), t.objectFit !== void 0 && (o.style.objectFit = t.objectFit), t.aspectRatio !== void 0 && (o.style.aspectRatio = t.aspectRatio), t.clipPath !== void 0 && (o.style.clipPath = t.clipPath), t.overflow !== void 0 && (o.style.overflow = t.overflow);
|
|
1934
2124
|
}
|
|
1935
|
-
function ft(
|
|
1936
|
-
const
|
|
1937
|
-
|
|
2125
|
+
function ft(o, t, i, e) {
|
|
2126
|
+
const n = et(t, i, e);
|
|
2127
|
+
Ne(o, n);
|
|
1938
2128
|
}
|
|
1939
|
-
function Pt(
|
|
1940
|
-
return
|
|
2129
|
+
function Pt(o) {
|
|
2130
|
+
return o ? Array.isArray(o) ? o.join(" ") : o : "";
|
|
1941
2131
|
}
|
|
1942
|
-
function st(
|
|
2132
|
+
function st(o, t) {
|
|
1943
2133
|
const i = Pt(t);
|
|
1944
2134
|
i && i.split(" ").forEach((e) => {
|
|
1945
|
-
e.trim() &&
|
|
2135
|
+
e.trim() && o.classList.add(e.trim());
|
|
1946
2136
|
});
|
|
1947
2137
|
}
|
|
1948
|
-
function pt(
|
|
2138
|
+
function pt(o, t) {
|
|
1949
2139
|
const i = Pt(t);
|
|
1950
2140
|
i && i.split(" ").forEach((e) => {
|
|
1951
|
-
e.trim() &&
|
|
2141
|
+
e.trim() && o.classList.remove(e.trim());
|
|
1952
2142
|
});
|
|
1953
2143
|
}
|
|
1954
2144
|
const Ft = {
|
|
1955
2145
|
UNFOCUSING: 999,
|
|
1956
2146
|
FOCUSING: 1e3
|
|
1957
2147
|
};
|
|
1958
|
-
class
|
|
2148
|
+
class je {
|
|
1959
2149
|
constructor(t, i, e) {
|
|
1960
|
-
this.state = S.IDLE, this.currentFocus = null, this.focusData = null, this.outgoing = null, this.incoming = null, this.focusGeneration = 0, this.config = t, this.animationEngine = i, this.styling = e, this.focusedClassName = e?.focused?.className;
|
|
2150
|
+
this.state = S.IDLE, this.currentFocus = null, this.focusData = null, this.outgoing = null, this.incoming = null, this.focusGeneration = 0, this.onUnfocusComplete = null, this.config = t, this.animationEngine = i, this.styling = e, this.focusedClassName = e?.focused?.className;
|
|
2151
|
+
}
|
|
2152
|
+
/**
|
|
2153
|
+
* Set callback to be fired when an unfocus animation fully completes.
|
|
2154
|
+
*/
|
|
2155
|
+
setOnUnfocusCompleteCallback(t) {
|
|
2156
|
+
this.onUnfocusComplete = t;
|
|
1961
2157
|
}
|
|
1962
2158
|
/**
|
|
1963
2159
|
* Get current state machine state
|
|
@@ -1982,9 +2178,9 @@ class Pe {
|
|
|
1982
2178
|
* Returns actual pixel dimensions instead of scale factor for sharper rendering
|
|
1983
2179
|
*/
|
|
1984
2180
|
calculateFocusDimensions(t, i, e) {
|
|
1985
|
-
const
|
|
2181
|
+
const n = this.normalizeScalePercent(this.config.scalePercent), a = e.height * n, r = t / i;
|
|
1986
2182
|
let s = a, c = s * r;
|
|
1987
|
-
const l = e.width *
|
|
2183
|
+
const l = e.width * n;
|
|
1988
2184
|
return c > l && (c = l, s = c / r), { width: c, height: s };
|
|
1989
2185
|
}
|
|
1990
2186
|
/**
|
|
@@ -1992,7 +2188,7 @@ class Pe {
|
|
|
1992
2188
|
* Scale is handled by animating actual dimensions for sharper rendering
|
|
1993
2189
|
*/
|
|
1994
2190
|
calculateFocusTransform(t, i) {
|
|
1995
|
-
const e = t.width / 2,
|
|
2191
|
+
const e = t.width / 2, n = t.height / 2, a = e - i.x, r = n - i.y;
|
|
1996
2192
|
return {
|
|
1997
2193
|
x: a,
|
|
1998
2194
|
y: r,
|
|
@@ -2007,8 +2203,8 @@ class Pe {
|
|
|
2007
2203
|
buildDimensionZoomTransform(t) {
|
|
2008
2204
|
const i = ["translate(-50%, -50%)"];
|
|
2009
2205
|
if (t.x !== void 0 || t.y !== void 0) {
|
|
2010
|
-
const e = t.x ?? 0,
|
|
2011
|
-
i.push(`translate(${e}px, ${
|
|
2206
|
+
const e = t.x ?? 0, n = t.y ?? 0;
|
|
2207
|
+
i.push(`translate(${e}px, ${n}px)`);
|
|
2012
2208
|
}
|
|
2013
2209
|
return t.rotation !== void 0 && i.push(`rotate(${t.rotation}deg)`), i.join(" ");
|
|
2014
2210
|
}
|
|
@@ -2016,13 +2212,13 @@ class Pe {
|
|
|
2016
2212
|
* Create a Web Animation that animates both transform (position) and dimensions
|
|
2017
2213
|
* This provides sharper zoom by re-rendering at target size instead of scaling pixels
|
|
2018
2214
|
*/
|
|
2019
|
-
animateWithDimensions(t, i, e,
|
|
2215
|
+
animateWithDimensions(t, i, e, n, a, r, s, c) {
|
|
2020
2216
|
const l = this.buildDimensionZoomTransform(i), u = this.buildDimensionZoomTransform(e);
|
|
2021
2217
|
return t.style.transition = "none", t.animate(
|
|
2022
2218
|
[
|
|
2023
2219
|
{
|
|
2024
2220
|
transform: l,
|
|
2025
|
-
width: `${
|
|
2221
|
+
width: `${n}px`,
|
|
2026
2222
|
height: `${a}px`
|
|
2027
2223
|
},
|
|
2028
2224
|
{
|
|
@@ -2063,10 +2259,10 @@ class Pe {
|
|
|
2063
2259
|
* This ensures clip-path changes smoothly as width/height animate
|
|
2064
2260
|
*/
|
|
2065
2261
|
startClipPathAnimation(t, i, e) {
|
|
2066
|
-
let
|
|
2067
|
-
e && this.styling?.focused && this.styling.focused.clipPath === void 0 && (
|
|
2262
|
+
let n = e ? this.styling?.focused ?? this.styling?.default : this.styling?.default;
|
|
2263
|
+
e && this.styling?.focused && this.styling.focused.clipPath === void 0 && (n = { ...n, clipPath: void 0 });
|
|
2068
2264
|
const a = () => {
|
|
2069
|
-
const r = t.offsetHeight, s = t.offsetWidth, c = et(
|
|
2265
|
+
const r = t.offsetHeight, s = t.offsetWidth, c = et(n, r, s);
|
|
2070
2266
|
c.clipPath !== void 0 ? t.style.clipPath = c.clipPath : t.style.clipPath = "unset", c.overflow !== void 0 && (t.style.overflow = c.overflow), i.animation.playState === "running" && requestAnimationFrame(a);
|
|
2071
2267
|
};
|
|
2072
2268
|
requestAnimationFrame(a);
|
|
@@ -2077,12 +2273,12 @@ class Pe {
|
|
|
2077
2273
|
* @param fromTransform - Optional starting transform (for mid-animation reversals)
|
|
2078
2274
|
* @param fromDimensions - Optional starting dimensions (for mid-animation reversals)
|
|
2079
2275
|
*/
|
|
2080
|
-
startFocusAnimation(t, i, e,
|
|
2276
|
+
startFocusAnimation(t, i, e, n, a) {
|
|
2081
2277
|
const r = t.style.zIndex || "", s = t.offsetWidth, c = t.offsetHeight, l = this.calculateFocusDimensions(s, c, i), u = this.calculateFocusTransform(i, e);
|
|
2082
2278
|
this.animationEngine.cancelAllAnimations(t);
|
|
2083
2279
|
const h = this.config.animationDuration ?? 600;
|
|
2084
2280
|
this.applyFocusedStyling(t, Ft.FOCUSING);
|
|
2085
|
-
const d =
|
|
2281
|
+
const d = n ?? {
|
|
2086
2282
|
x: 0,
|
|
2087
2283
|
y: 0,
|
|
2088
2284
|
rotation: e.rotation,
|
|
@@ -2129,11 +2325,11 @@ class Pe {
|
|
|
2129
2325
|
* Animates back to original dimensions for consistent behavior
|
|
2130
2326
|
* @param fromDimensions - Optional starting dimensions (for mid-animation reversals)
|
|
2131
2327
|
*/
|
|
2132
|
-
startUnfocusAnimation(t, i, e,
|
|
2328
|
+
startUnfocusAnimation(t, i, e, n) {
|
|
2133
2329
|
t.style.zIndex = String(Ft.UNFOCUSING), this.animationEngine.cancelAllAnimations(t);
|
|
2134
2330
|
const a = this.config.animationDuration ?? 600;
|
|
2135
2331
|
t.classList.remove("fbn-ic-focused"), pt(t, this.focusedClassName);
|
|
2136
|
-
const r = e ?? this.focusData?.focusTransform ?? { x: 0, y: 0, rotation: 0, scale: 1 }, s =
|
|
2332
|
+
const r = e ?? this.focusData?.focusTransform ?? { x: 0, y: 0, rotation: 0, scale: 1 }, s = n?.width ?? this.focusData?.focusWidth ?? t.offsetWidth, c = n?.height ?? this.focusData?.focusHeight ?? t.offsetHeight, l = {
|
|
2137
2333
|
x: 0,
|
|
2138
2334
|
y: 0,
|
|
2139
2335
|
rotation: i.rotation,
|
|
@@ -2181,10 +2377,10 @@ class Pe {
|
|
|
2181
2377
|
* Caller is responsible for calling animationEngine.cancelAllAnimations() afterwards.
|
|
2182
2378
|
*/
|
|
2183
2379
|
captureMidAnimationState(t) {
|
|
2184
|
-
const i = getComputedStyle(t), e = new DOMMatrix(i.transform),
|
|
2185
|
-
return t.style.width = `${
|
|
2380
|
+
const i = getComputedStyle(t), e = new DOMMatrix(i.transform), n = t.offsetWidth, a = t.offsetHeight, r = e.e + n * 0.5, s = e.f + a * 0.5, c = Math.atan2(e.b, e.a) * (180 / Math.PI);
|
|
2381
|
+
return t.style.width = `${n}px`, t.style.height = `${a}px`, t.style.transform = `translate(-50%, -50%) translate(${r}px, ${s}px) rotate(${c}deg)`, t.style.transition = "none", {
|
|
2186
2382
|
transform: { x: r, y: s, rotation: c, scale: 1 },
|
|
2187
|
-
dimensions: { width:
|
|
2383
|
+
dimensions: { width: n, height: a }
|
|
2188
2384
|
};
|
|
2189
2385
|
}
|
|
2190
2386
|
/**
|
|
@@ -2199,10 +2395,10 @@ class Pe {
|
|
|
2199
2395
|
/**
|
|
2200
2396
|
* Reset an element instantly to its original position and dimensions (no animation)
|
|
2201
2397
|
*/
|
|
2202
|
-
resetElementInstantly(t, i, e,
|
|
2398
|
+
resetElementInstantly(t, i, e, n, a) {
|
|
2203
2399
|
this.animationEngine.cancelAllAnimations(t);
|
|
2204
2400
|
const r = ["translate(-50%, -50%)"];
|
|
2205
|
-
r.push("translate(0px, 0px)"), r.push(`rotate(${i.rotation}deg)`), t.style.transition = "none", t.style.transform = r.join(" "),
|
|
2401
|
+
r.push("translate(0px, 0px)"), r.push(`rotate(${i.rotation}deg)`), t.style.transition = "none", t.style.transform = r.join(" "), n !== void 0 && a !== void 0 && (t.style.width = `${n}px`, t.style.height = `${a}px`), this.removeFocusedStyling(t, e);
|
|
2206
2402
|
}
|
|
2207
2403
|
/**
|
|
2208
2404
|
* Focus (zoom) an image to center of container
|
|
@@ -2221,10 +2417,10 @@ class Pe {
|
|
|
2221
2417
|
), this.incoming = null, this.state = S.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 = S.IDLE;
|
|
2222
2418
|
return;
|
|
2223
2419
|
}
|
|
2224
|
-
const
|
|
2420
|
+
const n = ++this.focusGeneration;
|
|
2225
2421
|
switch (this.state) {
|
|
2226
2422
|
case S.IDLE:
|
|
2227
|
-
if (this.state = S.FOCUSING, this.incoming = this.startFocusAnimation(t, i, e), await this.waitForAnimation(this.incoming.animationHandle), this.focusGeneration !==
|
|
2423
|
+
if (this.state = S.FOCUSING, this.incoming = this.startFocusAnimation(t, i, e), await this.waitForAnimation(this.incoming.animationHandle), this.focusGeneration !== n) return;
|
|
2228
2424
|
this.currentFocus = t, this.incoming = null, this.state = S.FOCUSED;
|
|
2229
2425
|
break;
|
|
2230
2426
|
case S.FOCUSED:
|
|
@@ -2234,9 +2430,13 @@ class Pe {
|
|
|
2234
2430
|
)), this.incoming = this.startFocusAnimation(t, i, e), await Promise.all([
|
|
2235
2431
|
this.outgoing ? this.waitForAnimation(this.outgoing.animationHandle) : Promise.resolve(),
|
|
2236
2432
|
this.waitForAnimation(this.incoming.animationHandle)
|
|
2237
|
-
]), this.focusGeneration !==
|
|
2433
|
+
]), this.focusGeneration !== n)
|
|
2238
2434
|
return;
|
|
2239
|
-
|
|
2435
|
+
if (this.outgoing) {
|
|
2436
|
+
const a = this.outgoing.element;
|
|
2437
|
+
this.removeFocusedStyling(a, this.outgoing.originalState.zIndex?.toString() || ""), this.outgoing = null, this.onUnfocusComplete?.(a);
|
|
2438
|
+
}
|
|
2439
|
+
this.currentFocus = t, this.incoming = null, this.state = S.FOCUSED;
|
|
2240
2440
|
break;
|
|
2241
2441
|
case S.FOCUSING:
|
|
2242
2442
|
if (this.incoming && (this.animationEngine.cancelAnimation(this.incoming.animationHandle, !1), this.resetElementInstantly(
|
|
@@ -2245,15 +2445,19 @@ class Pe {
|
|
|
2245
2445
|
this.focusData?.originalZIndex || "",
|
|
2246
2446
|
this.focusData?.originalWidth,
|
|
2247
2447
|
this.focusData?.originalHeight
|
|
2248
|
-
), this.incoming = null), this.incoming = this.startFocusAnimation(t, i, e), await this.waitForAnimation(this.incoming.animationHandle), this.focusGeneration !==
|
|
2448
|
+
), this.incoming = null), this.incoming = this.startFocusAnimation(t, i, e), await this.waitForAnimation(this.incoming.animationHandle), this.focusGeneration !== n) return;
|
|
2249
2449
|
this.currentFocus = t, this.incoming = null, this.state = S.FOCUSED;
|
|
2250
2450
|
break;
|
|
2251
2451
|
case S.UNFOCUSING:
|
|
2252
2452
|
if (this.state = S.CROSS_ANIMATING, this.incoming = this.startFocusAnimation(t, i, e), await Promise.all([
|
|
2253
2453
|
this.outgoing ? this.waitForAnimation(this.outgoing.animationHandle) : Promise.resolve(),
|
|
2254
2454
|
this.waitForAnimation(this.incoming.animationHandle)
|
|
2255
|
-
]), this.focusGeneration !==
|
|
2256
|
-
|
|
2455
|
+
]), this.focusGeneration !== n) return;
|
|
2456
|
+
if (this.outgoing) {
|
|
2457
|
+
const a = this.outgoing.element;
|
|
2458
|
+
this.removeFocusedStyling(a, this.outgoing.originalState.zIndex?.toString() || ""), this.outgoing = null, this.onUnfocusComplete?.(a);
|
|
2459
|
+
}
|
|
2460
|
+
this.currentFocus = t, this.incoming = null, this.state = S.FOCUSED;
|
|
2257
2461
|
break;
|
|
2258
2462
|
case S.CROSS_ANIMATING:
|
|
2259
2463
|
if (this.incoming?.element === t)
|
|
@@ -2273,8 +2477,12 @@ class Pe {
|
|
|
2273
2477
|
if (this.incoming = this.startFocusAnimation(t, i, e, a, r), await Promise.all([
|
|
2274
2478
|
this.outgoing ? this.waitForAnimation(this.outgoing.animationHandle) : Promise.resolve(),
|
|
2275
2479
|
this.waitForAnimation(this.incoming.animationHandle)
|
|
2276
|
-
]), this.focusGeneration !==
|
|
2277
|
-
|
|
2480
|
+
]), this.focusGeneration !== n) return;
|
|
2481
|
+
if (this.outgoing) {
|
|
2482
|
+
const s = this.outgoing.element;
|
|
2483
|
+
this.removeFocusedStyling(s, this.outgoing.originalState.zIndex?.toString() || ""), this.outgoing = null, this.onUnfocusComplete?.(s);
|
|
2484
|
+
}
|
|
2485
|
+
this.currentFocus = t, this.incoming = null, this.state = S.FOCUSED;
|
|
2278
2486
|
return;
|
|
2279
2487
|
}
|
|
2280
2488
|
if (this.outgoing && (this.animationEngine.cancelAnimation(this.outgoing.animationHandle, !1), this.resetElementInstantly(
|
|
@@ -2295,8 +2503,12 @@ class Pe {
|
|
|
2295
2503
|
if (this.incoming = this.startFocusAnimation(t, i, e), await Promise.all([
|
|
2296
2504
|
this.outgoing ? this.waitForAnimation(this.outgoing.animationHandle) : Promise.resolve(),
|
|
2297
2505
|
this.waitForAnimation(this.incoming.animationHandle)
|
|
2298
|
-
]), this.focusGeneration !==
|
|
2299
|
-
|
|
2506
|
+
]), this.focusGeneration !== n) return;
|
|
2507
|
+
if (this.outgoing) {
|
|
2508
|
+
const a = this.outgoing.element;
|
|
2509
|
+
this.removeFocusedStyling(a, this.outgoing.originalState.zIndex?.toString() || ""), this.outgoing = null, this.onUnfocusComplete?.(a);
|
|
2510
|
+
}
|
|
2511
|
+
this.currentFocus = t, this.incoming = null, this.state = S.FOCUSED;
|
|
2300
2512
|
break;
|
|
2301
2513
|
}
|
|
2302
2514
|
}
|
|
@@ -2316,7 +2528,8 @@ class Pe {
|
|
|
2316
2528
|
a,
|
|
2317
2529
|
r
|
|
2318
2530
|
), this.incoming = null, this.state = S.UNFOCUSING, await this.waitForAnimation(this.outgoing.animationHandle), this.focusGeneration !== t) return;
|
|
2319
|
-
|
|
2531
|
+
const s = this.outgoing.element;
|
|
2532
|
+
this.removeFocusedStyling(s, this.focusData?.originalZIndex || ""), this.outgoing = null, this.focusData = null, this.state = S.IDLE, this.onUnfocusComplete?.(s);
|
|
2320
2533
|
}
|
|
2321
2534
|
return;
|
|
2322
2535
|
}
|
|
@@ -2333,12 +2546,15 @@ class Pe {
|
|
|
2333
2546
|
this.outgoing ? this.waitForAnimation(this.outgoing.animationHandle) : Promise.resolve(),
|
|
2334
2547
|
this.waitForAnimation(s.animationHandle)
|
|
2335
2548
|
]), this.focusGeneration !== t) return;
|
|
2336
|
-
|
|
2549
|
+
let c = null;
|
|
2550
|
+
this.outgoing && (c = this.outgoing.element, this.removeFocusedStyling(c, this.outgoing.originalState.zIndex?.toString() || ""));
|
|
2551
|
+
const l = s.element;
|
|
2552
|
+
this.removeFocusedStyling(l, this.incoming.originalState.zIndex?.toString() || ""), this.outgoing = null, this.incoming = null, this.currentFocus = null, this.focusData = null, this.state = S.IDLE, c && this.onUnfocusComplete?.(c), this.onUnfocusComplete?.(l);
|
|
2337
2553
|
return;
|
|
2338
2554
|
}
|
|
2339
2555
|
this.state = S.UNFOCUSING;
|
|
2340
|
-
const i = this.currentFocus, e = this.focusData.originalState,
|
|
2341
|
-
this.outgoing = this.startUnfocusAnimation(i, e), await this.waitForAnimation(this.outgoing.animationHandle), this.focusGeneration === t && (this.removeFocusedStyling(i,
|
|
2556
|
+
const i = this.currentFocus, e = this.focusData.originalState, n = this.focusData.originalZIndex;
|
|
2557
|
+
this.outgoing = this.startUnfocusAnimation(i, e), await this.waitForAnimation(this.outgoing.animationHandle), this.focusGeneration === t && (this.removeFocusedStyling(i, n), this.outgoing = null, this.currentFocus = null, this.focusData = null, this.state = S.IDLE, this.onUnfocusComplete?.(i));
|
|
2342
2558
|
}
|
|
2343
2559
|
/**
|
|
2344
2560
|
* Swap focus from current image to a new one (alias for focusImage with cross-animation)
|
|
@@ -2378,8 +2594,8 @@ class Pe {
|
|
|
2378
2594
|
*/
|
|
2379
2595
|
setDragOffset(t) {
|
|
2380
2596
|
if (!this.currentFocus || !this.focusData || this.state !== S.FOCUSED) return;
|
|
2381
|
-
const i = this.currentFocus, e = this.focusData.focusTransform,
|
|
2382
|
-
|
|
2597
|
+
const i = this.currentFocus, e = this.focusData.focusTransform, n = ["translate(-50%, -50%)"], a = (e.x ?? 0) + t, r = e.y ?? 0;
|
|
2598
|
+
n.push(`translate(${a}px, ${r}px)`), e.rotation !== void 0 && n.push(`rotate(${e.rotation}deg)`), i.style.transition = "none", i.style.transform = n.join(" ");
|
|
2383
2599
|
}
|
|
2384
2600
|
/**
|
|
2385
2601
|
* Clear the drag offset, optionally animating back to center
|
|
@@ -2388,8 +2604,8 @@ class Pe {
|
|
|
2388
2604
|
*/
|
|
2389
2605
|
clearDragOffset(t, i = 150) {
|
|
2390
2606
|
if (!this.currentFocus || !this.focusData || this.state !== S.FOCUSED) return;
|
|
2391
|
-
const e = this.currentFocus,
|
|
2392
|
-
a.push(`translate(${r}px, ${s}px)`),
|
|
2607
|
+
const e = this.currentFocus, n = this.focusData.focusTransform, a = ["translate(-50%, -50%)"], r = n.x ?? 0, s = n.y ?? 0;
|
|
2608
|
+
a.push(`translate(${r}px, ${s}px)`), n.rotation !== void 0 && a.push(`rotate(${n.rotation}deg)`);
|
|
2393
2609
|
const c = a.join(" ");
|
|
2394
2610
|
t ? (e.style.transition = `transform ${i}ms ease-out`, e.style.transform = c, setTimeout(() => {
|
|
2395
2611
|
this.currentFocus === e && (e.style.transition = "none");
|
|
@@ -2420,7 +2636,7 @@ class Pe {
|
|
|
2420
2636
|
), this.state = S.IDLE, this.currentFocus = null, this.focusData = null, this.outgoing = null, this.incoming = null;
|
|
2421
2637
|
}
|
|
2422
2638
|
}
|
|
2423
|
-
const
|
|
2639
|
+
const We = 50, Ge = 0.5, qe = 20, Be = 0.3, Xe = 150, Ye = 30, at = class at {
|
|
2424
2640
|
constructor(t, i) {
|
|
2425
2641
|
this.enabled = !1, this.touchState = null, this.recentTouchTimestamp = 0, this.container = t, this.callbacks = i, this.boundTouchStart = this.handleTouchStart.bind(this), this.boundTouchMove = this.handleTouchMove.bind(this), this.boundTouchEnd = this.handleTouchEnd.bind(this), this.boundTouchCancel = this.handleTouchCancel.bind(this);
|
|
2426
2642
|
}
|
|
@@ -2464,23 +2680,23 @@ const _e = 50, Ue = 0.5, He = 20, Ne = 0.3, je = 150, ke = 30, at = class at {
|
|
|
2464
2680
|
}
|
|
2465
2681
|
handleTouchMove(t) {
|
|
2466
2682
|
if (!this.touchState || t.touches.length !== 1) return;
|
|
2467
|
-
const i = t.touches[0], e = i.clientX - this.touchState.startX,
|
|
2468
|
-
if (this.touchState.isHorizontalSwipe === null && Math.sqrt(e * e +
|
|
2469
|
-
const s = Math.atan2(Math.abs(
|
|
2470
|
-
this.touchState.isHorizontalSwipe = s <=
|
|
2683
|
+
const i = t.touches[0], e = i.clientX - this.touchState.startX, n = i.clientY - this.touchState.startY;
|
|
2684
|
+
if (this.touchState.isHorizontalSwipe === null && Math.sqrt(e * e + n * n) > 10) {
|
|
2685
|
+
const s = Math.atan2(Math.abs(n), Math.abs(e)) * (180 / Math.PI);
|
|
2686
|
+
this.touchState.isHorizontalSwipe = s <= Ye;
|
|
2471
2687
|
}
|
|
2472
2688
|
if (this.touchState.isHorizontalSwipe !== !1 && this.touchState.isHorizontalSwipe === !0) {
|
|
2473
2689
|
t.preventDefault(), this.touchState.isDragging = !0, this.touchState.currentX = i.clientX;
|
|
2474
|
-
const a = e *
|
|
2690
|
+
const a = e * Be;
|
|
2475
2691
|
this.callbacks.onDragOffset(a);
|
|
2476
2692
|
}
|
|
2477
2693
|
}
|
|
2478
2694
|
handleTouchEnd(t) {
|
|
2479
2695
|
if (!this.touchState) return;
|
|
2480
2696
|
this.recentTouchTimestamp = Date.now();
|
|
2481
|
-
const i = this.touchState.currentX - this.touchState.startX, e = performance.now() - this.touchState.startTime,
|
|
2697
|
+
const i = this.touchState.currentX - this.touchState.startX, e = performance.now() - this.touchState.startTime, n = Math.abs(i) / e, a = Math.abs(i);
|
|
2482
2698
|
let r = !1;
|
|
2483
|
-
this.touchState.isHorizontalSwipe === !0 && this.touchState.isDragging && (a >=
|
|
2699
|
+
this.touchState.isHorizontalSwipe === !0 && this.touchState.isDragging && (a >= We || n >= Ge && a >= qe) && (r = !0, i < 0 ? this.callbacks.onNext() : this.callbacks.onPrev()), this.touchState.isDragging && this.callbacks.onDragEnd(r), this.touchState = null;
|
|
2484
2700
|
}
|
|
2485
2701
|
handleTouchCancel(t) {
|
|
2486
2702
|
this.touchState?.isDragging && this.callbacks.onDragEnd(!1), this.touchState = null;
|
|
@@ -2488,7 +2704,7 @@ const _e = 50, Ue = 0.5, He = 20, Ne = 0.3, je = 150, ke = 30, at = class at {
|
|
|
2488
2704
|
};
|
|
2489
2705
|
at.TOUCH_CLICK_DELAY = 300;
|
|
2490
2706
|
let bt = at;
|
|
2491
|
-
class
|
|
2707
|
+
class Je {
|
|
2492
2708
|
constructor(t) {
|
|
2493
2709
|
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)
|
|
2494
2710
|
throw new Error("GoogleDriveLoader requires at least one source to be configured");
|
|
@@ -2502,7 +2718,7 @@ class We {
|
|
|
2502
2718
|
for (const i of this.sources)
|
|
2503
2719
|
if ("folders" in i)
|
|
2504
2720
|
for (const e of i.folders) {
|
|
2505
|
-
const
|
|
2721
|
+
const n = i.recursive !== void 0 ? i.recursive : !0, a = await this.loadFromFolder(e, t, n);
|
|
2506
2722
|
this._discoveredUrls.push(...a);
|
|
2507
2723
|
}
|
|
2508
2724
|
else if ("files" in i) {
|
|
@@ -2548,9 +2764,9 @@ class We {
|
|
|
2548
2764
|
// Alternative format
|
|
2549
2765
|
];
|
|
2550
2766
|
for (const e of i) {
|
|
2551
|
-
const
|
|
2552
|
-
if (
|
|
2553
|
-
return
|
|
2767
|
+
const n = t.match(e);
|
|
2768
|
+
if (n && n[1])
|
|
2769
|
+
return n[1];
|
|
2554
2770
|
}
|
|
2555
2771
|
return null;
|
|
2556
2772
|
}
|
|
@@ -2562,15 +2778,15 @@ class We {
|
|
|
2562
2778
|
* @returns Promise resolving to array of image URLs
|
|
2563
2779
|
*/
|
|
2564
2780
|
async loadFromFolder(t, i, e = !0) {
|
|
2565
|
-
const
|
|
2566
|
-
if (!
|
|
2781
|
+
const n = this.extractFolderId(t);
|
|
2782
|
+
if (!n)
|
|
2567
2783
|
throw new Error("Invalid Google Drive folder URL. Please check the URL format.");
|
|
2568
2784
|
if (!this.apiKey || this.apiKey === "YOUR_API_KEY_HERE")
|
|
2569
|
-
return this.loadImagesDirectly(
|
|
2785
|
+
return this.loadImagesDirectly(n, i);
|
|
2570
2786
|
try {
|
|
2571
|
-
return e ? await this.loadImagesRecursively(
|
|
2787
|
+
return e ? await this.loadImagesRecursively(n, i) : await this.loadImagesFromSingleFolder(n, i);
|
|
2572
2788
|
} catch (a) {
|
|
2573
|
-
return console.error("Error loading from Google Drive API:", a), this.loadImagesDirectly(
|
|
2789
|
+
return console.error("Error loading from Google Drive API:", a), this.loadImagesDirectly(n, i);
|
|
2574
2790
|
}
|
|
2575
2791
|
}
|
|
2576
2792
|
/**
|
|
@@ -2580,7 +2796,7 @@ class We {
|
|
|
2580
2796
|
* @returns Promise resolving to array of image URLs
|
|
2581
2797
|
*/
|
|
2582
2798
|
async loadImagesFromSingleFolder(t, i) {
|
|
2583
|
-
const e = [],
|
|
2799
|
+
const e = [], n = `'${t}' in parents and trashed=false`, r = `${this.apiEndpoint}?q=${encodeURIComponent(n)}&fields=files(id,name,mimeType,thumbnailLink)&key=${this.apiKey}`, s = await fetch(r);
|
|
2584
2800
|
if (!s.ok)
|
|
2585
2801
|
throw new Error(`API request failed: ${s.status} ${s.statusText}`);
|
|
2586
2802
|
const l = (await s.json()).files.filter(
|
|
@@ -2598,10 +2814,10 @@ class We {
|
|
|
2598
2814
|
*/
|
|
2599
2815
|
async loadFiles(t, i) {
|
|
2600
2816
|
const e = [];
|
|
2601
|
-
for (const
|
|
2602
|
-
const a = this.extractFileId(
|
|
2817
|
+
for (const n of t) {
|
|
2818
|
+
const a = this.extractFileId(n);
|
|
2603
2819
|
if (!a) {
|
|
2604
|
-
this.log(`Skipping invalid file URL: ${
|
|
2820
|
+
this.log(`Skipping invalid file URL: ${n}`);
|
|
2605
2821
|
continue;
|
|
2606
2822
|
}
|
|
2607
2823
|
if (this.apiKey && this.apiKey !== "YOUR_API_KEY_HERE")
|
|
@@ -2637,9 +2853,9 @@ class We {
|
|
|
2637
2853
|
// Generic id parameter
|
|
2638
2854
|
];
|
|
2639
2855
|
for (const e of i) {
|
|
2640
|
-
const
|
|
2641
|
-
if (
|
|
2642
|
-
return
|
|
2856
|
+
const n = t.match(e);
|
|
2857
|
+
if (n && n[1])
|
|
2858
|
+
return n[1];
|
|
2643
2859
|
}
|
|
2644
2860
|
return null;
|
|
2645
2861
|
}
|
|
@@ -2650,7 +2866,7 @@ class We {
|
|
|
2650
2866
|
* @returns Promise resolving to array of image URLs
|
|
2651
2867
|
*/
|
|
2652
2868
|
async loadImagesRecursively(t, i) {
|
|
2653
|
-
const e = [],
|
|
2869
|
+
const e = [], n = `'${t}' in parents and trashed=false`, r = `${this.apiEndpoint}?q=${encodeURIComponent(n)}&fields=files(id,name,mimeType,thumbnailLink)&key=${this.apiKey}`, s = await fetch(r);
|
|
2654
2870
|
if (!s.ok)
|
|
2655
2871
|
throw new Error(`API request failed: ${s.status} ${s.statusText}`);
|
|
2656
2872
|
const c = await s.json(), l = c.files.filter(
|
|
@@ -2677,10 +2893,10 @@ class We {
|
|
|
2677
2893
|
*/
|
|
2678
2894
|
async loadImagesDirectly(t, i) {
|
|
2679
2895
|
try {
|
|
2680
|
-
const e = `https://drive.google.com/embeddedfolderview?id=${t}`,
|
|
2681
|
-
if (!
|
|
2896
|
+
const e = `https://drive.google.com/embeddedfolderview?id=${t}`, n = await fetch(e, { mode: "cors" });
|
|
2897
|
+
if (!n.ok)
|
|
2682
2898
|
throw new Error("Cannot access folder directly (CORS or permissions issue)");
|
|
2683
|
-
const a = await
|
|
2899
|
+
const a = await n.text(), r = /\/file\/d\/([a-zA-Z0-9_-]+)/g, s = [...a.matchAll(r)];
|
|
2684
2900
|
return [...new Set(s.map((u) => u[1]))].map(
|
|
2685
2901
|
(u) => `https://drive.google.com/uc?export=view&id=${u}`
|
|
2686
2902
|
);
|
|
@@ -2709,7 +2925,7 @@ class We {
|
|
|
2709
2925
|
this.debugLogging && typeof console < "u" && console.log(...t);
|
|
2710
2926
|
}
|
|
2711
2927
|
}
|
|
2712
|
-
class
|
|
2928
|
+
class Ve {
|
|
2713
2929
|
constructor(t) {
|
|
2714
2930
|
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)
|
|
2715
2931
|
throw new Error("StaticImageLoader requires at least one source to be configured");
|
|
@@ -2773,13 +2989,13 @@ class Ge {
|
|
|
2773
2989
|
if (!Array.isArray(t))
|
|
2774
2990
|
return console.warn("URLs must be an array:", t), [];
|
|
2775
2991
|
const e = [];
|
|
2776
|
-
for (const
|
|
2777
|
-
const a =
|
|
2992
|
+
for (const n of t) {
|
|
2993
|
+
const a = n.split("/").pop() || n;
|
|
2778
2994
|
if (!i.isAllowed(a)) {
|
|
2779
|
-
this.log(`Skipping filtered URL: ${
|
|
2995
|
+
this.log(`Skipping filtered URL: ${n}`);
|
|
2780
2996
|
continue;
|
|
2781
2997
|
}
|
|
2782
|
-
this.validateUrls ? await this.validateUrl(
|
|
2998
|
+
this.validateUrls ? await this.validateUrl(n) ? e.push(n) : console.warn(`Skipping invalid/missing URL: ${n}`) : e.push(n);
|
|
2783
2999
|
}
|
|
2784
3000
|
return e;
|
|
2785
3001
|
}
|
|
@@ -2793,16 +3009,16 @@ class Ge {
|
|
|
2793
3009
|
async processPath(t, i, e) {
|
|
2794
3010
|
if (!Array.isArray(i))
|
|
2795
3011
|
return console.warn("files must be an array:", i), [];
|
|
2796
|
-
const
|
|
3012
|
+
const n = [];
|
|
2797
3013
|
for (const a of i) {
|
|
2798
3014
|
if (!e.isAllowed(a)) {
|
|
2799
3015
|
this.log(`Skipping filtered file: ${a}`);
|
|
2800
3016
|
continue;
|
|
2801
3017
|
}
|
|
2802
3018
|
const r = this.constructUrl(t, a);
|
|
2803
|
-
this.validateUrls ? await this.validateUrl(r) ?
|
|
3019
|
+
this.validateUrls ? await this.validateUrl(r) ? n.push(r) : console.warn(`Skipping invalid/missing file: ${r}`) : n.push(r);
|
|
2804
3020
|
}
|
|
2805
|
-
return
|
|
3021
|
+
return n;
|
|
2806
3022
|
}
|
|
2807
3023
|
/**
|
|
2808
3024
|
* Process a JSON endpoint source
|
|
@@ -2813,17 +3029,17 @@ class Ge {
|
|
|
2813
3029
|
*/
|
|
2814
3030
|
async processJson(t, i) {
|
|
2815
3031
|
this.log(`Fetching JSON endpoint: ${t}`);
|
|
2816
|
-
const e = new AbortController(),
|
|
3032
|
+
const e = new AbortController(), n = setTimeout(() => e.abort(), 1e4);
|
|
2817
3033
|
try {
|
|
2818
3034
|
const a = await fetch(t, { signal: e.signal });
|
|
2819
|
-
if (clearTimeout(
|
|
3035
|
+
if (clearTimeout(n), !a.ok)
|
|
2820
3036
|
throw new Error(`HTTP ${a.status} fetching ${t}`);
|
|
2821
3037
|
const r = await a.json();
|
|
2822
3038
|
if (!r || !Array.isArray(r.images))
|
|
2823
3039
|
throw new Error('JSON source must return JSON with shape { "images": ["url1", "url2", ...] }');
|
|
2824
3040
|
return this.log(`JSON endpoint returned ${r.images.length} image(s)`), await this.processUrls(r.images, i);
|
|
2825
3041
|
} catch (a) {
|
|
2826
|
-
throw clearTimeout(
|
|
3042
|
+
throw clearTimeout(n), a instanceof Error && a.name === "AbortError" ? new Error(`Timeout fetching JSON endpoint: ${t}`) : a;
|
|
2827
3043
|
}
|
|
2828
3044
|
}
|
|
2829
3045
|
/**
|
|
@@ -2845,11 +3061,11 @@ class Ge {
|
|
|
2845
3061
|
if (!(t.startsWith(window.location.origin) || t.startsWith("/")))
|
|
2846
3062
|
return this.log(`Skipping validation for cross-origin URL: ${t}`), !0;
|
|
2847
3063
|
try {
|
|
2848
|
-
const e = new AbortController(),
|
|
3064
|
+
const e = new AbortController(), n = setTimeout(() => e.abort(), this.validationTimeout), a = await fetch(t, {
|
|
2849
3065
|
method: "HEAD",
|
|
2850
3066
|
signal: e.signal
|
|
2851
3067
|
});
|
|
2852
|
-
return clearTimeout(
|
|
3068
|
+
return clearTimeout(n), a.ok ? !0 : (this.log(`Validation failed for ${t}: HTTP ${a.status}`), !1);
|
|
2853
3069
|
} catch (e) {
|
|
2854
3070
|
return e instanceof Error && (e.name === "AbortError" ? this.log(`Validation timeout for ${t}`) : this.log(`Validation failed for ${t}:`, e.message)), !1;
|
|
2855
3071
|
}
|
|
@@ -2866,8 +3082,8 @@ class Ge {
|
|
|
2866
3082
|
return `${e}/${i}`;
|
|
2867
3083
|
if (typeof window > "u")
|
|
2868
3084
|
return `${e}/${i}`;
|
|
2869
|
-
const
|
|
2870
|
-
return `${
|
|
3085
|
+
const n = window.location.origin, r = (t.startsWith("/") ? t : "/" + t).replace(/\/$/, "");
|
|
3086
|
+
return `${n}${r}/${i}`;
|
|
2871
3087
|
}
|
|
2872
3088
|
/**
|
|
2873
3089
|
* Check if URL is absolute (contains protocol)
|
|
@@ -2889,7 +3105,7 @@ class Ge {
|
|
|
2889
3105
|
this.debugLogging && typeof console < "u" && console.log(...t);
|
|
2890
3106
|
}
|
|
2891
3107
|
}
|
|
2892
|
-
class
|
|
3108
|
+
class Ke {
|
|
2893
3109
|
constructor(t) {
|
|
2894
3110
|
if (this._prepared = !1, this._discoveredUrls = [], this.loaders = t.loaders, this.debugLogging = t.debugLogging ?? !1, !this.loaders || this.loaders.length === 0)
|
|
2895
3111
|
throw new Error("CompositeLoader requires at least one loader to be configured");
|
|
@@ -2901,16 +3117,16 @@ class qe {
|
|
|
2901
3117
|
*/
|
|
2902
3118
|
async prepare(t) {
|
|
2903
3119
|
this._discoveredUrls = [], this.log(`Preparing ${this.loaders.length} loader(s) in parallel`);
|
|
2904
|
-
const i = this.loaders.map((e,
|
|
2905
|
-
this.log(`Loader ${
|
|
3120
|
+
const i = this.loaders.map((e, n) => e.prepare(t).then(() => {
|
|
3121
|
+
this.log(`Loader ${n} prepared with ${e.imagesLength()} images`);
|
|
2906
3122
|
}).catch((a) => {
|
|
2907
|
-
console.warn(`Loader ${
|
|
3123
|
+
console.warn(`Loader ${n} failed to prepare:`, a);
|
|
2908
3124
|
}));
|
|
2909
3125
|
await Promise.all(i);
|
|
2910
3126
|
for (const e of this.loaders)
|
|
2911
3127
|
if (e.isPrepared()) {
|
|
2912
|
-
const
|
|
2913
|
-
this._discoveredUrls.push(...
|
|
3128
|
+
const n = e.imageURLs();
|
|
3129
|
+
this._discoveredUrls.push(...n);
|
|
2914
3130
|
}
|
|
2915
3131
|
this._prepared = !0, this.log(`CompositeLoader prepared with ${this._discoveredUrls.length} total images`);
|
|
2916
3132
|
}
|
|
@@ -2946,7 +3162,7 @@ class qe {
|
|
|
2946
3162
|
this.debugLogging && typeof console < "u" && console.log("[CompositeLoader]", ...t);
|
|
2947
3163
|
}
|
|
2948
3164
|
}
|
|
2949
|
-
class
|
|
3165
|
+
class Ze {
|
|
2950
3166
|
/**
|
|
2951
3167
|
* Create a new ImageFilter
|
|
2952
3168
|
* @param extensions - Array of allowed file extensions (without dots)
|
|
@@ -2983,7 +3199,7 @@ class Xe {
|
|
|
2983
3199
|
// isAllowedDate(date: Date): boolean
|
|
2984
3200
|
// isAllowedDimensions(width: number, height: number): boolean
|
|
2985
3201
|
}
|
|
2986
|
-
const
|
|
3202
|
+
const Qe = `
|
|
2987
3203
|
.fbn-ic-gallery {
|
|
2988
3204
|
position: relative;
|
|
2989
3205
|
width: 100%;
|
|
@@ -3033,31 +3249,38 @@ const Ye = `
|
|
|
3033
3249
|
display: none !important;
|
|
3034
3250
|
}
|
|
3035
3251
|
`;
|
|
3036
|
-
function
|
|
3252
|
+
function ti() {
|
|
3037
3253
|
if (typeof document > "u") return;
|
|
3038
|
-
const
|
|
3039
|
-
if (document.getElementById(
|
|
3254
|
+
const o = "fbn-ic-functional-styles";
|
|
3255
|
+
if (document.getElementById(o)) return;
|
|
3040
3256
|
const t = document.createElement("style");
|
|
3041
|
-
t.id =
|
|
3257
|
+
t.id = o, t.textContent = Qe, document.head.appendChild(t);
|
|
3042
3258
|
}
|
|
3043
|
-
class
|
|
3259
|
+
class ei {
|
|
3044
3260
|
constructor(t = {}) {
|
|
3045
|
-
this.fullConfig =
|
|
3261
|
+
this.fullConfig = te(t), t.container instanceof HTMLElement ? (this.containerRef = t.container, this.containerId = null) : (this.containerRef = null, this.containerId = t.container || "imageCloud"), this.imagesLoaded = !1, this.imageElements = [], this.imageLayouts = [], this.currentImageHeight = 225, this.currentFocusIndex = null, this.hoveredImage = null, this.resizeTimeout = null, this.displayQueue = [], this.queueInterval = null, this.loadGeneration = 0, this.loadingElAutoCreated = !1, this.errorElAutoCreated = !1, this.counterEl = null, this.counterElAutoCreated = !1, this.animationEngine = new oe(this.fullConfig.animation), this.layoutEngine = new De({
|
|
3046
3262
|
layout: this.fullConfig.layout,
|
|
3047
3263
|
image: this.fullConfig.image
|
|
3048
|
-
}), this.zoomEngine = new
|
|
3049
|
-
const i = this.fullConfig.animation.entry ||
|
|
3050
|
-
this.entryAnimationEngine = new
|
|
3264
|
+
}), this.zoomEngine = new je(this.fullConfig.interaction.focus, this.animationEngine, this.fullConfig.styling), this.defaultStyles = et(this.fullConfig.styling?.default), this.defaultClassName = this.fullConfig.styling?.default?.className, this.hoverClassName = this.fullConfig.styling?.hover?.className;
|
|
3265
|
+
const i = this.fullConfig.animation.entry || x.animation.entry;
|
|
3266
|
+
this.entryAnimationEngine = new me(
|
|
3051
3267
|
i,
|
|
3052
3268
|
this.fullConfig.layout.algorithm
|
|
3053
|
-
)
|
|
3269
|
+
);
|
|
3270
|
+
const e = this.fullConfig.animation.idle;
|
|
3271
|
+
e && e.type !== "none" ? this.idleAnimationEngine = new pe(
|
|
3272
|
+
e,
|
|
3273
|
+
i.timing?.duration ?? 600
|
|
3274
|
+
) : this.idleAnimationEngine = null, this.zoomEngine.setOnUnfocusCompleteCallback((n) => {
|
|
3275
|
+
this.idleAnimationEngine?.resumeForImage(n);
|
|
3276
|
+
}), this.swipeEngine = null, this.imageFilter = this.createImageFilter(), this.imageLoader = this.createLoader(), this.containerEl = null, this.loadingEl = null, this.errorEl = null;
|
|
3054
3277
|
}
|
|
3055
3278
|
/**
|
|
3056
3279
|
* Create image filter based on shared loader config
|
|
3057
3280
|
*/
|
|
3058
3281
|
createImageFilter() {
|
|
3059
3282
|
const t = this.fullConfig.config.loaders?.allowedExtensions;
|
|
3060
|
-
return new
|
|
3283
|
+
return new Ze(t);
|
|
3061
3284
|
}
|
|
3062
3285
|
/**
|
|
3063
3286
|
* Create appropriate image loader based on config
|
|
@@ -3067,8 +3290,8 @@ class Je {
|
|
|
3067
3290
|
const t = this.fullConfig.loaders, i = this.fullConfig.config.loaders ?? {};
|
|
3068
3291
|
if (!t || t.length === 0)
|
|
3069
3292
|
throw new Error("No loaders configured. Provide `images`, `loaders`, or both.");
|
|
3070
|
-
const e = t.map((
|
|
3071
|
-
return e.length === 1 ? e[0] : new
|
|
3293
|
+
const e = t.map((n) => this.createLoaderFromEntry(n, i));
|
|
3294
|
+
return e.length === 1 ? e[0] : new Ke({
|
|
3072
3295
|
loaders: e,
|
|
3073
3296
|
debugLogging: this.fullConfig.config.debug?.loaders
|
|
3074
3297
|
});
|
|
@@ -3078,7 +3301,7 @@ class Je {
|
|
|
3078
3301
|
*/
|
|
3079
3302
|
createLoaderFromEntry(t, i) {
|
|
3080
3303
|
if ("static" in t) {
|
|
3081
|
-
const e = t.static,
|
|
3304
|
+
const e = t.static, n = {
|
|
3082
3305
|
...e,
|
|
3083
3306
|
validateUrls: e.validateUrls ?? i.validateUrls,
|
|
3084
3307
|
validationTimeout: e.validationTimeout ?? i.validationTimeout,
|
|
@@ -3086,14 +3309,14 @@ class Je {
|
|
|
3086
3309
|
allowedExtensions: e.allowedExtensions ?? i.allowedExtensions,
|
|
3087
3310
|
debugLogging: e.debugLogging ?? this.fullConfig.config.debug?.loaders
|
|
3088
3311
|
};
|
|
3089
|
-
return new
|
|
3312
|
+
return new Ve(n);
|
|
3090
3313
|
} else if ("googleDrive" in t) {
|
|
3091
|
-
const e = t.googleDrive,
|
|
3314
|
+
const e = t.googleDrive, n = {
|
|
3092
3315
|
...e,
|
|
3093
3316
|
allowedExtensions: e.allowedExtensions ?? i.allowedExtensions,
|
|
3094
3317
|
debugLogging: e.debugLogging ?? this.fullConfig.config.debug?.loaders
|
|
3095
3318
|
};
|
|
3096
|
-
return new
|
|
3319
|
+
return new Je(n);
|
|
3097
3320
|
} else
|
|
3098
3321
|
throw new Error(`Unknown loader entry: ${JSON.stringify(t)}`);
|
|
3099
3322
|
}
|
|
@@ -3102,7 +3325,7 @@ class Je {
|
|
|
3102
3325
|
*/
|
|
3103
3326
|
async init() {
|
|
3104
3327
|
try {
|
|
3105
|
-
if (
|
|
3328
|
+
if (ti(), this.containerRef)
|
|
3106
3329
|
this.containerEl = this.containerRef;
|
|
3107
3330
|
else if (this.containerEl = document.getElementById(this.containerId), !this.containerEl)
|
|
3108
3331
|
throw new Error(`Container #${this.containerId} not found`);
|
|
@@ -3111,7 +3334,7 @@ class Je {
|
|
|
3111
3334
|
onPrev: () => this.navigateToPreviousImage(),
|
|
3112
3335
|
onDragOffset: (t) => this.zoomEngine.setDragOffset(t),
|
|
3113
3336
|
onDragEnd: (t) => {
|
|
3114
|
-
t ? this.zoomEngine.clearDragOffset(!1) : this.zoomEngine.clearDragOffset(!0,
|
|
3337
|
+
t ? this.zoomEngine.clearDragOffset(!1) : this.zoomEngine.clearDragOffset(!0, Xe);
|
|
3115
3338
|
}
|
|
3116
3339
|
}), this.setupUI(), this.setupEventListeners(), this.logDebug("ImageCloud initialized"), await this.loadImages();
|
|
3117
3340
|
} catch (t) {
|
|
@@ -3154,7 +3377,7 @@ class Je {
|
|
|
3154
3377
|
navigateToNextImage() {
|
|
3155
3378
|
if (this.currentFocusIndex === null || this.imageElements.length === 0) return;
|
|
3156
3379
|
const t = (this.currentFocusIndex + 1) % this.imageLayouts.length, i = this.imageElements.find(
|
|
3157
|
-
(
|
|
3380
|
+
(n) => n.dataset.imageId === String(t)
|
|
3158
3381
|
);
|
|
3159
3382
|
if (!i) return;
|
|
3160
3383
|
const e = this.imageLayouts[t];
|
|
@@ -3166,7 +3389,7 @@ class Je {
|
|
|
3166
3389
|
navigateToPreviousImage() {
|
|
3167
3390
|
if (this.currentFocusIndex === null || this.imageElements.length === 0) return;
|
|
3168
3391
|
const t = (this.currentFocusIndex - 1 + this.imageLayouts.length) % this.imageLayouts.length, i = this.imageElements.find(
|
|
3169
|
-
(
|
|
3392
|
+
(n) => n.dataset.imageId === String(t)
|
|
3170
3393
|
);
|
|
3171
3394
|
if (!i) return;
|
|
3172
3395
|
const e = this.imageLayouts[t];
|
|
@@ -3182,8 +3405,8 @@ class Je {
|
|
|
3182
3405
|
}, 500));
|
|
3183
3406
|
}
|
|
3184
3407
|
getImageHeight() {
|
|
3185
|
-
const t = window.innerWidth, i = this.fullConfig.layout.responsive,
|
|
3186
|
-
return i ? t <= i.mobile.maxWidth ? Math.min(100,
|
|
3408
|
+
const t = window.innerWidth, i = this.fullConfig.layout.responsive, n = this.fullConfig.image.sizing?.maxSize ?? 400;
|
|
3409
|
+
return i ? t <= i.mobile.maxWidth ? Math.min(100, n) : t <= i.tablet.maxWidth ? Math.min(180, n) : Math.min(225, n) : t <= 767 ? Math.min(100, n) : t <= 1199 ? Math.min(180, n) : Math.min(225, n);
|
|
3187
3410
|
}
|
|
3188
3411
|
/**
|
|
3189
3412
|
* Get container bounds for layout calculations
|
|
@@ -3206,12 +3429,12 @@ class Je {
|
|
|
3206
3429
|
this.showError("No images found."), this.showLoading(!1);
|
|
3207
3430
|
return;
|
|
3208
3431
|
}
|
|
3209
|
-
const e = this.getContainerBounds(),
|
|
3210
|
-
this.logDebug(`Adaptive sizing input: container=${e.width}x${e.height}px, images=${t}, responsiveMax=${
|
|
3432
|
+
const e = this.getContainerBounds(), n = this.getImageHeight(), a = window.innerWidth;
|
|
3433
|
+
this.logDebug(`Adaptive sizing input: container=${e.width}x${e.height}px, images=${t}, responsiveMax=${n}px`);
|
|
3211
3434
|
const r = this.layoutEngine.calculateAdaptiveSize(
|
|
3212
3435
|
e,
|
|
3213
3436
|
t,
|
|
3214
|
-
|
|
3437
|
+
n,
|
|
3215
3438
|
a
|
|
3216
3439
|
);
|
|
3217
3440
|
this.logDebug(`Adaptive sizing result: height=${r.height}px`), await this.createImageCloud(i, r.height), this.showLoading(!1), this.imagesLoaded = !0;
|
|
@@ -3229,7 +3452,7 @@ class Je {
|
|
|
3229
3452
|
if (!this.containerEl) return;
|
|
3230
3453
|
const e = this.getContainerBounds();
|
|
3231
3454
|
this.currentImageHeight = i;
|
|
3232
|
-
const
|
|
3455
|
+
const n = this.loadGeneration, a = this.layoutEngine.generateLayout(t.length, e, { fixedHeight: i });
|
|
3233
3456
|
this.imageLayouts = a, this.displayQueue = [];
|
|
3234
3457
|
let r = 0;
|
|
3235
3458
|
const s = (l) => {
|
|
@@ -3242,7 +3465,7 @@ class Je {
|
|
|
3242
3465
|
x: parseFloat(l.dataset.endX),
|
|
3243
3466
|
y: parseFloat(l.dataset.endY)
|
|
3244
3467
|
}, b = parseFloat(l.dataset.imageWidth), p = parseFloat(l.dataset.imageHeight), g = parseFloat(l.dataset.rotation), m = parseFloat(l.dataset.scale), y = l.dataset.startRotation ? parseFloat(l.dataset.startRotation) : g, w = l.dataset.startScale ? parseFloat(l.dataset.startScale) : m, v = this.entryAnimationEngine.getTiming();
|
|
3245
|
-
|
|
3468
|
+
ue({
|
|
3246
3469
|
element: l,
|
|
3247
3470
|
startPosition: d,
|
|
3248
3471
|
endPosition: f,
|
|
@@ -3275,6 +3498,10 @@ class Je {
|
|
|
3275
3498
|
pathType: this.entryAnimationEngine.getPathType()
|
|
3276
3499
|
});
|
|
3277
3500
|
}
|
|
3501
|
+
if (this.idleAnimationEngine) {
|
|
3502
|
+
const d = this.entryAnimationEngine.getTiming().duration;
|
|
3503
|
+
this.idleAnimationEngine.register(l, h, this.imageElements.length, d);
|
|
3504
|
+
}
|
|
3278
3505
|
}), r++);
|
|
3279
3506
|
}, c = () => {
|
|
3280
3507
|
if (this.logDebug("Starting queue processing, enabled:", this.fullConfig.animation.queue.enabled), !this.fullConfig.animation.queue.enabled) {
|
|
@@ -3285,7 +3512,7 @@ class Je {
|
|
|
3285
3512
|
return;
|
|
3286
3513
|
}
|
|
3287
3514
|
this.queueInterval !== null && clearInterval(this.queueInterval), this.queueInterval = window.setInterval(() => {
|
|
3288
|
-
if (
|
|
3515
|
+
if (n !== this.loadGeneration) {
|
|
3289
3516
|
this.queueInterval !== null && (clearInterval(this.queueInterval), this.queueInterval = null);
|
|
3290
3517
|
return;
|
|
3291
3518
|
}
|
|
@@ -3327,7 +3554,7 @@ class Je {
|
|
|
3327
3554
|
}), h.addEventListener("click", (f) => {
|
|
3328
3555
|
f.stopPropagation(), this.handleImageClick(h, d);
|
|
3329
3556
|
}), h.style.opacity = "0", h.style.transition = this.entryAnimationEngine.getTransitionCSS(), h.onload = () => {
|
|
3330
|
-
if (
|
|
3557
|
+
if (n !== this.loadGeneration)
|
|
3331
3558
|
return;
|
|
3332
3559
|
const f = h.naturalWidth / h.naturalHeight, b = i * f;
|
|
3333
3560
|
h.dataset.onloadCalled = "true", window.DEBUG_CLIPPATH && console.log(`[onload #${u}] Called with imageHeight=${i}, renderedWidth=${b}`), h.style.width = `${b}px`, h.cachedRenderedWidth = b, h.aspectRatio = f, ft(h, this.fullConfig.styling?.default, i, b);
|
|
@@ -3342,7 +3569,7 @@ class Je {
|
|
|
3342
3569
|
d.scale,
|
|
3343
3570
|
b,
|
|
3344
3571
|
i
|
|
3345
|
-
),
|
|
3572
|
+
), I = this.entryAnimationEngine.buildStartTransform(
|
|
3346
3573
|
m,
|
|
3347
3574
|
p,
|
|
3348
3575
|
d.rotation,
|
|
@@ -3360,28 +3587,29 @@ class Je {
|
|
|
3360
3587
|
finalTransform: v,
|
|
3361
3588
|
renderedWidth: b,
|
|
3362
3589
|
renderedHeight: i
|
|
3363
|
-
}), h.style.transform =
|
|
3590
|
+
}), h.style.transform = I, h.dataset.finalTransform = v, (this.entryAnimationEngine.requiresJSAnimation() || this.entryAnimationEngine.requiresJSRotation() || this.entryAnimationEngine.requiresJSScale() || y !== d.rotation || w !== d.scale) && (h.dataset.startX = String(m.x), h.dataset.startY = String(m.y), h.dataset.endX = String(p.x), h.dataset.endY = String(p.y), h.dataset.imageWidth = String(b), h.dataset.imageHeight = String(i), h.dataset.rotation = String(d.rotation), h.dataset.scale = String(d.scale), h.dataset.startRotation = String(y), h.dataset.startScale = String(w)), this.displayQueue.push(h);
|
|
3364
3591
|
}, h.onerror = () => r++, h.src = l;
|
|
3365
3592
|
});
|
|
3366
3593
|
}
|
|
3367
3594
|
async handleImageClick(t, i) {
|
|
3368
3595
|
if (!this.containerEl) return;
|
|
3369
|
-
const e = this.zoomEngine.isFocused(t),
|
|
3596
|
+
const e = this.zoomEngine.isFocused(t), n = {
|
|
3370
3597
|
width: this.containerEl.offsetWidth,
|
|
3371
3598
|
height: this.containerEl.offsetHeight
|
|
3372
3599
|
};
|
|
3373
3600
|
if (e)
|
|
3374
3601
|
await this.zoomEngine.unfocusImage(), this.currentFocusIndex = null, this.swipeEngine?.disable(), this.hideCounter();
|
|
3375
3602
|
else {
|
|
3603
|
+
this.idleAnimationEngine?.pauseForImage(t);
|
|
3376
3604
|
const a = t.dataset.imageId;
|
|
3377
|
-
this.currentFocusIndex = a !== void 0 ? parseInt(a, 10) : null, this.swipeEngine?.enable(), await this.zoomEngine.focusImage(t,
|
|
3605
|
+
this.currentFocusIndex = a !== void 0 ? parseInt(a, 10) : null, this.swipeEngine?.enable(), await this.zoomEngine.focusImage(t, n, i), this.currentFocusIndex !== null && this.updateCounter(this.currentFocusIndex);
|
|
3378
3606
|
}
|
|
3379
3607
|
}
|
|
3380
3608
|
/**
|
|
3381
3609
|
* Clear the image cloud and reset state
|
|
3382
3610
|
*/
|
|
3383
3611
|
clearImageCloud() {
|
|
3384
|
-
this.queueInterval !== null && (clearInterval(this.queueInterval), this.queueInterval = null), this.loadGeneration++, this.displayQueue = [], this.containerEl && this.containerEl.querySelectorAll(".fbn-ic-image, .fbn-ic-debug-center").forEach((t) => t.remove()), this.imageElements = [], this.imageLayouts = [], this.currentFocusIndex = null, this.hoveredImage = null, this.layoutEngine.reset(), this.zoomEngine.reset(), this.imagesLoaded = !1;
|
|
3612
|
+
this.queueInterval !== null && (clearInterval(this.queueInterval), this.queueInterval = null), this.loadGeneration++, this.displayQueue = [], this.containerEl && this.containerEl.querySelectorAll(".fbn-ic-image, .fbn-ic-debug-center").forEach((t) => t.remove()), this.imageElements = [], this.imageLayouts = [], this.currentFocusIndex = null, this.hoveredImage = null, this.layoutEngine.reset(), this.zoomEngine.reset(), this.idleAnimationEngine?.stopAll(), this.imagesLoaded = !1;
|
|
3385
3613
|
}
|
|
3386
3614
|
showLoading(t) {
|
|
3387
3615
|
!this.fullConfig.rendering.ui.showLoadingSpinner || !this.loadingEl || (t ? this.loadingEl.classList.remove("fbn-ic-hidden") : this.loadingEl.classList.add("fbn-ic-hidden"));
|
|
@@ -3402,10 +3630,10 @@ class Je {
|
|
|
3402
3630
|
* Destroy the gallery and clean up resources
|
|
3403
3631
|
*/
|
|
3404
3632
|
destroy() {
|
|
3405
|
-
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();
|
|
3633
|
+
this.clearImageCloud(), this.loadingElAutoCreated && this.loadingEl && (this.loadingEl.remove(), this.loadingEl = null), this.errorElAutoCreated && this.errorEl && (this.errorEl.remove(), this.errorEl = null), this.counterElAutoCreated && this.counterEl && (this.counterEl.remove(), this.counterEl = null), this.resizeTimeout !== null && clearTimeout(this.resizeTimeout), this.swipeEngine?.destroy(), this.idleAnimationEngine?.stopAll(), this.idleAnimationEngine = null;
|
|
3406
3634
|
}
|
|
3407
3635
|
}
|
|
3408
|
-
const
|
|
3636
|
+
const It = class It extends HTMLElement {
|
|
3409
3637
|
constructor() {
|
|
3410
3638
|
super(...arguments), this._instance = null, this._container = null;
|
|
3411
3639
|
}
|
|
@@ -3437,17 +3665,17 @@ const Rt = class Rt extends HTMLElement {
|
|
|
3437
3665
|
} catch (a) {
|
|
3438
3666
|
console.error("<image-cloud> invalid images JSON:", a);
|
|
3439
3667
|
}
|
|
3440
|
-
const
|
|
3441
|
-
return
|
|
3668
|
+
const n = this.getAttribute("layout");
|
|
3669
|
+
return n && (t.layout = {
|
|
3442
3670
|
...t.layout,
|
|
3443
|
-
algorithm:
|
|
3671
|
+
algorithm: n
|
|
3444
3672
|
}), t;
|
|
3445
3673
|
}
|
|
3446
3674
|
_init() {
|
|
3447
3675
|
if (this._container)
|
|
3448
3676
|
try {
|
|
3449
3677
|
const t = this._getOptions();
|
|
3450
|
-
this._instance = new
|
|
3678
|
+
this._instance = new ei({
|
|
3451
3679
|
container: this._container,
|
|
3452
3680
|
...t
|
|
3453
3681
|
}), this._instance.init().then(() => {
|
|
@@ -3463,8 +3691,8 @@ const Rt = class Rt extends HTMLElement {
|
|
|
3463
3691
|
this._instance?.destroy(), this._instance = null;
|
|
3464
3692
|
}
|
|
3465
3693
|
};
|
|
3466
|
-
|
|
3467
|
-
let yt =
|
|
3694
|
+
It.observedAttributes = ["config", "images", "layout"];
|
|
3695
|
+
let yt = It;
|
|
3468
3696
|
typeof customElements < "u" && !customElements.get("image-cloud") && customElements.define("image-cloud", yt);
|
|
3469
3697
|
export {
|
|
3470
3698
|
yt as ImageCloudElement
|