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