@frybynite/image-cloud 0.10.1 → 0.11.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 +979 -853
- package/dist/image-cloud-auto-init.js.map +1 -1
- package/dist/image-cloud.js +1081 -955
- 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 +137 -36
- package/dist/react.d.ts +137 -36
- package/dist/react.js +776 -649
- package/dist/react.js.map +1 -1
- package/dist/vue.d.ts +137 -36
- package/dist/vue.js +1057 -930
- package/dist/vue.js.map +1 -1
- package/dist/web-component.d.ts +137 -36
- package/dist/web-component.js +774 -647
- package/dist/web-component.js.map +1 -1
- package/package.json +9 -6
package/dist/image-cloud.js
CHANGED
|
@@ -4,16 +4,16 @@ const mt = Object.freeze({
|
|
|
4
4
|
md: "0 4px 16px rgba(0,0,0,0.4)",
|
|
5
5
|
lg: "0 8px 32px rgba(0,0,0,0.5)",
|
|
6
6
|
glow: "0 0 30px rgba(255,255,255,0.6)"
|
|
7
|
-
}),
|
|
7
|
+
}), St = Object.freeze({
|
|
8
8
|
energetic: Object.freeze({ overshoot: 0.25, bounces: 2, decayRatio: 0.5 }),
|
|
9
9
|
playful: Object.freeze({ overshoot: 0.15, bounces: 1, decayRatio: 0.5 }),
|
|
10
10
|
subtle: Object.freeze({ overshoot: 0.08, bounces: 1, decayRatio: 0.5 })
|
|
11
|
-
}),
|
|
11
|
+
}), Ct = Object.freeze({
|
|
12
12
|
gentle: Object.freeze({ stiffness: 150, damping: 30, mass: 1, oscillations: 2 }),
|
|
13
13
|
bouncy: Object.freeze({ stiffness: 300, damping: 15, mass: 1, oscillations: 4 }),
|
|
14
14
|
wobbly: Object.freeze({ stiffness: 180, damping: 12, mass: 1.5, oscillations: 5 }),
|
|
15
15
|
snappy: Object.freeze({ stiffness: 400, damping: 25, mass: 0.8, oscillations: 2 })
|
|
16
|
-
}),
|
|
16
|
+
}), Rt = Object.freeze({
|
|
17
17
|
gentle: Object.freeze({ amplitude: 30, frequency: 1.5, decay: !0, decayRate: 0.9, phase: 0 }),
|
|
18
18
|
playful: Object.freeze({ amplitude: 50, frequency: 2.5, decay: !0, decayRate: 0.7, phase: 0 }),
|
|
19
19
|
serpentine: Object.freeze({ amplitude: 60, frequency: 3, decay: !1, decayRate: 1, phase: 0 }),
|
|
@@ -22,9 +22,9 @@ const mt = Object.freeze({
|
|
|
22
22
|
type: "linear"
|
|
23
23
|
}), vt = Object.freeze({
|
|
24
24
|
mode: "none"
|
|
25
|
-
}),
|
|
25
|
+
}), xt = Object.freeze({
|
|
26
26
|
mode: "none"
|
|
27
|
-
}),
|
|
27
|
+
}), Ft = Object.freeze({
|
|
28
28
|
default: Object.freeze({
|
|
29
29
|
border: Object.freeze({
|
|
30
30
|
width: 0,
|
|
@@ -52,16 +52,16 @@ const mt = Object.freeze({
|
|
|
52
52
|
})
|
|
53
53
|
}), Ut = Object.freeze({
|
|
54
54
|
tightness: 1
|
|
55
|
-
}),
|
|
55
|
+
}), kt = Object.freeze({
|
|
56
56
|
rows: 1,
|
|
57
57
|
amplitude: 100,
|
|
58
58
|
frequency: 2,
|
|
59
59
|
phaseShift: 0,
|
|
60
60
|
synchronization: "offset"
|
|
61
61
|
// Note: Image rotation along wave is now controlled via image.rotation.mode = 'tangent'
|
|
62
|
-
}),
|
|
62
|
+
}), Ht = Object.freeze({
|
|
63
63
|
spacing: 0
|
|
64
|
-
}),
|
|
64
|
+
}), Nt = Object.freeze({
|
|
65
65
|
mobile: Object.freeze({ maxWidth: 767 }),
|
|
66
66
|
tablet: Object.freeze({ maxWidth: 1199 })
|
|
67
67
|
}), Bt = Object.freeze({
|
|
@@ -82,34 +82,34 @@ const mt = Object.freeze({
|
|
|
82
82
|
min: -15,
|
|
83
83
|
max: 15
|
|
84
84
|
})
|
|
85
|
-
}),
|
|
85
|
+
}), Mt = Object.freeze({
|
|
86
86
|
sizing: Bt,
|
|
87
87
|
rotation: jt
|
|
88
|
-
}),
|
|
88
|
+
}), Ot = 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
|
+
}), zt = Object.freeze({
|
|
94
94
|
enabled: !1,
|
|
95
95
|
centers: !1,
|
|
96
96
|
loaders: !1
|
|
97
|
-
}), Wt = Object.freeze({ maxAngle: 5, speed: 2e3, sync: "random" }), Gt = Object.freeze({ minScale: 0.95, maxScale: 1.05, speed: 2400, sync: "random" }), qt = Object.freeze({ onRatio: 0.7, speed: 3e3, style: "snap" }),
|
|
97
|
+
}), Wt = Object.freeze({ maxAngle: 5, speed: 2e3, sync: "random" }), Gt = Object.freeze({ minScale: 0.95, maxScale: 1.05, speed: 2400, sync: "random" }), qt = Object.freeze({ onRatio: 0.7, speed: 3e3, style: "snap" }), Yt = Object.freeze({ speed: 4e3, direction: "clockwise" }), Dt = Object.freeze({ type: "none" }), L = 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
|
-
loaders:
|
|
103
|
-
debug:
|
|
102
|
+
loaders: Ot,
|
|
103
|
+
debug: zt
|
|
104
104
|
}),
|
|
105
105
|
// Image sizing and rotation configuration
|
|
106
|
-
image:
|
|
106
|
+
image: Mt,
|
|
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: Nt,
|
|
113
113
|
targetCoverage: 0.6,
|
|
114
114
|
// Target 60% of container area
|
|
115
115
|
densityFactor: 1,
|
|
@@ -157,7 +157,7 @@ const mt = Object.freeze({
|
|
|
157
157
|
// smooth deceleration
|
|
158
158
|
path: yt,
|
|
159
159
|
rotation: vt,
|
|
160
|
-
scale:
|
|
160
|
+
scale: xt
|
|
161
161
|
}),
|
|
162
162
|
idle: Dt
|
|
163
163
|
}),
|
|
@@ -172,9 +172,7 @@ const mt = Object.freeze({
|
|
|
172
172
|
}),
|
|
173
173
|
navigation: Object.freeze({
|
|
174
174
|
keyboard: !0,
|
|
175
|
-
swipe: !0
|
|
176
|
-
mouseWheel: void 0
|
|
177
|
-
// STUB: Not implemented yet
|
|
175
|
+
swipe: !0
|
|
178
176
|
}),
|
|
179
177
|
dragging: !0
|
|
180
178
|
}),
|
|
@@ -186,174 +184,140 @@ const mt = Object.freeze({
|
|
|
186
184
|
showFocusOutline: !1
|
|
187
185
|
}),
|
|
188
186
|
// Image styling
|
|
189
|
-
styling:
|
|
187
|
+
styling: Ft
|
|
190
188
|
});
|
|
191
|
-
function Z(
|
|
192
|
-
if (!
|
|
193
|
-
if (!t) return { ...
|
|
194
|
-
const i = { ...
|
|
195
|
-
return t.border !== void 0 && (i.border = { ...
|
|
196
|
-
}
|
|
197
|
-
function
|
|
198
|
-
if (!t) return { ...
|
|
199
|
-
const i = Z(
|
|
200
|
-
Z(i,
|
|
189
|
+
function Z(n, t) {
|
|
190
|
+
if (!n) return t || {};
|
|
191
|
+
if (!t) return { ...n };
|
|
192
|
+
const i = { ...n };
|
|
193
|
+
return t.border !== void 0 && (i.border = { ...n.border, ...t.border }), t.borderTop !== void 0 && (i.borderTop = { ...n.borderTop, ...t.borderTop }), t.borderRight !== void 0 && (i.borderRight = { ...n.borderRight, ...t.borderRight }), t.borderBottom !== void 0 && (i.borderBottom = { ...n.borderBottom, ...t.borderBottom }), t.borderLeft !== void 0 && (i.borderLeft = { ...n.borderLeft, ...t.borderLeft }), t.filter !== void 0 && (i.filter = { ...n.filter, ...t.filter }), t.outline !== void 0 && (i.outline = { ...n.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;
|
|
194
|
+
}
|
|
195
|
+
function Xt(n, t) {
|
|
196
|
+
if (!t) return { ...n };
|
|
197
|
+
const i = Z(n.default, t.default), e = Z(
|
|
198
|
+
Z(i, n.hover),
|
|
201
199
|
t.hover
|
|
202
|
-
),
|
|
203
|
-
Z(i,
|
|
200
|
+
), o = Z(
|
|
201
|
+
Z(i, n.focused),
|
|
204
202
|
t.focused
|
|
205
203
|
);
|
|
206
204
|
return {
|
|
207
205
|
default: i,
|
|
208
206
|
hover: e,
|
|
209
|
-
focused:
|
|
207
|
+
focused: o
|
|
210
208
|
};
|
|
211
209
|
}
|
|
212
|
-
function Vt(
|
|
213
|
-
if (!t) return { ...
|
|
214
|
-
const i = { ...
|
|
210
|
+
function Vt(n, t) {
|
|
211
|
+
if (!t) return { ...n };
|
|
212
|
+
const i = { ...n };
|
|
215
213
|
if (t.sizing !== void 0 && (i.sizing = {
|
|
216
|
-
...
|
|
214
|
+
...n.sizing,
|
|
217
215
|
...t.sizing
|
|
218
216
|
}, t.sizing.variance)) {
|
|
219
|
-
const e = t.sizing.variance,
|
|
220
|
-
i.sizing.variance = { min:
|
|
217
|
+
const e = t.sizing.variance, o = e.min !== void 0 && e.min >= 0.25 && e.min <= 1 ? e.min : n.sizing?.variance?.min ?? 1, s = e.max !== void 0 && e.max >= 1 && e.max <= 1.75 ? e.max : n.sizing?.variance?.max ?? 1;
|
|
218
|
+
i.sizing.variance = { min: o, max: s };
|
|
221
219
|
}
|
|
222
220
|
if (t.rotation !== void 0 && (i.rotation = {
|
|
223
|
-
...
|
|
221
|
+
...n.rotation,
|
|
224
222
|
...t.rotation
|
|
225
223
|
}, t.rotation.range)) {
|
|
226
|
-
const e = t.rotation.range,
|
|
227
|
-
i.rotation.range = { min:
|
|
224
|
+
const e = t.rotation.range, o = e.min !== void 0 && e.min >= -180 && e.min <= 0 ? e.min : n.rotation?.range?.min ?? -15, s = e.max !== void 0 && e.max >= 0 && e.max <= 180 ? e.max : n.rotation?.range?.max ?? 15;
|
|
225
|
+
i.rotation.range = { min: o, max: s };
|
|
228
226
|
}
|
|
229
227
|
return i;
|
|
230
228
|
}
|
|
231
|
-
function Jt(
|
|
232
|
-
const t =
|
|
233
|
-
|
|
234
|
-
return {
|
|
235
|
-
rotation: {
|
|
236
|
-
mode: t.enabled ? "random" : "none",
|
|
237
|
-
range: t.range
|
|
238
|
-
}
|
|
239
|
-
};
|
|
240
|
-
}
|
|
241
|
-
function Kt(o) {
|
|
242
|
-
const t = o.layout?.sizing?.variance;
|
|
243
|
-
if (t)
|
|
244
|
-
return {
|
|
245
|
-
sizing: {
|
|
246
|
-
mode: "adaptive",
|
|
247
|
-
// Legacy variance config implies adaptive mode
|
|
248
|
-
variance: t
|
|
249
|
-
}
|
|
250
|
-
};
|
|
251
|
-
}
|
|
252
|
-
function Zt(o = {}) {
|
|
253
|
-
const t = Jt(o), i = Kt(o);
|
|
254
|
-
let e = o.image;
|
|
255
|
-
(t || i) && (e = {
|
|
256
|
-
...i || {},
|
|
257
|
-
...t || {},
|
|
258
|
-
...e
|
|
259
|
-
}, e.rotation && t?.rotation && o.image?.rotation && (e.rotation = {
|
|
260
|
-
...t.rotation,
|
|
261
|
-
...o.image.rotation
|
|
262
|
-
}));
|
|
263
|
-
const n = [...o.loaders ?? []];
|
|
264
|
-
o.images && o.images.length > 0 && n.unshift({
|
|
229
|
+
function Jt(n = {}) {
|
|
230
|
+
const t = n.image, i = [...n.loaders ?? []];
|
|
231
|
+
n.images && n.images.length > 0 && i.unshift({
|
|
265
232
|
static: {
|
|
266
|
-
sources: [{ urls:
|
|
233
|
+
sources: [{ urls: n.images }]
|
|
267
234
|
}
|
|
268
235
|
});
|
|
269
|
-
const
|
|
236
|
+
const o = {
|
|
270
237
|
loaders: {
|
|
271
|
-
...
|
|
272
|
-
...
|
|
238
|
+
...Ot,
|
|
239
|
+
...n.config?.loaders ?? {}
|
|
273
240
|
}
|
|
274
|
-
},
|
|
275
|
-
loaders:
|
|
276
|
-
config:
|
|
277
|
-
image: Vt(
|
|
278
|
-
layout: { ...
|
|
279
|
-
animation: { ...
|
|
280
|
-
interaction: { ...
|
|
281
|
-
ui: { ...
|
|
282
|
-
styling:
|
|
241
|
+
}, s = {
|
|
242
|
+
loaders: i,
|
|
243
|
+
config: o,
|
|
244
|
+
image: Vt(Mt, t),
|
|
245
|
+
layout: { ...L.layout },
|
|
246
|
+
animation: { ...L.animation },
|
|
247
|
+
interaction: { ...L.interaction },
|
|
248
|
+
ui: { ...L.ui },
|
|
249
|
+
styling: Xt(Ft, n.styling)
|
|
283
250
|
};
|
|
284
|
-
|
|
285
|
-
...
|
|
286
|
-
...
|
|
287
|
-
},
|
|
288
|
-
...
|
|
289
|
-
mobile:
|
|
290
|
-
tablet:
|
|
291
|
-
}),
|
|
292
|
-
...
|
|
293
|
-
...
|
|
294
|
-
})),
|
|
295
|
-
...
|
|
296
|
-
...
|
|
297
|
-
},
|
|
298
|
-
...
|
|
299
|
-
...
|
|
300
|
-
}),
|
|
301
|
-
...
|
|
302
|
-
...
|
|
303
|
-
}),
|
|
304
|
-
...
|
|
305
|
-
...
|
|
306
|
-
start:
|
|
307
|
-
...
|
|
308
|
-
...
|
|
309
|
-
circular:
|
|
310
|
-
} :
|
|
311
|
-
timing:
|
|
312
|
-
path:
|
|
313
|
-
rotation:
|
|
314
|
-
scale:
|
|
315
|
-
}),
|
|
251
|
+
if (n.layout && (s.layout = {
|
|
252
|
+
...L.layout,
|
|
253
|
+
...n.layout
|
|
254
|
+
}, n.layout.responsive && (s.layout.responsive = {
|
|
255
|
+
...L.layout.responsive,
|
|
256
|
+
mobile: n.layout.responsive.mobile ? { ...L.layout.responsive.mobile, ...n.layout.responsive.mobile } : L.layout.responsive.mobile,
|
|
257
|
+
tablet: n.layout.responsive.tablet ? { ...L.layout.responsive.tablet, ...n.layout.responsive.tablet } : L.layout.responsive.tablet
|
|
258
|
+
}), n.layout.spacing && (s.layout.spacing = {
|
|
259
|
+
...L.layout.spacing,
|
|
260
|
+
...n.layout.spacing
|
|
261
|
+
})), n.animation && (s.animation = {
|
|
262
|
+
...L.animation,
|
|
263
|
+
...n.animation
|
|
264
|
+
}, n.animation.easing && (s.animation.easing = {
|
|
265
|
+
...L.animation.easing,
|
|
266
|
+
...n.animation.easing
|
|
267
|
+
}), n.animation.queue && (s.animation.queue = {
|
|
268
|
+
...L.animation.queue,
|
|
269
|
+
...n.animation.queue
|
|
270
|
+
}), n.animation.entry && (s.animation.entry = {
|
|
271
|
+
...L.animation.entry,
|
|
272
|
+
...n.animation.entry,
|
|
273
|
+
start: n.animation.entry.start ? {
|
|
274
|
+
...L.animation.entry.start,
|
|
275
|
+
...n.animation.entry.start,
|
|
276
|
+
circular: n.animation.entry.start.circular ? { ...L.animation.entry.start.circular, ...n.animation.entry.start.circular } : L.animation.entry.start.circular
|
|
277
|
+
} : L.animation.entry.start,
|
|
278
|
+
timing: n.animation.entry.timing ? { ...L.animation.entry.timing, ...n.animation.entry.timing } : L.animation.entry.timing,
|
|
279
|
+
path: n.animation.entry.path ? { ...yt, ...n.animation.entry.path } : L.animation.entry.path,
|
|
280
|
+
rotation: n.animation.entry.rotation ? { ...vt, ...n.animation.entry.rotation } : L.animation.entry.rotation,
|
|
281
|
+
scale: n.animation.entry.scale ? { ...xt, ...n.animation.entry.scale } : L.animation.entry.scale
|
|
282
|
+
}), n.animation.idle && (s.animation.idle = {
|
|
316
283
|
...Dt,
|
|
317
|
-
...
|
|
318
|
-
})),
|
|
319
|
-
...
|
|
320
|
-
...
|
|
321
|
-
},
|
|
322
|
-
...
|
|
323
|
-
...
|
|
324
|
-
}),
|
|
325
|
-
...
|
|
326
|
-
...
|
|
327
|
-
}))
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
...
|
|
332
|
-
...
|
|
333
|
-
},
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
...a.styling,
|
|
340
|
-
default: { ...a.styling.default, clipPath: l },
|
|
341
|
-
hover: { ...a.styling.hover, clipPath: l }
|
|
284
|
+
...n.animation.idle
|
|
285
|
+
})), n.interaction && (s.interaction = {
|
|
286
|
+
...L.interaction,
|
|
287
|
+
...n.interaction
|
|
288
|
+
}, n.interaction.focus && (s.interaction.focus = {
|
|
289
|
+
...L.interaction.focus,
|
|
290
|
+
...n.interaction.focus
|
|
291
|
+
}), n.interaction.navigation && (s.interaction.navigation = {
|
|
292
|
+
...L.interaction.navigation,
|
|
293
|
+
...n.interaction.navigation
|
|
294
|
+
})), s.ui = {
|
|
295
|
+
...L.ui,
|
|
296
|
+
...n.ui
|
|
297
|
+
}, s.config.debug = {
|
|
298
|
+
...zt,
|
|
299
|
+
...n.config?.debug ?? {}
|
|
300
|
+
}, s.layout.algorithm === "honeycomb" && s.styling) {
|
|
301
|
+
const r = { shape: "hexagon", mode: "height-relative" };
|
|
302
|
+
s.styling = {
|
|
303
|
+
...s.styling,
|
|
304
|
+
default: { ...s.styling.default, clipPath: r },
|
|
305
|
+
hover: { ...s.styling.hover, clipPath: r }
|
|
342
306
|
// focused: untouched — user config respected
|
|
343
307
|
};
|
|
344
308
|
}
|
|
345
|
-
return
|
|
309
|
+
return s;
|
|
346
310
|
}
|
|
347
|
-
function
|
|
348
|
-
return { ...
|
|
311
|
+
function Kt(n, t) {
|
|
312
|
+
return { ...n ? St[n] : St.playful, ...t };
|
|
349
313
|
}
|
|
350
|
-
function
|
|
351
|
-
return { ...
|
|
314
|
+
function Zt(n, t) {
|
|
315
|
+
return { ...n ? Ct[n] : Ct.gentle, ...t };
|
|
352
316
|
}
|
|
353
|
-
function
|
|
354
|
-
return { ...
|
|
317
|
+
function Qt(n, t) {
|
|
318
|
+
return { ...n ? Rt[n] : Rt.gentle, ...t };
|
|
355
319
|
}
|
|
356
|
-
class
|
|
320
|
+
class te {
|
|
357
321
|
constructor(t) {
|
|
358
322
|
this.activeAnimations = /* @__PURE__ */ new Map(), this.animationIdCounter = 0, this.config = t;
|
|
359
323
|
}
|
|
@@ -364,8 +328,8 @@ class ie {
|
|
|
364
328
|
buildTransformString(t) {
|
|
365
329
|
const i = ["translate(-50%, -50%)"];
|
|
366
330
|
if (t.x !== void 0 || t.y !== void 0) {
|
|
367
|
-
const e = t.x ?? 0,
|
|
368
|
-
i.push(`translate(${e}px, ${
|
|
331
|
+
const e = t.x ?? 0, o = t.y ?? 0;
|
|
332
|
+
i.push(`translate(${e}px, ${o}px)`);
|
|
369
333
|
}
|
|
370
334
|
return t.rotation !== void 0 && i.push(`rotate(${t.rotation}deg)`), t.scale !== void 0 && i.push(`scale(${t.scale})`), i.join(" ");
|
|
371
335
|
}
|
|
@@ -378,14 +342,14 @@ class ie {
|
|
|
378
342
|
* @param easing - CSS easing function (optional)
|
|
379
343
|
* @returns AnimationHandle that can be used to cancel or query the animation
|
|
380
344
|
*/
|
|
381
|
-
animateTransformCancellable(t, i, e,
|
|
345
|
+
animateTransformCancellable(t, i, e, o = null, s = null) {
|
|
382
346
|
this.cancelAllAnimations(t);
|
|
383
|
-
const r =
|
|
347
|
+
const r = o ?? this.config.duration, a = s ?? this.config.easing.default, c = this.buildTransformString(i), d = this.buildTransformString(e);
|
|
384
348
|
t.style.transition = "none";
|
|
385
349
|
const u = t.animate(
|
|
386
350
|
[
|
|
387
351
|
{ transform: c },
|
|
388
|
-
{ transform:
|
|
352
|
+
{ transform: d }
|
|
389
353
|
],
|
|
390
354
|
{
|
|
391
355
|
duration: r,
|
|
@@ -393,7 +357,7 @@ class ie {
|
|
|
393
357
|
fill: "forwards"
|
|
394
358
|
// Keep final state after animation
|
|
395
359
|
}
|
|
396
|
-
),
|
|
360
|
+
), f = {
|
|
397
361
|
id: `anim-${++this.animationIdCounter}`,
|
|
398
362
|
element: t,
|
|
399
363
|
animation: u,
|
|
@@ -402,11 +366,11 @@ class ie {
|
|
|
402
366
|
startTime: performance.now(),
|
|
403
367
|
duration: r
|
|
404
368
|
};
|
|
405
|
-
return this.activeAnimations.set(t,
|
|
406
|
-
t.style.transform =
|
|
369
|
+
return this.activeAnimations.set(t, f), u.finished.then(() => {
|
|
370
|
+
t.style.transform = d, this.activeAnimations.delete(t);
|
|
407
371
|
}).catch(() => {
|
|
408
372
|
this.activeAnimations.delete(t);
|
|
409
|
-
}),
|
|
373
|
+
}), f;
|
|
410
374
|
}
|
|
411
375
|
/**
|
|
412
376
|
* Cancel an active animation
|
|
@@ -417,13 +381,13 @@ class ie {
|
|
|
417
381
|
cancelAnimation(t, i = !0) {
|
|
418
382
|
const e = this.getCurrentTransform(t.element);
|
|
419
383
|
if (t.animation.cancel(), i) {
|
|
420
|
-
const
|
|
384
|
+
const o = this.buildTransformString({
|
|
421
385
|
x: e.x,
|
|
422
386
|
y: e.y,
|
|
423
387
|
rotation: e.rotation,
|
|
424
388
|
scale: e.scale
|
|
425
389
|
});
|
|
426
|
-
t.element.style.transform =
|
|
390
|
+
t.element.style.transform = o;
|
|
427
391
|
}
|
|
428
392
|
return this.activeAnimations.delete(t.element), e;
|
|
429
393
|
}
|
|
@@ -436,8 +400,8 @@ class ie {
|
|
|
436
400
|
const i = this.activeAnimations.get(t);
|
|
437
401
|
i && this.cancelAnimation(i, !1);
|
|
438
402
|
const e = t.getAnimations();
|
|
439
|
-
for (const
|
|
440
|
-
|
|
403
|
+
for (const o of e)
|
|
404
|
+
o.cancel();
|
|
441
405
|
}
|
|
442
406
|
/**
|
|
443
407
|
* Get current transform state of an element (works mid-animation)
|
|
@@ -449,7 +413,7 @@ class ie {
|
|
|
449
413
|
const e = getComputedStyle(t).transform;
|
|
450
414
|
if (e === "none" || !e)
|
|
451
415
|
return { x: 0, y: 0, rotation: 0, scale: 1 };
|
|
452
|
-
const
|
|
416
|
+
const o = new DOMMatrix(e), s = Math.sqrt(o.a * o.a + o.b * o.b), r = Math.atan2(o.b, o.a) * (180 / Math.PI), a = o.e, c = o.f;
|
|
453
417
|
return { x: a, y: c, rotation: r, scale: s };
|
|
454
418
|
}
|
|
455
419
|
/**
|
|
@@ -476,9 +440,9 @@ class ie {
|
|
|
476
440
|
* @param easing - CSS easing function (optional)
|
|
477
441
|
* @returns Promise that resolves when animation completes
|
|
478
442
|
*/
|
|
479
|
-
animateTransform(t, i, e = null,
|
|
443
|
+
animateTransform(t, i, e = null, o = null) {
|
|
480
444
|
return new Promise((s) => {
|
|
481
|
-
const r = e ?? this.config.duration, a =
|
|
445
|
+
const r = e ?? this.config.duration, a = o ?? this.config.easing.default;
|
|
482
446
|
t.style.transition = `transform ${r}ms ${a}, box-shadow ${r}ms ${a}`, t.style.transform = this.buildTransformString(i), setTimeout(() => {
|
|
483
447
|
s();
|
|
484
448
|
}, r);
|
|
@@ -509,161 +473,167 @@ class ie {
|
|
|
509
473
|
return new Promise((i) => setTimeout(i, t));
|
|
510
474
|
}
|
|
511
475
|
}
|
|
512
|
-
function J(
|
|
513
|
-
return
|
|
476
|
+
function J(n, t, i) {
|
|
477
|
+
return n + (t - n) * i;
|
|
514
478
|
}
|
|
515
|
-
function
|
|
516
|
-
const { overshoot:
|
|
517
|
-
let u = 0,
|
|
518
|
-
for (let
|
|
519
|
-
if (
|
|
520
|
-
|
|
479
|
+
function ee(n, t, i, e) {
|
|
480
|
+
const { overshoot: o, bounces: s, decayRatio: r } = e, a = i.x - t.x, c = i.y - t.y, d = ie(s, r);
|
|
481
|
+
let u = 0, f = 0, m = 1, p = o, w = !1;
|
|
482
|
+
for (let l = 0; l < d.length; l++)
|
|
483
|
+
if (n <= d[l].time) {
|
|
484
|
+
f = l === 0 ? 0 : d[l - 1].time, m = d[l].time, p = d[l].overshoot, w = d[l].isOvershoot;
|
|
521
485
|
break;
|
|
522
486
|
}
|
|
523
|
-
const
|
|
524
|
-
if (
|
|
525
|
-
u = 1 +
|
|
526
|
-
else if (
|
|
527
|
-
u = at(
|
|
487
|
+
const v = (n - f) / (m - f);
|
|
488
|
+
if (w)
|
|
489
|
+
u = 1 + p * at(v);
|
|
490
|
+
else if (f === 0)
|
|
491
|
+
u = at(v);
|
|
528
492
|
else {
|
|
529
|
-
const
|
|
530
|
-
(
|
|
531
|
-
)?.overshoot ||
|
|
532
|
-
u = J(
|
|
493
|
+
const g = 1 + (d.find(
|
|
494
|
+
(h, b) => h.time > f && b > 0 && d[b - 1].isOvershoot
|
|
495
|
+
)?.overshoot || p);
|
|
496
|
+
u = J(g, 1, at(v));
|
|
533
497
|
}
|
|
534
498
|
return {
|
|
535
499
|
x: t.x + a * u,
|
|
536
500
|
y: t.y + c * u
|
|
537
501
|
};
|
|
538
502
|
}
|
|
539
|
-
function
|
|
503
|
+
function ie(n, t) {
|
|
540
504
|
const i = [];
|
|
541
505
|
let e = 0.6;
|
|
542
506
|
i.push({ time: e, overshoot: 0, isOvershoot: !1 });
|
|
543
|
-
let
|
|
544
|
-
const r = 0.4 / (
|
|
545
|
-
for (let a = 0; a <
|
|
546
|
-
e += r, i.push({ time: e, overshoot:
|
|
507
|
+
let o = 0.15;
|
|
508
|
+
const r = 0.4 / (n * 2);
|
|
509
|
+
for (let a = 0; a < n; a++)
|
|
510
|
+
e += r, i.push({ time: e, overshoot: o, isOvershoot: !0 }), e += r, i.push({ time: e, overshoot: o * t, isOvershoot: !1 }), o *= t;
|
|
547
511
|
return i.push({ time: 1, overshoot: 0, isOvershoot: !1 }), i;
|
|
548
512
|
}
|
|
549
|
-
function
|
|
550
|
-
const { stiffness:
|
|
551
|
-
let
|
|
552
|
-
if (
|
|
553
|
-
const
|
|
554
|
-
|
|
513
|
+
function oe(n, t, i, e) {
|
|
514
|
+
const { stiffness: o, damping: s, mass: r, oscillations: a } = e, c = i.x - t.x, d = i.y - t.y, u = Math.sqrt(o / r), f = s / (2 * Math.sqrt(o * r));
|
|
515
|
+
let m;
|
|
516
|
+
if (f < 1) {
|
|
517
|
+
const p = u * Math.sqrt(1 - f * f), w = Math.exp(-f * u * n * 3), v = Math.cos(p * n * a * Math.PI);
|
|
518
|
+
m = 1 - w * v;
|
|
555
519
|
} else
|
|
556
|
-
|
|
557
|
-
return
|
|
558
|
-
x: t.x + c *
|
|
559
|
-
y: t.y +
|
|
520
|
+
m = 1 - Math.exp(-u * n * 3);
|
|
521
|
+
return m = Math.max(0, Math.min(m, 1.3)), {
|
|
522
|
+
x: t.x + c * m,
|
|
523
|
+
y: t.y + d * m
|
|
560
524
|
};
|
|
561
525
|
}
|
|
562
|
-
function
|
|
563
|
-
const { amplitude:
|
|
526
|
+
function ne(n, t, i, e) {
|
|
527
|
+
const { amplitude: o, frequency: s, decay: r, decayRate: a, phase: c } = e, d = i.x - t.x, u = i.y - t.y, f = Math.sqrt(d * d + u * u), m = f > 0 ? -u / f : 0, p = f > 0 ? d / f : 1, w = s * Math.PI * 2 * n + c, v = r ? Math.pow(1 - n, a) : 1, l = o * Math.sin(w) * v, g = se(n);
|
|
564
528
|
return {
|
|
565
|
-
x: J(t.x, i.x,
|
|
566
|
-
y: J(t.y, i.y,
|
|
529
|
+
x: J(t.x, i.x, g) + l * m,
|
|
530
|
+
y: J(t.y, i.y, g) + l * p
|
|
567
531
|
};
|
|
568
532
|
}
|
|
569
|
-
function at(
|
|
570
|
-
return 1 - (1 -
|
|
533
|
+
function at(n) {
|
|
534
|
+
return 1 - (1 - n) * (1 - n);
|
|
571
535
|
}
|
|
572
|
-
function
|
|
573
|
-
return 1 - Math.pow(1 -
|
|
536
|
+
function se(n) {
|
|
537
|
+
return 1 - Math.pow(1 - n, 3);
|
|
574
538
|
}
|
|
575
|
-
function
|
|
576
|
-
const { amplitude: e, frequency:
|
|
539
|
+
function ae(n, t, i) {
|
|
540
|
+
const { amplitude: e, frequency: o, decay: s } = i, r = Math.sin(n * o * Math.PI * 2), a = s ? Math.pow(1 - n, 2) : 1, c = e * r * a;
|
|
577
541
|
return t + c;
|
|
578
542
|
}
|
|
579
|
-
function
|
|
580
|
-
const { overshoot: e, bounces:
|
|
543
|
+
function re(n, t, i) {
|
|
544
|
+
const { overshoot: e, bounces: o } = i, s = [];
|
|
581
545
|
s.push({ time: 0.5, scale: e });
|
|
582
546
|
let r = e;
|
|
583
|
-
const a = 0.5,
|
|
547
|
+
const a = 0.5, d = 0.5 / (o * 2);
|
|
584
548
|
let u = 0.5;
|
|
585
|
-
for (let
|
|
586
|
-
const
|
|
587
|
-
u +=
|
|
549
|
+
for (let m = 0; m < o; m++) {
|
|
550
|
+
const p = 1 - (r - 1) * a;
|
|
551
|
+
u += d, s.push({ time: u, scale: p }), r = 1 + (r - 1) * a * a, u += d, m < o - 1 && s.push({ time: u, scale: r });
|
|
588
552
|
}
|
|
589
553
|
s.push({ time: 1, scale: 1 });
|
|
590
|
-
let
|
|
591
|
-
for (let
|
|
592
|
-
if (
|
|
593
|
-
const
|
|
594
|
-
|
|
554
|
+
let f = 1;
|
|
555
|
+
for (let m = 0; m < s.length; m++)
|
|
556
|
+
if (n <= s[m].time) {
|
|
557
|
+
const p = m === 0 ? 0 : s[m - 1].time, w = m === 0 ? 1 : s[m - 1].scale, v = (n - p) / (s[m].time - p), l = at(v);
|
|
558
|
+
f = w + (s[m].scale - w) * l;
|
|
595
559
|
break;
|
|
596
560
|
}
|
|
597
|
-
return
|
|
561
|
+
return f * t;
|
|
598
562
|
}
|
|
599
|
-
function
|
|
563
|
+
function ce(n) {
|
|
600
564
|
const {
|
|
601
565
|
element: t,
|
|
602
566
|
startPosition: i,
|
|
603
567
|
endPosition: e,
|
|
604
|
-
pathConfig:
|
|
568
|
+
pathConfig: o,
|
|
605
569
|
duration: s,
|
|
606
570
|
imageWidth: r,
|
|
607
571
|
imageHeight: a,
|
|
608
572
|
rotation: c,
|
|
609
|
-
scale:
|
|
573
|
+
scale: d,
|
|
610
574
|
onComplete: u,
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
575
|
+
onProgress: f,
|
|
576
|
+
rotationConfig: m,
|
|
577
|
+
startRotation: p,
|
|
578
|
+
scaleConfig: w,
|
|
579
|
+
startScale: v
|
|
580
|
+
} = n, l = o.type, g = p !== void 0 && p !== c, h = m?.mode === "wobble", b = m?.wobble || { amplitude: 15, frequency: 3, decay: !0 }, I = g || h, y = v !== void 0 && v !== d, x = w?.mode === "pop", E = w?.pop || { overshoot: 1.2, bounces: 1 };
|
|
581
|
+
if (l === "linear" && !I && !(y || x)) {
|
|
617
582
|
u && u();
|
|
618
583
|
return;
|
|
619
584
|
}
|
|
620
|
-
const
|
|
621
|
-
function
|
|
622
|
-
const
|
|
623
|
-
let
|
|
624
|
-
switch (
|
|
585
|
+
const R = performance.now(), M = -r / 2, T = -a / 2;
|
|
586
|
+
function z(k) {
|
|
587
|
+
const D = k - R, O = Math.min(D / s, 1);
|
|
588
|
+
let S;
|
|
589
|
+
switch (l) {
|
|
625
590
|
case "bounce": {
|
|
626
|
-
const
|
|
627
|
-
|
|
628
|
-
|
|
591
|
+
const N = Kt(
|
|
592
|
+
o.bouncePreset,
|
|
593
|
+
o.bounce
|
|
629
594
|
);
|
|
630
|
-
|
|
595
|
+
S = ee(O, i, e, N);
|
|
631
596
|
break;
|
|
632
597
|
}
|
|
633
598
|
case "elastic": {
|
|
634
|
-
const
|
|
635
|
-
|
|
636
|
-
|
|
599
|
+
const N = Zt(
|
|
600
|
+
o.elasticPreset,
|
|
601
|
+
o.elastic
|
|
637
602
|
);
|
|
638
|
-
|
|
603
|
+
S = oe(O, i, e, N);
|
|
639
604
|
break;
|
|
640
605
|
}
|
|
641
606
|
case "wave": {
|
|
642
|
-
const
|
|
643
|
-
|
|
644
|
-
|
|
607
|
+
const N = Qt(
|
|
608
|
+
o.wavePreset,
|
|
609
|
+
o.wave
|
|
645
610
|
);
|
|
646
|
-
|
|
611
|
+
S = ne(O, i, e, N);
|
|
647
612
|
break;
|
|
648
613
|
}
|
|
649
614
|
default:
|
|
650
|
-
|
|
651
|
-
x: J(i.x, e.x,
|
|
652
|
-
y: J(i.y, e.y,
|
|
615
|
+
S = {
|
|
616
|
+
x: J(i.x, e.x, O),
|
|
617
|
+
y: J(i.y, e.y, O)
|
|
653
618
|
};
|
|
654
619
|
}
|
|
655
|
-
const
|
|
656
|
-
let
|
|
657
|
-
|
|
658
|
-
let
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
}
|
|
666
|
-
|
|
620
|
+
const _ = S.x - e.x, $ = S.y - e.y;
|
|
621
|
+
let A;
|
|
622
|
+
h ? A = ae(O, c, b) : g ? A = J(p, c, O) : A = c;
|
|
623
|
+
let j;
|
|
624
|
+
x ? j = re(O, d, E) : y ? j = J(v, d, O) : j = d, t.style.transform = `translate(${M}px, ${T}px) translate(${_}px, ${$}px) rotate(${A}deg) scale(${j})`, f && O < 1 && f(O, D, {
|
|
625
|
+
x: S.x,
|
|
626
|
+
y: S.y,
|
|
627
|
+
rotation: A,
|
|
628
|
+
scale: j
|
|
629
|
+
}), O < 1 ? requestAnimationFrame(z) : (t.style.transform = `translate(${M}px, ${T}px) rotate(${c}deg) scale(${d})`, u && u());
|
|
630
|
+
}
|
|
631
|
+
requestAnimationFrame(z);
|
|
632
|
+
}
|
|
633
|
+
function le(n) {
|
|
634
|
+
return n === "bounce" || n === "elastic" || n === "wave";
|
|
635
|
+
}
|
|
636
|
+
const he = {
|
|
667
637
|
radial: "center",
|
|
668
638
|
spiral: "center",
|
|
669
639
|
grid: "top",
|
|
@@ -672,20 +642,20 @@ const ue = {
|
|
|
672
642
|
wave: "left",
|
|
673
643
|
honeycomb: "center"
|
|
674
644
|
};
|
|
675
|
-
class
|
|
645
|
+
class de {
|
|
676
646
|
constructor(t, i) {
|
|
677
|
-
this.config = t, this.layoutAlgorithm = i, this.resolvedStartPosition = this.resolveStartPosition(), this.pathConfig = t.path || yt, this.rotationConfig = t.rotation || vt, this.scaleConfig = t.scale ||
|
|
647
|
+
this.config = t, this.layoutAlgorithm = i, this.resolvedStartPosition = this.resolveStartPosition(), this.pathConfig = t.path || yt, this.rotationConfig = t.rotation || vt, this.scaleConfig = t.scale || xt;
|
|
678
648
|
}
|
|
679
649
|
/**
|
|
680
650
|
* Get the effective start position, considering layout-aware defaults
|
|
681
651
|
*/
|
|
682
652
|
resolveStartPosition() {
|
|
683
|
-
return this.config.start.position ? this.config.start.position :
|
|
653
|
+
return this.config.start.position ? this.config.start.position : he[this.layoutAlgorithm] || "nearest-edge";
|
|
684
654
|
}
|
|
685
655
|
/**
|
|
686
656
|
* Calculate the starting position for an image's entry animation
|
|
687
657
|
*/
|
|
688
|
-
calculateStartPosition(t, i, e,
|
|
658
|
+
calculateStartPosition(t, i, e, o, s) {
|
|
689
659
|
const r = this.resolvedStartPosition, a = this.config.start.offset ?? 100;
|
|
690
660
|
switch (r) {
|
|
691
661
|
case "nearest-edge":
|
|
@@ -707,7 +677,7 @@ class fe {
|
|
|
707
677
|
t,
|
|
708
678
|
i,
|
|
709
679
|
e,
|
|
710
|
-
|
|
680
|
+
o,
|
|
711
681
|
s
|
|
712
682
|
);
|
|
713
683
|
default:
|
|
@@ -717,28 +687,28 @@ class fe {
|
|
|
717
687
|
/**
|
|
718
688
|
* Calculate start position from the nearest edge (current default behavior)
|
|
719
689
|
*/
|
|
720
|
-
calculateNearestEdge(t, i, e,
|
|
721
|
-
const s = t.x, r = t.y, a = s, c = e.width - s,
|
|
722
|
-
let
|
|
723
|
-
return
|
|
690
|
+
calculateNearestEdge(t, i, e, o) {
|
|
691
|
+
const s = t.x, r = t.y, a = s, c = e.width - s, d = r, u = e.height - r, f = Math.min(a, c, d, u);
|
|
692
|
+
let m = t.x, p = t.y;
|
|
693
|
+
return f === a ? m = -(i.width + o) : f === c ? m = e.width + o : f === d ? p = -(i.height + o) : p = e.height + o, { x: m, y: p };
|
|
724
694
|
}
|
|
725
695
|
/**
|
|
726
696
|
* Calculate start position from a specific edge
|
|
727
697
|
*/
|
|
728
|
-
calculateEdgePosition(t, i, e,
|
|
698
|
+
calculateEdgePosition(t, i, e, o, s) {
|
|
729
699
|
let r = i.x, a = i.y;
|
|
730
700
|
switch (t) {
|
|
731
701
|
case "top":
|
|
732
702
|
a = -(e.height + s);
|
|
733
703
|
break;
|
|
734
704
|
case "bottom":
|
|
735
|
-
a =
|
|
705
|
+
a = o.height + s;
|
|
736
706
|
break;
|
|
737
707
|
case "left":
|
|
738
708
|
r = -(e.width + s);
|
|
739
709
|
break;
|
|
740
710
|
case "right":
|
|
741
|
-
r =
|
|
711
|
+
r = o.width + s;
|
|
742
712
|
break;
|
|
743
713
|
}
|
|
744
714
|
return { x: r, y: a };
|
|
@@ -747,9 +717,9 @@ class fe {
|
|
|
747
717
|
* Calculate start position from center with scale animation
|
|
748
718
|
*/
|
|
749
719
|
calculateCenterPosition(t, i, e) {
|
|
750
|
-
const
|
|
720
|
+
const o = t.width / 2, s = t.height / 2;
|
|
751
721
|
return {
|
|
752
|
-
x:
|
|
722
|
+
x: o,
|
|
753
723
|
y: s,
|
|
754
724
|
useScale: !0
|
|
755
725
|
// Signal to use scale animation from 0
|
|
@@ -758,28 +728,28 @@ class fe {
|
|
|
758
728
|
/**
|
|
759
729
|
* Calculate start position from a random edge
|
|
760
730
|
*/
|
|
761
|
-
calculateRandomEdge(t, i, e,
|
|
731
|
+
calculateRandomEdge(t, i, e, o) {
|
|
762
732
|
const s = ["top", "bottom", "left", "right"], r = s[Math.floor(Math.random() * s.length)];
|
|
763
|
-
return this.calculateEdgePosition(r, t, i, e,
|
|
733
|
+
return this.calculateEdgePosition(r, t, i, e, o);
|
|
764
734
|
}
|
|
765
735
|
/**
|
|
766
736
|
* Calculate start position on a circle around the container
|
|
767
737
|
*/
|
|
768
|
-
calculateCircularPosition(t, i, e,
|
|
738
|
+
calculateCircularPosition(t, i, e, o, s) {
|
|
769
739
|
const r = this.config.start.circular || {}, a = r.distribution || "even";
|
|
770
740
|
let c;
|
|
771
|
-
const
|
|
772
|
-
if (typeof
|
|
773
|
-
const
|
|
741
|
+
const d = r.radius || "120%";
|
|
742
|
+
if (typeof d == "string" && d.endsWith("%")) {
|
|
743
|
+
const v = parseFloat(d) / 100;
|
|
774
744
|
c = Math.sqrt(
|
|
775
745
|
e.width ** 2 + e.height ** 2
|
|
776
|
-
) *
|
|
746
|
+
) * v / 2;
|
|
777
747
|
} else
|
|
778
|
-
c = typeof
|
|
748
|
+
c = typeof d == "number" ? d : 500;
|
|
779
749
|
let u;
|
|
780
|
-
a === "even" ? u =
|
|
781
|
-
const
|
|
782
|
-
return { x:
|
|
750
|
+
a === "even" ? u = o / s * 2 * Math.PI : u = Math.random() * 2 * Math.PI;
|
|
751
|
+
const f = e.width / 2, m = e.height / 2, p = f + Math.cos(u) * c, w = m + Math.sin(u) * c;
|
|
752
|
+
return { x: p, y: w };
|
|
783
753
|
}
|
|
784
754
|
/**
|
|
785
755
|
* Get animation parameters for an image
|
|
@@ -798,17 +768,17 @@ class fe {
|
|
|
798
768
|
* Build a CSS transform string for the start position
|
|
799
769
|
* Uses pixel-based centering offset for reliable cross-browser behavior
|
|
800
770
|
*/
|
|
801
|
-
buildStartTransform(t, i, e,
|
|
802
|
-
const
|
|
803
|
-
return t.useScale ? `${
|
|
771
|
+
buildStartTransform(t, i, e, o, s, r, a, c) {
|
|
772
|
+
const d = t.x - i.x, u = t.y - i.y, f = a !== void 0 ? a : e, m = c !== void 0 ? c : o, p = s !== void 0 ? -s / 2 : 0, w = r !== void 0 ? -r / 2 : 0, v = s !== void 0 ? `translate(${p}px, ${w}px)` : "translate(-50%, -50%)";
|
|
773
|
+
return t.useScale ? `${v} translate(${d}px, ${u}px) rotate(${f}deg) scale(0)` : `${v} translate(${d}px, ${u}px) rotate(${f}deg) scale(${m})`;
|
|
804
774
|
}
|
|
805
775
|
/**
|
|
806
776
|
* Build the final CSS transform string
|
|
807
777
|
* Uses pixel-based centering offset for reliable cross-browser behavior
|
|
808
778
|
*/
|
|
809
|
-
buildFinalTransform(t, i, e,
|
|
810
|
-
if (e !== void 0 &&
|
|
811
|
-
const s = -e / 2, r = -
|
|
779
|
+
buildFinalTransform(t, i, e, o) {
|
|
780
|
+
if (e !== void 0 && o !== void 0) {
|
|
781
|
+
const s = -e / 2, r = -o / 2;
|
|
812
782
|
return `translate(${s}px, ${r}px) rotate(${t}deg) scale(${i})`;
|
|
813
783
|
}
|
|
814
784
|
return `translate(-50%, -50%) rotate(${t}deg) scale(${i})`;
|
|
@@ -825,7 +795,7 @@ class fe {
|
|
|
825
795
|
* Check if the current path type requires JavaScript animation
|
|
826
796
|
*/
|
|
827
797
|
requiresJSAnimation() {
|
|
828
|
-
return
|
|
798
|
+
return le(this.pathConfig.type);
|
|
829
799
|
}
|
|
830
800
|
/**
|
|
831
801
|
* Get the path configuration
|
|
@@ -874,12 +844,12 @@ class fe {
|
|
|
874
844
|
return t + (Math.random() - 0.5) * 60;
|
|
875
845
|
if (typeof e == "number")
|
|
876
846
|
return e;
|
|
877
|
-
const
|
|
878
|
-
return e.min + Math.random() *
|
|
847
|
+
const o = e.max - e.min;
|
|
848
|
+
return e.min + Math.random() * o;
|
|
879
849
|
}
|
|
880
850
|
case "spin": {
|
|
881
|
-
const e = this.rotationConfig.spinCount ?? 1,
|
|
882
|
-
return t + e * 360 *
|
|
851
|
+
const e = this.rotationConfig.spinCount ?? 1, o = this.resolveSpinDirection(t);
|
|
852
|
+
return t + e * 360 * o;
|
|
883
853
|
}
|
|
884
854
|
case "random":
|
|
885
855
|
return t + (Math.random() - 0.5) * 60;
|
|
@@ -927,8 +897,8 @@ class fe {
|
|
|
927
897
|
amplitude: 15,
|
|
928
898
|
frequency: 3,
|
|
929
899
|
decay: !0
|
|
930
|
-
}, { amplitude:
|
|
931
|
-
return i +
|
|
900
|
+
}, { amplitude: o, frequency: s, decay: r } = e, a = Math.sin(t * s * Math.PI * 2), c = r ? Math.pow(1 - t, 2) : 1, d = o * a * c;
|
|
901
|
+
return i + d;
|
|
932
902
|
}
|
|
933
903
|
/**
|
|
934
904
|
* Get the scale configuration
|
|
@@ -984,12 +954,12 @@ class fe {
|
|
|
984
954
|
const e = this.scaleConfig.pop || {
|
|
985
955
|
overshoot: 1.2,
|
|
986
956
|
bounces: 1
|
|
987
|
-
}, { overshoot:
|
|
957
|
+
}, { overshoot: o, bounces: s } = e, r = this.generateScaleBounceKeyframes(s, o);
|
|
988
958
|
let a = i;
|
|
989
959
|
for (let c = 0; c < r.length; c++)
|
|
990
960
|
if (t <= r[c].time) {
|
|
991
|
-
const
|
|
992
|
-
a = u + (r[c].scale - u) *
|
|
961
|
+
const d = c === 0 ? 0 : r[c - 1].time, u = c === 0 ? i : r[c - 1].scale, f = (t - d) / (r[c].time - d), m = this.easeOutQuad(f);
|
|
962
|
+
a = u + (r[c].scale - u) * m;
|
|
993
963
|
break;
|
|
994
964
|
}
|
|
995
965
|
return a * i;
|
|
@@ -1000,12 +970,12 @@ class fe {
|
|
|
1000
970
|
generateScaleBounceKeyframes(t, i) {
|
|
1001
971
|
const e = [];
|
|
1002
972
|
e.push({ time: 0.5, scale: i });
|
|
1003
|
-
let
|
|
973
|
+
let o = i;
|
|
1004
974
|
const s = 0.5, a = 0.5 / (t * 2);
|
|
1005
975
|
let c = 0.5;
|
|
1006
|
-
for (let
|
|
1007
|
-
const u = 1 - (
|
|
1008
|
-
c += a, e.push({ time: c, scale: u }),
|
|
976
|
+
for (let d = 0; d < t; d++) {
|
|
977
|
+
const u = 1 - (o - 1) * s;
|
|
978
|
+
c += a, e.push({ time: c, scale: u }), o = 1 + (o - 1) * s * s, c += a, d < t - 1 && e.push({ time: c, scale: o });
|
|
1009
979
|
}
|
|
1010
980
|
return e.push({ time: 1, scale: 1 }), e;
|
|
1011
981
|
}
|
|
@@ -1016,7 +986,7 @@ class fe {
|
|
|
1016
986
|
return 1 - (1 - t) * (1 - t);
|
|
1017
987
|
}
|
|
1018
988
|
}
|
|
1019
|
-
class
|
|
989
|
+
class ue {
|
|
1020
990
|
constructor(t, i = 600) {
|
|
1021
991
|
this.entries = /* @__PURE__ */ new Map(), this.togetherRafId = null, this.togetherSpeed = 0, this.config = t, this.entryDurationMs = i;
|
|
1022
992
|
}
|
|
@@ -1024,9 +994,9 @@ class ge {
|
|
|
1024
994
|
* Register an image element for idle animation.
|
|
1025
995
|
* Starts animation after entry duration completes.
|
|
1026
996
|
*/
|
|
1027
|
-
register(t, i, e,
|
|
997
|
+
register(t, i, e, o) {
|
|
1028
998
|
if (this.entries.has(t)) return;
|
|
1029
|
-
const s =
|
|
999
|
+
const s = o ?? this.entryDurationMs, r = this.config.startDelay ?? s, a = {
|
|
1030
1000
|
element: t,
|
|
1031
1001
|
index: i,
|
|
1032
1002
|
totalImages: e,
|
|
@@ -1141,23 +1111,23 @@ class ge {
|
|
|
1141
1111
|
});
|
|
1142
1112
|
}
|
|
1143
1113
|
_startBlink(t) {
|
|
1144
|
-
const i = { ...qt, ...this.config.blink }, e = -(Math.random() * i.speed),
|
|
1114
|
+
const i = { ...qt, ...this.config.blink }, e = -(Math.random() * i.speed), o = parseFloat(getComputedStyle(t.element).opacity) || 1;
|
|
1145
1115
|
let s, r;
|
|
1146
1116
|
i.style === "fade" ? (s = [
|
|
1147
|
-
{ opacity:
|
|
1117
|
+
{ opacity: o, offset: 0 },
|
|
1148
1118
|
{ opacity: 0, offset: 0.5 },
|
|
1149
|
-
{ opacity:
|
|
1119
|
+
{ opacity: o, offset: 1 }
|
|
1150
1120
|
], r = {
|
|
1151
1121
|
duration: i.speed,
|
|
1152
1122
|
delay: e,
|
|
1153
1123
|
iterations: 1 / 0,
|
|
1154
1124
|
easing: "ease-in-out"
|
|
1155
1125
|
}) : (s = [
|
|
1156
|
-
{ opacity:
|
|
1157
|
-
{ opacity:
|
|
1126
|
+
{ opacity: o, offset: 0 },
|
|
1127
|
+
{ opacity: o, offset: i.onRatio },
|
|
1158
1128
|
{ opacity: 0, offset: Math.min(i.onRatio + 0.01, 0.99) },
|
|
1159
1129
|
{ opacity: 0, offset: 0.99 },
|
|
1160
|
-
{ opacity:
|
|
1130
|
+
{ opacity: o, offset: 1 }
|
|
1161
1131
|
], r = {
|
|
1162
1132
|
duration: i.speed,
|
|
1163
1133
|
delay: e,
|
|
@@ -1165,7 +1135,7 @@ class ge {
|
|
|
1165
1135
|
}), t.blinkAnimation = t.element.animate(s, r);
|
|
1166
1136
|
}
|
|
1167
1137
|
_startSpin(t) {
|
|
1168
|
-
const i = { ...
|
|
1138
|
+
const i = { ...Yt, ...this.config.spin }, e = i.direction === "clockwise" ? 360 : -360;
|
|
1169
1139
|
t.animation = t.element.animate(
|
|
1170
1140
|
[{ transform: "rotate(0deg)" }, { transform: `rotate(${e}deg)` }],
|
|
1171
1141
|
{
|
|
@@ -1186,8 +1156,8 @@ class ge {
|
|
|
1186
1156
|
if (this.togetherSpeed = t, this.togetherRafId !== null) return;
|
|
1187
1157
|
const i = () => {
|
|
1188
1158
|
const e = performance.now() % this.togetherSpeed;
|
|
1189
|
-
for (const
|
|
1190
|
-
!
|
|
1159
|
+
for (const o of this.entries.values())
|
|
1160
|
+
!o.stopped && !o.paused && o.animation && (o.animation.currentTime = e);
|
|
1191
1161
|
this.togetherRafId = requestAnimationFrame(i);
|
|
1192
1162
|
};
|
|
1193
1163
|
this.togetherRafId = requestAnimationFrame(i);
|
|
@@ -1202,7 +1172,7 @@ class ge {
|
|
|
1202
1172
|
t.animation && (t.animation.cancel(), t.animation = null), t.blinkAnimation && (t.blinkAnimation.cancel(), t.blinkAnimation = null), t.customTeardown && (t.customTeardown(), t.customTeardown = null);
|
|
1203
1173
|
}
|
|
1204
1174
|
}
|
|
1205
|
-
class
|
|
1175
|
+
class fe {
|
|
1206
1176
|
constructor(t, i = {}) {
|
|
1207
1177
|
this.config = t, this.imageConfig = i;
|
|
1208
1178
|
}
|
|
@@ -1214,19 +1184,19 @@ class me {
|
|
|
1214
1184
|
* @returns Array of layout objects with position, rotation, scale
|
|
1215
1185
|
*/
|
|
1216
1186
|
generate(t, i, e = {}) {
|
|
1217
|
-
const
|
|
1218
|
-
for (let
|
|
1219
|
-
const
|
|
1220
|
-
id:
|
|
1221
|
-
x:
|
|
1222
|
-
y:
|
|
1223
|
-
rotation:
|
|
1224
|
-
scale:
|
|
1225
|
-
baseSize:
|
|
1187
|
+
const o = [], { width: s, height: r } = i, a = this.config.spacing.padding, c = e.fixedHeight ?? 200, d = this.imageConfig.rotation?.mode ?? "none", u = this.imageConfig.rotation?.range?.min ?? -15, f = this.imageConfig.rotation?.range?.max ?? 15, m = this.imageConfig.sizing?.variance?.min ?? 1, p = this.imageConfig.sizing?.variance?.max ?? 1, w = m !== 1 || p !== 1, l = c * 1.5 / 2, g = c / 2, h = s - a - l, b = r - a - g, I = a + l, y = a + g;
|
|
1188
|
+
for (let x = 0; x < t; x++) {
|
|
1189
|
+
const E = this.random(I, h), F = this.random(y, b), R = d === "random" ? this.random(u, f) : 0, M = w ? this.random(m, p) : 1, T = c * M, z = {
|
|
1190
|
+
id: x,
|
|
1191
|
+
x: E,
|
|
1192
|
+
y: F,
|
|
1193
|
+
rotation: R,
|
|
1194
|
+
scale: M,
|
|
1195
|
+
baseSize: T
|
|
1226
1196
|
};
|
|
1227
|
-
|
|
1197
|
+
o.push(z);
|
|
1228
1198
|
}
|
|
1229
|
-
return
|
|
1199
|
+
return o;
|
|
1230
1200
|
}
|
|
1231
1201
|
/**
|
|
1232
1202
|
* Utility: Generate random number between min and max
|
|
@@ -1238,7 +1208,7 @@ class me {
|
|
|
1238
1208
|
return Math.random() * (i - t) + t;
|
|
1239
1209
|
}
|
|
1240
1210
|
}
|
|
1241
|
-
class
|
|
1211
|
+
class ge {
|
|
1242
1212
|
constructor(t, i = {}) {
|
|
1243
1213
|
this.config = t, this.imageConfig = i;
|
|
1244
1214
|
}
|
|
@@ -1250,55 +1220,55 @@ class pe {
|
|
|
1250
1220
|
* @returns Array of layout objects with position, rotation, scale
|
|
1251
1221
|
*/
|
|
1252
1222
|
generate(t, i, e = {}) {
|
|
1253
|
-
const
|
|
1223
|
+
const o = [], { width: s, height: r } = i, a = e.fixedHeight ?? 200, c = this.imageConfig.rotation?.mode ?? "none", d = this.imageConfig.rotation?.range?.min ?? -15, u = this.imageConfig.rotation?.range?.max ?? 15, f = this.imageConfig.sizing?.variance?.min ?? 1, m = this.imageConfig.sizing?.variance?.max ?? 1, p = f !== 1 || m !== 1, w = this.config.scaleDecay ?? 0, v = {
|
|
1254
1224
|
...Ut,
|
|
1255
1225
|
...this.config.radial
|
|
1256
|
-
},
|
|
1257
|
-
|
|
1258
|
-
|
|
1226
|
+
}, l = e.fixedHeight ?? a, g = s / 2, h = r / 2, b = Math.ceil(Math.sqrt(t)), I = this.config.spacing.padding ?? 50, y = Math.max(l * 0.8, Math.min(
|
|
1227
|
+
g - I - l / 2,
|
|
1228
|
+
h - I - l / 2
|
|
1259
1229
|
));
|
|
1260
1230
|
if (t > 0) {
|
|
1261
|
-
const
|
|
1262
|
-
|
|
1231
|
+
const F = p ? this.random(f, m) : 1, R = l * F;
|
|
1232
|
+
o.push({
|
|
1263
1233
|
id: 0,
|
|
1264
|
-
x:
|
|
1265
|
-
y,
|
|
1266
|
-
rotation: c === "random" ? this.random(
|
|
1234
|
+
x: g,
|
|
1235
|
+
y: h,
|
|
1236
|
+
rotation: c === "random" ? this.random(d * 0.33, u * 0.33) : 0,
|
|
1267
1237
|
// Less rotation for center
|
|
1268
|
-
scale:
|
|
1269
|
-
baseSize:
|
|
1238
|
+
scale: F,
|
|
1239
|
+
baseSize: R,
|
|
1270
1240
|
zIndex: 100
|
|
1271
1241
|
// Center image is highest
|
|
1272
1242
|
});
|
|
1273
1243
|
}
|
|
1274
|
-
let
|
|
1275
|
-
for (;
|
|
1276
|
-
const
|
|
1277
|
-
if (
|
|
1278
|
-
|
|
1244
|
+
let x = 1, E = 1;
|
|
1245
|
+
for (; x < t; ) {
|
|
1246
|
+
const F = E / b, R = w > 0 ? 1 - F * w * 0.5 : 1, M = Math.max(l * 0.8, y / b * 1.5 / v.tightness), T = E * M, z = T * 1.5, k = Math.PI * (3 * (z + T) - Math.sqrt((3 * z + T) * (z + 3 * T))), D = this.estimateWidth(l), O = Math.floor(k / (D * 0.7));
|
|
1247
|
+
if (O === 0) {
|
|
1248
|
+
E++;
|
|
1279
1249
|
continue;
|
|
1280
1250
|
}
|
|
1281
|
-
const
|
|
1282
|
-
for (let
|
|
1283
|
-
const
|
|
1284
|
-
let
|
|
1285
|
-
const
|
|
1286
|
-
|
|
1287
|
-
const
|
|
1288
|
-
|
|
1289
|
-
id:
|
|
1290
|
-
x:
|
|
1291
|
-
y:
|
|
1292
|
-
rotation:
|
|
1293
|
-
scale:
|
|
1294
|
-
baseSize:
|
|
1295
|
-
zIndex: Math.max(1, 100 -
|
|
1251
|
+
const S = 2 * Math.PI / O, _ = E * (20 * Math.PI / 180);
|
|
1252
|
+
for (let $ = 0; $ < O && x < t; $++) {
|
|
1253
|
+
const A = $ * S + _, j = p ? this.random(f, m) : 1, N = R * j, P = l * N;
|
|
1254
|
+
let H = g + Math.cos(A) * z, U = h + Math.sin(A) * T;
|
|
1255
|
+
const B = P * 1.5 / 2, W = P / 2;
|
|
1256
|
+
H - B < I ? H = I + B : H + B > s - I && (H = s - I - B), U - W < I ? U = I + W : U + W > r - I && (U = r - I - W);
|
|
1257
|
+
const X = c === "random" ? this.random(d, u) : 0;
|
|
1258
|
+
o.push({
|
|
1259
|
+
id: x,
|
|
1260
|
+
x: H,
|
|
1261
|
+
y: U,
|
|
1262
|
+
rotation: X,
|
|
1263
|
+
scale: N,
|
|
1264
|
+
baseSize: P,
|
|
1265
|
+
zIndex: Math.max(1, 100 - E)
|
|
1296
1266
|
// Outer rings have lower z-index
|
|
1297
|
-
}),
|
|
1267
|
+
}), x++;
|
|
1298
1268
|
}
|
|
1299
|
-
|
|
1269
|
+
E++;
|
|
1300
1270
|
}
|
|
1301
|
-
return
|
|
1271
|
+
return o;
|
|
1302
1272
|
}
|
|
1303
1273
|
/**
|
|
1304
1274
|
* Estimate image width based on height
|
|
@@ -1319,7 +1289,7 @@ class pe {
|
|
|
1319
1289
|
return Math.random() * (i - t) + t;
|
|
1320
1290
|
}
|
|
1321
1291
|
}
|
|
1322
|
-
const
|
|
1292
|
+
const me = {
|
|
1323
1293
|
columns: "auto",
|
|
1324
1294
|
rows: "auto",
|
|
1325
1295
|
stagger: "none",
|
|
@@ -1329,7 +1299,7 @@ const be = {
|
|
|
1329
1299
|
alignment: "center",
|
|
1330
1300
|
gap: 10,
|
|
1331
1301
|
overflowOffset: 0.25
|
|
1332
|
-
},
|
|
1302
|
+
}, Tt = [
|
|
1333
1303
|
{ x: 1, y: 1 },
|
|
1334
1304
|
// bottom-right
|
|
1335
1305
|
{ x: -1, y: -1 },
|
|
@@ -1347,7 +1317,7 @@ const be = {
|
|
|
1347
1317
|
{ x: 0, y: 1 }
|
|
1348
1318
|
// down
|
|
1349
1319
|
];
|
|
1350
|
-
class
|
|
1320
|
+
class pe {
|
|
1351
1321
|
constructor(t, i = {}) {
|
|
1352
1322
|
this.config = t, this.imageConfig = i;
|
|
1353
1323
|
}
|
|
@@ -1359,60 +1329,60 @@ class ye {
|
|
|
1359
1329
|
* @returns Array of layout objects with position, rotation, scale
|
|
1360
1330
|
*/
|
|
1361
1331
|
generate(t, i, e = {}) {
|
|
1362
|
-
const
|
|
1332
|
+
const o = [], { width: s, height: r } = i, a = { ...me, ...this.config.grid }, c = this.config.spacing.padding, d = e.fixedHeight ?? 200, u = this.imageConfig.rotation?.mode ?? "none", f = this.imageConfig.sizing?.variance?.min ?? 1, m = this.imageConfig.sizing?.variance?.max ?? 1, p = f !== 1 || m !== 1, w = s - 2 * c, v = r - 2 * c, { columns: l, rows: g } = this.calculateGridDimensions(
|
|
1363
1333
|
t,
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1334
|
+
w,
|
|
1335
|
+
v,
|
|
1336
|
+
d,
|
|
1367
1337
|
a
|
|
1368
|
-
),
|
|
1338
|
+
), h = a.stagger === "row", b = a.stagger === "column", I = h ? l + 0.5 : l, y = b ? g + 0.5 : g, x = (w - a.gap * (l - 1)) / I, E = (v - a.gap * (g - 1)) / y, F = h ? x / 2 : 0, R = b ? E / 2 : 0, M = 1 + a.overlap, T = Math.min(x, E) * M, z = e.fixedHeight ? Math.min(e.fixedHeight, T) : T, k = l * x + (l - 1) * a.gap + F, D = g * E + (g - 1) * a.gap + R, O = c + (w - k) / 2, S = c + (v - D) / 2, _ = l * g, $ = a.columns !== "auto" && a.rows !== "auto", A = $ && t > _;
|
|
1369
1339
|
typeof window < "u" && (window.__gridOverflowDebug = {
|
|
1370
1340
|
gridConfigColumns: a.columns,
|
|
1371
1341
|
gridConfigRows: a.rows,
|
|
1372
|
-
columns:
|
|
1373
|
-
rows:
|
|
1374
|
-
cellCount:
|
|
1375
|
-
hasFixedGrid:
|
|
1342
|
+
columns: l,
|
|
1343
|
+
rows: g,
|
|
1344
|
+
cellCount: _,
|
|
1345
|
+
hasFixedGrid: $,
|
|
1376
1346
|
imageCount: t,
|
|
1377
|
-
isOverflowMode:
|
|
1347
|
+
isOverflowMode: A
|
|
1378
1348
|
});
|
|
1379
|
-
const
|
|
1380
|
-
for (let
|
|
1381
|
-
let
|
|
1382
|
-
if (
|
|
1383
|
-
const
|
|
1384
|
-
|
|
1349
|
+
const j = A ? new Array(_).fill(0) : [], N = Math.min(x, E) * a.overflowOffset;
|
|
1350
|
+
for (let P = 0; P < t; P++) {
|
|
1351
|
+
let H, U, Y = 0;
|
|
1352
|
+
if (A && P >= _) {
|
|
1353
|
+
const q = P - _, G = q % _;
|
|
1354
|
+
Y = Math.floor(q / _) + 1, j[G]++, a.fillDirection === "row" ? (H = G % l, U = Math.floor(G / l)) : (U = G % g, H = Math.floor(G / g));
|
|
1385
1355
|
} else
|
|
1386
|
-
a.fillDirection === "row" ? (
|
|
1387
|
-
let
|
|
1388
|
-
if (a.stagger === "row" &&
|
|
1389
|
-
const
|
|
1390
|
-
|
|
1356
|
+
a.fillDirection === "row" ? (H = P % l, U = Math.floor(P / l)) : (U = P % g, H = Math.floor(P / g));
|
|
1357
|
+
let B = O + H * (x + a.gap) + x / 2, W = S + U * (E + a.gap) + E / 2;
|
|
1358
|
+
if (a.stagger === "row" && U % 2 === 1 ? B += x / 2 : a.stagger === "column" && H % 2 === 1 && (W += E / 2), Y > 0) {
|
|
1359
|
+
const q = (Y - 1) % Tt.length, G = Tt[q];
|
|
1360
|
+
B += G.x * N, W += G.y * N;
|
|
1391
1361
|
}
|
|
1392
1362
|
if (a.jitter > 0) {
|
|
1393
|
-
const
|
|
1394
|
-
|
|
1363
|
+
const q = x / 2 * a.jitter, G = E / 2 * a.jitter;
|
|
1364
|
+
B += this.random(-q, q), W += this.random(-G, G);
|
|
1395
1365
|
}
|
|
1396
|
-
let
|
|
1397
|
-
if (!
|
|
1398
|
-
const
|
|
1399
|
-
if (
|
|
1400
|
-
const
|
|
1366
|
+
let X = B, V = W;
|
|
1367
|
+
if (!A && a.fillDirection === "row") {
|
|
1368
|
+
const q = t % l || l;
|
|
1369
|
+
if (U === Math.floor((t - 1) / l) && q < l) {
|
|
1370
|
+
const It = q * x + (q - 1) * a.gap;
|
|
1401
1371
|
let gt = 0;
|
|
1402
|
-
a.alignment === "center" ? gt = (
|
|
1372
|
+
a.alignment === "center" ? gt = (k - It) / 2 : a.alignment === "end" && (gt = k - It), X += gt;
|
|
1403
1373
|
}
|
|
1404
1374
|
}
|
|
1405
|
-
const ct =
|
|
1406
|
-
|
|
1375
|
+
const ct = p ? this.random(f, m) : 1, K = z * ct, ot = K * 1.5 / 2, nt = K / 2, ht = c + ot, dt = s - c - ot, Pt = c + nt, _t = r - c - nt;
|
|
1376
|
+
X = Math.max(ht, Math.min(X, dt)), V = Math.max(Pt, Math.min(V, _t));
|
|
1407
1377
|
let ut = 0;
|
|
1408
1378
|
if (u === "random") {
|
|
1409
|
-
const
|
|
1410
|
-
a.jitter > 0 ? ut = this.random(
|
|
1379
|
+
const q = this.imageConfig.rotation?.range?.min ?? -15, G = this.imageConfig.rotation?.range?.max ?? 15;
|
|
1380
|
+
a.jitter > 0 ? ut = this.random(q * a.jitter, G * a.jitter) : ut = this.random(q, G);
|
|
1411
1381
|
}
|
|
1412
1382
|
let ft;
|
|
1413
|
-
|
|
1414
|
-
id:
|
|
1415
|
-
x:
|
|
1383
|
+
A && Y > 0 ? ft = 50 - Y : ft = A ? 100 + P : P + 1, o.push({
|
|
1384
|
+
id: P,
|
|
1385
|
+
x: X,
|
|
1416
1386
|
y: V,
|
|
1417
1387
|
rotation: ut,
|
|
1418
1388
|
scale: ct,
|
|
@@ -1420,12 +1390,12 @@ class ye {
|
|
|
1420
1390
|
zIndex: ft
|
|
1421
1391
|
});
|
|
1422
1392
|
}
|
|
1423
|
-
return
|
|
1393
|
+
return o;
|
|
1424
1394
|
}
|
|
1425
1395
|
/**
|
|
1426
1396
|
* Calculate optimal grid dimensions based on image count and container
|
|
1427
1397
|
*/
|
|
1428
|
-
calculateGridDimensions(t, i, e,
|
|
1398
|
+
calculateGridDimensions(t, i, e, o, s) {
|
|
1429
1399
|
let r, a;
|
|
1430
1400
|
if (s.columns !== "auto" && s.rows !== "auto")
|
|
1431
1401
|
r = s.columns, a = s.rows;
|
|
@@ -1447,14 +1417,14 @@ class ye {
|
|
|
1447
1417
|
return Math.random() * (i - t) + t;
|
|
1448
1418
|
}
|
|
1449
1419
|
}
|
|
1450
|
-
const
|
|
1420
|
+
const be = Math.PI * (3 - Math.sqrt(5)), ye = {
|
|
1451
1421
|
spiralType: "golden",
|
|
1452
1422
|
direction: "counterclockwise",
|
|
1453
1423
|
tightness: 1,
|
|
1454
1424
|
scaleDecay: 0,
|
|
1455
1425
|
startAngle: 0
|
|
1456
1426
|
};
|
|
1457
|
-
class
|
|
1427
|
+
class ve {
|
|
1458
1428
|
constructor(t, i = {}) {
|
|
1459
1429
|
this.config = t, this.imageConfig = i;
|
|
1460
1430
|
}
|
|
@@ -1466,80 +1436,80 @@ class we {
|
|
|
1466
1436
|
* @returns Array of layout objects with position, rotation, scale
|
|
1467
1437
|
*/
|
|
1468
1438
|
generate(t, i, e = {}) {
|
|
1469
|
-
const
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
),
|
|
1473
|
-
for (let
|
|
1474
|
-
let
|
|
1439
|
+
const o = [], { width: s, height: r } = i, a = { ...ye, ...this.config.spiral }, c = this.config.spacing.padding, d = e.fixedHeight ?? 200, u = this.imageConfig.rotation?.mode ?? "none", f = this.imageConfig.rotation?.range?.min ?? -15, m = this.imageConfig.rotation?.range?.max ?? 15, p = this.imageConfig.sizing?.variance?.min ?? 1, w = this.imageConfig.sizing?.variance?.max ?? 1, v = p !== 1 || w !== 1, l = this.config.scaleDecay ?? a.scaleDecay, g = s / 2, h = r / 2, b = Math.min(
|
|
1440
|
+
g - c - d / 2,
|
|
1441
|
+
h - c - d / 2
|
|
1442
|
+
), I = a.direction === "clockwise" ? -1 : 1;
|
|
1443
|
+
for (let y = 0; y < t; y++) {
|
|
1444
|
+
let x, E;
|
|
1475
1445
|
if (a.spiralType === "golden")
|
|
1476
|
-
|
|
1446
|
+
x = y * be * I + a.startAngle, E = this.calculateGoldenRadius(y, t, b, a.tightness);
|
|
1477
1447
|
else if (a.spiralType === "archimedean") {
|
|
1478
|
-
const
|
|
1479
|
-
|
|
1448
|
+
const B = y * 0.5 * a.tightness;
|
|
1449
|
+
x = B * I + a.startAngle, E = this.calculateArchimedeanRadius(B, t, b, a.tightness);
|
|
1480
1450
|
} else {
|
|
1481
|
-
const
|
|
1482
|
-
|
|
1451
|
+
const B = y * 0.3 * a.tightness;
|
|
1452
|
+
x = B * I + a.startAngle, E = this.calculateLogarithmicRadius(B, t, b, a.tightness);
|
|
1483
1453
|
}
|
|
1484
|
-
const
|
|
1485
|
-
let
|
|
1454
|
+
const F = g + Math.cos(x) * E, R = h + Math.sin(x) * E, M = E / b, T = l > 0 ? 1 - M * l * 0.5 : 1, z = v ? this.random(p, w) : 1, k = T * z, D = d * k, S = D * 1.5 / 2, _ = D / 2, $ = c + S, A = s - c - S, j = c + _, N = r - c - _, P = Math.max($, Math.min(F, A)), H = Math.max(j, Math.min(R, N));
|
|
1455
|
+
let U = 0;
|
|
1486
1456
|
if (u === "random") {
|
|
1487
|
-
const
|
|
1488
|
-
|
|
1489
|
-
} else u === "tangent" && (
|
|
1490
|
-
const
|
|
1491
|
-
|
|
1492
|
-
id:
|
|
1493
|
-
x:
|
|
1494
|
-
y:
|
|
1495
|
-
rotation:
|
|
1496
|
-
scale:
|
|
1497
|
-
baseSize:
|
|
1498
|
-
zIndex:
|
|
1457
|
+
const B = x * 180 / Math.PI % 360, W = this.random(f, m);
|
|
1458
|
+
U = a.spiralType === "golden" ? W : B * 0.1 + W * 0.9;
|
|
1459
|
+
} else u === "tangent" && (U = this.calculateSpiralTangent(x, E, a));
|
|
1460
|
+
const Y = t - y;
|
|
1461
|
+
o.push({
|
|
1462
|
+
id: y,
|
|
1463
|
+
x: P,
|
|
1464
|
+
y: H,
|
|
1465
|
+
rotation: U,
|
|
1466
|
+
scale: k,
|
|
1467
|
+
baseSize: D,
|
|
1468
|
+
zIndex: Y
|
|
1499
1469
|
});
|
|
1500
1470
|
}
|
|
1501
|
-
return
|
|
1471
|
+
return o;
|
|
1502
1472
|
}
|
|
1503
1473
|
/**
|
|
1504
1474
|
* Calculate tangent angle for spiral curve at given position
|
|
1505
1475
|
* This aligns the image along the spiral's direction of travel
|
|
1506
1476
|
*/
|
|
1507
1477
|
calculateSpiralTangent(t, i, e) {
|
|
1508
|
-
let
|
|
1478
|
+
let o;
|
|
1509
1479
|
if (e.spiralType === "golden")
|
|
1510
|
-
|
|
1480
|
+
o = t + Math.PI / 2;
|
|
1511
1481
|
else if (e.spiralType === "archimedean") {
|
|
1512
1482
|
const r = 1 / e.tightness, a = Math.atan(i / r);
|
|
1513
|
-
|
|
1483
|
+
o = t + a;
|
|
1514
1484
|
} else {
|
|
1515
1485
|
const r = 0.15 / e.tightness, a = Math.atan(1 / r);
|
|
1516
|
-
|
|
1486
|
+
o = t + a;
|
|
1517
1487
|
}
|
|
1518
|
-
return
|
|
1488
|
+
return o * 180 / Math.PI % 360 - 90;
|
|
1519
1489
|
}
|
|
1520
1490
|
/**
|
|
1521
1491
|
* Calculate radius for golden spiral (Vogel's model)
|
|
1522
1492
|
* Creates even distribution like sunflower seeds
|
|
1523
1493
|
*/
|
|
1524
|
-
calculateGoldenRadius(t, i, e,
|
|
1525
|
-
const r = e / Math.sqrt(i) * Math.sqrt(t) /
|
|
1494
|
+
calculateGoldenRadius(t, i, e, o) {
|
|
1495
|
+
const r = e / Math.sqrt(i) * Math.sqrt(t) / o;
|
|
1526
1496
|
return Math.min(r, e);
|
|
1527
1497
|
}
|
|
1528
1498
|
/**
|
|
1529
1499
|
* Calculate radius for Archimedean spiral
|
|
1530
1500
|
* r = a + b*θ (constant spacing between arms)
|
|
1531
1501
|
*/
|
|
1532
|
-
calculateArchimedeanRadius(t, i, e,
|
|
1533
|
-
const s = i * 0.5 *
|
|
1502
|
+
calculateArchimedeanRadius(t, i, e, o) {
|
|
1503
|
+
const s = i * 0.5 * o;
|
|
1534
1504
|
return t / s * e;
|
|
1535
1505
|
}
|
|
1536
1506
|
/**
|
|
1537
1507
|
* Calculate radius for logarithmic (equiangular) spiral
|
|
1538
1508
|
* r = a * e^(b*θ)
|
|
1539
1509
|
*/
|
|
1540
|
-
calculateLogarithmicRadius(t, i, e,
|
|
1541
|
-
const s = e * 0.05, r = 0.15 /
|
|
1542
|
-
return a /
|
|
1510
|
+
calculateLogarithmicRadius(t, i, e, o) {
|
|
1511
|
+
const s = e * 0.05, r = 0.15 / o, a = s * Math.exp(r * t), c = i * 0.3 * o, d = s * Math.exp(r * c);
|
|
1512
|
+
return a / d * e;
|
|
1543
1513
|
}
|
|
1544
1514
|
/**
|
|
1545
1515
|
* Utility: Generate random number between min and max
|
|
@@ -1556,7 +1526,7 @@ const xe = {
|
|
|
1556
1526
|
overlap: 0.3,
|
|
1557
1527
|
distribution: "gaussian"
|
|
1558
1528
|
};
|
|
1559
|
-
class
|
|
1529
|
+
class Ee {
|
|
1560
1530
|
constructor(t, i = {}) {
|
|
1561
1531
|
this.config = t, this.imageConfig = i;
|
|
1562
1532
|
}
|
|
@@ -1568,85 +1538,85 @@ class Se {
|
|
|
1568
1538
|
* @returns Array of layout objects with position, rotation, scale
|
|
1569
1539
|
*/
|
|
1570
1540
|
generate(t, i, e = {}) {
|
|
1571
|
-
const
|
|
1541
|
+
const o = [], { width: s, height: r } = i, a = { ...xe, ...this.config.cluster }, c = this.config.spacing.padding, d = e.fixedHeight ?? 200, u = this.imageConfig.rotation?.mode ?? "none", f = this.imageConfig.rotation?.range?.min ?? -15, m = this.imageConfig.rotation?.range?.max ?? 15, p = this.imageConfig.sizing?.variance?.min ?? 1, w = this.imageConfig.sizing?.variance?.max ?? 1, v = p !== 1 || w !== 1, l = this.calculateClusterCount(
|
|
1572
1542
|
t,
|
|
1573
1543
|
a.clusterCount,
|
|
1574
1544
|
s,
|
|
1575
1545
|
r,
|
|
1576
1546
|
a.clusterSpacing
|
|
1577
|
-
),
|
|
1578
|
-
|
|
1547
|
+
), g = this.generateClusterCenters(
|
|
1548
|
+
l,
|
|
1579
1549
|
s,
|
|
1580
1550
|
r,
|
|
1581
1551
|
c,
|
|
1582
1552
|
a
|
|
1583
|
-
),
|
|
1584
|
-
for (let
|
|
1585
|
-
|
|
1586
|
-
let
|
|
1587
|
-
for (let
|
|
1588
|
-
const
|
|
1589
|
-
for (let
|
|
1590
|
-
let
|
|
1553
|
+
), h = new Array(l).fill(0);
|
|
1554
|
+
for (let I = 0; I < t; I++)
|
|
1555
|
+
h[I % l]++;
|
|
1556
|
+
let b = 0;
|
|
1557
|
+
for (let I = 0; I < l; I++) {
|
|
1558
|
+
const y = g[I], x = h[I];
|
|
1559
|
+
for (let E = 0; E < x; E++) {
|
|
1560
|
+
let F, R;
|
|
1591
1561
|
if (a.distribution === "gaussian")
|
|
1592
|
-
|
|
1562
|
+
F = this.gaussianRandom() * y.spread, R = this.gaussianRandom() * y.spread;
|
|
1593
1563
|
else {
|
|
1594
|
-
const
|
|
1595
|
-
|
|
1564
|
+
const U = this.random(0, Math.PI * 2), Y = this.random(0, y.spread);
|
|
1565
|
+
F = Math.cos(U) * Y, R = Math.sin(U) * Y;
|
|
1596
1566
|
}
|
|
1597
|
-
const
|
|
1598
|
-
|
|
1599
|
-
const
|
|
1600
|
-
let
|
|
1601
|
-
const
|
|
1602
|
-
|
|
1603
|
-
const
|
|
1604
|
-
|
|
1605
|
-
id:
|
|
1606
|
-
x:
|
|
1607
|
-
y:
|
|
1608
|
-
rotation:
|
|
1609
|
-
scale:
|
|
1610
|
-
baseSize:
|
|
1611
|
-
zIndex:
|
|
1612
|
-
}),
|
|
1567
|
+
const M = 1 + a.overlap * 0.5, T = 1 + a.overlap * 0.3;
|
|
1568
|
+
F /= M, R /= M;
|
|
1569
|
+
const z = v ? this.random(p, w) : 1, k = T * z, D = d * k;
|
|
1570
|
+
let O = y.x + F, S = y.y + R;
|
|
1571
|
+
const $ = D * 1.5 / 2, A = D / 2;
|
|
1572
|
+
O = Math.max(c + $, Math.min(O, s - c - $)), S = Math.max(c + A, Math.min(S, r - c - A));
|
|
1573
|
+
const j = u === "random" ? this.random(f, m) : 0, P = Math.sqrt(F * F + R * R) / y.spread, H = Math.round((1 - P) * 50) + 1;
|
|
1574
|
+
o.push({
|
|
1575
|
+
id: b,
|
|
1576
|
+
x: O,
|
|
1577
|
+
y: S,
|
|
1578
|
+
rotation: j,
|
|
1579
|
+
scale: k,
|
|
1580
|
+
baseSize: D,
|
|
1581
|
+
zIndex: H
|
|
1582
|
+
}), b++;
|
|
1613
1583
|
}
|
|
1614
1584
|
}
|
|
1615
|
-
return
|
|
1585
|
+
return o;
|
|
1616
1586
|
}
|
|
1617
1587
|
/**
|
|
1618
1588
|
* Calculate optimal number of clusters based on image count and container
|
|
1619
1589
|
*/
|
|
1620
|
-
calculateClusterCount(t, i, e,
|
|
1590
|
+
calculateClusterCount(t, i, e, o, s) {
|
|
1621
1591
|
if (i !== "auto")
|
|
1622
1592
|
return Math.max(1, Math.min(i, t));
|
|
1623
1593
|
const a = Math.max(1, Math.ceil(t / 8)), c = Math.floor(
|
|
1624
|
-
e / s * (
|
|
1594
|
+
e / s * (o / s) * 0.6
|
|
1625
1595
|
);
|
|
1626
1596
|
return Math.max(1, Math.min(a, c, 10));
|
|
1627
1597
|
}
|
|
1628
1598
|
/**
|
|
1629
1599
|
* Generate cluster center positions with spacing constraints
|
|
1630
1600
|
*/
|
|
1631
|
-
generateClusterCenters(t, i, e,
|
|
1632
|
-
const r = [], c =
|
|
1633
|
-
for (let
|
|
1634
|
-
let
|
|
1635
|
-
for (let
|
|
1636
|
-
const
|
|
1637
|
-
x: this.random(c,
|
|
1638
|
-
y: this.random(u,
|
|
1601
|
+
generateClusterCenters(t, i, e, o, s) {
|
|
1602
|
+
const r = [], c = o + s.clusterSpread, d = i - o - s.clusterSpread, u = o + s.clusterSpread, f = e - o - s.clusterSpread;
|
|
1603
|
+
for (let m = 0; m < t; m++) {
|
|
1604
|
+
let p = null, w = -1;
|
|
1605
|
+
for (let v = 0; v < 100; v++) {
|
|
1606
|
+
const l = {
|
|
1607
|
+
x: this.random(c, d),
|
|
1608
|
+
y: this.random(u, f),
|
|
1639
1609
|
spread: this.calculateClusterSpread(s)
|
|
1640
1610
|
};
|
|
1641
|
-
let
|
|
1642
|
-
for (const
|
|
1643
|
-
const
|
|
1644
|
-
|
|
1611
|
+
let g = 1 / 0;
|
|
1612
|
+
for (const h of r) {
|
|
1613
|
+
const b = l.x - h.x, I = l.y - h.y, y = Math.sqrt(b * b + I * I);
|
|
1614
|
+
g = Math.min(g, y);
|
|
1645
1615
|
}
|
|
1646
|
-
if ((r.length === 0 ||
|
|
1616
|
+
if ((r.length === 0 || g > w) && (p = l, w = g), g >= s.clusterSpacing)
|
|
1647
1617
|
break;
|
|
1648
1618
|
}
|
|
1649
|
-
|
|
1619
|
+
p && r.push(p);
|
|
1650
1620
|
}
|
|
1651
1621
|
return r;
|
|
1652
1622
|
}
|
|
@@ -1674,7 +1644,7 @@ class Se {
|
|
|
1674
1644
|
return Math.random() * (i - t) + t;
|
|
1675
1645
|
}
|
|
1676
1646
|
}
|
|
1677
|
-
class
|
|
1647
|
+
class we {
|
|
1678
1648
|
constructor(t, i = {}) {
|
|
1679
1649
|
this.config = t, this.imageConfig = i;
|
|
1680
1650
|
}
|
|
@@ -1686,32 +1656,32 @@ class Ie {
|
|
|
1686
1656
|
* @returns Array of layout objects with position, rotation, scale
|
|
1687
1657
|
*/
|
|
1688
1658
|
generate(t, i, e = {}) {
|
|
1689
|
-
const
|
|
1690
|
-
...
|
|
1659
|
+
const o = [], { width: s, height: r } = i, a = e.fixedHeight ?? 200, c = this.config.spacing.padding ?? 50, d = this.imageConfig.rotation?.mode ?? "none", u = this.imageConfig.rotation?.range?.min ?? -15, f = this.imageConfig.rotation?.range?.max ?? 15, m = this.imageConfig.sizing?.variance?.min ?? 1, p = this.imageConfig.sizing?.variance?.max ?? 1, w = m !== 1 || p !== 1, v = e.fixedHeight ?? a, l = {
|
|
1660
|
+
...kt,
|
|
1691
1661
|
...this.config.wave
|
|
1692
|
-
}, { rows:
|
|
1693
|
-
let
|
|
1694
|
-
for (let
|
|
1695
|
-
const
|
|
1696
|
-
let
|
|
1697
|
-
|
|
1698
|
-
for (let
|
|
1699
|
-
const
|
|
1662
|
+
}, { rows: g, amplitude: h, frequency: b, phaseShift: I, synchronization: y } = l, x = Math.ceil(t / g), R = v * 1.5 / 2, M = c + R, T = s - c - R, z = T - M, k = x > 1 ? z / (x - 1) : 0, D = c + h + v / 2, O = r - c - h - v / 2, S = O - D, _ = g > 1 ? S / (g - 1) : 0;
|
|
1663
|
+
let $ = 0;
|
|
1664
|
+
for (let A = 0; A < g && $ < t; A++) {
|
|
1665
|
+
const j = g === 1 ? (D + O) / 2 : D + A * _;
|
|
1666
|
+
let N = 0;
|
|
1667
|
+
y === "offset" ? N = A * I : y === "alternating" && (N = A * Math.PI);
|
|
1668
|
+
for (let P = 0; P < x && $ < t; P++) {
|
|
1669
|
+
const H = x === 1 ? (M + T) / 2 : M + P * k, U = this.calculateWaveY(H, s, h, b, N), Y = H, B = j + U, W = w ? this.random(m, p) : 1, X = v * W;
|
|
1700
1670
|
let V = 0;
|
|
1701
|
-
|
|
1702
|
-
const K =
|
|
1703
|
-
|
|
1704
|
-
id:
|
|
1705
|
-
x: Math.max(
|
|
1706
|
-
y: Math.max(ht, Math.min(
|
|
1671
|
+
d === "tangent" ? V = this.calculateRotation(H, s, h, b, N) : d === "random" && (V = this.random(u, f));
|
|
1672
|
+
const K = X * 1.5 / 2, lt = X / 2, ot = c + K, nt = s - c - K, ht = c + lt, dt = r - c - lt;
|
|
1673
|
+
o.push({
|
|
1674
|
+
id: $,
|
|
1675
|
+
x: Math.max(ot, Math.min(Y, nt)),
|
|
1676
|
+
y: Math.max(ht, Math.min(B, dt)),
|
|
1707
1677
|
rotation: V,
|
|
1708
|
-
scale:
|
|
1709
|
-
baseSize:
|
|
1710
|
-
zIndex:
|
|
1711
|
-
}),
|
|
1678
|
+
scale: W,
|
|
1679
|
+
baseSize: X,
|
|
1680
|
+
zIndex: $ + 1
|
|
1681
|
+
}), $++;
|
|
1712
1682
|
}
|
|
1713
1683
|
}
|
|
1714
|
-
return
|
|
1684
|
+
return o;
|
|
1715
1685
|
}
|
|
1716
1686
|
/**
|
|
1717
1687
|
* Calculate Y position displacement on wave curve
|
|
@@ -1722,9 +1692,9 @@ class Ie {
|
|
|
1722
1692
|
* @param phase - Phase offset
|
|
1723
1693
|
* @returns Y displacement from baseline
|
|
1724
1694
|
*/
|
|
1725
|
-
calculateWaveY(t, i, e,
|
|
1695
|
+
calculateWaveY(t, i, e, o, s) {
|
|
1726
1696
|
const r = t / i;
|
|
1727
|
-
return e * Math.sin(
|
|
1697
|
+
return e * Math.sin(o * r * 2 * Math.PI + s);
|
|
1728
1698
|
}
|
|
1729
1699
|
/**
|
|
1730
1700
|
* Calculate rotation based on wave tangent
|
|
@@ -1735,8 +1705,8 @@ class Ie {
|
|
|
1735
1705
|
* @param phase - Phase offset
|
|
1736
1706
|
* @returns Rotation angle in degrees
|
|
1737
1707
|
*/
|
|
1738
|
-
calculateRotation(t, i, e,
|
|
1739
|
-
const r = t / i, a = e *
|
|
1708
|
+
calculateRotation(t, i, e, o, s) {
|
|
1709
|
+
const r = t / i, a = e * o * 2 * Math.PI * Math.cos(o * r * 2 * Math.PI + s) / i;
|
|
1740
1710
|
return Math.atan(a) * (180 / Math.PI);
|
|
1741
1711
|
}
|
|
1742
1712
|
/**
|
|
@@ -1751,7 +1721,7 @@ class Ie {
|
|
|
1751
1721
|
return Math.random() * (i - t) + t;
|
|
1752
1722
|
}
|
|
1753
1723
|
}
|
|
1754
|
-
const
|
|
1724
|
+
const Et = 100, Q = 100 / Math.sqrt(3), wt = [
|
|
1755
1725
|
[Q / 2, 0],
|
|
1756
1726
|
// upper-left
|
|
1757
1727
|
[3 * Q / 2, 0],
|
|
@@ -1764,21 +1734,21 @@ const wt = 100, Q = 100 / Math.sqrt(3), xt = [
|
|
|
1764
1734
|
// lower-left
|
|
1765
1735
|
[0, 50]
|
|
1766
1736
|
// left
|
|
1767
|
-
],
|
|
1768
|
-
function
|
|
1737
|
+
], Ie = wt[1][0] / Et, Se = wt[2][1] / Et;
|
|
1738
|
+
function Ce(n) {
|
|
1769
1739
|
return {
|
|
1770
|
-
colStep:
|
|
1771
|
-
rowOffset:
|
|
1740
|
+
colStep: Ie * n,
|
|
1741
|
+
rowOffset: Se * n
|
|
1772
1742
|
};
|
|
1773
1743
|
}
|
|
1774
|
-
function
|
|
1775
|
-
const { colStep: r } =
|
|
1744
|
+
function Re(n, t, i, e, o, s) {
|
|
1745
|
+
const { colStep: r } = Ce(s);
|
|
1776
1746
|
return {
|
|
1777
|
-
px: e + r *
|
|
1778
|
-
py:
|
|
1747
|
+
px: e + r * n,
|
|
1748
|
+
py: o + s * (t + n / 2)
|
|
1779
1749
|
};
|
|
1780
1750
|
}
|
|
1781
|
-
const
|
|
1751
|
+
const Te = [
|
|
1782
1752
|
[1, 0, -1],
|
|
1783
1753
|
[0, 1, -1],
|
|
1784
1754
|
[-1, 1, 0],
|
|
@@ -1786,49 +1756,49 @@ const Le = [
|
|
|
1786
1756
|
[0, -1, 1],
|
|
1787
1757
|
[1, -1, 0]
|
|
1788
1758
|
];
|
|
1789
|
-
function
|
|
1790
|
-
if (
|
|
1759
|
+
function Ae(n) {
|
|
1760
|
+
if (n === 0) return [[0, 0, 0]];
|
|
1791
1761
|
const t = [];
|
|
1792
|
-
let [i, e,
|
|
1793
|
-
for (const [s, r, a] of
|
|
1794
|
-
for (let c = 0; c <
|
|
1795
|
-
t.push([i, e,
|
|
1762
|
+
let [i, e, o] = [0, -n, n];
|
|
1763
|
+
for (const [s, r, a] of Te)
|
|
1764
|
+
for (let c = 0; c < n; c++)
|
|
1765
|
+
t.push([i, e, o]), i += s, e += r, o += a;
|
|
1796
1766
|
return t;
|
|
1797
1767
|
}
|
|
1798
|
-
class
|
|
1768
|
+
class Le {
|
|
1799
1769
|
// imageConfig intentionally not stored — honeycomb forces uniform sizing (rotation/variance
|
|
1800
1770
|
// would break hex tiling). Kept as parameter for interface compatibility.
|
|
1801
1771
|
constructor(t, i = {}) {
|
|
1802
1772
|
this.config = t;
|
|
1803
1773
|
}
|
|
1804
1774
|
generate(t, i, e = {}) {
|
|
1805
|
-
const
|
|
1806
|
-
...
|
|
1775
|
+
const o = [], { width: s, height: r } = i, a = s / 2, c = r / 2, d = e.fixedHeight ?? 200, f = {
|
|
1776
|
+
...Ht,
|
|
1807
1777
|
...this.config.honeycomb
|
|
1808
|
-
}.spacing ?? 0,
|
|
1809
|
-
let
|
|
1810
|
-
for (;
|
|
1811
|
-
const
|
|
1812
|
-
for (const [
|
|
1813
|
-
if (
|
|
1814
|
-
const { px:
|
|
1815
|
-
|
|
1816
|
-
id:
|
|
1817
|
-
x:
|
|
1818
|
-
y:
|
|
1778
|
+
}.spacing ?? 0, m = d + f;
|
|
1779
|
+
let p = 0, w = 0;
|
|
1780
|
+
for (; p < t; ) {
|
|
1781
|
+
const v = Ae(w);
|
|
1782
|
+
for (const [l, g, h] of v) {
|
|
1783
|
+
if (p >= t) break;
|
|
1784
|
+
const { px: b, py: I } = Re(l, g, h, a, c, m);
|
|
1785
|
+
o.push({
|
|
1786
|
+
id: p,
|
|
1787
|
+
x: b,
|
|
1788
|
+
y: I,
|
|
1819
1789
|
rotation: 0,
|
|
1820
1790
|
scale: 1,
|
|
1821
|
-
baseSize:
|
|
1791
|
+
baseSize: d,
|
|
1822
1792
|
// Inner rings render above outer rings
|
|
1823
|
-
zIndex: Math.max(1, 100 -
|
|
1824
|
-
}),
|
|
1793
|
+
zIndex: Math.max(1, 100 - w)
|
|
1794
|
+
}), p++;
|
|
1825
1795
|
}
|
|
1826
|
-
|
|
1796
|
+
w++;
|
|
1827
1797
|
}
|
|
1828
|
-
return
|
|
1798
|
+
return o;
|
|
1829
1799
|
}
|
|
1830
1800
|
}
|
|
1831
|
-
class
|
|
1801
|
+
class Fe {
|
|
1832
1802
|
constructor(t) {
|
|
1833
1803
|
this.config = t.layout, this.imageConfig = t.image, this.layouts = /* @__PURE__ */ new Map(), this.placementLayout = this.initLayout();
|
|
1834
1804
|
}
|
|
@@ -1839,19 +1809,19 @@ class ze {
|
|
|
1839
1809
|
initLayout() {
|
|
1840
1810
|
switch (this.config.algorithm) {
|
|
1841
1811
|
case "radial":
|
|
1842
|
-
return new
|
|
1812
|
+
return new ge(this.config, this.imageConfig);
|
|
1843
1813
|
case "grid":
|
|
1844
|
-
return new
|
|
1814
|
+
return new pe(this.config, this.imageConfig);
|
|
1845
1815
|
case "spiral":
|
|
1846
|
-
return new
|
|
1816
|
+
return new ve(this.config, this.imageConfig);
|
|
1847
1817
|
case "cluster":
|
|
1848
|
-
return new
|
|
1818
|
+
return new Ee(this.config, this.imageConfig);
|
|
1849
1819
|
case "wave":
|
|
1850
|
-
return new
|
|
1820
|
+
return new we(this.config, this.imageConfig);
|
|
1851
1821
|
case "honeycomb":
|
|
1852
|
-
return new
|
|
1822
|
+
return new Le(this.config, this.imageConfig);
|
|
1853
1823
|
default:
|
|
1854
|
-
return new
|
|
1824
|
+
return new fe(this.config, this.imageConfig);
|
|
1855
1825
|
}
|
|
1856
1826
|
}
|
|
1857
1827
|
/**
|
|
@@ -1862,10 +1832,10 @@ class ze {
|
|
|
1862
1832
|
* @returns Array of layout objects with position, rotation, scale
|
|
1863
1833
|
*/
|
|
1864
1834
|
generateLayout(t, i, e = {}) {
|
|
1865
|
-
const
|
|
1866
|
-
return
|
|
1835
|
+
const o = this.placementLayout.generate(t, i, e);
|
|
1836
|
+
return o.forEach((s) => {
|
|
1867
1837
|
this.layouts.set(s.id, s);
|
|
1868
|
-
}),
|
|
1838
|
+
}), o;
|
|
1869
1839
|
}
|
|
1870
1840
|
/**
|
|
1871
1841
|
* Get the original layout state for an image
|
|
@@ -1918,8 +1888,8 @@ class ze {
|
|
|
1918
1888
|
return;
|
|
1919
1889
|
if (typeof e == "number")
|
|
1920
1890
|
return e;
|
|
1921
|
-
const
|
|
1922
|
-
return s === "mobile" ?
|
|
1891
|
+
const o = e, s = this.resolveBreakpoint(t);
|
|
1892
|
+
return s === "mobile" ? o.mobile ?? o.tablet ?? o.screen : s === "tablet" ? o.tablet ?? o.screen ?? o.mobile : o.screen ?? o.tablet ?? o.mobile;
|
|
1923
1893
|
}
|
|
1924
1894
|
/**
|
|
1925
1895
|
* Calculate adaptive image size based on container dimensions and image count
|
|
@@ -1929,19 +1899,19 @@ class ze {
|
|
|
1929
1899
|
* @param viewportWidth - Current viewport width for baseHeight resolution
|
|
1930
1900
|
* @returns Calculated sizing result with height
|
|
1931
1901
|
*/
|
|
1932
|
-
calculateAdaptiveSize(t, i, e,
|
|
1933
|
-
const s = this.imageConfig.sizing, r = this.resolveBaseHeight(
|
|
1902
|
+
calculateAdaptiveSize(t, i, e, o) {
|
|
1903
|
+
const s = this.imageConfig.sizing, r = this.resolveBaseHeight(o);
|
|
1934
1904
|
if (r !== void 0)
|
|
1935
1905
|
return { height: r };
|
|
1936
|
-
const a = s?.minSize ?? 50, c = s?.maxSize ?? 400,
|
|
1937
|
-
let
|
|
1938
|
-
|
|
1939
|
-
let
|
|
1940
|
-
if (
|
|
1941
|
-
const
|
|
1942
|
-
|
|
1906
|
+
const a = s?.minSize ?? 50, c = s?.maxSize ?? 400, d = this.config.targetCoverage ?? 0.6, u = this.config.densityFactor ?? 1, { width: f, height: m } = t, v = f * m * d / i;
|
|
1907
|
+
let g = Math.sqrt(v / 1.4);
|
|
1908
|
+
g *= u, g = Math.min(g, e);
|
|
1909
|
+
let h = this.clamp(g, a, c);
|
|
1910
|
+
if (h === a && g < a) {
|
|
1911
|
+
const b = Math.max(a * 0.05, 20);
|
|
1912
|
+
h = Math.max(b, g);
|
|
1943
1913
|
}
|
|
1944
|
-
return this.config.algorithm === "honeycomb" && (
|
|
1914
|
+
return this.config.algorithm === "honeycomb" && (h = Math.min(h, this.honeycombMaxImageHeight(i, t))), { height: h };
|
|
1945
1915
|
}
|
|
1946
1916
|
/**
|
|
1947
1917
|
* Returns the largest image height at which all honeycomb rings fit within the container.
|
|
@@ -1950,11 +1920,11 @@ class ze {
|
|
|
1950
1920
|
*/
|
|
1951
1921
|
honeycombMaxImageHeight(t, i) {
|
|
1952
1922
|
if (t <= 1) return 1 / 0;
|
|
1953
|
-
let e = 0,
|
|
1954
|
-
for (;
|
|
1955
|
-
e++,
|
|
1956
|
-
const s = this.config.spacing?.padding ?? 50, r = this.config.honeycomb?.spacing ?? 0, a = i.width / 2, c = i.height / 2,
|
|
1957
|
-
return Math.max(10, Math.min(
|
|
1923
|
+
let e = 0, o = 1;
|
|
1924
|
+
for (; o < t; )
|
|
1925
|
+
e++, o += 6 * e;
|
|
1926
|
+
const s = this.config.spacing?.padding ?? 50, r = this.config.honeycomb?.spacing ?? 0, a = i.width / 2, c = i.height / 2, d = Math.sqrt(3) / 2, u = 1 / Math.sqrt(3), f = (c - s - r * e) / (e + 0.5), m = (a - s - d * r * e) / (d * e + u);
|
|
1927
|
+
return Math.max(10, Math.min(f, m));
|
|
1958
1928
|
}
|
|
1959
1929
|
/**
|
|
1960
1930
|
* Utility: Clamp a value between min and max
|
|
@@ -1963,8 +1933,8 @@ class ze {
|
|
|
1963
1933
|
return Math.max(i, Math.min(e, t));
|
|
1964
1934
|
}
|
|
1965
1935
|
}
|
|
1966
|
-
var
|
|
1967
|
-
const
|
|
1936
|
+
var C = /* @__PURE__ */ ((n) => (n.IDLE = "idle", n.FOCUSING = "focusing", n.FOCUSED = "focused", n.UNFOCUSING = "unfocusing", n.CROSS_ANIMATING = "cross_animating", n))(C || {});
|
|
1937
|
+
const At = {
|
|
1968
1938
|
// Geometric shapes - uses percentages for responsive sizing
|
|
1969
1939
|
circle: "circle(50%)",
|
|
1970
1940
|
square: "polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%)",
|
|
@@ -1973,7 +1943,7 @@ const Tt = {
|
|
|
1973
1943
|
hexagon: "polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%)",
|
|
1974
1944
|
octagon: "polygon(30% 0%, 70% 0%, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0% 70%, 0% 30%)",
|
|
1975
1945
|
diamond: "polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%)"
|
|
1976
|
-
},
|
|
1946
|
+
}, Me = {
|
|
1977
1947
|
// Circle - uses radius in pixels (refHeight of 100px = 50px radius)
|
|
1978
1948
|
circle: {
|
|
1979
1949
|
refHeight: 100,
|
|
@@ -1997,8 +1967,8 @@ const Tt = {
|
|
|
1997
1967
|
},
|
|
1998
1968
|
// Hexagon - regular hexagon (reference points imported from hexagonGeometry)
|
|
1999
1969
|
hexagon: {
|
|
2000
|
-
refHeight:
|
|
2001
|
-
points:
|
|
1970
|
+
refHeight: Et,
|
|
1971
|
+
points: wt
|
|
2002
1972
|
},
|
|
2003
1973
|
// Octagon - regular octagon
|
|
2004
1974
|
octagon: {
|
|
@@ -2011,105 +1981,105 @@ const Tt = {
|
|
|
2011
1981
|
points: [[50, 0], [100, 50], [50, 100], [0, 50]]
|
|
2012
1982
|
}
|
|
2013
1983
|
};
|
|
2014
|
-
function
|
|
2015
|
-
if (
|
|
2016
|
-
return
|
|
1984
|
+
function Oe(n) {
|
|
1985
|
+
if (n)
|
|
1986
|
+
return n in At ? At[n] : n;
|
|
2017
1987
|
}
|
|
2018
|
-
function
|
|
2019
|
-
const e =
|
|
1988
|
+
function ze(n, t, i) {
|
|
1989
|
+
const e = Me[n];
|
|
2020
1990
|
if (!e) return "";
|
|
2021
|
-
const
|
|
2022
|
-
if (
|
|
2023
|
-
return `circle(${Math.round(50 *
|
|
2024
|
-
const s = e.points.map(([
|
|
2025
|
-
return `polygon(${e.points.map(([
|
|
2026
|
-
const
|
|
2027
|
-
return `${
|
|
1991
|
+
const o = t / e.refHeight;
|
|
1992
|
+
if (n === "circle")
|
|
1993
|
+
return `circle(${Math.round(50 * o * 100) / 100}px)`;
|
|
1994
|
+
const s = e.points.map(([v]) => v), r = e.points.map(([, v]) => v), a = (Math.min(...s) + Math.max(...s)) / 2 * o, c = (Math.min(...r) + Math.max(...r)) / 2 * o, d = (Math.max(...s) - Math.min(...s)) * o, u = (i ?? d) / 2, f = t / 2, m = u - a, p = f - c;
|
|
1995
|
+
return `polygon(${e.points.map(([v, l]) => {
|
|
1996
|
+
const g = Math.round((v * o + m) * 100) / 100, h = Math.round((l * o + p) * 100) / 100;
|
|
1997
|
+
return `${g}px ${h}px`;
|
|
2028
1998
|
}).join(", ")})`;
|
|
2029
1999
|
}
|
|
2030
|
-
function
|
|
2031
|
-
return
|
|
2000
|
+
function De(n) {
|
|
2001
|
+
return n in mt;
|
|
2032
2002
|
}
|
|
2033
|
-
function
|
|
2034
|
-
return
|
|
2003
|
+
function $e(n) {
|
|
2004
|
+
return n ? De(n) ? mt[n] : n : mt.md;
|
|
2035
2005
|
}
|
|
2036
|
-
function
|
|
2037
|
-
if (!
|
|
2006
|
+
function Pe(n) {
|
|
2007
|
+
if (!n) return "";
|
|
2038
2008
|
const t = [];
|
|
2039
|
-
if (
|
|
2040
|
-
if (typeof
|
|
2041
|
-
t.push(`drop-shadow(${
|
|
2009
|
+
if (n.grayscale !== void 0 && t.push(`grayscale(${n.grayscale})`), n.blur !== void 0 && t.push(`blur(${n.blur}px)`), n.brightness !== void 0 && t.push(`brightness(${n.brightness})`), n.contrast !== void 0 && t.push(`contrast(${n.contrast})`), n.saturate !== void 0 && t.push(`saturate(${n.saturate})`), n.opacity !== void 0 && t.push(`opacity(${n.opacity})`), n.sepia !== void 0 && t.push(`sepia(${n.sepia})`), n.hueRotate !== void 0 && t.push(`hue-rotate(${n.hueRotate}deg)`), n.invert !== void 0 && t.push(`invert(${n.invert})`), n.dropShadow !== void 0)
|
|
2010
|
+
if (typeof n.dropShadow == "string")
|
|
2011
|
+
t.push(`drop-shadow(${n.dropShadow})`);
|
|
2042
2012
|
else {
|
|
2043
|
-
const i =
|
|
2013
|
+
const i = n.dropShadow;
|
|
2044
2014
|
t.push(`drop-shadow(${i.x}px ${i.y}px ${i.blur}px ${i.color})`);
|
|
2045
2015
|
}
|
|
2046
2016
|
return t.join(" ");
|
|
2047
2017
|
}
|
|
2048
|
-
function tt(
|
|
2049
|
-
if (!
|
|
2018
|
+
function tt(n) {
|
|
2019
|
+
if (!n || n.style === "none" || n.width === 0)
|
|
2050
2020
|
return "none";
|
|
2051
|
-
const t =
|
|
2021
|
+
const t = n.width ?? 0, i = n.style ?? "solid", e = n.color ?? "#000000";
|
|
2052
2022
|
return `${t}px ${i} ${e}`;
|
|
2053
2023
|
}
|
|
2054
|
-
function it(
|
|
2055
|
-
if (!
|
|
2024
|
+
function it(n, t, i) {
|
|
2025
|
+
if (!n) return {};
|
|
2056
2026
|
const e = {};
|
|
2057
|
-
if (
|
|
2058
|
-
const a =
|
|
2059
|
-
|
|
2060
|
-
} else
|
|
2061
|
-
if (
|
|
2062
|
-
const a =
|
|
2063
|
-
e.borderTop = tt(c), e.borderRight = tt(
|
|
2064
|
-
} else
|
|
2065
|
-
|
|
2066
|
-
const r =
|
|
2067
|
-
if (e.filter = r || "none",
|
|
2068
|
-
const a =
|
|
2069
|
-
e.outline = `${a}px ${c} ${
|
|
2070
|
-
}
|
|
2071
|
-
if (
|
|
2027
|
+
if (n.borderRadiusTopLeft !== void 0 || n.borderRadiusTopRight !== void 0 || n.borderRadiusBottomRight !== void 0 || n.borderRadiusBottomLeft !== void 0) {
|
|
2028
|
+
const a = n.border?.radius ?? 0;
|
|
2029
|
+
n.borderRadiusTopLeft !== void 0 ? e.borderTopLeftRadius = `${n.borderRadiusTopLeft}px` : a && (e.borderTopLeftRadius = `${a}px`), n.borderRadiusTopRight !== void 0 ? e.borderTopRightRadius = `${n.borderRadiusTopRight}px` : a && (e.borderTopRightRadius = `${a}px`), n.borderRadiusBottomRight !== void 0 ? e.borderBottomRightRadius = `${n.borderRadiusBottomRight}px` : a && (e.borderBottomRightRadius = `${a}px`), n.borderRadiusBottomLeft !== void 0 ? e.borderBottomLeftRadius = `${n.borderRadiusBottomLeft}px` : a && (e.borderBottomLeftRadius = `${a}px`);
|
|
2030
|
+
} else n.border?.radius !== void 0 && (e.borderRadius = `${n.border.radius}px`);
|
|
2031
|
+
if (n.borderTop || n.borderRight || n.borderBottom || n.borderLeft) {
|
|
2032
|
+
const a = n.border || {}, c = { ...a, ...n.borderTop }, d = { ...a, ...n.borderRight }, u = { ...a, ...n.borderBottom }, f = { ...a, ...n.borderLeft };
|
|
2033
|
+
e.borderTop = tt(c), e.borderRight = tt(d), e.borderBottom = tt(u), e.borderLeft = tt(f);
|
|
2034
|
+
} else n.border && (e.border = tt(n.border));
|
|
2035
|
+
n.shadow !== void 0 && (e.boxShadow = $e(n.shadow));
|
|
2036
|
+
const r = Pe(n.filter);
|
|
2037
|
+
if (e.filter = r || "none", n.opacity !== void 0 && (e.opacity = String(n.opacity)), n.cursor !== void 0 && (e.cursor = n.cursor), n.outline && n.outline.style !== "none" && (n.outline.width ?? 0) > 0) {
|
|
2038
|
+
const a = n.outline.width ?? 0, c = n.outline.style ?? "solid", d = n.outline.color ?? "#000000";
|
|
2039
|
+
e.outline = `${a}px ${c} ${d}`, n.outline.offset !== void 0 && (e.outlineOffset = `${n.outline.offset}px`);
|
|
2040
|
+
}
|
|
2041
|
+
if (n.objectFit !== void 0 && (e.objectFit = n.objectFit), n.aspectRatio !== void 0 && (e.aspectRatio = n.aspectRatio), n.clipPath !== void 0) {
|
|
2072
2042
|
let a;
|
|
2073
|
-
const c = typeof
|
|
2074
|
-
if (
|
|
2075
|
-
a =
|
|
2043
|
+
const c = typeof n.clipPath == "object" && n.clipPath !== null && "shape" in n.clipPath, d = c ? n.clipPath : void 0;
|
|
2044
|
+
if (d?.mode === "height-relative" && t)
|
|
2045
|
+
a = ze(d.shape, t, i);
|
|
2076
2046
|
else {
|
|
2077
|
-
const u = c &&
|
|
2078
|
-
a =
|
|
2047
|
+
const u = c && d ? d.shape : n.clipPath;
|
|
2048
|
+
a = Oe(u);
|
|
2079
2049
|
}
|
|
2080
2050
|
a && (a === "none" ? e.clipPath = "unset" : (e.clipPath = a, e.overflow = "hidden"));
|
|
2081
2051
|
}
|
|
2082
2052
|
return e;
|
|
2083
2053
|
}
|
|
2084
|
-
function
|
|
2085
|
-
t.borderRadius !== void 0 && (
|
|
2054
|
+
function _e(n, t) {
|
|
2055
|
+
t.borderRadius !== void 0 && (n.style.borderRadius = t.borderRadius), t.borderTopLeftRadius !== void 0 && (n.style.borderTopLeftRadius = t.borderTopLeftRadius), t.borderTopRightRadius !== void 0 && (n.style.borderTopRightRadius = t.borderTopRightRadius), t.borderBottomRightRadius !== void 0 && (n.style.borderBottomRightRadius = t.borderBottomRightRadius), t.borderBottomLeftRadius !== void 0 && (n.style.borderBottomLeftRadius = t.borderBottomLeftRadius), t.border !== void 0 && (n.style.border = t.border), t.borderTop !== void 0 && (n.style.borderTop = t.borderTop), t.borderRight !== void 0 && (n.style.borderRight = t.borderRight), t.borderBottom !== void 0 && (n.style.borderBottom = t.borderBottom), t.borderLeft !== void 0 && (n.style.borderLeft = t.borderLeft), t.boxShadow !== void 0 && (n.style.boxShadow = t.boxShadow), t.filter !== void 0 && (n.style.filter = t.filter), t.opacity !== void 0 && (n.style.opacity = t.opacity), t.cursor !== void 0 && (n.style.cursor = t.cursor), t.outline !== void 0 && (n.style.outline = t.outline), t.outlineOffset !== void 0 && (n.style.outlineOffset = t.outlineOffset), t.objectFit !== void 0 && (n.style.objectFit = t.objectFit), t.aspectRatio !== void 0 && (n.style.aspectRatio = t.aspectRatio), t.clipPath !== void 0 && (n.style.clipPath = t.clipPath), t.overflow !== void 0 && (n.style.overflow = t.overflow);
|
|
2086
2056
|
}
|
|
2087
|
-
function st(
|
|
2088
|
-
const
|
|
2089
|
-
|
|
2057
|
+
function st(n, t, i, e) {
|
|
2058
|
+
const o = it(t, i, e);
|
|
2059
|
+
_e(n, o);
|
|
2090
2060
|
}
|
|
2091
|
-
function $t(
|
|
2092
|
-
return
|
|
2061
|
+
function $t(n) {
|
|
2062
|
+
return n ? Array.isArray(n) ? n.join(" ") : n : "";
|
|
2093
2063
|
}
|
|
2094
|
-
function et(
|
|
2064
|
+
function et(n, t) {
|
|
2095
2065
|
const i = $t(t);
|
|
2096
2066
|
i && i.split(" ").forEach((e) => {
|
|
2097
|
-
e.trim() &&
|
|
2067
|
+
e.trim() && n.classList.add(e.trim());
|
|
2098
2068
|
});
|
|
2099
2069
|
}
|
|
2100
|
-
function pt(
|
|
2070
|
+
function pt(n, t) {
|
|
2101
2071
|
const i = $t(t);
|
|
2102
2072
|
i && i.split(" ").forEach((e) => {
|
|
2103
|
-
e.trim() &&
|
|
2073
|
+
e.trim() && n.classList.remove(e.trim());
|
|
2104
2074
|
});
|
|
2105
2075
|
}
|
|
2106
2076
|
const Lt = {
|
|
2107
2077
|
UNFOCUSING: 999,
|
|
2108
2078
|
FOCUSING: 1e3
|
|
2109
2079
|
};
|
|
2110
|
-
class
|
|
2080
|
+
class Ue {
|
|
2111
2081
|
constructor(t, i, e) {
|
|
2112
|
-
this.state =
|
|
2082
|
+
this.state = C.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;
|
|
2113
2083
|
}
|
|
2114
2084
|
/**
|
|
2115
2085
|
* Set callback to be fired when an unfocus animation fully completes.
|
|
@@ -2127,7 +2097,7 @@ class Ne {
|
|
|
2127
2097
|
* Check if any animation is in progress
|
|
2128
2098
|
*/
|
|
2129
2099
|
isAnimating() {
|
|
2130
|
-
return this.state !==
|
|
2100
|
+
return this.state !== C.IDLE && this.state !== C.FOCUSED;
|
|
2131
2101
|
}
|
|
2132
2102
|
/**
|
|
2133
2103
|
* Normalize scalePercent value
|
|
@@ -2140,17 +2110,17 @@ class Ne {
|
|
|
2140
2110
|
* Returns actual pixel dimensions instead of scale factor for sharper rendering
|
|
2141
2111
|
*/
|
|
2142
2112
|
calculateFocusDimensions(t, i, e) {
|
|
2143
|
-
const
|
|
2113
|
+
const o = this.normalizeScalePercent(this.config.scalePercent), s = e.height * o, r = t / i;
|
|
2144
2114
|
let a = s, c = a * r;
|
|
2145
|
-
const
|
|
2146
|
-
return c >
|
|
2115
|
+
const d = e.width * o;
|
|
2116
|
+
return c > d && (c = d, a = c / r), { width: c, height: a };
|
|
2147
2117
|
}
|
|
2148
2118
|
/**
|
|
2149
2119
|
* Calculate the transform needed to center an image (position only, no scale)
|
|
2150
2120
|
* Scale is handled by animating actual dimensions for sharper rendering
|
|
2151
2121
|
*/
|
|
2152
2122
|
calculateFocusTransform(t, i) {
|
|
2153
|
-
const e = t.width / 2,
|
|
2123
|
+
const e = t.width / 2, o = t.height / 2, s = e - i.x, r = o - i.y;
|
|
2154
2124
|
return {
|
|
2155
2125
|
x: s,
|
|
2156
2126
|
y: r,
|
|
@@ -2165,8 +2135,8 @@ class Ne {
|
|
|
2165
2135
|
buildDimensionZoomTransform(t) {
|
|
2166
2136
|
const i = ["translate(-50%, -50%)"];
|
|
2167
2137
|
if (t.x !== void 0 || t.y !== void 0) {
|
|
2168
|
-
const e = t.x ?? 0,
|
|
2169
|
-
i.push(`translate(${e}px, ${
|
|
2138
|
+
const e = t.x ?? 0, o = t.y ?? 0;
|
|
2139
|
+
i.push(`translate(${e}px, ${o}px)`);
|
|
2170
2140
|
}
|
|
2171
2141
|
return t.rotation !== void 0 && i.push(`rotate(${t.rotation}deg)`), i.join(" ");
|
|
2172
2142
|
}
|
|
@@ -2174,13 +2144,13 @@ class Ne {
|
|
|
2174
2144
|
* Create a Web Animation that animates both transform (position) and dimensions
|
|
2175
2145
|
* This provides sharper zoom by re-rendering at target size instead of scaling pixels
|
|
2176
2146
|
*/
|
|
2177
|
-
animateWithDimensions(t, i, e,
|
|
2178
|
-
const
|
|
2147
|
+
animateWithDimensions(t, i, e, o, s, r, a, c) {
|
|
2148
|
+
const d = this.buildDimensionZoomTransform(i), u = this.buildDimensionZoomTransform(e);
|
|
2179
2149
|
return t.style.transition = "none", t.animate(
|
|
2180
2150
|
[
|
|
2181
2151
|
{
|
|
2182
|
-
transform:
|
|
2183
|
-
width: `${
|
|
2152
|
+
transform: d,
|
|
2153
|
+
width: `${o}px`,
|
|
2184
2154
|
height: `${s}px`
|
|
2185
2155
|
},
|
|
2186
2156
|
{
|
|
@@ -2221,10 +2191,10 @@ class Ne {
|
|
|
2221
2191
|
* This ensures clip-path changes smoothly as width/height animate
|
|
2222
2192
|
*/
|
|
2223
2193
|
startClipPathAnimation(t, i, e) {
|
|
2224
|
-
let
|
|
2225
|
-
e && this.styling?.focused && this.styling.focused.clipPath === void 0 && (
|
|
2194
|
+
let o = e ? this.styling?.focused ?? this.styling?.default : this.styling?.default;
|
|
2195
|
+
e && this.styling?.focused && this.styling.focused.clipPath === void 0 && (o = { ...o, clipPath: void 0 });
|
|
2226
2196
|
const s = () => {
|
|
2227
|
-
const r = t.offsetHeight, a = t.offsetWidth, c = it(
|
|
2197
|
+
const r = t.offsetHeight, a = t.offsetWidth, c = it(o, r, a);
|
|
2228
2198
|
c.clipPath !== void 0 ? t.style.clipPath = c.clipPath : t.style.clipPath = "unset", c.overflow !== void 0 && (t.style.overflow = c.overflow), i.animation.playState === "running" && requestAnimationFrame(s);
|
|
2229
2199
|
};
|
|
2230
2200
|
requestAnimationFrame(s);
|
|
@@ -2235,34 +2205,34 @@ class Ne {
|
|
|
2235
2205
|
* @param fromTransform - Optional starting transform (for mid-animation reversals)
|
|
2236
2206
|
* @param fromDimensions - Optional starting dimensions (for mid-animation reversals)
|
|
2237
2207
|
*/
|
|
2238
|
-
startFocusAnimation(t, i, e,
|
|
2239
|
-
const r = t.style.zIndex || "", a = t.offsetWidth, c = t.offsetHeight,
|
|
2208
|
+
startFocusAnimation(t, i, e, o, s) {
|
|
2209
|
+
const r = t.style.zIndex || "", a = t.offsetWidth, c = t.offsetHeight, d = this.calculateFocusDimensions(a, c, i), u = this.calculateFocusTransform(i, e);
|
|
2240
2210
|
this.animationEngine.cancelAllAnimations(t);
|
|
2241
|
-
const
|
|
2211
|
+
const f = this.config.animationDuration ?? 600;
|
|
2242
2212
|
this.applyFocusedStyling(t, Lt.FOCUSING);
|
|
2243
|
-
const
|
|
2213
|
+
const m = o ?? {
|
|
2244
2214
|
x: 0,
|
|
2245
2215
|
y: 0,
|
|
2246
2216
|
rotation: e.rotation,
|
|
2247
2217
|
scale: 1
|
|
2248
2218
|
// No scale - using dimensions
|
|
2249
|
-
},
|
|
2219
|
+
}, p = s?.width ?? a, w = s?.height ?? c, v = this.animateWithDimensions(
|
|
2250
2220
|
t,
|
|
2251
|
-
|
|
2221
|
+
m,
|
|
2252
2222
|
u,
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
),
|
|
2223
|
+
p,
|
|
2224
|
+
w,
|
|
2225
|
+
d.width,
|
|
2226
|
+
d.height,
|
|
2227
|
+
f
|
|
2228
|
+
), l = {
|
|
2259
2229
|
id: `focus-${Date.now()}`,
|
|
2260
2230
|
element: t,
|
|
2261
|
-
animation:
|
|
2262
|
-
fromState:
|
|
2231
|
+
animation: v,
|
|
2232
|
+
fromState: m,
|
|
2263
2233
|
toState: u,
|
|
2264
2234
|
startTime: performance.now(),
|
|
2265
|
-
duration:
|
|
2235
|
+
duration: f
|
|
2266
2236
|
};
|
|
2267
2237
|
return this.focusData = {
|
|
2268
2238
|
element: t,
|
|
@@ -2271,12 +2241,12 @@ class Ne {
|
|
|
2271
2241
|
originalZIndex: r,
|
|
2272
2242
|
originalWidth: a,
|
|
2273
2243
|
originalHeight: c,
|
|
2274
|
-
focusWidth:
|
|
2275
|
-
focusHeight:
|
|
2276
|
-
}, this.startClipPathAnimation(t,
|
|
2244
|
+
focusWidth: d.width,
|
|
2245
|
+
focusHeight: d.height
|
|
2246
|
+
}, this.startClipPathAnimation(t, l, !0), {
|
|
2277
2247
|
element: t,
|
|
2278
2248
|
originalState: e,
|
|
2279
|
-
animationHandle:
|
|
2249
|
+
animationHandle: l,
|
|
2280
2250
|
direction: "in",
|
|
2281
2251
|
originalWidth: a,
|
|
2282
2252
|
originalHeight: c
|
|
@@ -2287,41 +2257,41 @@ class Ne {
|
|
|
2287
2257
|
* Animates back to original dimensions for consistent behavior
|
|
2288
2258
|
* @param fromDimensions - Optional starting dimensions (for mid-animation reversals)
|
|
2289
2259
|
*/
|
|
2290
|
-
startUnfocusAnimation(t, i, e,
|
|
2260
|
+
startUnfocusAnimation(t, i, e, o) {
|
|
2291
2261
|
t.style.zIndex = String(Lt.UNFOCUSING), this.animationEngine.cancelAllAnimations(t);
|
|
2292
2262
|
const s = this.config.animationDuration ?? 600;
|
|
2293
2263
|
t.classList.remove("fbn-ic-focused"), pt(t, this.focusedClassName);
|
|
2294
|
-
const r = e ?? this.focusData?.focusTransform ?? { x: 0, y: 0, rotation: 0, scale: 1 }, a =
|
|
2264
|
+
const r = e ?? this.focusData?.focusTransform ?? { x: 0, y: 0, rotation: 0, scale: 1 }, a = o?.width ?? this.focusData?.focusWidth ?? t.offsetWidth, c = o?.height ?? this.focusData?.focusHeight ?? t.offsetHeight, d = {
|
|
2295
2265
|
x: 0,
|
|
2296
2266
|
y: 0,
|
|
2297
2267
|
rotation: i.rotation,
|
|
2298
2268
|
scale: 1
|
|
2299
2269
|
// No scale - using dimensions
|
|
2300
|
-
}, u = this.focusData?.originalWidth ?? t.offsetWidth,
|
|
2270
|
+
}, u = this.focusData?.originalWidth ?? t.offsetWidth, f = this.focusData?.originalHeight ?? t.offsetHeight, m = this.animateWithDimensions(
|
|
2301
2271
|
t,
|
|
2302
2272
|
r,
|
|
2303
|
-
|
|
2273
|
+
d,
|
|
2304
2274
|
a,
|
|
2305
2275
|
c,
|
|
2306
2276
|
u,
|
|
2307
|
-
|
|
2277
|
+
f,
|
|
2308
2278
|
s
|
|
2309
|
-
),
|
|
2279
|
+
), p = {
|
|
2310
2280
|
id: `unfocus-${Date.now()}`,
|
|
2311
2281
|
element: t,
|
|
2312
|
-
animation:
|
|
2282
|
+
animation: m,
|
|
2313
2283
|
fromState: r,
|
|
2314
|
-
toState:
|
|
2284
|
+
toState: d,
|
|
2315
2285
|
startTime: performance.now(),
|
|
2316
2286
|
duration: s
|
|
2317
2287
|
};
|
|
2318
|
-
return this.startClipPathAnimation(t,
|
|
2288
|
+
return this.startClipPathAnimation(t, p, !1), {
|
|
2319
2289
|
element: t,
|
|
2320
2290
|
originalState: i,
|
|
2321
|
-
animationHandle:
|
|
2291
|
+
animationHandle: p,
|
|
2322
2292
|
direction: "out",
|
|
2323
2293
|
originalWidth: u,
|
|
2324
|
-
originalHeight:
|
|
2294
|
+
originalHeight: f
|
|
2325
2295
|
};
|
|
2326
2296
|
}
|
|
2327
2297
|
/**
|
|
@@ -2339,10 +2309,10 @@ class Ne {
|
|
|
2339
2309
|
* Caller is responsible for calling animationEngine.cancelAllAnimations() afterwards.
|
|
2340
2310
|
*/
|
|
2341
2311
|
captureMidAnimationState(t) {
|
|
2342
|
-
const i = getComputedStyle(t), e = new DOMMatrix(i.transform),
|
|
2343
|
-
return t.style.width = `${
|
|
2312
|
+
const i = getComputedStyle(t), e = new DOMMatrix(i.transform), o = t.offsetWidth, s = t.offsetHeight, r = e.e + o * 0.5, a = e.f + s * 0.5, c = Math.atan2(e.b, e.a) * (180 / Math.PI);
|
|
2313
|
+
return t.style.width = `${o}px`, t.style.height = `${s}px`, t.style.transform = `translate(-50%, -50%) translate(${r}px, ${a}px) rotate(${c}deg)`, t.style.transition = "none", {
|
|
2344
2314
|
transform: { x: r, y: a, rotation: c, scale: 1 },
|
|
2345
|
-
dimensions: { width:
|
|
2315
|
+
dimensions: { width: o, height: s }
|
|
2346
2316
|
};
|
|
2347
2317
|
}
|
|
2348
2318
|
/**
|
|
@@ -2357,71 +2327,71 @@ class Ne {
|
|
|
2357
2327
|
/**
|
|
2358
2328
|
* Reset an element instantly to its original position and dimensions (no animation)
|
|
2359
2329
|
*/
|
|
2360
|
-
resetElementInstantly(t, i, e,
|
|
2330
|
+
resetElementInstantly(t, i, e, o, s) {
|
|
2361
2331
|
this.animationEngine.cancelAllAnimations(t);
|
|
2362
2332
|
const r = ["translate(-50%, -50%)"];
|
|
2363
|
-
r.push("translate(0px, 0px)"), r.push(`rotate(${i.rotation}deg)`), t.style.transition = "none", t.style.transform = r.join(" "),
|
|
2333
|
+
r.push("translate(0px, 0px)"), r.push(`rotate(${i.rotation}deg)`), t.style.transition = "none", t.style.transform = r.join(" "), o !== void 0 && s !== void 0 && (t.style.width = `${o}px`, t.style.height = `${s}px`), this.removeFocusedStyling(t, e);
|
|
2364
2334
|
}
|
|
2365
2335
|
/**
|
|
2366
2336
|
* Focus (zoom) an image to center of container
|
|
2367
2337
|
* Implements cross-animation when swapping focus
|
|
2368
2338
|
*/
|
|
2369
2339
|
async focusImage(t, i, e) {
|
|
2370
|
-
if (this.currentFocus === t && this.state ===
|
|
2340
|
+
if (this.currentFocus === t && this.state === C.FOCUSED)
|
|
2371
2341
|
return this.unfocusImage();
|
|
2372
|
-
if (this.incoming?.element === t && this.state ===
|
|
2342
|
+
if (this.incoming?.element === t && this.state === C.FOCUSING) {
|
|
2373
2343
|
const { transform: s, dimensions: r } = this.captureMidAnimationState(t);
|
|
2374
2344
|
this.animationEngine.cancelAllAnimations(t), this.outgoing = this.startUnfocusAnimation(
|
|
2375
2345
|
t,
|
|
2376
2346
|
this.incoming.originalState,
|
|
2377
2347
|
s,
|
|
2378
2348
|
r
|
|
2379
|
-
), this.incoming = null, this.state =
|
|
2349
|
+
), this.incoming = null, this.state = C.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 = C.IDLE;
|
|
2380
2350
|
return;
|
|
2381
2351
|
}
|
|
2382
|
-
const
|
|
2352
|
+
const o = ++this.focusGeneration;
|
|
2383
2353
|
switch (this.state) {
|
|
2384
|
-
case
|
|
2385
|
-
if (this.state =
|
|
2386
|
-
this.currentFocus = t, this.incoming = null, this.state =
|
|
2354
|
+
case C.IDLE:
|
|
2355
|
+
if (this.state = C.FOCUSING, this.incoming = this.startFocusAnimation(t, i, e), await this.waitForAnimation(this.incoming.animationHandle), this.focusGeneration !== o) return;
|
|
2356
|
+
this.currentFocus = t, this.incoming = null, this.state = C.FOCUSED;
|
|
2387
2357
|
break;
|
|
2388
|
-
case
|
|
2389
|
-
if (this.state =
|
|
2358
|
+
case C.FOCUSED:
|
|
2359
|
+
if (this.state = C.CROSS_ANIMATING, this.currentFocus && this.focusData && (this.outgoing = this.startUnfocusAnimation(
|
|
2390
2360
|
this.currentFocus,
|
|
2391
2361
|
this.focusData.originalState
|
|
2392
2362
|
)), this.incoming = this.startFocusAnimation(t, i, e), await Promise.all([
|
|
2393
2363
|
this.outgoing ? this.waitForAnimation(this.outgoing.animationHandle) : Promise.resolve(),
|
|
2394
2364
|
this.waitForAnimation(this.incoming.animationHandle)
|
|
2395
|
-
]), this.focusGeneration !==
|
|
2365
|
+
]), this.focusGeneration !== o)
|
|
2396
2366
|
return;
|
|
2397
2367
|
if (this.outgoing) {
|
|
2398
2368
|
const s = this.outgoing.element;
|
|
2399
2369
|
this.removeFocusedStyling(s, this.outgoing.originalState.zIndex?.toString() || ""), this.outgoing = null, this.onUnfocusComplete?.(s);
|
|
2400
2370
|
}
|
|
2401
|
-
this.currentFocus = t, this.incoming = null, this.state =
|
|
2371
|
+
this.currentFocus = t, this.incoming = null, this.state = C.FOCUSED;
|
|
2402
2372
|
break;
|
|
2403
|
-
case
|
|
2373
|
+
case C.FOCUSING:
|
|
2404
2374
|
if (this.incoming && (this.animationEngine.cancelAnimation(this.incoming.animationHandle, !1), this.resetElementInstantly(
|
|
2405
2375
|
this.incoming.element,
|
|
2406
2376
|
this.incoming.originalState,
|
|
2407
2377
|
this.focusData?.originalZIndex || "",
|
|
2408
2378
|
this.focusData?.originalWidth,
|
|
2409
2379
|
this.focusData?.originalHeight
|
|
2410
|
-
), this.incoming = null), this.incoming = this.startFocusAnimation(t, i, e), await this.waitForAnimation(this.incoming.animationHandle), this.focusGeneration !==
|
|
2411
|
-
this.currentFocus = t, this.incoming = null, this.state =
|
|
2380
|
+
), this.incoming = null), this.incoming = this.startFocusAnimation(t, i, e), await this.waitForAnimation(this.incoming.animationHandle), this.focusGeneration !== o) return;
|
|
2381
|
+
this.currentFocus = t, this.incoming = null, this.state = C.FOCUSED;
|
|
2412
2382
|
break;
|
|
2413
|
-
case
|
|
2414
|
-
if (this.state =
|
|
2383
|
+
case C.UNFOCUSING:
|
|
2384
|
+
if (this.state = C.CROSS_ANIMATING, this.incoming = this.startFocusAnimation(t, i, e), await Promise.all([
|
|
2415
2385
|
this.outgoing ? this.waitForAnimation(this.outgoing.animationHandle) : Promise.resolve(),
|
|
2416
2386
|
this.waitForAnimation(this.incoming.animationHandle)
|
|
2417
|
-
]), this.focusGeneration !==
|
|
2387
|
+
]), this.focusGeneration !== o) return;
|
|
2418
2388
|
if (this.outgoing) {
|
|
2419
2389
|
const s = this.outgoing.element;
|
|
2420
2390
|
this.removeFocusedStyling(s, this.outgoing.originalState.zIndex?.toString() || ""), this.outgoing = null, this.onUnfocusComplete?.(s);
|
|
2421
2391
|
}
|
|
2422
|
-
this.currentFocus = t, this.incoming = null, this.state =
|
|
2392
|
+
this.currentFocus = t, this.incoming = null, this.state = C.FOCUSED;
|
|
2423
2393
|
break;
|
|
2424
|
-
case
|
|
2394
|
+
case C.CROSS_ANIMATING:
|
|
2425
2395
|
if (this.incoming?.element === t)
|
|
2426
2396
|
return;
|
|
2427
2397
|
if (this.outgoing?.element === t) {
|
|
@@ -2439,12 +2409,12 @@ class Ne {
|
|
|
2439
2409
|
if (this.incoming = this.startFocusAnimation(t, i, e, s, r), await Promise.all([
|
|
2440
2410
|
this.outgoing ? this.waitForAnimation(this.outgoing.animationHandle) : Promise.resolve(),
|
|
2441
2411
|
this.waitForAnimation(this.incoming.animationHandle)
|
|
2442
|
-
]), this.focusGeneration !==
|
|
2412
|
+
]), this.focusGeneration !== o) return;
|
|
2443
2413
|
if (this.outgoing) {
|
|
2444
2414
|
const a = this.outgoing.element;
|
|
2445
2415
|
this.removeFocusedStyling(a, this.outgoing.originalState.zIndex?.toString() || ""), this.outgoing = null, this.onUnfocusComplete?.(a);
|
|
2446
2416
|
}
|
|
2447
|
-
this.currentFocus = t, this.incoming = null, this.state =
|
|
2417
|
+
this.currentFocus = t, this.incoming = null, this.state = C.FOCUSED;
|
|
2448
2418
|
return;
|
|
2449
2419
|
}
|
|
2450
2420
|
if (this.outgoing && (this.animationEngine.cancelAnimation(this.outgoing.animationHandle, !1), this.resetElementInstantly(
|
|
@@ -2465,12 +2435,12 @@ class Ne {
|
|
|
2465
2435
|
if (this.incoming = this.startFocusAnimation(t, i, e), await Promise.all([
|
|
2466
2436
|
this.outgoing ? this.waitForAnimation(this.outgoing.animationHandle) : Promise.resolve(),
|
|
2467
2437
|
this.waitForAnimation(this.incoming.animationHandle)
|
|
2468
|
-
]), this.focusGeneration !==
|
|
2438
|
+
]), this.focusGeneration !== o) return;
|
|
2469
2439
|
if (this.outgoing) {
|
|
2470
2440
|
const s = this.outgoing.element;
|
|
2471
2441
|
this.removeFocusedStyling(s, this.outgoing.originalState.zIndex?.toString() || ""), this.outgoing = null, this.onUnfocusComplete?.(s);
|
|
2472
2442
|
}
|
|
2473
|
-
this.currentFocus = t, this.incoming = null, this.state =
|
|
2443
|
+
this.currentFocus = t, this.incoming = null, this.state = C.FOCUSED;
|
|
2474
2444
|
break;
|
|
2475
2445
|
}
|
|
2476
2446
|
}
|
|
@@ -2478,24 +2448,24 @@ class Ne {
|
|
|
2478
2448
|
* Unfocus current image, returning it to original position
|
|
2479
2449
|
*/
|
|
2480
2450
|
async unfocusImage() {
|
|
2481
|
-
if (this.state ===
|
|
2451
|
+
if (this.state === C.UNFOCUSING)
|
|
2482
2452
|
return;
|
|
2483
2453
|
const t = ++this.focusGeneration;
|
|
2484
2454
|
if (!this.currentFocus || !this.focusData) {
|
|
2485
|
-
if (this.incoming && this.state ===
|
|
2455
|
+
if (this.incoming && this.state === C.FOCUSING) {
|
|
2486
2456
|
const { transform: s, dimensions: r } = this.captureMidAnimationState(this.incoming.element);
|
|
2487
2457
|
if (this.animationEngine.cancelAllAnimations(this.incoming.element), this.outgoing = this.startUnfocusAnimation(
|
|
2488
2458
|
this.incoming.element,
|
|
2489
2459
|
this.incoming.originalState,
|
|
2490
2460
|
s,
|
|
2491
2461
|
r
|
|
2492
|
-
), this.incoming = null, this.state =
|
|
2462
|
+
), this.incoming = null, this.state = C.UNFOCUSING, await this.waitForAnimation(this.outgoing.animationHandle), this.focusGeneration !== t) return;
|
|
2493
2463
|
const a = this.outgoing.element;
|
|
2494
|
-
this.removeFocusedStyling(a, this.focusData?.originalZIndex || ""), this.outgoing = null, this.focusData = null, this.state =
|
|
2464
|
+
this.removeFocusedStyling(a, this.focusData?.originalZIndex || ""), this.outgoing = null, this.focusData = null, this.state = C.IDLE, this.onUnfocusComplete?.(a);
|
|
2495
2465
|
}
|
|
2496
2466
|
return;
|
|
2497
2467
|
}
|
|
2498
|
-
if (this.state ===
|
|
2468
|
+
if (this.state === C.CROSS_ANIMATING && this.incoming) {
|
|
2499
2469
|
const { transform: s, dimensions: r } = this.captureMidAnimationState(this.incoming.element);
|
|
2500
2470
|
this.animationEngine.cancelAllAnimations(this.incoming.element);
|
|
2501
2471
|
const a = this.startUnfocusAnimation(
|
|
@@ -2510,13 +2480,13 @@ class Ne {
|
|
|
2510
2480
|
]), this.focusGeneration !== t) return;
|
|
2511
2481
|
let c = null;
|
|
2512
2482
|
this.outgoing && (c = this.outgoing.element, this.removeFocusedStyling(c, this.outgoing.originalState.zIndex?.toString() || ""));
|
|
2513
|
-
const
|
|
2514
|
-
this.removeFocusedStyling(
|
|
2483
|
+
const d = a.element;
|
|
2484
|
+
this.removeFocusedStyling(d, this.incoming.originalState.zIndex?.toString() || ""), this.outgoing = null, this.incoming = null, this.currentFocus = null, this.focusData = null, this.state = C.IDLE, c && this.onUnfocusComplete?.(c), this.onUnfocusComplete?.(d);
|
|
2515
2485
|
return;
|
|
2516
2486
|
}
|
|
2517
|
-
this.state =
|
|
2518
|
-
const i = this.currentFocus, e = this.focusData.originalState,
|
|
2519
|
-
this.outgoing = this.startUnfocusAnimation(i, e), await this.waitForAnimation(this.outgoing.animationHandle), this.focusGeneration === t && (this.removeFocusedStyling(i,
|
|
2487
|
+
this.state = C.UNFOCUSING;
|
|
2488
|
+
const i = this.currentFocus, e = this.focusData.originalState, o = this.focusData.originalZIndex;
|
|
2489
|
+
this.outgoing = this.startUnfocusAnimation(i, e), await this.waitForAnimation(this.outgoing.animationHandle), this.focusGeneration === t && (this.removeFocusedStyling(i, o), this.outgoing = null, this.currentFocus = null, this.focusData = null, this.state = C.IDLE, this.onUnfocusComplete?.(i));
|
|
2520
2490
|
}
|
|
2521
2491
|
/**
|
|
2522
2492
|
* Swap focus from current image to a new one (alias for focusImage with cross-animation)
|
|
@@ -2534,7 +2504,7 @@ class Ne {
|
|
|
2534
2504
|
* Check if an image is currently focused (stable state)
|
|
2535
2505
|
*/
|
|
2536
2506
|
isFocused(t) {
|
|
2537
|
-
return this.currentFocus === t && this.state ===
|
|
2507
|
+
return this.currentFocus === t && this.state === C.FOCUSED;
|
|
2538
2508
|
}
|
|
2539
2509
|
/**
|
|
2540
2510
|
* Check if an image is the target of current focus animation
|
|
@@ -2555,9 +2525,9 @@ class Ne {
|
|
|
2555
2525
|
* Used during swipe gestures for visual feedback
|
|
2556
2526
|
*/
|
|
2557
2527
|
setDragOffset(t) {
|
|
2558
|
-
if (!this.currentFocus || !this.focusData || this.state !==
|
|
2559
|
-
const i = this.currentFocus, e = this.focusData.focusTransform,
|
|
2560
|
-
|
|
2528
|
+
if (!this.currentFocus || !this.focusData || this.state !== C.FOCUSED) return;
|
|
2529
|
+
const i = this.currentFocus, e = this.focusData.focusTransform, o = ["translate(-50%, -50%)"], s = (e.x ?? 0) + t, r = e.y ?? 0;
|
|
2530
|
+
o.push(`translate(${s}px, ${r}px)`), e.rotation !== void 0 && o.push(`rotate(${e.rotation}deg)`), i.style.transition = "none", i.style.transform = o.join(" ");
|
|
2561
2531
|
}
|
|
2562
2532
|
/**
|
|
2563
2533
|
* Clear the drag offset, optionally animating back to center
|
|
@@ -2565,9 +2535,9 @@ class Ne {
|
|
|
2565
2535
|
* @param duration - Animation duration in ms (default 150)
|
|
2566
2536
|
*/
|
|
2567
2537
|
clearDragOffset(t, i = 150) {
|
|
2568
|
-
if (!this.currentFocus || !this.focusData || this.state !==
|
|
2569
|
-
const e = this.currentFocus,
|
|
2570
|
-
s.push(`translate(${r}px, ${a}px)`),
|
|
2538
|
+
if (!this.currentFocus || !this.focusData || this.state !== C.FOCUSED) return;
|
|
2539
|
+
const e = this.currentFocus, o = this.focusData.focusTransform, s = ["translate(-50%, -50%)"], r = o.x ?? 0, a = o.y ?? 0;
|
|
2540
|
+
s.push(`translate(${r}px, ${a}px)`), o.rotation !== void 0 && s.push(`rotate(${o.rotation}deg)`);
|
|
2571
2541
|
const c = s.join(" ");
|
|
2572
2542
|
t ? (e.style.transition = `transform ${i}ms ease-out`, e.style.transform = c, setTimeout(() => {
|
|
2573
2543
|
this.currentFocus === e && (e.style.transition = "none");
|
|
@@ -2595,10 +2565,10 @@ class Ne {
|
|
|
2595
2565
|
this.focusData.originalZIndex,
|
|
2596
2566
|
this.focusData.originalWidth,
|
|
2597
2567
|
this.focusData.originalHeight
|
|
2598
|
-
), this.state =
|
|
2568
|
+
), this.state = C.IDLE, this.currentFocus = null, this.focusData = null, this.outgoing = null, this.incoming = null;
|
|
2599
2569
|
}
|
|
2600
2570
|
}
|
|
2601
|
-
const ke = 50,
|
|
2571
|
+
const ke = 50, He = 0.5, Ne = 20, Be = 0.3, je = 150, We = 30, rt = class rt {
|
|
2602
2572
|
constructor(t, i) {
|
|
2603
2573
|
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);
|
|
2604
2574
|
}
|
|
@@ -2642,23 +2612,23 @@ const ke = 50, Be = 0.5, je = 20, We = 0.3, Ge = 150, qe = 30, rt = class rt {
|
|
|
2642
2612
|
}
|
|
2643
2613
|
handleTouchMove(t) {
|
|
2644
2614
|
if (!this.touchState || t.touches.length !== 1) return;
|
|
2645
|
-
const i = t.touches[0], e = i.clientX - this.touchState.startX,
|
|
2646
|
-
if (this.touchState.isHorizontalSwipe === null && Math.sqrt(e * e +
|
|
2647
|
-
const a = Math.atan2(Math.abs(
|
|
2648
|
-
this.touchState.isHorizontalSwipe = a <=
|
|
2615
|
+
const i = t.touches[0], e = i.clientX - this.touchState.startX, o = i.clientY - this.touchState.startY;
|
|
2616
|
+
if (this.touchState.isHorizontalSwipe === null && Math.sqrt(e * e + o * o) > 10) {
|
|
2617
|
+
const a = Math.atan2(Math.abs(o), Math.abs(e)) * (180 / Math.PI);
|
|
2618
|
+
this.touchState.isHorizontalSwipe = a <= We;
|
|
2649
2619
|
}
|
|
2650
2620
|
if (this.touchState.isHorizontalSwipe !== !1 && this.touchState.isHorizontalSwipe === !0) {
|
|
2651
2621
|
t.preventDefault(), this.touchState.isDragging = !0, this.touchState.currentX = i.clientX;
|
|
2652
|
-
const s = e *
|
|
2622
|
+
const s = e * Be;
|
|
2653
2623
|
this.callbacks.onDragOffset(s);
|
|
2654
2624
|
}
|
|
2655
2625
|
}
|
|
2656
2626
|
handleTouchEnd(t) {
|
|
2657
2627
|
if (!this.touchState) return;
|
|
2658
2628
|
this.recentTouchTimestamp = Date.now();
|
|
2659
|
-
const i = this.touchState.currentX - this.touchState.startX, e = performance.now() - this.touchState.startTime,
|
|
2629
|
+
const i = this.touchState.currentX - this.touchState.startX, e = performance.now() - this.touchState.startTime, o = Math.abs(i) / e, s = Math.abs(i);
|
|
2660
2630
|
let r = !1;
|
|
2661
|
-
this.touchState.isHorizontalSwipe === !0 && this.touchState.isDragging && (s >= ke ||
|
|
2631
|
+
this.touchState.isHorizontalSwipe === !0 && this.touchState.isDragging && (s >= ke || o >= He && s >= Ne) && (r = !0, i < 0 ? this.callbacks.onNext() : this.callbacks.onPrev()), this.touchState.isDragging && this.callbacks.onDragEnd(r), this.touchState = null;
|
|
2662
2632
|
}
|
|
2663
2633
|
handleTouchCancel(t) {
|
|
2664
2634
|
this.touchState?.isDragging && this.callbacks.onDragEnd(!1), this.touchState = null;
|
|
@@ -2666,7 +2636,7 @@ const ke = 50, Be = 0.5, je = 20, We = 0.3, Ge = 150, qe = 30, rt = class rt {
|
|
|
2666
2636
|
};
|
|
2667
2637
|
rt.TOUCH_CLICK_DELAY = 300;
|
|
2668
2638
|
let bt = rt;
|
|
2669
|
-
class
|
|
2639
|
+
class Ge {
|
|
2670
2640
|
constructor(t) {
|
|
2671
2641
|
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)
|
|
2672
2642
|
throw new Error("GoogleDriveLoader requires at least one source to be configured");
|
|
@@ -2680,7 +2650,7 @@ class Xe {
|
|
|
2680
2650
|
for (const i of this.sources)
|
|
2681
2651
|
if ("folders" in i)
|
|
2682
2652
|
for (const e of i.folders) {
|
|
2683
|
-
const
|
|
2653
|
+
const o = i.recursive !== void 0 ? i.recursive : !0, s = await this.loadFromFolder(e, t, o);
|
|
2684
2654
|
this._discoveredUrls.push(...s);
|
|
2685
2655
|
}
|
|
2686
2656
|
else if ("files" in i) {
|
|
@@ -2726,9 +2696,9 @@ class Xe {
|
|
|
2726
2696
|
// Alternative format
|
|
2727
2697
|
];
|
|
2728
2698
|
for (const e of i) {
|
|
2729
|
-
const
|
|
2730
|
-
if (
|
|
2731
|
-
return
|
|
2699
|
+
const o = t.match(e);
|
|
2700
|
+
if (o && o[1])
|
|
2701
|
+
return o[1];
|
|
2732
2702
|
}
|
|
2733
2703
|
return null;
|
|
2734
2704
|
}
|
|
@@ -2740,15 +2710,15 @@ class Xe {
|
|
|
2740
2710
|
* @returns Promise resolving to array of image URLs
|
|
2741
2711
|
*/
|
|
2742
2712
|
async loadFromFolder(t, i, e = !0) {
|
|
2743
|
-
const
|
|
2744
|
-
if (!
|
|
2713
|
+
const o = this.extractFolderId(t);
|
|
2714
|
+
if (!o)
|
|
2745
2715
|
throw new Error("Invalid Google Drive folder URL. Please check the URL format.");
|
|
2746
2716
|
if (!this.apiKey || this.apiKey === "YOUR_API_KEY_HERE")
|
|
2747
|
-
return this.loadImagesDirectly(
|
|
2717
|
+
return this.loadImagesDirectly(o, i);
|
|
2748
2718
|
try {
|
|
2749
|
-
return e ? await this.loadImagesRecursively(
|
|
2719
|
+
return e ? await this.loadImagesRecursively(o, i) : await this.loadImagesFromSingleFolder(o, i);
|
|
2750
2720
|
} catch (s) {
|
|
2751
|
-
return console.error("Error loading from Google Drive API:", s), this.loadImagesDirectly(
|
|
2721
|
+
return console.error("Error loading from Google Drive API:", s), this.loadImagesDirectly(o, i);
|
|
2752
2722
|
}
|
|
2753
2723
|
}
|
|
2754
2724
|
/**
|
|
@@ -2758,13 +2728,13 @@ class Xe {
|
|
|
2758
2728
|
* @returns Promise resolving to array of image URLs
|
|
2759
2729
|
*/
|
|
2760
2730
|
async loadImagesFromSingleFolder(t, i) {
|
|
2761
|
-
const e = [],
|
|
2731
|
+
const e = [], o = `'${t}' in parents and trashed=false`, r = `${this.apiEndpoint}?q=${encodeURIComponent(o)}&fields=files(id,name,mimeType,thumbnailLink)&key=${this.apiKey}`, a = await fetch(r);
|
|
2762
2732
|
if (!a.ok)
|
|
2763
2733
|
throw new Error(`API request failed: ${a.status} ${a.statusText}`);
|
|
2764
|
-
const
|
|
2734
|
+
const d = (await a.json()).files.filter(
|
|
2765
2735
|
(u) => u.mimeType.startsWith("image/") && i.isAllowed(u.name)
|
|
2766
2736
|
);
|
|
2767
|
-
return this.log(`Found ${
|
|
2737
|
+
return this.log(`Found ${d.length} images in folder ${t} (non-recursive)`), d.forEach((u) => {
|
|
2768
2738
|
e.push(`https://lh3.googleusercontent.com/d/${u.id}=s1600`), this.log(`Added file: ${u.name}`);
|
|
2769
2739
|
}), e;
|
|
2770
2740
|
}
|
|
@@ -2776,10 +2746,10 @@ class Xe {
|
|
|
2776
2746
|
*/
|
|
2777
2747
|
async loadFiles(t, i) {
|
|
2778
2748
|
const e = [];
|
|
2779
|
-
for (const
|
|
2780
|
-
const s = this.extractFileId(
|
|
2749
|
+
for (const o of t) {
|
|
2750
|
+
const s = this.extractFileId(o);
|
|
2781
2751
|
if (!s) {
|
|
2782
|
-
this.log(`Skipping invalid file URL: ${
|
|
2752
|
+
this.log(`Skipping invalid file URL: ${o}`);
|
|
2783
2753
|
continue;
|
|
2784
2754
|
}
|
|
2785
2755
|
if (this.apiKey && this.apiKey !== "YOUR_API_KEY_HERE")
|
|
@@ -2815,9 +2785,9 @@ class Xe {
|
|
|
2815
2785
|
// Generic id parameter
|
|
2816
2786
|
];
|
|
2817
2787
|
for (const e of i) {
|
|
2818
|
-
const
|
|
2819
|
-
if (
|
|
2820
|
-
return
|
|
2788
|
+
const o = t.match(e);
|
|
2789
|
+
if (o && o[1])
|
|
2790
|
+
return o[1];
|
|
2821
2791
|
}
|
|
2822
2792
|
return null;
|
|
2823
2793
|
}
|
|
@@ -2828,21 +2798,21 @@ class Xe {
|
|
|
2828
2798
|
* @returns Promise resolving to array of image URLs
|
|
2829
2799
|
*/
|
|
2830
2800
|
async loadImagesRecursively(t, i) {
|
|
2831
|
-
const e = [],
|
|
2801
|
+
const e = [], o = `'${t}' in parents and trashed=false`, r = `${this.apiEndpoint}?q=${encodeURIComponent(o)}&fields=files(id,name,mimeType,thumbnailLink)&key=${this.apiKey}`, a = await fetch(r);
|
|
2832
2802
|
if (!a.ok)
|
|
2833
2803
|
throw new Error(`API request failed: ${a.status} ${a.statusText}`);
|
|
2834
|
-
const c = await a.json(),
|
|
2835
|
-
(
|
|
2804
|
+
const c = await a.json(), d = c.files.filter(
|
|
2805
|
+
(f) => f.mimeType.startsWith("image/") && i.isAllowed(f.name)
|
|
2836
2806
|
), u = c.files.filter(
|
|
2837
|
-
(
|
|
2807
|
+
(f) => f.mimeType === "application/vnd.google-apps.folder"
|
|
2838
2808
|
);
|
|
2839
|
-
this.log(`Found ${c.files.length} total items in folder ${t}`), c.files.forEach((
|
|
2840
|
-
e.push(`https://lh3.googleusercontent.com/d/${
|
|
2809
|
+
this.log(`Found ${c.files.length} total items in folder ${t}`), c.files.forEach((f) => this.log(` - File: ${f.name} (${f.mimeType})`)), this.log(`- ${d.length} valid files (images only)`), this.log(`- ${u.length} subfolders`), d.forEach((f) => {
|
|
2810
|
+
e.push(`https://lh3.googleusercontent.com/d/${f.id}=s1600`), this.log(`Added file: ${f.name}`);
|
|
2841
2811
|
});
|
|
2842
|
-
for (const
|
|
2843
|
-
this.log(`Loading images from subfolder: ${
|
|
2844
|
-
const
|
|
2845
|
-
e.push(...
|
|
2812
|
+
for (const f of u) {
|
|
2813
|
+
this.log(`Loading images from subfolder: ${f.name}`);
|
|
2814
|
+
const m = await this.loadImagesRecursively(f.id, i);
|
|
2815
|
+
e.push(...m);
|
|
2846
2816
|
}
|
|
2847
2817
|
return e;
|
|
2848
2818
|
}
|
|
@@ -2855,10 +2825,10 @@ class Xe {
|
|
|
2855
2825
|
*/
|
|
2856
2826
|
async loadImagesDirectly(t, i) {
|
|
2857
2827
|
try {
|
|
2858
|
-
const e = `https://drive.google.com/embeddedfolderview?id=${t}`,
|
|
2859
|
-
if (!
|
|
2828
|
+
const e = `https://drive.google.com/embeddedfolderview?id=${t}`, o = await fetch(e, { mode: "cors" });
|
|
2829
|
+
if (!o.ok)
|
|
2860
2830
|
throw new Error("Cannot access folder directly (CORS or permissions issue)");
|
|
2861
|
-
const s = await
|
|
2831
|
+
const s = await o.text(), r = /\/file\/d\/([a-zA-Z0-9_-]+)/g, a = [...s.matchAll(r)];
|
|
2862
2832
|
return [...new Set(a.map((u) => u[1]))].map(
|
|
2863
2833
|
(u) => `https://drive.google.com/uc?export=view&id=${u}`
|
|
2864
2834
|
);
|
|
@@ -2887,7 +2857,7 @@ class Xe {
|
|
|
2887
2857
|
this.debugLogging && typeof console < "u" && console.log(...t);
|
|
2888
2858
|
}
|
|
2889
2859
|
}
|
|
2890
|
-
class
|
|
2860
|
+
class qe {
|
|
2891
2861
|
constructor(t) {
|
|
2892
2862
|
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)
|
|
2893
2863
|
throw new Error("StaticImageLoader requires at least one source to be configured");
|
|
@@ -2951,13 +2921,13 @@ class Ye {
|
|
|
2951
2921
|
if (!Array.isArray(t))
|
|
2952
2922
|
return console.warn("URLs must be an array:", t), [];
|
|
2953
2923
|
const e = [];
|
|
2954
|
-
for (const
|
|
2955
|
-
const s =
|
|
2924
|
+
for (const o of t) {
|
|
2925
|
+
const s = o.split("/").pop() || o;
|
|
2956
2926
|
if (!i.isAllowed(s)) {
|
|
2957
|
-
this.log(`Skipping filtered URL: ${
|
|
2927
|
+
this.log(`Skipping filtered URL: ${o}`);
|
|
2958
2928
|
continue;
|
|
2959
2929
|
}
|
|
2960
|
-
this.validateUrls ? await this.validateUrl(
|
|
2930
|
+
this.validateUrls ? await this.validateUrl(o) ? e.push(o) : console.warn(`Skipping invalid/missing URL: ${o}`) : e.push(o);
|
|
2961
2931
|
}
|
|
2962
2932
|
return e;
|
|
2963
2933
|
}
|
|
@@ -2971,16 +2941,16 @@ class Ye {
|
|
|
2971
2941
|
async processPath(t, i, e) {
|
|
2972
2942
|
if (!Array.isArray(i))
|
|
2973
2943
|
return console.warn("files must be an array:", i), [];
|
|
2974
|
-
const
|
|
2944
|
+
const o = [];
|
|
2975
2945
|
for (const s of i) {
|
|
2976
2946
|
if (!e.isAllowed(s)) {
|
|
2977
2947
|
this.log(`Skipping filtered file: ${s}`);
|
|
2978
2948
|
continue;
|
|
2979
2949
|
}
|
|
2980
2950
|
const r = this.constructUrl(t, s);
|
|
2981
|
-
this.validateUrls ? await this.validateUrl(r) ?
|
|
2951
|
+
this.validateUrls ? await this.validateUrl(r) ? o.push(r) : console.warn(`Skipping invalid/missing file: ${r}`) : o.push(r);
|
|
2982
2952
|
}
|
|
2983
|
-
return
|
|
2953
|
+
return o;
|
|
2984
2954
|
}
|
|
2985
2955
|
/**
|
|
2986
2956
|
* Process a JSON endpoint source
|
|
@@ -2991,17 +2961,17 @@ class Ye {
|
|
|
2991
2961
|
*/
|
|
2992
2962
|
async processJson(t, i) {
|
|
2993
2963
|
this.log(`Fetching JSON endpoint: ${t}`);
|
|
2994
|
-
const e = new AbortController(),
|
|
2964
|
+
const e = new AbortController(), o = setTimeout(() => e.abort(), 1e4);
|
|
2995
2965
|
try {
|
|
2996
2966
|
const s = await fetch(t, { signal: e.signal });
|
|
2997
|
-
if (clearTimeout(
|
|
2967
|
+
if (clearTimeout(o), !s.ok)
|
|
2998
2968
|
throw new Error(`HTTP ${s.status} fetching ${t}`);
|
|
2999
2969
|
const r = await s.json();
|
|
3000
2970
|
if (!r || !Array.isArray(r.images))
|
|
3001
2971
|
throw new Error('JSON source must return JSON with shape { "images": ["url1", "url2", ...] }');
|
|
3002
2972
|
return this.log(`JSON endpoint returned ${r.images.length} image(s)`), await this.processUrls(r.images, i);
|
|
3003
2973
|
} catch (s) {
|
|
3004
|
-
throw clearTimeout(
|
|
2974
|
+
throw clearTimeout(o), s instanceof Error && s.name === "AbortError" ? new Error(`Timeout fetching JSON endpoint: ${t}`) : s;
|
|
3005
2975
|
}
|
|
3006
2976
|
}
|
|
3007
2977
|
/**
|
|
@@ -3023,11 +2993,11 @@ class Ye {
|
|
|
3023
2993
|
if (!(t.startsWith(window.location.origin) || t.startsWith("/")))
|
|
3024
2994
|
return this.log(`Skipping validation for cross-origin URL: ${t}`), !0;
|
|
3025
2995
|
try {
|
|
3026
|
-
const e = new AbortController(),
|
|
2996
|
+
const e = new AbortController(), o = setTimeout(() => e.abort(), this.validationTimeout), s = await fetch(t, {
|
|
3027
2997
|
method: "HEAD",
|
|
3028
2998
|
signal: e.signal
|
|
3029
2999
|
});
|
|
3030
|
-
return clearTimeout(
|
|
3000
|
+
return clearTimeout(o), s.ok ? !0 : (this.log(`Validation failed for ${t}: HTTP ${s.status}`), !1);
|
|
3031
3001
|
} catch (e) {
|
|
3032
3002
|
return e instanceof Error && (e.name === "AbortError" ? this.log(`Validation timeout for ${t}`) : this.log(`Validation failed for ${t}:`, e.message)), !1;
|
|
3033
3003
|
}
|
|
@@ -3044,8 +3014,8 @@ class Ye {
|
|
|
3044
3014
|
return `${e}/${i}`;
|
|
3045
3015
|
if (typeof window > "u")
|
|
3046
3016
|
return `${e}/${i}`;
|
|
3047
|
-
const
|
|
3048
|
-
return `${
|
|
3017
|
+
const o = window.location.origin, r = (t.startsWith("/") ? t : "/" + t).replace(/\/$/, "");
|
|
3018
|
+
return `${o}${r}/${i}`;
|
|
3049
3019
|
}
|
|
3050
3020
|
/**
|
|
3051
3021
|
* Check if URL is absolute (contains protocol)
|
|
@@ -3067,7 +3037,7 @@ class Ye {
|
|
|
3067
3037
|
this.debugLogging && typeof console < "u" && console.log(...t);
|
|
3068
3038
|
}
|
|
3069
3039
|
}
|
|
3070
|
-
class
|
|
3040
|
+
class Ye {
|
|
3071
3041
|
constructor(t) {
|
|
3072
3042
|
if (this._prepared = !1, this._discoveredUrls = [], this.loaders = t.loaders, this.debugLogging = t.debugLogging ?? !1, !this.loaders || this.loaders.length === 0)
|
|
3073
3043
|
throw new Error("CompositeLoader requires at least one loader to be configured");
|
|
@@ -3079,16 +3049,16 @@ class Ve {
|
|
|
3079
3049
|
*/
|
|
3080
3050
|
async prepare(t) {
|
|
3081
3051
|
this._discoveredUrls = [], this.log(`Preparing ${this.loaders.length} loader(s) in parallel`);
|
|
3082
|
-
const i = this.loaders.map((e,
|
|
3083
|
-
this.log(`Loader ${
|
|
3052
|
+
const i = this.loaders.map((e, o) => e.prepare(t).then(() => {
|
|
3053
|
+
this.log(`Loader ${o} prepared with ${e.imagesLength()} images`);
|
|
3084
3054
|
}).catch((s) => {
|
|
3085
|
-
console.warn(`Loader ${
|
|
3055
|
+
console.warn(`Loader ${o} failed to prepare:`, s);
|
|
3086
3056
|
}));
|
|
3087
3057
|
await Promise.all(i);
|
|
3088
3058
|
for (const e of this.loaders)
|
|
3089
3059
|
if (e.isPrepared()) {
|
|
3090
|
-
const
|
|
3091
|
-
this._discoveredUrls.push(...
|
|
3060
|
+
const o = e.imageURLs();
|
|
3061
|
+
this._discoveredUrls.push(...o);
|
|
3092
3062
|
}
|
|
3093
3063
|
this._prepared = !0, this.log(`CompositeLoader prepared with ${this._discoveredUrls.length} total images`);
|
|
3094
3064
|
}
|
|
@@ -3124,7 +3094,7 @@ class Ve {
|
|
|
3124
3094
|
this.debugLogging && typeof console < "u" && console.log("[CompositeLoader]", ...t);
|
|
3125
3095
|
}
|
|
3126
3096
|
}
|
|
3127
|
-
class
|
|
3097
|
+
class Xe {
|
|
3128
3098
|
/**
|
|
3129
3099
|
* Create a new ImageFilter
|
|
3130
3100
|
* @param extensions - Array of allowed file extensions (without dots)
|
|
@@ -3161,7 +3131,7 @@ class Je {
|
|
|
3161
3131
|
// isAllowedDate(date: Date): boolean
|
|
3162
3132
|
// isAllowedDimensions(width: number, height: number): boolean
|
|
3163
3133
|
}
|
|
3164
|
-
const
|
|
3134
|
+
const Ve = `
|
|
3165
3135
|
.fbn-ic-gallery {
|
|
3166
3136
|
position: relative;
|
|
3167
3137
|
width: 100%;
|
|
@@ -3242,37 +3212,46 @@ const Ke = `
|
|
|
3242
3212
|
display: none !important;
|
|
3243
3213
|
}
|
|
3244
3214
|
`;
|
|
3245
|
-
function
|
|
3215
|
+
function Je() {
|
|
3246
3216
|
if (typeof document > "u") return;
|
|
3247
|
-
const
|
|
3248
|
-
if (document.getElementById(
|
|
3217
|
+
const n = "fbn-ic-functional-styles";
|
|
3218
|
+
if (document.getElementById(n)) return;
|
|
3249
3219
|
const t = document.createElement("style");
|
|
3250
|
-
t.id =
|
|
3220
|
+
t.id = n, t.textContent = Ve, document.head.appendChild(t);
|
|
3251
3221
|
}
|
|
3252
|
-
class
|
|
3222
|
+
class Ke {
|
|
3253
3223
|
constructor(t = {}) {
|
|
3254
|
-
this.fullConfig =
|
|
3224
|
+
this.fullConfig = Jt(t), t.container instanceof HTMLElement ? (this.containerRef = t.container, this.containerId = null) : (this.containerRef = null, this.containerId = t.container || "imageCloud"), this.callbacks = t.on ?? {}, this.imagesLoaded = !1, this.imageElements = [], this.imageLayouts = [], this.currentImageHeight = 225, this.currentFocusIndex = null, this.hoveredImage = null, this.resizeTimeout = null, this.displayQueue = [], this.queueInterval = null, this.loadGeneration = 0, this.loadingElAutoCreated = !1, this.errorElAutoCreated = !1, this.counterEl = null, this.counterElAutoCreated = !1, this.prevButtonEl = null, this.nextButtonEl = null, this.prevButtonElAutoCreated = !1, this.nextButtonElAutoCreated = !1, this.animationEngine = new te(this.fullConfig.animation), this.layoutEngine = new Fe({
|
|
3255
3225
|
layout: this.fullConfig.layout,
|
|
3256
3226
|
image: this.fullConfig.image
|
|
3257
|
-
}), this.zoomEngine = new
|
|
3258
|
-
const i = this.fullConfig.animation.entry ||
|
|
3259
|
-
this.entryAnimationEngine = new
|
|
3227
|
+
}), this.zoomEngine = new Ue(this.fullConfig.interaction.focus, this.animationEngine, this.fullConfig.styling), this.defaultStyles = it(this.fullConfig.styling?.default), this.defaultClassName = this.fullConfig.styling?.default?.className, this.hoverClassName = this.fullConfig.styling?.hover?.className;
|
|
3228
|
+
const i = this.fullConfig.animation.entry || L.animation.entry;
|
|
3229
|
+
this.entryAnimationEngine = new de(
|
|
3260
3230
|
i,
|
|
3261
3231
|
this.fullConfig.layout.algorithm
|
|
3262
3232
|
);
|
|
3263
3233
|
const e = this.fullConfig.animation.idle;
|
|
3264
|
-
e && e.type !== "none" ? this.idleAnimationEngine = new
|
|
3234
|
+
e && e.type !== "none" ? this.idleAnimationEngine = new ue(
|
|
3265
3235
|
e,
|
|
3266
3236
|
i.timing?.duration ?? 600
|
|
3267
|
-
) : this.idleAnimationEngine = null, this.zoomEngine.setOnUnfocusCompleteCallback((
|
|
3268
|
-
this.idleAnimationEngine?.resumeForImage(
|
|
3269
|
-
const s =
|
|
3237
|
+
) : this.idleAnimationEngine = null, this.zoomEngine.setOnUnfocusCompleteCallback((o) => {
|
|
3238
|
+
this.idleAnimationEngine?.resumeForImage(o);
|
|
3239
|
+
const s = o, r = this.imageElements.indexOf(s);
|
|
3240
|
+
if (this.callbacks.onImageUnfocus && r !== -1) {
|
|
3241
|
+
const a = this.imageLoader.imageURLs(), c = {
|
|
3242
|
+
element: s,
|
|
3243
|
+
index: r,
|
|
3244
|
+
url: a[r] ?? "",
|
|
3245
|
+
layout: this.imageLayouts[r]
|
|
3246
|
+
};
|
|
3247
|
+
this.callbacks.onImageUnfocus(c);
|
|
3248
|
+
}
|
|
3270
3249
|
requestAnimationFrame(() => {
|
|
3271
3250
|
if (s.matches(":hover") && this.fullConfig.styling?.hover) {
|
|
3272
|
-
const
|
|
3273
|
-
if (
|
|
3274
|
-
const
|
|
3275
|
-
st(s, this.fullConfig.styling.hover,
|
|
3251
|
+
const a = this.imageElements.indexOf(s);
|
|
3252
|
+
if (a !== -1) {
|
|
3253
|
+
const c = s.offsetHeight, d = s.cachedRenderedWidth;
|
|
3254
|
+
st(s, this.fullConfig.styling.hover, c, d), et(s, this.hoverClassName), this.hoveredImage = { element: s, layout: this.imageLayouts[a] };
|
|
3276
3255
|
}
|
|
3277
3256
|
}
|
|
3278
3257
|
});
|
|
@@ -3283,7 +3262,7 @@ class Qe {
|
|
|
3283
3262
|
*/
|
|
3284
3263
|
createImageFilter() {
|
|
3285
3264
|
const t = this.fullConfig.config.loaders?.allowedExtensions;
|
|
3286
|
-
return new
|
|
3265
|
+
return new Xe(t);
|
|
3287
3266
|
}
|
|
3288
3267
|
/**
|
|
3289
3268
|
* Create appropriate image loader based on config
|
|
@@ -3293,8 +3272,8 @@ class Qe {
|
|
|
3293
3272
|
const t = this.fullConfig.loaders, i = this.fullConfig.config.loaders ?? {};
|
|
3294
3273
|
if (!t || t.length === 0)
|
|
3295
3274
|
throw new Error("No loaders configured. Provide `images`, `loaders`, or both.\n Example: imageCloud({ container: 'id', images: ['https://...'] })");
|
|
3296
|
-
const e = t.map((
|
|
3297
|
-
return e.length === 1 ? e[0] : new
|
|
3275
|
+
const e = t.map((o) => this.createLoaderFromEntry(o, i));
|
|
3276
|
+
return e.length === 1 ? e[0] : new Ye({
|
|
3298
3277
|
loaders: e,
|
|
3299
3278
|
debugLogging: this.fullConfig.config.debug?.loaders
|
|
3300
3279
|
});
|
|
@@ -3304,7 +3283,7 @@ class Qe {
|
|
|
3304
3283
|
*/
|
|
3305
3284
|
createLoaderFromEntry(t, i) {
|
|
3306
3285
|
if ("static" in t) {
|
|
3307
|
-
const e = t.static,
|
|
3286
|
+
const e = t.static, o = {
|
|
3308
3287
|
...e,
|
|
3309
3288
|
validateUrls: e.validateUrls ?? i.validateUrls,
|
|
3310
3289
|
validationTimeout: e.validationTimeout ?? i.validationTimeout,
|
|
@@ -3312,14 +3291,14 @@ class Qe {
|
|
|
3312
3291
|
allowedExtensions: e.allowedExtensions ?? i.allowedExtensions,
|
|
3313
3292
|
debugLogging: e.debugLogging ?? this.fullConfig.config.debug?.loaders
|
|
3314
3293
|
};
|
|
3315
|
-
return new
|
|
3294
|
+
return new qe(o);
|
|
3316
3295
|
} else if ("googleDrive" in t) {
|
|
3317
|
-
const e = t.googleDrive,
|
|
3296
|
+
const e = t.googleDrive, o = {
|
|
3318
3297
|
...e,
|
|
3319
3298
|
allowedExtensions: e.allowedExtensions ?? i.allowedExtensions,
|
|
3320
3299
|
debugLogging: e.debugLogging ?? this.fullConfig.config.debug?.loaders
|
|
3321
3300
|
};
|
|
3322
|
-
return new
|
|
3301
|
+
return new Ge(o);
|
|
3323
3302
|
} else
|
|
3324
3303
|
throw new Error(`Unknown loader entry: ${JSON.stringify(t)}`);
|
|
3325
3304
|
}
|
|
@@ -3328,7 +3307,7 @@ class Qe {
|
|
|
3328
3307
|
*/
|
|
3329
3308
|
async init() {
|
|
3330
3309
|
try {
|
|
3331
|
-
if (
|
|
3310
|
+
if (Je(), this.containerRef)
|
|
3332
3311
|
this.containerEl = this.containerRef;
|
|
3333
3312
|
else if (this.containerEl = document.getElementById(this.containerId), !this.containerEl)
|
|
3334
3313
|
throw new Error(`Container "#${this.containerId}" not found. Ensure an element with id="${this.containerId}" exists in the DOM before calling imageCloud().`);
|
|
@@ -3337,7 +3316,7 @@ class Qe {
|
|
|
3337
3316
|
onPrev: () => this.navigateToPreviousImage(),
|
|
3338
3317
|
onDragOffset: (t) => this.zoomEngine.setDragOffset(t),
|
|
3339
3318
|
onDragEnd: (t) => {
|
|
3340
|
-
t ? this.zoomEngine.clearDragOffset(!1) : this.zoomEngine.clearDragOffset(!0,
|
|
3319
|
+
t ? this.zoomEngine.clearDragOffset(!1) : this.zoomEngine.clearDragOffset(!0, je);
|
|
3341
3320
|
}
|
|
3342
3321
|
})), this.setupUI(), this.setupEventListeners(), this.logDebug("ImageCloud initialized"), await this.loadImages();
|
|
3343
3322
|
} catch (t) {
|
|
@@ -3392,7 +3371,7 @@ class Qe {
|
|
|
3392
3371
|
navigateToNextImage() {
|
|
3393
3372
|
if (this.currentFocusIndex === null || this.imageElements.length === 0) return;
|
|
3394
3373
|
const t = (this.currentFocusIndex + 1) % this.imageLayouts.length, i = this.imageElements.find(
|
|
3395
|
-
(
|
|
3374
|
+
(o) => o.dataset.imageId === String(t)
|
|
3396
3375
|
);
|
|
3397
3376
|
if (!i) return;
|
|
3398
3377
|
const e = this.imageLayouts[t];
|
|
@@ -3404,7 +3383,7 @@ class Qe {
|
|
|
3404
3383
|
navigateToPreviousImage() {
|
|
3405
3384
|
if (this.currentFocusIndex === null || this.imageElements.length === 0) return;
|
|
3406
3385
|
const t = (this.currentFocusIndex - 1 + this.imageLayouts.length) % this.imageLayouts.length, i = this.imageElements.find(
|
|
3407
|
-
(
|
|
3386
|
+
(o) => o.dataset.imageId === String(t)
|
|
3408
3387
|
);
|
|
3409
3388
|
if (!i) return;
|
|
3410
3389
|
const e = this.imageLayouts[t];
|
|
@@ -3420,8 +3399,8 @@ class Qe {
|
|
|
3420
3399
|
}, 500));
|
|
3421
3400
|
}
|
|
3422
3401
|
getImageHeight() {
|
|
3423
|
-
const t = window.innerWidth, i = this.fullConfig.layout.responsive,
|
|
3424
|
-
return i ? t <= i.mobile.maxWidth ? Math.min(100,
|
|
3402
|
+
const t = window.innerWidth, i = this.fullConfig.layout.responsive, o = this.fullConfig.image.sizing?.maxSize ?? 400;
|
|
3403
|
+
return i ? t <= i.mobile.maxWidth ? Math.min(100, o) : t <= i.tablet.maxWidth ? Math.min(180, o) : Math.min(225, o) : t <= 767 ? Math.min(100, o) : t <= 1199 ? Math.min(180, o) : Math.min(225, o);
|
|
3425
3404
|
}
|
|
3426
3405
|
/**
|
|
3427
3406
|
* Get container bounds for layout calculations
|
|
@@ -3444,12 +3423,12 @@ class Qe {
|
|
|
3444
3423
|
this.showError("No images found."), this.showLoading(!1);
|
|
3445
3424
|
return;
|
|
3446
3425
|
}
|
|
3447
|
-
const e = this.getContainerBounds(),
|
|
3448
|
-
this.logDebug(`Adaptive sizing input: container=${e.width}x${e.height}px, images=${t}, responsiveMax=${
|
|
3426
|
+
const e = this.getContainerBounds(), o = this.getImageHeight(), s = window.innerWidth;
|
|
3427
|
+
this.logDebug(`Adaptive sizing input: container=${e.width}x${e.height}px, images=${t}, responsiveMax=${o}px`);
|
|
3449
3428
|
const r = this.layoutEngine.calculateAdaptiveSize(
|
|
3450
3429
|
e,
|
|
3451
3430
|
t,
|
|
3452
|
-
|
|
3431
|
+
o,
|
|
3453
3432
|
s
|
|
3454
3433
|
);
|
|
3455
3434
|
this.logDebug(`Adaptive sizing result: height=${r.height}px`), await this.createImageCloud(i, r.height), this.showLoading(!1), this.imagesLoaded = !0;
|
|
@@ -3467,148 +3446,288 @@ class Qe {
|
|
|
3467
3446
|
if (!this.containerEl) return;
|
|
3468
3447
|
const e = this.getContainerBounds();
|
|
3469
3448
|
this.currentImageHeight = i;
|
|
3470
|
-
const
|
|
3471
|
-
this.imageLayouts = s, this.
|
|
3472
|
-
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3449
|
+
const o = this.loadGeneration, s = this.layoutEngine.generateLayout(t.length, e, { fixedHeight: i });
|
|
3450
|
+
if (this.imageLayouts = s, this.callbacks.onLayoutComplete) {
|
|
3451
|
+
const l = {
|
|
3452
|
+
layouts: [...s],
|
|
3453
|
+
// shallow copy — caller should not mutate
|
|
3454
|
+
containerBounds: { ...e },
|
|
3455
|
+
algorithm: this.fullConfig.layout.algorithm,
|
|
3456
|
+
imageCount: t.length
|
|
3457
|
+
};
|
|
3458
|
+
this.callbacks.onLayoutComplete(l);
|
|
3459
|
+
}
|
|
3460
|
+
this.displayQueue = [];
|
|
3461
|
+
let r = 0, a = 0, c = 0, d = 0, u = !1;
|
|
3462
|
+
const f = /* @__PURE__ */ new Map(), m = () => {
|
|
3463
|
+
if (u || o !== this.loadGeneration || !this.callbacks.onGalleryReady) return;
|
|
3464
|
+
u = !0;
|
|
3465
|
+
const l = {
|
|
3466
|
+
totalImages: t.length,
|
|
3467
|
+
failedImages: c,
|
|
3468
|
+
loadDuration: d > 0 ? performance.now() - d : 0
|
|
3469
|
+
};
|
|
3470
|
+
this.callbacks.onGalleryReady(l);
|
|
3471
|
+
}, p = () => {
|
|
3472
|
+
r >= t.length && this.displayQueue.length === 0 && m();
|
|
3473
|
+
}, w = (l) => {
|
|
3474
|
+
this.containerEl && (this.containerEl.appendChild(l), this.imageElements.push(l), requestAnimationFrame(async () => {
|
|
3475
|
+
l.offsetWidth, l.style.opacity = this.defaultStyles.opacity ?? "1";
|
|
3476
|
+
const g = parseInt(l.dataset.imageId || "0"), h = this.imageLayouts[g], b = this.entryAnimationEngine.getTiming(), I = performance.now(), y = parseFloat(l.dataset.startX || "0"), x = parseFloat(l.dataset.startY || "0"), E = parseFloat(l.dataset.endX || "0"), F = parseFloat(l.dataset.endY || "0"), R = parseFloat(l.dataset.rotation || "0"), M = parseFloat(l.dataset.scale || "1"), T = parseFloat(l.dataset.startRotation || l.dataset.rotation || "0"), z = parseFloat(l.dataset.startScale || l.dataset.scale || "1"), k = parseFloat(l.dataset.imageWidth || "0"), D = parseFloat(l.dataset.imageHeight || "0");
|
|
3477
|
+
if (this.callbacks.onEntryStart && h) {
|
|
3478
|
+
const S = {
|
|
3484
3479
|
element: l,
|
|
3485
|
-
|
|
3486
|
-
|
|
3480
|
+
index: g,
|
|
3481
|
+
totalImages: this.imageLayouts.length,
|
|
3482
|
+
layout: h,
|
|
3483
|
+
from: { x: y, y: x, rotation: T, scale: z },
|
|
3484
|
+
to: { x: E, y: F, rotation: R, scale: M },
|
|
3485
|
+
startTime: I,
|
|
3486
|
+
duration: b.duration
|
|
3487
|
+
};
|
|
3488
|
+
this.callbacks.onEntryStart(S);
|
|
3489
|
+
}
|
|
3490
|
+
if (this.entryAnimationEngine.requiresJSAnimation() || this.entryAnimationEngine.requiresJSRotation() || this.entryAnimationEngine.requiresJSScale() || l.dataset.startRotation !== l.dataset.rotation || l.dataset.startScale !== l.dataset.scale)
|
|
3491
|
+
ce({
|
|
3492
|
+
element: l,
|
|
3493
|
+
startPosition: { x: y, y: x },
|
|
3494
|
+
endPosition: { x: E, y: F },
|
|
3487
3495
|
pathConfig: this.entryAnimationEngine.getPathConfig(),
|
|
3488
|
-
duration:
|
|
3489
|
-
imageWidth:
|
|
3490
|
-
imageHeight:
|
|
3491
|
-
rotation:
|
|
3492
|
-
scale:
|
|
3496
|
+
duration: b.duration,
|
|
3497
|
+
imageWidth: k,
|
|
3498
|
+
imageHeight: D,
|
|
3499
|
+
rotation: R,
|
|
3500
|
+
scale: M,
|
|
3493
3501
|
rotationConfig: this.entryAnimationEngine.getRotationConfig(),
|
|
3494
|
-
startRotation:
|
|
3502
|
+
startRotation: T,
|
|
3495
3503
|
scaleConfig: this.entryAnimationEngine.getScaleConfig(),
|
|
3496
|
-
startScale:
|
|
3504
|
+
startScale: z,
|
|
3505
|
+
onProgress: this.callbacks.onEntryProgress && h ? (S, _, $) => {
|
|
3506
|
+
const A = {
|
|
3507
|
+
element: l,
|
|
3508
|
+
index: g,
|
|
3509
|
+
totalImages: this.imageLayouts.length,
|
|
3510
|
+
layout: h,
|
|
3511
|
+
from: { x: y, y: x, rotation: T, scale: z },
|
|
3512
|
+
to: { x: E, y: F, rotation: R, scale: M },
|
|
3513
|
+
startTime: I,
|
|
3514
|
+
duration: b.duration,
|
|
3515
|
+
progress: S,
|
|
3516
|
+
rawProgress: S,
|
|
3517
|
+
elapsed: _,
|
|
3518
|
+
current: $
|
|
3519
|
+
};
|
|
3520
|
+
this.callbacks.onEntryProgress(A);
|
|
3521
|
+
} : void 0,
|
|
3522
|
+
onComplete: h ? () => {
|
|
3523
|
+
if (this.callbacks.onEntryComplete) {
|
|
3524
|
+
const S = {
|
|
3525
|
+
element: l,
|
|
3526
|
+
index: g,
|
|
3527
|
+
layout: h,
|
|
3528
|
+
startTime: I,
|
|
3529
|
+
endTime: performance.now(),
|
|
3530
|
+
duration: b.duration
|
|
3531
|
+
};
|
|
3532
|
+
this.callbacks.onEntryComplete(S);
|
|
3533
|
+
}
|
|
3534
|
+
} : void 0
|
|
3497
3535
|
});
|
|
3498
|
-
|
|
3499
|
-
const
|
|
3500
|
-
l.style.transform =
|
|
3536
|
+
else {
|
|
3537
|
+
const S = l.dataset.finalTransform || "";
|
|
3538
|
+
if (l.style.transform = S, this.callbacks.onEntryComplete && h) {
|
|
3539
|
+
const _ = ($) => {
|
|
3540
|
+
if ($.propertyName !== "transform") return;
|
|
3541
|
+
l.removeEventListener("transitionend", _);
|
|
3542
|
+
const A = {
|
|
3543
|
+
element: l,
|
|
3544
|
+
index: g,
|
|
3545
|
+
layout: h,
|
|
3546
|
+
startTime: I,
|
|
3547
|
+
endTime: performance.now(),
|
|
3548
|
+
duration: b.duration
|
|
3549
|
+
};
|
|
3550
|
+
this.callbacks.onEntryComplete(A);
|
|
3551
|
+
};
|
|
3552
|
+
l.addEventListener("transitionend", _);
|
|
3553
|
+
}
|
|
3501
3554
|
}
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
console.log(`Image ${h} final state:`, {
|
|
3555
|
+
if (this.fullConfig.config.debug?.enabled && g < 3) {
|
|
3556
|
+
const S = l.dataset.finalTransform || "";
|
|
3557
|
+
console.log(`Image ${g} final state:`, {
|
|
3506
3558
|
left: l.style.left,
|
|
3507
3559
|
top: l.style.top,
|
|
3508
3560
|
width: l.style.width,
|
|
3509
3561
|
height: l.style.height,
|
|
3510
3562
|
computedWidth: l.offsetWidth,
|
|
3511
3563
|
computedHeight: l.offsetHeight,
|
|
3512
|
-
transform:
|
|
3564
|
+
transform: S,
|
|
3513
3565
|
pathType: this.entryAnimationEngine.getPathType()
|
|
3514
3566
|
});
|
|
3515
3567
|
}
|
|
3516
3568
|
if (this.idleAnimationEngine) {
|
|
3517
|
-
const
|
|
3518
|
-
this.idleAnimationEngine.register(l,
|
|
3569
|
+
const S = this.entryAnimationEngine.getTiming().duration;
|
|
3570
|
+
this.idleAnimationEngine.register(l, g, this.imageElements.length, S);
|
|
3519
3571
|
}
|
|
3520
|
-
}), r
|
|
3521
|
-
},
|
|
3572
|
+
}), r++, p());
|
|
3573
|
+
}, v = () => {
|
|
3522
3574
|
if (this.logDebug("Starting queue processing, enabled:", this.fullConfig.animation.queue.enabled), !this.fullConfig.animation.queue.enabled) {
|
|
3523
3575
|
for (; this.displayQueue.length > 0; ) {
|
|
3524
3576
|
const l = this.displayQueue.shift();
|
|
3525
|
-
l &&
|
|
3577
|
+
l && w(l);
|
|
3526
3578
|
}
|
|
3527
3579
|
return;
|
|
3528
3580
|
}
|
|
3529
3581
|
this.queueInterval !== null && clearInterval(this.queueInterval), this.queueInterval = window.setInterval(() => {
|
|
3530
|
-
if (
|
|
3582
|
+
if (o !== this.loadGeneration) {
|
|
3531
3583
|
this.queueInterval !== null && (clearInterval(this.queueInterval), this.queueInterval = null);
|
|
3532
3584
|
return;
|
|
3533
3585
|
}
|
|
3534
3586
|
if (this.displayQueue.length > 0) {
|
|
3535
3587
|
const l = this.displayQueue.shift();
|
|
3536
|
-
l &&
|
|
3588
|
+
l && w(l);
|
|
3537
3589
|
}
|
|
3538
|
-
r >= t.length && this.displayQueue.length === 0 && this.queueInterval !== null && (clearInterval(this.queueInterval), this.queueInterval = null);
|
|
3590
|
+
r >= t.length && this.displayQueue.length === 0 && (this.queueInterval !== null && (clearInterval(this.queueInterval), this.queueInterval = null), m());
|
|
3539
3591
|
}, this.fullConfig.animation.queue.interval);
|
|
3540
3592
|
};
|
|
3541
3593
|
if ("IntersectionObserver" in window && this.containerEl) {
|
|
3542
|
-
const l = new IntersectionObserver((
|
|
3543
|
-
|
|
3544
|
-
h.isIntersecting && (
|
|
3594
|
+
const l = new IntersectionObserver((g) => {
|
|
3595
|
+
g.forEach((h) => {
|
|
3596
|
+
h.isIntersecting && (v(), l.disconnect());
|
|
3545
3597
|
});
|
|
3546
3598
|
}, { threshold: 0.1, rootMargin: "50px" });
|
|
3547
3599
|
l.observe(this.containerEl);
|
|
3548
3600
|
} else
|
|
3549
|
-
|
|
3550
|
-
this.fullConfig.config.debug?.centers && this.containerEl && (this.containerEl.querySelectorAll(".fbn-ic-debug-center").forEach((l) => l.remove()), s.forEach((l,
|
|
3601
|
+
v();
|
|
3602
|
+
this.fullConfig.config.debug?.centers && this.containerEl && (this.containerEl.querySelectorAll(".fbn-ic-debug-center").forEach((l) => l.remove()), s.forEach((l, g) => {
|
|
3551
3603
|
const h = document.createElement("div");
|
|
3552
3604
|
h.className = "fbn-ic-debug-center", h.style.position = "absolute", h.style.width = "12px", h.style.height = "12px", h.style.borderRadius = "50%", h.style.backgroundColor = "red", h.style.border = "2px solid yellow", h.style.zIndex = "9999", h.style.pointerEvents = "none";
|
|
3553
|
-
const
|
|
3554
|
-
h.style.left = `${
|
|
3555
|
-
})), t.forEach((l,
|
|
3605
|
+
const b = l.x, I = l.y;
|
|
3606
|
+
h.style.left = `${b - 6}px`, h.style.top = `${I - 6}px`, h.title = `Image ${g}: center (${Math.round(b)}, ${Math.round(I)})`, this.containerEl.appendChild(h);
|
|
3607
|
+
})), t.forEach((l, g) => {
|
|
3556
3608
|
const h = document.createElement("img");
|
|
3557
|
-
h.referrerPolicy = "no-referrer", h.classList.add("fbn-ic-image"), this.fullConfig.interaction.dragging === !1 && (h.draggable = !1), h.dataset.imageId = String(
|
|
3558
|
-
const
|
|
3559
|
-
h.style.position = "absolute", h.style.width = "auto", h.style.height = `${i}px`, h.style.left = `${
|
|
3560
|
-
if (this.hoveredImage = { element: h, layout:
|
|
3561
|
-
const
|
|
3562
|
-
st(h, this.fullConfig.styling?.hover, i,
|
|
3609
|
+
h.referrerPolicy = "no-referrer", h.classList.add("fbn-ic-image"), this.fullConfig.interaction.dragging === !1 && (h.draggable = !1), h.dataset.imageId = String(g), h.dataset.createdFlag = "true";
|
|
3610
|
+
const b = s[g];
|
|
3611
|
+
h.style.position = "absolute", h.style.width = "auto", h.style.height = `${i}px`, h.style.left = `${b.x}px`, h.style.top = `${b.y}px`, b.zIndex && (h.style.zIndex = String(b.zIndex)), et(h, this.defaultClassName), h.addEventListener("mouseenter", () => {
|
|
3612
|
+
if (this.hoveredImage = { element: h, layout: b }, !this.zoomEngine.isInvolved(h)) {
|
|
3613
|
+
const y = h.cachedRenderedWidth;
|
|
3614
|
+
st(h, this.fullConfig.styling?.hover, i, y), et(h, this.hoverClassName);
|
|
3615
|
+
}
|
|
3616
|
+
if (this.callbacks.onImageHover) {
|
|
3617
|
+
const y = { element: h, index: g, url: l, layout: b };
|
|
3618
|
+
this.callbacks.onImageHover(y);
|
|
3563
3619
|
}
|
|
3564
3620
|
}), h.addEventListener("mouseleave", () => {
|
|
3565
3621
|
if (this.hoveredImage = null, !this.zoomEngine.isInvolved(h)) {
|
|
3566
|
-
const
|
|
3567
|
-
st(h, this.fullConfig.styling?.default, i,
|
|
3622
|
+
const y = h.cachedRenderedWidth;
|
|
3623
|
+
st(h, this.fullConfig.styling?.default, i, y), pt(h, this.hoverClassName), et(h, this.defaultClassName);
|
|
3624
|
+
}
|
|
3625
|
+
if (this.callbacks.onImageUnhover) {
|
|
3626
|
+
const y = { element: h, index: g, url: l, layout: b };
|
|
3627
|
+
this.callbacks.onImageUnhover(y);
|
|
3568
3628
|
}
|
|
3569
|
-
}), h.addEventListener("click", (
|
|
3570
|
-
|
|
3629
|
+
}), h.addEventListener("click", (y) => {
|
|
3630
|
+
y.stopPropagation(), this.handleImageClick(h, b);
|
|
3571
3631
|
}), h.style.opacity = "0", h.style.transition = this.entryAnimationEngine.getTransitionCSS(), h.onload = () => {
|
|
3572
|
-
if (
|
|
3632
|
+
if (o !== this.loadGeneration)
|
|
3573
3633
|
return;
|
|
3574
|
-
const
|
|
3575
|
-
h.dataset.onloadCalled = "true", window.DEBUG_CLIPPATH && console.log(`[onload #${
|
|
3576
|
-
const
|
|
3577
|
-
|
|
3578
|
-
|
|
3634
|
+
const y = h.naturalWidth / h.naturalHeight, x = i * y;
|
|
3635
|
+
h.dataset.onloadCalled = "true", window.DEBUG_CLIPPATH && console.log(`[onload #${g}] Called with imageHeight=${i}, renderedWidth=${x}`), h.style.width = `${x}px`, h.cachedRenderedWidth = x, h.aspectRatio = y, st(h, this.fullConfig.styling?.default, i, x);
|
|
3636
|
+
const E = { x: b.x, y: b.y }, F = { width: x, height: i }, R = this.entryAnimationEngine.calculateStartPosition(
|
|
3637
|
+
E,
|
|
3638
|
+
F,
|
|
3579
3639
|
e,
|
|
3580
|
-
|
|
3640
|
+
g,
|
|
3581
3641
|
t.length
|
|
3582
|
-
),
|
|
3583
|
-
|
|
3584
|
-
|
|
3585
|
-
|
|
3642
|
+
), M = this.entryAnimationEngine.calculateStartRotation(b.rotation), T = this.entryAnimationEngine.calculateStartScale(b.scale), z = this.entryAnimationEngine.buildFinalTransform(
|
|
3643
|
+
b.rotation,
|
|
3644
|
+
b.scale,
|
|
3645
|
+
x,
|
|
3586
3646
|
i
|
|
3587
|
-
),
|
|
3588
|
-
|
|
3589
|
-
|
|
3590
|
-
|
|
3591
|
-
|
|
3592
|
-
|
|
3647
|
+
), k = this.entryAnimationEngine.buildStartTransform(
|
|
3648
|
+
R,
|
|
3649
|
+
E,
|
|
3650
|
+
b.rotation,
|
|
3651
|
+
b.scale,
|
|
3652
|
+
x,
|
|
3593
3653
|
i,
|
|
3594
|
-
|
|
3595
|
-
|
|
3654
|
+
M,
|
|
3655
|
+
T
|
|
3596
3656
|
);
|
|
3597
|
-
this.fullConfig.config.debug?.enabled &&
|
|
3598
|
-
finalPosition:
|
|
3599
|
-
imageSize:
|
|
3600
|
-
left:
|
|
3601
|
-
top:
|
|
3602
|
-
finalTransform:
|
|
3603
|
-
renderedWidth:
|
|
3657
|
+
if (this.fullConfig.config.debug?.enabled && g < 3 && console.log(`Image ${g}:`, {
|
|
3658
|
+
finalPosition: E,
|
|
3659
|
+
imageSize: F,
|
|
3660
|
+
left: b.x,
|
|
3661
|
+
top: b.y,
|
|
3662
|
+
finalTransform: z,
|
|
3663
|
+
renderedWidth: x,
|
|
3604
3664
|
renderedHeight: i
|
|
3605
|
-
}), h.style.transform =
|
|
3606
|
-
|
|
3665
|
+
}), h.style.transform = k, h.dataset.finalTransform = z, h.dataset.startX = String(R.x), h.dataset.startY = String(R.y), h.dataset.endX = String(E.x), h.dataset.endY = String(E.y), h.dataset.imageWidth = String(x), h.dataset.imageHeight = String(i), h.dataset.rotation = String(b.rotation), h.dataset.scale = String(b.scale), h.dataset.startRotation = String(M), h.dataset.startScale = String(T), a++, this.callbacks.onImageLoaded) {
|
|
3666
|
+
const D = {
|
|
3667
|
+
element: h,
|
|
3668
|
+
url: l,
|
|
3669
|
+
index: g,
|
|
3670
|
+
totalImages: t.length,
|
|
3671
|
+
loadTime: performance.now() - (f.get(g) ?? performance.now())
|
|
3672
|
+
};
|
|
3673
|
+
this.callbacks.onImageLoaded(D);
|
|
3674
|
+
}
|
|
3675
|
+
if (this.callbacks.onLoadProgress) {
|
|
3676
|
+
const D = {
|
|
3677
|
+
loaded: a,
|
|
3678
|
+
failed: c,
|
|
3679
|
+
total: t.length,
|
|
3680
|
+
percent: (a + c) / t.length * 100
|
|
3681
|
+
};
|
|
3682
|
+
this.callbacks.onLoadProgress(D);
|
|
3683
|
+
}
|
|
3684
|
+
this.displayQueue.push(h);
|
|
3685
|
+
};
|
|
3686
|
+
const I = () => {
|
|
3687
|
+
if (o === this.loadGeneration) {
|
|
3688
|
+
if (c++, this.callbacks.onImageError) {
|
|
3689
|
+
const y = { url: l, index: g, totalImages: t.length };
|
|
3690
|
+
this.callbacks.onImageError(y);
|
|
3691
|
+
}
|
|
3692
|
+
if (this.callbacks.onLoadProgress) {
|
|
3693
|
+
const y = {
|
|
3694
|
+
loaded: a,
|
|
3695
|
+
failed: c,
|
|
3696
|
+
total: t.length,
|
|
3697
|
+
percent: (a + c) / t.length * 100
|
|
3698
|
+
};
|
|
3699
|
+
this.callbacks.onLoadProgress(y);
|
|
3700
|
+
}
|
|
3701
|
+
r++, p();
|
|
3702
|
+
}
|
|
3703
|
+
};
|
|
3704
|
+
h.onerror = () => I(), (async () => {
|
|
3705
|
+
let y = l;
|
|
3706
|
+
if (this.callbacks.onBeforeImageLoad) {
|
|
3707
|
+
const x = { url: l, index: g, totalImages: t.length }, E = await this.callbacks.onBeforeImageLoad(x);
|
|
3708
|
+
if (E)
|
|
3709
|
+
if (E.fetch !== void 0) {
|
|
3710
|
+
const F = E.url ?? l;
|
|
3711
|
+
try {
|
|
3712
|
+
const M = await (await fetch(F, E.fetch)).blob(), T = URL.createObjectURL(M);
|
|
3713
|
+
y = T;
|
|
3714
|
+
const z = h.onload;
|
|
3715
|
+
h.onload = (k) => {
|
|
3716
|
+
URL.revokeObjectURL(T), z?.call(h, k);
|
|
3717
|
+
};
|
|
3718
|
+
} catch {
|
|
3719
|
+
I();
|
|
3720
|
+
return;
|
|
3721
|
+
}
|
|
3722
|
+
} else E.url && (y = E.url);
|
|
3723
|
+
}
|
|
3724
|
+
d === 0 && (d = performance.now()), f.set(g, performance.now()), h.src = y;
|
|
3725
|
+
})();
|
|
3607
3726
|
});
|
|
3608
3727
|
}
|
|
3609
3728
|
async handleImageClick(t, i) {
|
|
3610
3729
|
if (!this.containerEl) return;
|
|
3611
|
-
const e = this.zoomEngine.isFocused(t),
|
|
3730
|
+
const e = this.zoomEngine.isFocused(t), o = {
|
|
3612
3731
|
width: this.containerEl.offsetWidth,
|
|
3613
3732
|
height: this.containerEl.offsetHeight
|
|
3614
3733
|
};
|
|
@@ -3617,7 +3736,15 @@ class Qe {
|
|
|
3617
3736
|
else {
|
|
3618
3737
|
this.idleAnimationEngine?.pauseForImage(t);
|
|
3619
3738
|
const s = t.dataset.imageId;
|
|
3620
|
-
this.currentFocusIndex = s !== void 0 ? parseInt(s, 10) : null, this.swipeEngine?.enable(), this.containerEl?.focus({ preventScroll: !0 }), await this.zoomEngine.focusImage(t,
|
|
3739
|
+
if (this.currentFocusIndex = s !== void 0 ? parseInt(s, 10) : null, this.swipeEngine?.enable(), this.containerEl?.focus({ preventScroll: !0 }), await this.zoomEngine.focusImage(t, o, i), this.currentFocusIndex !== null && this.updateCounter(this.currentFocusIndex), this.showNavButtons(), this.showFocusIndicator(), this.callbacks.onImageFocus && this.currentFocusIndex !== null) {
|
|
3740
|
+
const r = this.imageLoader.imageURLs(), a = {
|
|
3741
|
+
element: t,
|
|
3742
|
+
index: this.currentFocusIndex,
|
|
3743
|
+
url: r[this.currentFocusIndex] ?? "",
|
|
3744
|
+
layout: i
|
|
3745
|
+
};
|
|
3746
|
+
this.callbacks.onImageFocus(a);
|
|
3747
|
+
}
|
|
3621
3748
|
}
|
|
3622
3749
|
}
|
|
3623
3750
|
/**
|
|
@@ -3660,37 +3787,36 @@ class Qe {
|
|
|
3660
3787
|
this.clearImageCloud(), this.loadingElAutoCreated && this.loadingEl && (this.loadingEl.remove(), this.loadingEl = null), this.errorElAutoCreated && this.errorEl && (this.errorEl.remove(), this.errorEl = null), this.counterElAutoCreated && this.counterEl && (this.counterEl.remove(), this.counterEl = null), this.prevButtonElAutoCreated && this.prevButtonEl && (this.prevButtonEl.remove(), this.prevButtonEl = null), this.nextButtonElAutoCreated && this.nextButtonEl && (this.nextButtonEl.remove(), this.nextButtonEl = null), this.resizeTimeout !== null && clearTimeout(this.resizeTimeout), this.swipeEngine?.destroy(), this.idleAnimationEngine?.stopAll(), this.idleAnimationEngine = null;
|
|
3661
3788
|
}
|
|
3662
3789
|
}
|
|
3663
|
-
async function
|
|
3664
|
-
const t = new
|
|
3790
|
+
async function Ze(n) {
|
|
3791
|
+
const t = new Ke(n);
|
|
3665
3792
|
return await t.init(), t;
|
|
3666
3793
|
}
|
|
3667
3794
|
export {
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
de as requiresJSAnimation
|
|
3795
|
+
te as AnimationEngine,
|
|
3796
|
+
St as BOUNCE_PRESETS,
|
|
3797
|
+
Ee as ClusterPlacementLayout,
|
|
3798
|
+
Ye as CompositeLoader,
|
|
3799
|
+
L as DEFAULT_CONFIG,
|
|
3800
|
+
Ot as DEFAULT_SHARED_LOADER_CONFIG,
|
|
3801
|
+
Ct as ELASTIC_PRESETS,
|
|
3802
|
+
de as EntryAnimationEngine,
|
|
3803
|
+
Ve as FUNCTIONAL_CSS,
|
|
3804
|
+
Ge as GoogleDriveLoader,
|
|
3805
|
+
pe as GridPlacementLayout,
|
|
3806
|
+
Le as HoneycombPlacementLayout,
|
|
3807
|
+
Ke as ImageCloud,
|
|
3808
|
+
Xe as ImageFilter,
|
|
3809
|
+
Fe as LayoutEngine,
|
|
3810
|
+
ge as RadialPlacementLayout,
|
|
3811
|
+
fe as RandomPlacementLayout,
|
|
3812
|
+
ve as SpiralPlacementLayout,
|
|
3813
|
+
qe as StaticImageLoader,
|
|
3814
|
+
Rt as WAVE_PATH_PRESETS,
|
|
3815
|
+
we as WavePlacementLayout,
|
|
3816
|
+
Ue as ZoomEngine,
|
|
3817
|
+
ce as animatePath,
|
|
3818
|
+
Ze as imageCloud,
|
|
3819
|
+
Je as injectFunctionalStyles,
|
|
3820
|
+
le as requiresJSAnimation
|
|
3695
3821
|
};
|
|
3696
3822
|
//# sourceMappingURL=image-cloud.js.map
|