@frybynite/image-cloud 0.10.3 → 0.11.1
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 +689 -526
- package/dist/image-cloud-auto-init.js.map +1 -1
- package/dist/image-cloud.js +1013 -850
- 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 +114 -2
- package/dist/react.d.ts +114 -2
- package/dist/react.js +698 -535
- package/dist/react.js.map +1 -1
- package/dist/vue.d.ts +114 -2
- package/dist/vue.js +1012 -849
- package/dist/vue.js.map +1 -1
- package/dist/web-component.d.ts +114 -2
- package/dist/web-component.js +690 -527
- package/dist/web-component.js.map +1 -1
- package/package.json +1 -1
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,
|
|
@@ -77,15 +77,15 @@ const mt = Object.freeze({
|
|
|
77
77
|
// No variance by default
|
|
78
78
|
max: 1
|
|
79
79
|
})
|
|
80
|
-
}),
|
|
80
|
+
}), Vt = Object.freeze({
|
|
81
81
|
mode: "none",
|
|
82
82
|
range: Object.freeze({
|
|
83
83
|
min: -15,
|
|
84
84
|
max: 15
|
|
85
85
|
})
|
|
86
86
|
}), Ot = Object.freeze({
|
|
87
|
-
sizing:
|
|
88
|
-
rotation:
|
|
87
|
+
sizing: Xt,
|
|
88
|
+
rotation: Vt
|
|
89
89
|
}), zt = Object.freeze({
|
|
90
90
|
validateUrls: !0,
|
|
91
91
|
validationTimeout: 5e3,
|
|
@@ -95,7 +95,7 @@ const mt = Object.freeze({
|
|
|
95
95
|
enabled: !1,
|
|
96
96
|
centers: !1,
|
|
97
97
|
loaders: !1
|
|
98
|
-
}),
|
|
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
|
|
@@ -110,7 +110,7 @@ const mt = 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
|
}),
|
|
@@ -185,119 +185,119 @@ const mt = Object.freeze({
|
|
|
185
185
|
showFocusOutline: !1
|
|
186
186
|
}),
|
|
187
187
|
// Image styling
|
|
188
|
-
styling:
|
|
188
|
+
styling: Mt
|
|
189
189
|
});
|
|
190
|
-
function Z(
|
|
191
|
-
if (!
|
|
192
|
-
if (!t) return { ...
|
|
193
|
-
const i = { ...
|
|
194
|
-
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;
|
|
195
195
|
}
|
|
196
|
-
function te(
|
|
197
|
-
if (!t) return { ...
|
|
198
|
-
const i = Z(
|
|
199
|
-
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),
|
|
200
200
|
t.hover
|
|
201
|
-
),
|
|
202
|
-
Z(i,
|
|
201
|
+
), o = Z(
|
|
202
|
+
Z(i, n.focused),
|
|
203
203
|
t.focused
|
|
204
204
|
);
|
|
205
205
|
return {
|
|
206
206
|
default: i,
|
|
207
207
|
hover: e,
|
|
208
|
-
focused:
|
|
208
|
+
focused: o
|
|
209
209
|
};
|
|
210
210
|
}
|
|
211
|
-
function ee(
|
|
212
|
-
if (!t) return { ...
|
|
213
|
-
const i = { ...
|
|
211
|
+
function ee(n, t) {
|
|
212
|
+
if (!t) return { ...n };
|
|
213
|
+
const i = { ...n };
|
|
214
214
|
if (t.sizing !== void 0 && (i.sizing = {
|
|
215
|
-
...
|
|
215
|
+
...n.sizing,
|
|
216
216
|
...t.sizing
|
|
217
217
|
}, t.sizing.variance)) {
|
|
218
|
-
const e = t.sizing.variance,
|
|
219
|
-
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 };
|
|
220
220
|
}
|
|
221
221
|
if (t.rotation !== void 0 && (i.rotation = {
|
|
222
|
-
...
|
|
222
|
+
...n.rotation,
|
|
223
223
|
...t.rotation
|
|
224
224
|
}, t.rotation.range)) {
|
|
225
|
-
const e = t.rotation.range,
|
|
226
|
-
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 };
|
|
227
227
|
}
|
|
228
228
|
return i;
|
|
229
229
|
}
|
|
230
|
-
function ie(
|
|
231
|
-
const t =
|
|
232
|
-
|
|
230
|
+
function ie(n = {}) {
|
|
231
|
+
const t = n.image, i = [...n.loaders ?? []];
|
|
232
|
+
n.images && n.images.length > 0 && i.unshift({
|
|
233
233
|
static: {
|
|
234
|
-
sources: [{ urls:
|
|
234
|
+
sources: [{ urls: n.images }]
|
|
235
235
|
}
|
|
236
236
|
});
|
|
237
|
-
const
|
|
237
|
+
const o = {
|
|
238
238
|
loaders: {
|
|
239
239
|
...zt,
|
|
240
|
-
...
|
|
240
|
+
...n.config?.loaders ?? {}
|
|
241
241
|
}
|
|
242
242
|
}, s = {
|
|
243
243
|
loaders: i,
|
|
244
|
-
config:
|
|
244
|
+
config: o,
|
|
245
245
|
image: ee(Ot, t),
|
|
246
|
-
layout: { ...
|
|
247
|
-
animation: { ...
|
|
248
|
-
interaction: { ...
|
|
249
|
-
ui: { ...
|
|
250
|
-
styling: te(
|
|
246
|
+
layout: { ...L.layout },
|
|
247
|
+
animation: { ...L.animation },
|
|
248
|
+
interaction: { ...L.interaction },
|
|
249
|
+
ui: { ...L.ui },
|
|
250
|
+
styling: te(Mt, n.styling)
|
|
251
251
|
};
|
|
252
|
-
if (
|
|
253
|
-
...
|
|
254
|
-
...
|
|
255
|
-
},
|
|
256
|
-
...
|
|
257
|
-
mobile:
|
|
258
|
-
tablet:
|
|
259
|
-
}),
|
|
260
|
-
...
|
|
261
|
-
...
|
|
262
|
-
})),
|
|
263
|
-
...
|
|
264
|
-
...
|
|
265
|
-
},
|
|
266
|
-
...
|
|
267
|
-
...
|
|
268
|
-
}),
|
|
269
|
-
...
|
|
270
|
-
...
|
|
271
|
-
}),
|
|
272
|
-
...
|
|
273
|
-
...
|
|
274
|
-
start:
|
|
275
|
-
...
|
|
276
|
-
...
|
|
277
|
-
circular:
|
|
278
|
-
} :
|
|
279
|
-
timing:
|
|
280
|
-
path:
|
|
281
|
-
rotation:
|
|
282
|
-
scale:
|
|
283
|
-
}),
|
|
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 = {
|
|
284
284
|
...$t,
|
|
285
|
-
...
|
|
286
|
-
})),
|
|
287
|
-
...
|
|
288
|
-
...
|
|
289
|
-
},
|
|
290
|
-
...
|
|
291
|
-
...
|
|
292
|
-
}),
|
|
293
|
-
...
|
|
294
|
-
...
|
|
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
295
|
})), s.ui = {
|
|
296
|
-
...
|
|
297
|
-
...
|
|
296
|
+
...L.ui,
|
|
297
|
+
...n.ui
|
|
298
298
|
}, s.config.debug = {
|
|
299
299
|
...Dt,
|
|
300
|
-
...
|
|
300
|
+
...n.config?.debug ?? {}
|
|
301
301
|
}, s.layout.algorithm === "honeycomb" && s.styling) {
|
|
302
302
|
const r = { shape: "hexagon", mode: "height-relative" };
|
|
303
303
|
s.styling = {
|
|
@@ -309,14 +309,14 @@ function ie(o = {}) {
|
|
|
309
309
|
}
|
|
310
310
|
return s;
|
|
311
311
|
}
|
|
312
|
-
function
|
|
313
|
-
return { ...
|
|
312
|
+
function oe(n, t) {
|
|
313
|
+
return { ...n ? Ct[n] : Ct.playful, ...t };
|
|
314
314
|
}
|
|
315
|
-
function
|
|
316
|
-
return { ...
|
|
315
|
+
function ne(n, t) {
|
|
316
|
+
return { ...n ? Rt[n] : Rt.gentle, ...t };
|
|
317
317
|
}
|
|
318
|
-
function se(
|
|
319
|
-
return { ...
|
|
318
|
+
function se(n, t) {
|
|
319
|
+
return { ...n ? Tt[n] : Tt.gentle, ...t };
|
|
320
320
|
}
|
|
321
321
|
class ae {
|
|
322
322
|
constructor(t) {
|
|
@@ -329,8 +329,8 @@ class ae {
|
|
|
329
329
|
buildTransformString(t) {
|
|
330
330
|
const i = ["translate(-50%, -50%)"];
|
|
331
331
|
if (t.x !== void 0 || t.y !== void 0) {
|
|
332
|
-
const e = t.x ?? 0,
|
|
333
|
-
i.push(`translate(${e}px, ${
|
|
332
|
+
const e = t.x ?? 0, o = t.y ?? 0;
|
|
333
|
+
i.push(`translate(${e}px, ${o}px)`);
|
|
334
334
|
}
|
|
335
335
|
return t.rotation !== void 0 && i.push(`rotate(${t.rotation}deg)`), t.scale !== void 0 && i.push(`scale(${t.scale})`), i.join(" ");
|
|
336
336
|
}
|
|
@@ -343,14 +343,14 @@ class ae {
|
|
|
343
343
|
* @param easing - CSS easing function (optional)
|
|
344
344
|
* @returns AnimationHandle that can be used to cancel or query the animation
|
|
345
345
|
*/
|
|
346
|
-
animateTransformCancellable(t, i, e,
|
|
346
|
+
animateTransformCancellable(t, i, e, o = null, s = null) {
|
|
347
347
|
this.cancelAllAnimations(t);
|
|
348
|
-
const r =
|
|
348
|
+
const r = o ?? this.config.duration, a = s ?? this.config.easing.default, c = this.buildTransformString(i), d = this.buildTransformString(e);
|
|
349
349
|
t.style.transition = "none";
|
|
350
350
|
const u = t.animate(
|
|
351
351
|
[
|
|
352
352
|
{ transform: c },
|
|
353
|
-
{ transform:
|
|
353
|
+
{ transform: d }
|
|
354
354
|
],
|
|
355
355
|
{
|
|
356
356
|
duration: r,
|
|
@@ -358,7 +358,7 @@ class ae {
|
|
|
358
358
|
fill: "forwards"
|
|
359
359
|
// Keep final state after animation
|
|
360
360
|
}
|
|
361
|
-
),
|
|
361
|
+
), f = {
|
|
362
362
|
id: `anim-${++this.animationIdCounter}`,
|
|
363
363
|
element: t,
|
|
364
364
|
animation: u,
|
|
@@ -367,11 +367,11 @@ class ae {
|
|
|
367
367
|
startTime: performance.now(),
|
|
368
368
|
duration: r
|
|
369
369
|
};
|
|
370
|
-
return this.activeAnimations.set(t,
|
|
371
|
-
t.style.transform =
|
|
370
|
+
return this.activeAnimations.set(t, f), u.finished.then(() => {
|
|
371
|
+
t.style.transform = d, this.activeAnimations.delete(t);
|
|
372
372
|
}).catch(() => {
|
|
373
373
|
this.activeAnimations.delete(t);
|
|
374
|
-
}),
|
|
374
|
+
}), f;
|
|
375
375
|
}
|
|
376
376
|
/**
|
|
377
377
|
* Cancel an active animation
|
|
@@ -382,13 +382,13 @@ class ae {
|
|
|
382
382
|
cancelAnimation(t, i = !0) {
|
|
383
383
|
const e = this.getCurrentTransform(t.element);
|
|
384
384
|
if (t.animation.cancel(), i) {
|
|
385
|
-
const
|
|
385
|
+
const o = this.buildTransformString({
|
|
386
386
|
x: e.x,
|
|
387
387
|
y: e.y,
|
|
388
388
|
rotation: e.rotation,
|
|
389
389
|
scale: e.scale
|
|
390
390
|
});
|
|
391
|
-
t.element.style.transform =
|
|
391
|
+
t.element.style.transform = o;
|
|
392
392
|
}
|
|
393
393
|
return this.activeAnimations.delete(t.element), e;
|
|
394
394
|
}
|
|
@@ -401,8 +401,8 @@ class ae {
|
|
|
401
401
|
const i = this.activeAnimations.get(t);
|
|
402
402
|
i && this.cancelAnimation(i, !1);
|
|
403
403
|
const e = t.getAnimations();
|
|
404
|
-
for (const
|
|
405
|
-
|
|
404
|
+
for (const o of e)
|
|
405
|
+
o.cancel();
|
|
406
406
|
}
|
|
407
407
|
/**
|
|
408
408
|
* Get current transform state of an element (works mid-animation)
|
|
@@ -414,7 +414,7 @@ class ae {
|
|
|
414
414
|
const e = getComputedStyle(t).transform;
|
|
415
415
|
if (e === "none" || !e)
|
|
416
416
|
return { x: 0, y: 0, rotation: 0, scale: 1 };
|
|
417
|
-
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;
|
|
418
418
|
return { x: a, y: c, rotation: r, scale: s };
|
|
419
419
|
}
|
|
420
420
|
/**
|
|
@@ -441,9 +441,9 @@ class ae {
|
|
|
441
441
|
* @param easing - CSS easing function (optional)
|
|
442
442
|
* @returns Promise that resolves when animation completes
|
|
443
443
|
*/
|
|
444
|
-
animateTransform(t, i, e = null,
|
|
444
|
+
animateTransform(t, i, e = null, o = null) {
|
|
445
445
|
return new Promise((s) => {
|
|
446
|
-
const r = e ?? this.config.duration, a =
|
|
446
|
+
const r = e ?? this.config.duration, a = o ?? this.config.easing.default;
|
|
447
447
|
t.style.transition = `transform ${r}ms ${a}, box-shadow ${r}ms ${a}`, t.style.transform = this.buildTransformString(i), setTimeout(() => {
|
|
448
448
|
s();
|
|
449
449
|
}, r);
|
|
@@ -474,159 +474,165 @@ class ae {
|
|
|
474
474
|
return new Promise((i) => setTimeout(i, t));
|
|
475
475
|
}
|
|
476
476
|
}
|
|
477
|
-
function
|
|
478
|
-
return
|
|
477
|
+
function J(n, t, i) {
|
|
478
|
+
return n + (t - n) * i;
|
|
479
479
|
}
|
|
480
|
-
function re(
|
|
481
|
-
const { overshoot:
|
|
482
|
-
let u = 0,
|
|
483
|
-
for (let
|
|
484
|
-
if (
|
|
485
|
-
|
|
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;
|
|
486
486
|
break;
|
|
487
487
|
}
|
|
488
|
-
const
|
|
489
|
-
if (
|
|
490
|
-
u = 1 +
|
|
491
|
-
else if (
|
|
492
|
-
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);
|
|
493
493
|
else {
|
|
494
|
-
const
|
|
495
|
-
(
|
|
496
|
-
)?.overshoot ||
|
|
497
|
-
u =
|
|
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));
|
|
498
498
|
}
|
|
499
499
|
return {
|
|
500
500
|
x: t.x + a * u,
|
|
501
501
|
y: t.y + c * u
|
|
502
502
|
};
|
|
503
503
|
}
|
|
504
|
-
function ce(
|
|
504
|
+
function ce(n, t) {
|
|
505
505
|
const i = [];
|
|
506
506
|
let e = 0.6;
|
|
507
507
|
i.push({ time: e, overshoot: 0, isOvershoot: !1 });
|
|
508
|
-
let
|
|
509
|
-
const r = 0.4 / (
|
|
510
|
-
for (let a = 0; a <
|
|
511
|
-
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;
|
|
512
512
|
return i.push({ time: 1, overshoot: 0, isOvershoot: !1 }), i;
|
|
513
513
|
}
|
|
514
|
-
function le(
|
|
515
|
-
const { stiffness:
|
|
516
|
-
let
|
|
517
|
-
if (
|
|
518
|
-
const
|
|
519
|
-
|
|
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;
|
|
520
520
|
} else
|
|
521
|
-
|
|
522
|
-
return
|
|
523
|
-
x: t.x + c *
|
|
524
|
-
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
|
|
525
525
|
};
|
|
526
526
|
}
|
|
527
|
-
function he(
|
|
528
|
-
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);
|
|
529
529
|
return {
|
|
530
|
-
x:
|
|
531
|
-
y:
|
|
530
|
+
x: J(t.x, i.x, g) + l * m,
|
|
531
|
+
y: J(t.y, i.y, g) + l * p
|
|
532
532
|
};
|
|
533
533
|
}
|
|
534
|
-
function at(
|
|
535
|
-
return 1 - (1 -
|
|
534
|
+
function at(n) {
|
|
535
|
+
return 1 - (1 - n) * (1 - n);
|
|
536
536
|
}
|
|
537
|
-
function de(
|
|
538
|
-
return 1 - Math.pow(1 -
|
|
537
|
+
function de(n) {
|
|
538
|
+
return 1 - Math.pow(1 - n, 3);
|
|
539
539
|
}
|
|
540
|
-
function ue(
|
|
541
|
-
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;
|
|
542
542
|
return t + c;
|
|
543
543
|
}
|
|
544
|
-
function fe(
|
|
545
|
-
const { overshoot: e, bounces:
|
|
544
|
+
function fe(n, t, i) {
|
|
545
|
+
const { overshoot: e, bounces: o } = i, s = [];
|
|
546
546
|
s.push({ time: 0.5, scale: e });
|
|
547
547
|
let r = e;
|
|
548
|
-
const a = 0.5,
|
|
548
|
+
const a = 0.5, d = 0.5 / (o * 2);
|
|
549
549
|
let u = 0.5;
|
|
550
|
-
for (let
|
|
551
|
-
const
|
|
552
|
-
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 });
|
|
553
553
|
}
|
|
554
554
|
s.push({ time: 1, scale: 1 });
|
|
555
|
-
let
|
|
556
|
-
for (let
|
|
557
|
-
if (
|
|
558
|
-
const
|
|
559
|
-
|
|
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;
|
|
560
560
|
break;
|
|
561
561
|
}
|
|
562
|
-
return
|
|
562
|
+
return f * t;
|
|
563
563
|
}
|
|
564
|
-
function ge(
|
|
564
|
+
function ge(n) {
|
|
565
565
|
const {
|
|
566
566
|
element: t,
|
|
567
567
|
startPosition: i,
|
|
568
568
|
endPosition: e,
|
|
569
|
-
pathConfig:
|
|
569
|
+
pathConfig: o,
|
|
570
570
|
duration: s,
|
|
571
571
|
imageWidth: r,
|
|
572
572
|
imageHeight: a,
|
|
573
573
|
rotation: c,
|
|
574
|
-
scale:
|
|
574
|
+
scale: d,
|
|
575
575
|
onComplete: u,
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
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)) {
|
|
582
583
|
u && u();
|
|
583
584
|
return;
|
|
584
585
|
}
|
|
585
|
-
const
|
|
586
|
-
function z(
|
|
587
|
-
const
|
|
588
|
-
let
|
|
589
|
-
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) {
|
|
590
591
|
case "bounce": {
|
|
591
|
-
const
|
|
592
|
-
|
|
593
|
-
|
|
592
|
+
const N = oe(
|
|
593
|
+
o.bouncePreset,
|
|
594
|
+
o.bounce
|
|
594
595
|
);
|
|
595
|
-
|
|
596
|
+
S = re(O, i, e, N);
|
|
596
597
|
break;
|
|
597
598
|
}
|
|
598
599
|
case "elastic": {
|
|
599
|
-
const
|
|
600
|
-
|
|
601
|
-
|
|
600
|
+
const N = ne(
|
|
601
|
+
o.elasticPreset,
|
|
602
|
+
o.elastic
|
|
602
603
|
);
|
|
603
|
-
|
|
604
|
+
S = le(O, i, e, N);
|
|
604
605
|
break;
|
|
605
606
|
}
|
|
606
607
|
case "wave": {
|
|
607
|
-
const
|
|
608
|
-
|
|
609
|
-
|
|
608
|
+
const N = se(
|
|
609
|
+
o.wavePreset,
|
|
610
|
+
o.wave
|
|
610
611
|
);
|
|
611
|
-
|
|
612
|
+
S = he(O, i, e, N);
|
|
612
613
|
break;
|
|
613
614
|
}
|
|
614
615
|
default:
|
|
615
|
-
|
|
616
|
-
x:
|
|
617
|
-
y:
|
|
616
|
+
S = {
|
|
617
|
+
x: J(i.x, e.x, O),
|
|
618
|
+
y: J(i.y, e.y, O)
|
|
618
619
|
};
|
|
619
620
|
}
|
|
620
|
-
const
|
|
621
|
-
let
|
|
622
|
-
|
|
623
|
-
let
|
|
624
|
-
|
|
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());
|
|
625
631
|
}
|
|
626
632
|
requestAnimationFrame(z);
|
|
627
633
|
}
|
|
628
|
-
function me(
|
|
629
|
-
return
|
|
634
|
+
function me(n) {
|
|
635
|
+
return n === "bounce" || n === "elastic" || n === "wave";
|
|
630
636
|
}
|
|
631
637
|
const pe = {
|
|
632
638
|
radial: "center",
|
|
@@ -639,7 +645,7 @@ const pe = {
|
|
|
639
645
|
};
|
|
640
646
|
class be {
|
|
641
647
|
constructor(t, i) {
|
|
642
|
-
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;
|
|
643
649
|
}
|
|
644
650
|
/**
|
|
645
651
|
* Get the effective start position, considering layout-aware defaults
|
|
@@ -650,7 +656,7 @@ class be {
|
|
|
650
656
|
/**
|
|
651
657
|
* Calculate the starting position for an image's entry animation
|
|
652
658
|
*/
|
|
653
|
-
calculateStartPosition(t, i, e,
|
|
659
|
+
calculateStartPosition(t, i, e, o, s) {
|
|
654
660
|
const r = this.resolvedStartPosition, a = this.config.start.offset ?? 100;
|
|
655
661
|
switch (r) {
|
|
656
662
|
case "nearest-edge":
|
|
@@ -672,7 +678,7 @@ class be {
|
|
|
672
678
|
t,
|
|
673
679
|
i,
|
|
674
680
|
e,
|
|
675
|
-
|
|
681
|
+
o,
|
|
676
682
|
s
|
|
677
683
|
);
|
|
678
684
|
default:
|
|
@@ -682,28 +688,28 @@ class be {
|
|
|
682
688
|
/**
|
|
683
689
|
* Calculate start position from the nearest edge (current default behavior)
|
|
684
690
|
*/
|
|
685
|
-
calculateNearestEdge(t, i, e,
|
|
686
|
-
const s = t.x, r = t.y, a = s, c = e.width - s,
|
|
687
|
-
let
|
|
688
|
-
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 };
|
|
689
695
|
}
|
|
690
696
|
/**
|
|
691
697
|
* Calculate start position from a specific edge
|
|
692
698
|
*/
|
|
693
|
-
calculateEdgePosition(t, i, e,
|
|
699
|
+
calculateEdgePosition(t, i, e, o, s) {
|
|
694
700
|
let r = i.x, a = i.y;
|
|
695
701
|
switch (t) {
|
|
696
702
|
case "top":
|
|
697
703
|
a = -(e.height + s);
|
|
698
704
|
break;
|
|
699
705
|
case "bottom":
|
|
700
|
-
a =
|
|
706
|
+
a = o.height + s;
|
|
701
707
|
break;
|
|
702
708
|
case "left":
|
|
703
709
|
r = -(e.width + s);
|
|
704
710
|
break;
|
|
705
711
|
case "right":
|
|
706
|
-
r =
|
|
712
|
+
r = o.width + s;
|
|
707
713
|
break;
|
|
708
714
|
}
|
|
709
715
|
return { x: r, y: a };
|
|
@@ -712,9 +718,9 @@ class be {
|
|
|
712
718
|
* Calculate start position from center with scale animation
|
|
713
719
|
*/
|
|
714
720
|
calculateCenterPosition(t, i, e) {
|
|
715
|
-
const
|
|
721
|
+
const o = t.width / 2, s = t.height / 2;
|
|
716
722
|
return {
|
|
717
|
-
x:
|
|
723
|
+
x: o,
|
|
718
724
|
y: s,
|
|
719
725
|
useScale: !0
|
|
720
726
|
// Signal to use scale animation from 0
|
|
@@ -723,28 +729,28 @@ class be {
|
|
|
723
729
|
/**
|
|
724
730
|
* Calculate start position from a random edge
|
|
725
731
|
*/
|
|
726
|
-
calculateRandomEdge(t, i, e,
|
|
732
|
+
calculateRandomEdge(t, i, e, o) {
|
|
727
733
|
const s = ["top", "bottom", "left", "right"], r = s[Math.floor(Math.random() * s.length)];
|
|
728
|
-
return this.calculateEdgePosition(r, t, i, e,
|
|
734
|
+
return this.calculateEdgePosition(r, t, i, e, o);
|
|
729
735
|
}
|
|
730
736
|
/**
|
|
731
737
|
* Calculate start position on a circle around the container
|
|
732
738
|
*/
|
|
733
|
-
calculateCircularPosition(t, i, e,
|
|
739
|
+
calculateCircularPosition(t, i, e, o, s) {
|
|
734
740
|
const r = this.config.start.circular || {}, a = r.distribution || "even";
|
|
735
741
|
let c;
|
|
736
|
-
const
|
|
737
|
-
if (typeof
|
|
738
|
-
const
|
|
742
|
+
const d = r.radius || "120%";
|
|
743
|
+
if (typeof d == "string" && d.endsWith("%")) {
|
|
744
|
+
const v = parseFloat(d) / 100;
|
|
739
745
|
c = Math.sqrt(
|
|
740
746
|
e.width ** 2 + e.height ** 2
|
|
741
|
-
) *
|
|
747
|
+
) * v / 2;
|
|
742
748
|
} else
|
|
743
|
-
c = typeof
|
|
749
|
+
c = typeof d == "number" ? d : 500;
|
|
744
750
|
let u;
|
|
745
|
-
a === "even" ? u =
|
|
746
|
-
const
|
|
747
|
-
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 };
|
|
748
754
|
}
|
|
749
755
|
/**
|
|
750
756
|
* Get animation parameters for an image
|
|
@@ -763,17 +769,17 @@ class be {
|
|
|
763
769
|
* Build a CSS transform string for the start position
|
|
764
770
|
* Uses pixel-based centering offset for reliable cross-browser behavior
|
|
765
771
|
*/
|
|
766
|
-
buildStartTransform(t, i, e,
|
|
767
|
-
const
|
|
768
|
-
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})`;
|
|
769
775
|
}
|
|
770
776
|
/**
|
|
771
777
|
* Build the final CSS transform string
|
|
772
778
|
* Uses pixel-based centering offset for reliable cross-browser behavior
|
|
773
779
|
*/
|
|
774
|
-
buildFinalTransform(t, i, e,
|
|
775
|
-
if (e !== void 0 &&
|
|
776
|
-
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;
|
|
777
783
|
return `translate(${s}px, ${r}px) rotate(${t}deg) scale(${i})`;
|
|
778
784
|
}
|
|
779
785
|
return `translate(-50%, -50%) rotate(${t}deg) scale(${i})`;
|
|
@@ -839,12 +845,12 @@ class be {
|
|
|
839
845
|
return t + (Math.random() - 0.5) * 60;
|
|
840
846
|
if (typeof e == "number")
|
|
841
847
|
return e;
|
|
842
|
-
const
|
|
843
|
-
return e.min + Math.random() *
|
|
848
|
+
const o = e.max - e.min;
|
|
849
|
+
return e.min + Math.random() * o;
|
|
844
850
|
}
|
|
845
851
|
case "spin": {
|
|
846
|
-
const e = this.rotationConfig.spinCount ?? 1,
|
|
847
|
-
return t + e * 360 *
|
|
852
|
+
const e = this.rotationConfig.spinCount ?? 1, o = this.resolveSpinDirection(t);
|
|
853
|
+
return t + e * 360 * o;
|
|
848
854
|
}
|
|
849
855
|
case "random":
|
|
850
856
|
return t + (Math.random() - 0.5) * 60;
|
|
@@ -892,8 +898,8 @@ class be {
|
|
|
892
898
|
amplitude: 15,
|
|
893
899
|
frequency: 3,
|
|
894
900
|
decay: !0
|
|
895
|
-
}, { amplitude:
|
|
896
|
-
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;
|
|
897
903
|
}
|
|
898
904
|
/**
|
|
899
905
|
* Get the scale configuration
|
|
@@ -949,12 +955,12 @@ class be {
|
|
|
949
955
|
const e = this.scaleConfig.pop || {
|
|
950
956
|
overshoot: 1.2,
|
|
951
957
|
bounces: 1
|
|
952
|
-
}, { overshoot:
|
|
958
|
+
}, { overshoot: o, bounces: s } = e, r = this.generateScaleBounceKeyframes(s, o);
|
|
953
959
|
let a = i;
|
|
954
960
|
for (let c = 0; c < r.length; c++)
|
|
955
961
|
if (t <= r[c].time) {
|
|
956
|
-
const
|
|
957
|
-
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;
|
|
958
964
|
break;
|
|
959
965
|
}
|
|
960
966
|
return a * i;
|
|
@@ -965,12 +971,12 @@ class be {
|
|
|
965
971
|
generateScaleBounceKeyframes(t, i) {
|
|
966
972
|
const e = [];
|
|
967
973
|
e.push({ time: 0.5, scale: i });
|
|
968
|
-
let
|
|
974
|
+
let o = i;
|
|
969
975
|
const s = 0.5, a = 0.5 / (t * 2);
|
|
970
976
|
let c = 0.5;
|
|
971
|
-
for (let
|
|
972
|
-
const u = 1 - (
|
|
973
|
-
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 });
|
|
974
980
|
}
|
|
975
981
|
return e.push({ time: 1, scale: 1 }), e;
|
|
976
982
|
}
|
|
@@ -989,9 +995,9 @@ class ye {
|
|
|
989
995
|
* Register an image element for idle animation.
|
|
990
996
|
* Starts animation after entry duration completes.
|
|
991
997
|
*/
|
|
992
|
-
register(t, i, e,
|
|
998
|
+
register(t, i, e, o) {
|
|
993
999
|
if (this.entries.has(t)) return;
|
|
994
|
-
const s =
|
|
1000
|
+
const s = o ?? this.entryDurationMs, r = this.config.startDelay ?? s, a = {
|
|
995
1001
|
element: t,
|
|
996
1002
|
index: i,
|
|
997
1003
|
totalImages: e,
|
|
@@ -1066,7 +1072,7 @@ class ye {
|
|
|
1066
1072
|
}
|
|
1067
1073
|
}
|
|
1068
1074
|
_startWiggle(t) {
|
|
1069
|
-
const i = { ...
|
|
1075
|
+
const i = { ...Jt, ...this.config.wiggle }, e = [
|
|
1070
1076
|
{ transform: "rotate(0deg)", offset: 0 },
|
|
1071
1077
|
{ transform: `rotate(${i.maxAngle}deg)`, offset: 0.25 },
|
|
1072
1078
|
{ transform: "rotate(0deg)", offset: 0.5 },
|
|
@@ -1106,23 +1112,23 @@ class ye {
|
|
|
1106
1112
|
});
|
|
1107
1113
|
}
|
|
1108
1114
|
_startBlink(t) {
|
|
1109
|
-
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;
|
|
1110
1116
|
let s, r;
|
|
1111
1117
|
i.style === "fade" ? (s = [
|
|
1112
|
-
{ opacity:
|
|
1118
|
+
{ opacity: o, offset: 0 },
|
|
1113
1119
|
{ opacity: 0, offset: 0.5 },
|
|
1114
|
-
{ opacity:
|
|
1120
|
+
{ opacity: o, offset: 1 }
|
|
1115
1121
|
], r = {
|
|
1116
1122
|
duration: i.speed,
|
|
1117
1123
|
delay: e,
|
|
1118
1124
|
iterations: 1 / 0,
|
|
1119
1125
|
easing: "ease-in-out"
|
|
1120
1126
|
}) : (s = [
|
|
1121
|
-
{ opacity:
|
|
1122
|
-
{ opacity:
|
|
1127
|
+
{ opacity: o, offset: 0 },
|
|
1128
|
+
{ opacity: o, offset: i.onRatio },
|
|
1123
1129
|
{ opacity: 0, offset: Math.min(i.onRatio + 0.01, 0.99) },
|
|
1124
1130
|
{ opacity: 0, offset: 0.99 },
|
|
1125
|
-
{ opacity:
|
|
1131
|
+
{ opacity: o, offset: 1 }
|
|
1126
1132
|
], r = {
|
|
1127
1133
|
duration: i.speed,
|
|
1128
1134
|
delay: e,
|
|
@@ -1151,8 +1157,8 @@ class ye {
|
|
|
1151
1157
|
if (this.togetherSpeed = t, this.togetherRafId !== null) return;
|
|
1152
1158
|
const i = () => {
|
|
1153
1159
|
const e = performance.now() % this.togetherSpeed;
|
|
1154
|
-
for (const
|
|
1155
|
-
!
|
|
1160
|
+
for (const o of this.entries.values())
|
|
1161
|
+
!o.stopped && !o.paused && o.animation && (o.animation.currentTime = e);
|
|
1156
1162
|
this.togetherRafId = requestAnimationFrame(i);
|
|
1157
1163
|
};
|
|
1158
1164
|
this.togetherRafId = requestAnimationFrame(i);
|
|
@@ -1179,19 +1185,19 @@ class ve {
|
|
|
1179
1185
|
* @returns Array of layout objects with position, rotation, scale
|
|
1180
1186
|
*/
|
|
1181
1187
|
generate(t, i, e = {}) {
|
|
1182
|
-
const
|
|
1183
|
-
for (let
|
|
1184
|
-
const
|
|
1185
|
-
id:
|
|
1186
|
-
x:
|
|
1187
|
-
y:
|
|
1188
|
-
rotation:
|
|
1189
|
-
scale:
|
|
1190
|
-
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
|
|
1191
1197
|
};
|
|
1192
|
-
|
|
1198
|
+
o.push(z);
|
|
1193
1199
|
}
|
|
1194
|
-
return
|
|
1200
|
+
return o;
|
|
1195
1201
|
}
|
|
1196
1202
|
/**
|
|
1197
1203
|
* Utility: Generate random number between min and max
|
|
@@ -1203,7 +1209,7 @@ class ve {
|
|
|
1203
1209
|
return Math.random() * (i - t) + t;
|
|
1204
1210
|
}
|
|
1205
1211
|
}
|
|
1206
|
-
class
|
|
1212
|
+
class xe {
|
|
1207
1213
|
constructor(t, i = {}) {
|
|
1208
1214
|
this.config = t, this.imageConfig = i;
|
|
1209
1215
|
}
|
|
@@ -1215,55 +1221,55 @@ class Ee {
|
|
|
1215
1221
|
* @returns Array of layout objects with position, rotation, scale
|
|
1216
1222
|
*/
|
|
1217
1223
|
generate(t, i, e = {}) {
|
|
1218
|
-
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 = {
|
|
1219
1225
|
...Wt,
|
|
1220
1226
|
...this.config.radial
|
|
1221
|
-
},
|
|
1222
|
-
|
|
1223
|
-
|
|
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
|
|
1224
1230
|
));
|
|
1225
1231
|
if (t > 0) {
|
|
1226
|
-
const
|
|
1227
|
-
|
|
1232
|
+
const F = p ? this.random(f, m) : 1, R = l * F;
|
|
1233
|
+
o.push({
|
|
1228
1234
|
id: 0,
|
|
1229
|
-
x:
|
|
1230
|
-
y,
|
|
1231
|
-
rotation: c === "random" ? this.random(
|
|
1235
|
+
x: g,
|
|
1236
|
+
y: h,
|
|
1237
|
+
rotation: c === "random" ? this.random(d * 0.33, u * 0.33) : 0,
|
|
1232
1238
|
// Less rotation for center
|
|
1233
|
-
scale:
|
|
1234
|
-
baseSize:
|
|
1239
|
+
scale: F,
|
|
1240
|
+
baseSize: R,
|
|
1235
1241
|
zIndex: 100
|
|
1236
1242
|
// Center image is highest
|
|
1237
1243
|
});
|
|
1238
1244
|
}
|
|
1239
|
-
let
|
|
1240
|
-
for (;
|
|
1241
|
-
const
|
|
1242
|
-
if (
|
|
1243
|
-
|
|
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++;
|
|
1244
1250
|
continue;
|
|
1245
1251
|
}
|
|
1246
|
-
const
|
|
1247
|
-
for (let
|
|
1248
|
-
const
|
|
1249
|
-
let
|
|
1250
|
-
const
|
|
1251
|
-
|
|
1252
|
-
const
|
|
1253
|
-
|
|
1254
|
-
id:
|
|
1255
|
-
x:
|
|
1256
|
-
y:
|
|
1257
|
-
rotation:
|
|
1258
|
-
scale:
|
|
1259
|
-
baseSize:
|
|
1260
|
-
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)
|
|
1261
1267
|
// Outer rings have lower z-index
|
|
1262
|
-
}),
|
|
1268
|
+
}), x++;
|
|
1263
1269
|
}
|
|
1264
|
-
|
|
1270
|
+
E++;
|
|
1265
1271
|
}
|
|
1266
|
-
return
|
|
1272
|
+
return o;
|
|
1267
1273
|
}
|
|
1268
1274
|
/**
|
|
1269
1275
|
* Estimate image width based on height
|
|
@@ -1284,7 +1290,7 @@ class Ee {
|
|
|
1284
1290
|
return Math.random() * (i - t) + t;
|
|
1285
1291
|
}
|
|
1286
1292
|
}
|
|
1287
|
-
const
|
|
1293
|
+
const Ee = {
|
|
1288
1294
|
columns: "auto",
|
|
1289
1295
|
rows: "auto",
|
|
1290
1296
|
stagger: "none",
|
|
@@ -1294,7 +1300,7 @@ const we = {
|
|
|
1294
1300
|
alignment: "center",
|
|
1295
1301
|
gap: 10,
|
|
1296
1302
|
overflowOffset: 0.25
|
|
1297
|
-
},
|
|
1303
|
+
}, At = [
|
|
1298
1304
|
{ x: 1, y: 1 },
|
|
1299
1305
|
// bottom-right
|
|
1300
1306
|
{ x: -1, y: -1 },
|
|
@@ -1312,7 +1318,7 @@ const we = {
|
|
|
1312
1318
|
{ x: 0, y: 1 }
|
|
1313
1319
|
// down
|
|
1314
1320
|
];
|
|
1315
|
-
class
|
|
1321
|
+
class we {
|
|
1316
1322
|
constructor(t, i = {}) {
|
|
1317
1323
|
this.config = t, this.imageConfig = i;
|
|
1318
1324
|
}
|
|
@@ -1324,73 +1330,73 @@ class xe {
|
|
|
1324
1330
|
* @returns Array of layout objects with position, rotation, scale
|
|
1325
1331
|
*/
|
|
1326
1332
|
generate(t, i, e = {}) {
|
|
1327
|
-
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(
|
|
1328
1334
|
t,
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1335
|
+
w,
|
|
1336
|
+
v,
|
|
1337
|
+
d,
|
|
1332
1338
|
a
|
|
1333
|
-
),
|
|
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 > _;
|
|
1334
1340
|
typeof window < "u" && (window.__gridOverflowDebug = {
|
|
1335
1341
|
gridConfigColumns: a.columns,
|
|
1336
1342
|
gridConfigRows: a.rows,
|
|
1337
|
-
columns:
|
|
1338
|
-
rows:
|
|
1339
|
-
cellCount:
|
|
1340
|
-
hasFixedGrid:
|
|
1343
|
+
columns: l,
|
|
1344
|
+
rows: g,
|
|
1345
|
+
cellCount: _,
|
|
1346
|
+
hasFixedGrid: $,
|
|
1341
1347
|
imageCount: t,
|
|
1342
|
-
isOverflowMode:
|
|
1348
|
+
isOverflowMode: A
|
|
1343
1349
|
});
|
|
1344
|
-
const
|
|
1345
|
-
for (let
|
|
1346
|
-
let
|
|
1347
|
-
if (
|
|
1348
|
-
const
|
|
1349
|
-
|
|
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));
|
|
1350
1356
|
} else
|
|
1351
|
-
a.fillDirection === "row" ? (
|
|
1352
|
-
let
|
|
1353
|
-
if (a.stagger === "row" &&
|
|
1354
|
-
const
|
|
1355
|
-
|
|
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;
|
|
1356
1362
|
}
|
|
1357
1363
|
if (a.jitter > 0) {
|
|
1358
|
-
const
|
|
1359
|
-
|
|
1364
|
+
const q = x / 2 * a.jitter, G = E / 2 * a.jitter;
|
|
1365
|
+
B += this.random(-q, q), W += this.random(-G, G);
|
|
1360
1366
|
}
|
|
1361
|
-
let
|
|
1362
|
-
if (!
|
|
1363
|
-
const
|
|
1364
|
-
if (
|
|
1365
|
-
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;
|
|
1366
1372
|
let gt = 0;
|
|
1367
|
-
a.alignment === "center" ? gt = (
|
|
1373
|
+
a.alignment === "center" ? gt = (k - It) / 2 : a.alignment === "end" && (gt = k - It), X += gt;
|
|
1368
1374
|
}
|
|
1369
1375
|
}
|
|
1370
|
-
const ct =
|
|
1371
|
-
|
|
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));
|
|
1372
1378
|
let ut = 0;
|
|
1373
1379
|
if (u === "random") {
|
|
1374
|
-
const
|
|
1375
|
-
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);
|
|
1376
1382
|
}
|
|
1377
1383
|
let ft;
|
|
1378
|
-
|
|
1379
|
-
id:
|
|
1380
|
-
x:
|
|
1381
|
-
y:
|
|
1384
|
+
A && Y > 0 ? ft = 50 - Y : ft = A ? 100 + P : P + 1, o.push({
|
|
1385
|
+
id: P,
|
|
1386
|
+
x: X,
|
|
1387
|
+
y: V,
|
|
1382
1388
|
rotation: ut,
|
|
1383
1389
|
scale: ct,
|
|
1384
1390
|
baseSize: K,
|
|
1385
1391
|
zIndex: ft
|
|
1386
1392
|
});
|
|
1387
1393
|
}
|
|
1388
|
-
return
|
|
1394
|
+
return o;
|
|
1389
1395
|
}
|
|
1390
1396
|
/**
|
|
1391
1397
|
* Calculate optimal grid dimensions based on image count and container
|
|
1392
1398
|
*/
|
|
1393
|
-
calculateGridDimensions(t, i, e,
|
|
1399
|
+
calculateGridDimensions(t, i, e, o, s) {
|
|
1394
1400
|
let r, a;
|
|
1395
1401
|
if (s.columns !== "auto" && s.rows !== "auto")
|
|
1396
1402
|
r = s.columns, a = s.rows;
|
|
@@ -1412,7 +1418,7 @@ class xe {
|
|
|
1412
1418
|
return Math.random() * (i - t) + t;
|
|
1413
1419
|
}
|
|
1414
1420
|
}
|
|
1415
|
-
const
|
|
1421
|
+
const Ie = Math.PI * (3 - Math.sqrt(5)), Se = {
|
|
1416
1422
|
spiralType: "golden",
|
|
1417
1423
|
direction: "counterclockwise",
|
|
1418
1424
|
tightness: 1,
|
|
@@ -1431,80 +1437,80 @@ class Ce {
|
|
|
1431
1437
|
* @returns Array of layout objects with position, rotation, scale
|
|
1432
1438
|
*/
|
|
1433
1439
|
generate(t, i, e = {}) {
|
|
1434
|
-
const
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
),
|
|
1438
|
-
for (let
|
|
1439
|
-
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;
|
|
1440
1446
|
if (a.spiralType === "golden")
|
|
1441
|
-
|
|
1447
|
+
x = y * Ie * I + a.startAngle, E = this.calculateGoldenRadius(y, t, b, a.tightness);
|
|
1442
1448
|
else if (a.spiralType === "archimedean") {
|
|
1443
|
-
const
|
|
1444
|
-
|
|
1449
|
+
const B = y * 0.5 * a.tightness;
|
|
1450
|
+
x = B * I + a.startAngle, E = this.calculateArchimedeanRadius(B, t, b, a.tightness);
|
|
1445
1451
|
} else {
|
|
1446
|
-
const
|
|
1447
|
-
|
|
1452
|
+
const B = y * 0.3 * a.tightness;
|
|
1453
|
+
x = B * I + a.startAngle, E = this.calculateLogarithmicRadius(B, t, b, a.tightness);
|
|
1448
1454
|
}
|
|
1449
|
-
const
|
|
1450
|
-
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;
|
|
1451
1457
|
if (u === "random") {
|
|
1452
|
-
const
|
|
1453
|
-
|
|
1454
|
-
} else u === "tangent" && (
|
|
1455
|
-
const
|
|
1456
|
-
|
|
1457
|
-
id:
|
|
1458
|
-
x:
|
|
1459
|
-
y:
|
|
1460
|
-
rotation:
|
|
1461
|
-
scale:
|
|
1462
|
-
baseSize:
|
|
1463
|
-
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
|
|
1464
1470
|
});
|
|
1465
1471
|
}
|
|
1466
|
-
return
|
|
1472
|
+
return o;
|
|
1467
1473
|
}
|
|
1468
1474
|
/**
|
|
1469
1475
|
* Calculate tangent angle for spiral curve at given position
|
|
1470
1476
|
* This aligns the image along the spiral's direction of travel
|
|
1471
1477
|
*/
|
|
1472
1478
|
calculateSpiralTangent(t, i, e) {
|
|
1473
|
-
let
|
|
1479
|
+
let o;
|
|
1474
1480
|
if (e.spiralType === "golden")
|
|
1475
|
-
|
|
1481
|
+
o = t + Math.PI / 2;
|
|
1476
1482
|
else if (e.spiralType === "archimedean") {
|
|
1477
1483
|
const r = 1 / e.tightness, a = Math.atan(i / r);
|
|
1478
|
-
|
|
1484
|
+
o = t + a;
|
|
1479
1485
|
} else {
|
|
1480
1486
|
const r = 0.15 / e.tightness, a = Math.atan(1 / r);
|
|
1481
|
-
|
|
1487
|
+
o = t + a;
|
|
1482
1488
|
}
|
|
1483
|
-
return
|
|
1489
|
+
return o * 180 / Math.PI % 360 - 90;
|
|
1484
1490
|
}
|
|
1485
1491
|
/**
|
|
1486
1492
|
* Calculate radius for golden spiral (Vogel's model)
|
|
1487
1493
|
* Creates even distribution like sunflower seeds
|
|
1488
1494
|
*/
|
|
1489
|
-
calculateGoldenRadius(t, i, e,
|
|
1490
|
-
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;
|
|
1491
1497
|
return Math.min(r, e);
|
|
1492
1498
|
}
|
|
1493
1499
|
/**
|
|
1494
1500
|
* Calculate radius for Archimedean spiral
|
|
1495
1501
|
* r = a + b*θ (constant spacing between arms)
|
|
1496
1502
|
*/
|
|
1497
|
-
calculateArchimedeanRadius(t, i, e,
|
|
1498
|
-
const s = i * 0.5 *
|
|
1503
|
+
calculateArchimedeanRadius(t, i, e, o) {
|
|
1504
|
+
const s = i * 0.5 * o;
|
|
1499
1505
|
return t / s * e;
|
|
1500
1506
|
}
|
|
1501
1507
|
/**
|
|
1502
1508
|
* Calculate radius for logarithmic (equiangular) spiral
|
|
1503
1509
|
* r = a * e^(b*θ)
|
|
1504
1510
|
*/
|
|
1505
|
-
calculateLogarithmicRadius(t, i, e,
|
|
1506
|
-
const s = e * 0.05, r = 0.15 /
|
|
1507
|
-
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;
|
|
1508
1514
|
}
|
|
1509
1515
|
/**
|
|
1510
1516
|
* Utility: Generate random number between min and max
|
|
@@ -1513,7 +1519,7 @@ class Ce {
|
|
|
1513
1519
|
return Math.random() * (i - t) + t;
|
|
1514
1520
|
}
|
|
1515
1521
|
}
|
|
1516
|
-
const
|
|
1522
|
+
const Re = {
|
|
1517
1523
|
clusterCount: "auto",
|
|
1518
1524
|
clusterSpread: 150,
|
|
1519
1525
|
clusterSpacing: 200,
|
|
@@ -1521,7 +1527,7 @@ const Ae = {
|
|
|
1521
1527
|
overlap: 0.3,
|
|
1522
1528
|
distribution: "gaussian"
|
|
1523
1529
|
};
|
|
1524
|
-
class
|
|
1530
|
+
class Te {
|
|
1525
1531
|
constructor(t, i = {}) {
|
|
1526
1532
|
this.config = t, this.imageConfig = i;
|
|
1527
1533
|
}
|
|
@@ -1533,85 +1539,85 @@ class Re {
|
|
|
1533
1539
|
* @returns Array of layout objects with position, rotation, scale
|
|
1534
1540
|
*/
|
|
1535
1541
|
generate(t, i, e = {}) {
|
|
1536
|
-
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(
|
|
1537
1543
|
t,
|
|
1538
1544
|
a.clusterCount,
|
|
1539
1545
|
s,
|
|
1540
1546
|
r,
|
|
1541
1547
|
a.clusterSpacing
|
|
1542
|
-
),
|
|
1543
|
-
|
|
1548
|
+
), g = this.generateClusterCenters(
|
|
1549
|
+
l,
|
|
1544
1550
|
s,
|
|
1545
1551
|
r,
|
|
1546
1552
|
c,
|
|
1547
1553
|
a
|
|
1548
|
-
),
|
|
1549
|
-
for (let
|
|
1550
|
-
|
|
1551
|
-
let
|
|
1552
|
-
for (let
|
|
1553
|
-
const
|
|
1554
|
-
for (let
|
|
1555
|
-
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;
|
|
1556
1562
|
if (a.distribution === "gaussian")
|
|
1557
|
-
|
|
1563
|
+
F = this.gaussianRandom() * y.spread, R = this.gaussianRandom() * y.spread;
|
|
1558
1564
|
else {
|
|
1559
|
-
const
|
|
1560
|
-
|
|
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;
|
|
1561
1567
|
}
|
|
1562
|
-
const
|
|
1563
|
-
|
|
1564
|
-
const
|
|
1565
|
-
let
|
|
1566
|
-
const
|
|
1567
|
-
|
|
1568
|
-
const
|
|
1569
|
-
|
|
1570
|
-
id:
|
|
1571
|
-
x:
|
|
1572
|
-
y:
|
|
1573
|
-
rotation:
|
|
1574
|
-
scale:
|
|
1575
|
-
baseSize:
|
|
1576
|
-
zIndex:
|
|
1577
|
-
}),
|
|
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++;
|
|
1578
1584
|
}
|
|
1579
1585
|
}
|
|
1580
|
-
return
|
|
1586
|
+
return o;
|
|
1581
1587
|
}
|
|
1582
1588
|
/**
|
|
1583
1589
|
* Calculate optimal number of clusters based on image count and container
|
|
1584
1590
|
*/
|
|
1585
|
-
calculateClusterCount(t, i, e,
|
|
1591
|
+
calculateClusterCount(t, i, e, o, s) {
|
|
1586
1592
|
if (i !== "auto")
|
|
1587
1593
|
return Math.max(1, Math.min(i, t));
|
|
1588
1594
|
const a = Math.max(1, Math.ceil(t / 8)), c = Math.floor(
|
|
1589
|
-
e / s * (
|
|
1595
|
+
e / s * (o / s) * 0.6
|
|
1590
1596
|
);
|
|
1591
1597
|
return Math.max(1, Math.min(a, c, 10));
|
|
1592
1598
|
}
|
|
1593
1599
|
/**
|
|
1594
1600
|
* Generate cluster center positions with spacing constraints
|
|
1595
1601
|
*/
|
|
1596
|
-
generateClusterCenters(t, i, e,
|
|
1597
|
-
const r = [], c =
|
|
1598
|
-
for (let
|
|
1599
|
-
let
|
|
1600
|
-
for (let
|
|
1601
|
-
const
|
|
1602
|
-
x: this.random(c,
|
|
1603
|
-
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),
|
|
1604
1610
|
spread: this.calculateClusterSpread(s)
|
|
1605
1611
|
};
|
|
1606
|
-
let
|
|
1607
|
-
for (const
|
|
1608
|
-
const
|
|
1609
|
-
|
|
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);
|
|
1610
1616
|
}
|
|
1611
|
-
if ((r.length === 0 ||
|
|
1617
|
+
if ((r.length === 0 || g > w) && (p = l, w = g), g >= s.clusterSpacing)
|
|
1612
1618
|
break;
|
|
1613
1619
|
}
|
|
1614
|
-
|
|
1620
|
+
p && r.push(p);
|
|
1615
1621
|
}
|
|
1616
1622
|
return r;
|
|
1617
1623
|
}
|
|
@@ -1639,7 +1645,7 @@ class Re {
|
|
|
1639
1645
|
return Math.random() * (i - t) + t;
|
|
1640
1646
|
}
|
|
1641
1647
|
}
|
|
1642
|
-
class
|
|
1648
|
+
class Ae {
|
|
1643
1649
|
constructor(t, i = {}) {
|
|
1644
1650
|
this.config = t, this.imageConfig = i;
|
|
1645
1651
|
}
|
|
@@ -1651,32 +1657,32 @@ class Te {
|
|
|
1651
1657
|
* @returns Array of layout objects with position, rotation, scale
|
|
1652
1658
|
*/
|
|
1653
1659
|
generate(t, i, e = {}) {
|
|
1654
|
-
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 = {
|
|
1655
1661
|
...Gt,
|
|
1656
1662
|
...this.config.wave
|
|
1657
|
-
}, { rows:
|
|
1658
|
-
let
|
|
1659
|
-
for (let
|
|
1660
|
-
const
|
|
1661
|
-
let
|
|
1662
|
-
|
|
1663
|
-
for (let
|
|
1664
|
-
const
|
|
1665
|
-
let
|
|
1666
|
-
|
|
1667
|
-
const K =
|
|
1668
|
-
|
|
1669
|
-
id:
|
|
1670
|
-
x: Math.max(
|
|
1671
|
-
y: Math.max(ht, Math.min(
|
|
1672
|
-
rotation:
|
|
1673
|
-
scale:
|
|
1674
|
-
baseSize:
|
|
1675
|
-
zIndex:
|
|
1676
|
-
}),
|
|
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;
|
|
1671
|
+
let V = 0;
|
|
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)),
|
|
1678
|
+
rotation: V,
|
|
1679
|
+
scale: W,
|
|
1680
|
+
baseSize: X,
|
|
1681
|
+
zIndex: $ + 1
|
|
1682
|
+
}), $++;
|
|
1677
1683
|
}
|
|
1678
1684
|
}
|
|
1679
|
-
return
|
|
1685
|
+
return o;
|
|
1680
1686
|
}
|
|
1681
1687
|
/**
|
|
1682
1688
|
* Calculate Y position displacement on wave curve
|
|
@@ -1687,9 +1693,9 @@ class Te {
|
|
|
1687
1693
|
* @param phase - Phase offset
|
|
1688
1694
|
* @returns Y displacement from baseline
|
|
1689
1695
|
*/
|
|
1690
|
-
calculateWaveY(t, i, e,
|
|
1696
|
+
calculateWaveY(t, i, e, o, s) {
|
|
1691
1697
|
const r = t / i;
|
|
1692
|
-
return e * Math.sin(
|
|
1698
|
+
return e * Math.sin(o * r * 2 * Math.PI + s);
|
|
1693
1699
|
}
|
|
1694
1700
|
/**
|
|
1695
1701
|
* Calculate rotation based on wave tangent
|
|
@@ -1700,8 +1706,8 @@ class Te {
|
|
|
1700
1706
|
* @param phase - Phase offset
|
|
1701
1707
|
* @returns Rotation angle in degrees
|
|
1702
1708
|
*/
|
|
1703
|
-
calculateRotation(t, i, e,
|
|
1704
|
-
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;
|
|
1705
1711
|
return Math.atan(a) * (180 / Math.PI);
|
|
1706
1712
|
}
|
|
1707
1713
|
/**
|
|
@@ -1716,7 +1722,7 @@ class Te {
|
|
|
1716
1722
|
return Math.random() * (i - t) + t;
|
|
1717
1723
|
}
|
|
1718
1724
|
}
|
|
1719
|
-
const
|
|
1725
|
+
const Et = 100, Q = 100 / Math.sqrt(3), wt = [
|
|
1720
1726
|
[Q / 2, 0],
|
|
1721
1727
|
// upper-left
|
|
1722
1728
|
[3 * Q / 2, 0],
|
|
@@ -1729,18 +1735,18 @@ const wt = 100, Q = 100 / Math.sqrt(3), xt = [
|
|
|
1729
1735
|
// lower-left
|
|
1730
1736
|
[0, 50]
|
|
1731
1737
|
// left
|
|
1732
|
-
], Le =
|
|
1733
|
-
function
|
|
1738
|
+
], Le = wt[1][0] / Et, Fe = wt[2][1] / Et;
|
|
1739
|
+
function Me(n) {
|
|
1734
1740
|
return {
|
|
1735
|
-
colStep: Le *
|
|
1736
|
-
rowOffset:
|
|
1741
|
+
colStep: Le * n,
|
|
1742
|
+
rowOffset: Fe * n
|
|
1737
1743
|
};
|
|
1738
1744
|
}
|
|
1739
|
-
function Oe(
|
|
1740
|
-
const { colStep: r } =
|
|
1745
|
+
function Oe(n, t, i, e, o, s) {
|
|
1746
|
+
const { colStep: r } = Me(s);
|
|
1741
1747
|
return {
|
|
1742
|
-
px: e + r *
|
|
1743
|
-
py:
|
|
1748
|
+
px: e + r * n,
|
|
1749
|
+
py: o + s * (t + n / 2)
|
|
1744
1750
|
};
|
|
1745
1751
|
}
|
|
1746
1752
|
const ze = [
|
|
@@ -1751,13 +1757,13 @@ const ze = [
|
|
|
1751
1757
|
[0, -1, 1],
|
|
1752
1758
|
[1, -1, 0]
|
|
1753
1759
|
];
|
|
1754
|
-
function De(
|
|
1755
|
-
if (
|
|
1760
|
+
function De(n) {
|
|
1761
|
+
if (n === 0) return [[0, 0, 0]];
|
|
1756
1762
|
const t = [];
|
|
1757
|
-
let [i, e,
|
|
1763
|
+
let [i, e, o] = [0, -n, n];
|
|
1758
1764
|
for (const [s, r, a] of ze)
|
|
1759
|
-
for (let c = 0; c <
|
|
1760
|
-
t.push([i, e,
|
|
1765
|
+
for (let c = 0; c < n; c++)
|
|
1766
|
+
t.push([i, e, o]), i += s, e += r, o += a;
|
|
1761
1767
|
return t;
|
|
1762
1768
|
}
|
|
1763
1769
|
class $e {
|
|
@@ -1767,30 +1773,30 @@ class $e {
|
|
|
1767
1773
|
this.config = t;
|
|
1768
1774
|
}
|
|
1769
1775
|
generate(t, i, e = {}) {
|
|
1770
|
-
const
|
|
1776
|
+
const o = [], { width: s, height: r } = i, a = s / 2, c = r / 2, d = e.fixedHeight ?? 200, f = {
|
|
1771
1777
|
...qt,
|
|
1772
1778
|
...this.config.honeycomb
|
|
1773
|
-
}.spacing ?? 0,
|
|
1774
|
-
let
|
|
1775
|
-
for (;
|
|
1776
|
-
const
|
|
1777
|
-
for (const [
|
|
1778
|
-
if (
|
|
1779
|
-
const { px:
|
|
1780
|
-
|
|
1781
|
-
id:
|
|
1782
|
-
x:
|
|
1783
|
-
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,
|
|
1784
1790
|
rotation: 0,
|
|
1785
1791
|
scale: 1,
|
|
1786
|
-
baseSize:
|
|
1792
|
+
baseSize: d,
|
|
1787
1793
|
// Inner rings render above outer rings
|
|
1788
|
-
zIndex: Math.max(1, 100 -
|
|
1789
|
-
}),
|
|
1794
|
+
zIndex: Math.max(1, 100 - w)
|
|
1795
|
+
}), p++;
|
|
1790
1796
|
}
|
|
1791
|
-
|
|
1797
|
+
w++;
|
|
1792
1798
|
}
|
|
1793
|
-
return
|
|
1799
|
+
return o;
|
|
1794
1800
|
}
|
|
1795
1801
|
}
|
|
1796
1802
|
class Pe {
|
|
@@ -1804,15 +1810,15 @@ class Pe {
|
|
|
1804
1810
|
initLayout() {
|
|
1805
1811
|
switch (this.config.algorithm) {
|
|
1806
1812
|
case "radial":
|
|
1807
|
-
return new Ee(this.config, this.imageConfig);
|
|
1808
|
-
case "grid":
|
|
1809
1813
|
return new xe(this.config, this.imageConfig);
|
|
1814
|
+
case "grid":
|
|
1815
|
+
return new we(this.config, this.imageConfig);
|
|
1810
1816
|
case "spiral":
|
|
1811
1817
|
return new Ce(this.config, this.imageConfig);
|
|
1812
1818
|
case "cluster":
|
|
1813
|
-
return new Re(this.config, this.imageConfig);
|
|
1814
|
-
case "wave":
|
|
1815
1819
|
return new Te(this.config, this.imageConfig);
|
|
1820
|
+
case "wave":
|
|
1821
|
+
return new Ae(this.config, this.imageConfig);
|
|
1816
1822
|
case "honeycomb":
|
|
1817
1823
|
return new $e(this.config, this.imageConfig);
|
|
1818
1824
|
default:
|
|
@@ -1827,10 +1833,10 @@ class Pe {
|
|
|
1827
1833
|
* @returns Array of layout objects with position, rotation, scale
|
|
1828
1834
|
*/
|
|
1829
1835
|
generateLayout(t, i, e = {}) {
|
|
1830
|
-
const
|
|
1831
|
-
return
|
|
1836
|
+
const o = this.placementLayout.generate(t, i, e);
|
|
1837
|
+
return o.forEach((s) => {
|
|
1832
1838
|
this.layouts.set(s.id, s);
|
|
1833
|
-
}),
|
|
1839
|
+
}), o;
|
|
1834
1840
|
}
|
|
1835
1841
|
/**
|
|
1836
1842
|
* Get the original layout state for an image
|
|
@@ -1883,8 +1889,8 @@ class Pe {
|
|
|
1883
1889
|
return;
|
|
1884
1890
|
if (typeof e == "number")
|
|
1885
1891
|
return e;
|
|
1886
|
-
const
|
|
1887
|
-
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;
|
|
1888
1894
|
}
|
|
1889
1895
|
/**
|
|
1890
1896
|
* Calculate adaptive image size based on container dimensions and image count
|
|
@@ -1894,19 +1900,19 @@ class Pe {
|
|
|
1894
1900
|
* @param viewportWidth - Current viewport width for baseHeight resolution
|
|
1895
1901
|
* @returns Calculated sizing result with height
|
|
1896
1902
|
*/
|
|
1897
|
-
calculateAdaptiveSize(t, i, e,
|
|
1898
|
-
const s = this.imageConfig.sizing, r = this.resolveBaseHeight(
|
|
1903
|
+
calculateAdaptiveSize(t, i, e, o) {
|
|
1904
|
+
const s = this.imageConfig.sizing, r = this.resolveBaseHeight(o);
|
|
1899
1905
|
if (r !== void 0)
|
|
1900
1906
|
return { height: r };
|
|
1901
|
-
const a = s?.minSize ?? 50, c = s?.maxSize ?? 400,
|
|
1902
|
-
let
|
|
1903
|
-
|
|
1904
|
-
let
|
|
1905
|
-
if (
|
|
1906
|
-
const
|
|
1907
|
-
|
|
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);
|
|
1908
1914
|
}
|
|
1909
|
-
return this.config.algorithm === "honeycomb" && (
|
|
1915
|
+
return this.config.algorithm === "honeycomb" && (h = Math.min(h, this.honeycombMaxImageHeight(i, t))), { height: h };
|
|
1910
1916
|
}
|
|
1911
1917
|
/**
|
|
1912
1918
|
* Returns the largest image height at which all honeycomb rings fit within the container.
|
|
@@ -1915,11 +1921,11 @@ class Pe {
|
|
|
1915
1921
|
*/
|
|
1916
1922
|
honeycombMaxImageHeight(t, i) {
|
|
1917
1923
|
if (t <= 1) return 1 / 0;
|
|
1918
|
-
let e = 0,
|
|
1919
|
-
for (;
|
|
1920
|
-
e++,
|
|
1921
|
-
const s = this.config.spacing?.padding ?? 50, r = this.config.honeycomb?.spacing ?? 0, a = i.width / 2, c = i.height / 2,
|
|
1922
|
-
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));
|
|
1923
1929
|
}
|
|
1924
1930
|
/**
|
|
1925
1931
|
* Utility: Clamp a value between min and max
|
|
@@ -1928,7 +1934,7 @@ class Pe {
|
|
|
1928
1934
|
return Math.max(i, Math.min(e, t));
|
|
1929
1935
|
}
|
|
1930
1936
|
}
|
|
1931
|
-
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 || {});
|
|
1932
1938
|
const Lt = {
|
|
1933
1939
|
// Geometric shapes - uses percentages for responsive sizing
|
|
1934
1940
|
circle: "circle(50%)",
|
|
@@ -1962,8 +1968,8 @@ const Lt = {
|
|
|
1962
1968
|
},
|
|
1963
1969
|
// Hexagon - regular hexagon (reference points imported from hexagonGeometry)
|
|
1964
1970
|
hexagon: {
|
|
1965
|
-
refHeight:
|
|
1966
|
-
points:
|
|
1971
|
+
refHeight: Et,
|
|
1972
|
+
points: wt
|
|
1967
1973
|
},
|
|
1968
1974
|
// Octagon - regular octagon
|
|
1969
1975
|
octagon: {
|
|
@@ -1976,105 +1982,105 @@ const Lt = {
|
|
|
1976
1982
|
points: [[50, 0], [100, 50], [50, 100], [0, 50]]
|
|
1977
1983
|
}
|
|
1978
1984
|
};
|
|
1979
|
-
function Ue(
|
|
1980
|
-
if (
|
|
1981
|
-
return
|
|
1985
|
+
function Ue(n) {
|
|
1986
|
+
if (n)
|
|
1987
|
+
return n in Lt ? Lt[n] : n;
|
|
1982
1988
|
}
|
|
1983
|
-
function
|
|
1984
|
-
const e = _e[
|
|
1989
|
+
function ke(n, t, i) {
|
|
1990
|
+
const e = _e[n];
|
|
1985
1991
|
if (!e) return "";
|
|
1986
|
-
const
|
|
1987
|
-
if (
|
|
1988
|
-
return `circle(${Math.round(50 *
|
|
1989
|
-
const s = e.points.map(([
|
|
1990
|
-
return `polygon(${e.points.map(([
|
|
1991
|
-
const
|
|
1992
|
-
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`;
|
|
1993
1999
|
}).join(", ")})`;
|
|
1994
2000
|
}
|
|
1995
|
-
function
|
|
1996
|
-
return
|
|
2001
|
+
function He(n) {
|
|
2002
|
+
return n in mt;
|
|
1997
2003
|
}
|
|
1998
|
-
function
|
|
1999
|
-
return
|
|
2004
|
+
function Ne(n) {
|
|
2005
|
+
return n ? He(n) ? mt[n] : n : mt.md;
|
|
2000
2006
|
}
|
|
2001
|
-
function Be(
|
|
2002
|
-
if (!
|
|
2007
|
+
function Be(n) {
|
|
2008
|
+
if (!n) return "";
|
|
2003
2009
|
const t = [];
|
|
2004
|
-
if (
|
|
2005
|
-
if (typeof
|
|
2006
|
-
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})`);
|
|
2007
2013
|
else {
|
|
2008
|
-
const i =
|
|
2014
|
+
const i = n.dropShadow;
|
|
2009
2015
|
t.push(`drop-shadow(${i.x}px ${i.y}px ${i.blur}px ${i.color})`);
|
|
2010
2016
|
}
|
|
2011
2017
|
return t.join(" ");
|
|
2012
2018
|
}
|
|
2013
|
-
function tt(
|
|
2014
|
-
if (!
|
|
2019
|
+
function tt(n) {
|
|
2020
|
+
if (!n || n.style === "none" || n.width === 0)
|
|
2015
2021
|
return "none";
|
|
2016
|
-
const t =
|
|
2022
|
+
const t = n.width ?? 0, i = n.style ?? "solid", e = n.color ?? "#000000";
|
|
2017
2023
|
return `${t}px ${i} ${e}`;
|
|
2018
2024
|
}
|
|
2019
|
-
function it(
|
|
2020
|
-
if (!
|
|
2025
|
+
function it(n, t, i) {
|
|
2026
|
+
if (!n) return {};
|
|
2021
2027
|
const e = {};
|
|
2022
|
-
if (
|
|
2023
|
-
const a =
|
|
2024
|
-
|
|
2025
|
-
} else
|
|
2026
|
-
if (
|
|
2027
|
-
const a =
|
|
2028
|
-
e.borderTop = tt(c), e.borderRight = tt(
|
|
2029
|
-
} else
|
|
2030
|
-
|
|
2031
|
-
const r = Be(
|
|
2032
|
-
if (e.filter = r || "none",
|
|
2033
|
-
const a =
|
|
2034
|
-
e.outline = `${a}px ${c} ${
|
|
2035
|
-
}
|
|
2036
|
-
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) {
|
|
2037
2043
|
let a;
|
|
2038
|
-
const c = typeof
|
|
2039
|
-
if (
|
|
2040
|
-
a =
|
|
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);
|
|
2041
2047
|
else {
|
|
2042
|
-
const u = c &&
|
|
2048
|
+
const u = c && d ? d.shape : n.clipPath;
|
|
2043
2049
|
a = Ue(u);
|
|
2044
2050
|
}
|
|
2045
2051
|
a && (a === "none" ? e.clipPath = "unset" : (e.clipPath = a, e.overflow = "hidden"));
|
|
2046
2052
|
}
|
|
2047
2053
|
return e;
|
|
2048
2054
|
}
|
|
2049
|
-
function je(
|
|
2050
|
-
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);
|
|
2051
2057
|
}
|
|
2052
|
-
function st(
|
|
2053
|
-
const
|
|
2054
|
-
je(
|
|
2058
|
+
function st(n, t, i, e) {
|
|
2059
|
+
const o = it(t, i, e);
|
|
2060
|
+
je(n, o);
|
|
2055
2061
|
}
|
|
2056
|
-
function Pt(
|
|
2057
|
-
return
|
|
2062
|
+
function Pt(n) {
|
|
2063
|
+
return n ? Array.isArray(n) ? n.join(" ") : n : "";
|
|
2058
2064
|
}
|
|
2059
|
-
function et(
|
|
2065
|
+
function et(n, t) {
|
|
2060
2066
|
const i = Pt(t);
|
|
2061
2067
|
i && i.split(" ").forEach((e) => {
|
|
2062
|
-
e.trim() &&
|
|
2068
|
+
e.trim() && n.classList.add(e.trim());
|
|
2063
2069
|
});
|
|
2064
2070
|
}
|
|
2065
|
-
function pt(
|
|
2071
|
+
function pt(n, t) {
|
|
2066
2072
|
const i = Pt(t);
|
|
2067
2073
|
i && i.split(" ").forEach((e) => {
|
|
2068
|
-
e.trim() &&
|
|
2074
|
+
e.trim() && n.classList.remove(e.trim());
|
|
2069
2075
|
});
|
|
2070
2076
|
}
|
|
2071
|
-
const
|
|
2077
|
+
const Ft = {
|
|
2072
2078
|
UNFOCUSING: 999,
|
|
2073
2079
|
FOCUSING: 1e3
|
|
2074
2080
|
};
|
|
2075
2081
|
class We {
|
|
2076
2082
|
constructor(t, i, e) {
|
|
2077
|
-
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;
|
|
2078
2084
|
}
|
|
2079
2085
|
/**
|
|
2080
2086
|
* Set callback to be fired when an unfocus animation fully completes.
|
|
@@ -2092,7 +2098,7 @@ class We {
|
|
|
2092
2098
|
* Check if any animation is in progress
|
|
2093
2099
|
*/
|
|
2094
2100
|
isAnimating() {
|
|
2095
|
-
return this.state !==
|
|
2101
|
+
return this.state !== C.IDLE && this.state !== C.FOCUSED;
|
|
2096
2102
|
}
|
|
2097
2103
|
/**
|
|
2098
2104
|
* Normalize scalePercent value
|
|
@@ -2105,17 +2111,17 @@ class We {
|
|
|
2105
2111
|
* Returns actual pixel dimensions instead of scale factor for sharper rendering
|
|
2106
2112
|
*/
|
|
2107
2113
|
calculateFocusDimensions(t, i, e) {
|
|
2108
|
-
const
|
|
2114
|
+
const o = this.normalizeScalePercent(this.config.scalePercent), s = e.height * o, r = t / i;
|
|
2109
2115
|
let a = s, c = a * r;
|
|
2110
|
-
const
|
|
2111
|
-
return c >
|
|
2116
|
+
const d = e.width * o;
|
|
2117
|
+
return c > d && (c = d, a = c / r), { width: c, height: a };
|
|
2112
2118
|
}
|
|
2113
2119
|
/**
|
|
2114
2120
|
* Calculate the transform needed to center an image (position only, no scale)
|
|
2115
2121
|
* Scale is handled by animating actual dimensions for sharper rendering
|
|
2116
2122
|
*/
|
|
2117
2123
|
calculateFocusTransform(t, i) {
|
|
2118
|
-
const e = t.width / 2,
|
|
2124
|
+
const e = t.width / 2, o = t.height / 2, s = e - i.x, r = o - i.y;
|
|
2119
2125
|
return {
|
|
2120
2126
|
x: s,
|
|
2121
2127
|
y: r,
|
|
@@ -2130,8 +2136,8 @@ class We {
|
|
|
2130
2136
|
buildDimensionZoomTransform(t) {
|
|
2131
2137
|
const i = ["translate(-50%, -50%)"];
|
|
2132
2138
|
if (t.x !== void 0 || t.y !== void 0) {
|
|
2133
|
-
const e = t.x ?? 0,
|
|
2134
|
-
i.push(`translate(${e}px, ${
|
|
2139
|
+
const e = t.x ?? 0, o = t.y ?? 0;
|
|
2140
|
+
i.push(`translate(${e}px, ${o}px)`);
|
|
2135
2141
|
}
|
|
2136
2142
|
return t.rotation !== void 0 && i.push(`rotate(${t.rotation}deg)`), i.join(" ");
|
|
2137
2143
|
}
|
|
@@ -2139,13 +2145,13 @@ class We {
|
|
|
2139
2145
|
* Create a Web Animation that animates both transform (position) and dimensions
|
|
2140
2146
|
* This provides sharper zoom by re-rendering at target size instead of scaling pixels
|
|
2141
2147
|
*/
|
|
2142
|
-
animateWithDimensions(t, i, e,
|
|
2143
|
-
const
|
|
2148
|
+
animateWithDimensions(t, i, e, o, s, r, a, c) {
|
|
2149
|
+
const d = this.buildDimensionZoomTransform(i), u = this.buildDimensionZoomTransform(e);
|
|
2144
2150
|
return t.style.transition = "none", t.animate(
|
|
2145
2151
|
[
|
|
2146
2152
|
{
|
|
2147
|
-
transform:
|
|
2148
|
-
width: `${
|
|
2153
|
+
transform: d,
|
|
2154
|
+
width: `${o}px`,
|
|
2149
2155
|
height: `${s}px`
|
|
2150
2156
|
},
|
|
2151
2157
|
{
|
|
@@ -2186,10 +2192,10 @@ class We {
|
|
|
2186
2192
|
* This ensures clip-path changes smoothly as width/height animate
|
|
2187
2193
|
*/
|
|
2188
2194
|
startClipPathAnimation(t, i, e) {
|
|
2189
|
-
let
|
|
2190
|
-
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 });
|
|
2191
2197
|
const s = () => {
|
|
2192
|
-
const r = t.offsetHeight, a = t.offsetWidth, c = it(
|
|
2198
|
+
const r = t.offsetHeight, a = t.offsetWidth, c = it(o, r, a);
|
|
2193
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);
|
|
2194
2200
|
};
|
|
2195
2201
|
requestAnimationFrame(s);
|
|
@@ -2200,34 +2206,34 @@ class We {
|
|
|
2200
2206
|
* @param fromTransform - Optional starting transform (for mid-animation reversals)
|
|
2201
2207
|
* @param fromDimensions - Optional starting dimensions (for mid-animation reversals)
|
|
2202
2208
|
*/
|
|
2203
|
-
startFocusAnimation(t, i, e,
|
|
2204
|
-
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);
|
|
2205
2211
|
this.animationEngine.cancelAllAnimations(t);
|
|
2206
|
-
const
|
|
2207
|
-
this.applyFocusedStyling(t,
|
|
2208
|
-
const
|
|
2212
|
+
const f = this.config.animationDuration ?? 600;
|
|
2213
|
+
this.applyFocusedStyling(t, Ft.FOCUSING);
|
|
2214
|
+
const m = o ?? {
|
|
2209
2215
|
x: 0,
|
|
2210
2216
|
y: 0,
|
|
2211
2217
|
rotation: e.rotation,
|
|
2212
2218
|
scale: 1
|
|
2213
2219
|
// No scale - using dimensions
|
|
2214
|
-
},
|
|
2220
|
+
}, p = s?.width ?? a, w = s?.height ?? c, v = this.animateWithDimensions(
|
|
2215
2221
|
t,
|
|
2216
|
-
|
|
2222
|
+
m,
|
|
2217
2223
|
u,
|
|
2218
|
-
g,
|
|
2219
2224
|
p,
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2225
|
+
w,
|
|
2226
|
+
d.width,
|
|
2227
|
+
d.height,
|
|
2228
|
+
f
|
|
2229
|
+
), l = {
|
|
2224
2230
|
id: `focus-${Date.now()}`,
|
|
2225
2231
|
element: t,
|
|
2226
|
-
animation:
|
|
2227
|
-
fromState:
|
|
2232
|
+
animation: v,
|
|
2233
|
+
fromState: m,
|
|
2228
2234
|
toState: u,
|
|
2229
2235
|
startTime: performance.now(),
|
|
2230
|
-
duration:
|
|
2236
|
+
duration: f
|
|
2231
2237
|
};
|
|
2232
2238
|
return this.focusData = {
|
|
2233
2239
|
element: t,
|
|
@@ -2236,12 +2242,12 @@ class We {
|
|
|
2236
2242
|
originalZIndex: r,
|
|
2237
2243
|
originalWidth: a,
|
|
2238
2244
|
originalHeight: c,
|
|
2239
|
-
focusWidth:
|
|
2240
|
-
focusHeight:
|
|
2241
|
-
}, this.startClipPathAnimation(t,
|
|
2245
|
+
focusWidth: d.width,
|
|
2246
|
+
focusHeight: d.height
|
|
2247
|
+
}, this.startClipPathAnimation(t, l, !0), {
|
|
2242
2248
|
element: t,
|
|
2243
2249
|
originalState: e,
|
|
2244
|
-
animationHandle:
|
|
2250
|
+
animationHandle: l,
|
|
2245
2251
|
direction: "in",
|
|
2246
2252
|
originalWidth: a,
|
|
2247
2253
|
originalHeight: c
|
|
@@ -2252,41 +2258,41 @@ class We {
|
|
|
2252
2258
|
* Animates back to original dimensions for consistent behavior
|
|
2253
2259
|
* @param fromDimensions - Optional starting dimensions (for mid-animation reversals)
|
|
2254
2260
|
*/
|
|
2255
|
-
startUnfocusAnimation(t, i, e,
|
|
2256
|
-
t.style.zIndex = String(
|
|
2261
|
+
startUnfocusAnimation(t, i, e, o) {
|
|
2262
|
+
t.style.zIndex = String(Ft.UNFOCUSING), this.animationEngine.cancelAllAnimations(t);
|
|
2257
2263
|
const s = this.config.animationDuration ?? 600;
|
|
2258
2264
|
t.classList.remove("fbn-ic-focused"), pt(t, this.focusedClassName);
|
|
2259
|
-
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 = {
|
|
2260
2266
|
x: 0,
|
|
2261
2267
|
y: 0,
|
|
2262
2268
|
rotation: i.rotation,
|
|
2263
2269
|
scale: 1
|
|
2264
2270
|
// No scale - using dimensions
|
|
2265
|
-
}, u = this.focusData?.originalWidth ?? t.offsetWidth,
|
|
2271
|
+
}, u = this.focusData?.originalWidth ?? t.offsetWidth, f = this.focusData?.originalHeight ?? t.offsetHeight, m = this.animateWithDimensions(
|
|
2266
2272
|
t,
|
|
2267
2273
|
r,
|
|
2268
|
-
|
|
2274
|
+
d,
|
|
2269
2275
|
a,
|
|
2270
2276
|
c,
|
|
2271
2277
|
u,
|
|
2272
|
-
|
|
2278
|
+
f,
|
|
2273
2279
|
s
|
|
2274
|
-
),
|
|
2280
|
+
), p = {
|
|
2275
2281
|
id: `unfocus-${Date.now()}`,
|
|
2276
2282
|
element: t,
|
|
2277
|
-
animation:
|
|
2283
|
+
animation: m,
|
|
2278
2284
|
fromState: r,
|
|
2279
|
-
toState:
|
|
2285
|
+
toState: d,
|
|
2280
2286
|
startTime: performance.now(),
|
|
2281
2287
|
duration: s
|
|
2282
2288
|
};
|
|
2283
|
-
return this.startClipPathAnimation(t,
|
|
2289
|
+
return this.startClipPathAnimation(t, p, !1), {
|
|
2284
2290
|
element: t,
|
|
2285
2291
|
originalState: i,
|
|
2286
|
-
animationHandle:
|
|
2292
|
+
animationHandle: p,
|
|
2287
2293
|
direction: "out",
|
|
2288
2294
|
originalWidth: u,
|
|
2289
|
-
originalHeight:
|
|
2295
|
+
originalHeight: f
|
|
2290
2296
|
};
|
|
2291
2297
|
}
|
|
2292
2298
|
/**
|
|
@@ -2304,10 +2310,10 @@ class We {
|
|
|
2304
2310
|
* Caller is responsible for calling animationEngine.cancelAllAnimations() afterwards.
|
|
2305
2311
|
*/
|
|
2306
2312
|
captureMidAnimationState(t) {
|
|
2307
|
-
const i = getComputedStyle(t), e = new DOMMatrix(i.transform),
|
|
2308
|
-
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", {
|
|
2309
2315
|
transform: { x: r, y: a, rotation: c, scale: 1 },
|
|
2310
|
-
dimensions: { width:
|
|
2316
|
+
dimensions: { width: o, height: s }
|
|
2311
2317
|
};
|
|
2312
2318
|
}
|
|
2313
2319
|
/**
|
|
@@ -2322,71 +2328,71 @@ class We {
|
|
|
2322
2328
|
/**
|
|
2323
2329
|
* Reset an element instantly to its original position and dimensions (no animation)
|
|
2324
2330
|
*/
|
|
2325
|
-
resetElementInstantly(t, i, e,
|
|
2331
|
+
resetElementInstantly(t, i, e, o, s) {
|
|
2326
2332
|
this.animationEngine.cancelAllAnimations(t);
|
|
2327
2333
|
const r = ["translate(-50%, -50%)"];
|
|
2328
|
-
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);
|
|
2329
2335
|
}
|
|
2330
2336
|
/**
|
|
2331
2337
|
* Focus (zoom) an image to center of container
|
|
2332
2338
|
* Implements cross-animation when swapping focus
|
|
2333
2339
|
*/
|
|
2334
2340
|
async focusImage(t, i, e) {
|
|
2335
|
-
if (this.currentFocus === t && this.state ===
|
|
2341
|
+
if (this.currentFocus === t && this.state === C.FOCUSED)
|
|
2336
2342
|
return this.unfocusImage();
|
|
2337
|
-
if (this.incoming?.element === t && this.state ===
|
|
2343
|
+
if (this.incoming?.element === t && this.state === C.FOCUSING) {
|
|
2338
2344
|
const { transform: s, dimensions: r } = this.captureMidAnimationState(t);
|
|
2339
2345
|
this.animationEngine.cancelAllAnimations(t), this.outgoing = this.startUnfocusAnimation(
|
|
2340
2346
|
t,
|
|
2341
2347
|
this.incoming.originalState,
|
|
2342
2348
|
s,
|
|
2343
2349
|
r
|
|
2344
|
-
), 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;
|
|
2345
2351
|
return;
|
|
2346
2352
|
}
|
|
2347
|
-
const
|
|
2353
|
+
const o = ++this.focusGeneration;
|
|
2348
2354
|
switch (this.state) {
|
|
2349
|
-
case
|
|
2350
|
-
if (this.state =
|
|
2351
|
-
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;
|
|
2352
2358
|
break;
|
|
2353
|
-
case
|
|
2354
|
-
if (this.state =
|
|
2359
|
+
case C.FOCUSED:
|
|
2360
|
+
if (this.state = C.CROSS_ANIMATING, this.currentFocus && this.focusData && (this.outgoing = this.startUnfocusAnimation(
|
|
2355
2361
|
this.currentFocus,
|
|
2356
2362
|
this.focusData.originalState
|
|
2357
2363
|
)), this.incoming = this.startFocusAnimation(t, i, e), await Promise.all([
|
|
2358
2364
|
this.outgoing ? this.waitForAnimation(this.outgoing.animationHandle) : Promise.resolve(),
|
|
2359
2365
|
this.waitForAnimation(this.incoming.animationHandle)
|
|
2360
|
-
]), this.focusGeneration !==
|
|
2366
|
+
]), this.focusGeneration !== o)
|
|
2361
2367
|
return;
|
|
2362
2368
|
if (this.outgoing) {
|
|
2363
2369
|
const s = this.outgoing.element;
|
|
2364
2370
|
this.removeFocusedStyling(s, this.outgoing.originalState.zIndex?.toString() || ""), this.outgoing = null, this.onUnfocusComplete?.(s);
|
|
2365
2371
|
}
|
|
2366
|
-
this.currentFocus = t, this.incoming = null, this.state =
|
|
2372
|
+
this.currentFocus = t, this.incoming = null, this.state = C.FOCUSED;
|
|
2367
2373
|
break;
|
|
2368
|
-
case
|
|
2374
|
+
case C.FOCUSING:
|
|
2369
2375
|
if (this.incoming && (this.animationEngine.cancelAnimation(this.incoming.animationHandle, !1), this.resetElementInstantly(
|
|
2370
2376
|
this.incoming.element,
|
|
2371
2377
|
this.incoming.originalState,
|
|
2372
2378
|
this.focusData?.originalZIndex || "",
|
|
2373
2379
|
this.focusData?.originalWidth,
|
|
2374
2380
|
this.focusData?.originalHeight
|
|
2375
|
-
), this.incoming = null), this.incoming = this.startFocusAnimation(t, i, e), await this.waitForAnimation(this.incoming.animationHandle), this.focusGeneration !==
|
|
2376
|
-
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;
|
|
2377
2383
|
break;
|
|
2378
|
-
case
|
|
2379
|
-
if (this.state =
|
|
2384
|
+
case C.UNFOCUSING:
|
|
2385
|
+
if (this.state = C.CROSS_ANIMATING, this.incoming = this.startFocusAnimation(t, i, e), await Promise.all([
|
|
2380
2386
|
this.outgoing ? this.waitForAnimation(this.outgoing.animationHandle) : Promise.resolve(),
|
|
2381
2387
|
this.waitForAnimation(this.incoming.animationHandle)
|
|
2382
|
-
]), this.focusGeneration !==
|
|
2388
|
+
]), this.focusGeneration !== o) return;
|
|
2383
2389
|
if (this.outgoing) {
|
|
2384
2390
|
const s = this.outgoing.element;
|
|
2385
2391
|
this.removeFocusedStyling(s, this.outgoing.originalState.zIndex?.toString() || ""), this.outgoing = null, this.onUnfocusComplete?.(s);
|
|
2386
2392
|
}
|
|
2387
|
-
this.currentFocus = t, this.incoming = null, this.state =
|
|
2393
|
+
this.currentFocus = t, this.incoming = null, this.state = C.FOCUSED;
|
|
2388
2394
|
break;
|
|
2389
|
-
case
|
|
2395
|
+
case C.CROSS_ANIMATING:
|
|
2390
2396
|
if (this.incoming?.element === t)
|
|
2391
2397
|
return;
|
|
2392
2398
|
if (this.outgoing?.element === t) {
|
|
@@ -2404,12 +2410,12 @@ class We {
|
|
|
2404
2410
|
if (this.incoming = this.startFocusAnimation(t, i, e, s, r), await Promise.all([
|
|
2405
2411
|
this.outgoing ? this.waitForAnimation(this.outgoing.animationHandle) : Promise.resolve(),
|
|
2406
2412
|
this.waitForAnimation(this.incoming.animationHandle)
|
|
2407
|
-
]), this.focusGeneration !==
|
|
2413
|
+
]), this.focusGeneration !== o) return;
|
|
2408
2414
|
if (this.outgoing) {
|
|
2409
2415
|
const a = this.outgoing.element;
|
|
2410
2416
|
this.removeFocusedStyling(a, this.outgoing.originalState.zIndex?.toString() || ""), this.outgoing = null, this.onUnfocusComplete?.(a);
|
|
2411
2417
|
}
|
|
2412
|
-
this.currentFocus = t, this.incoming = null, this.state =
|
|
2418
|
+
this.currentFocus = t, this.incoming = null, this.state = C.FOCUSED;
|
|
2413
2419
|
return;
|
|
2414
2420
|
}
|
|
2415
2421
|
if (this.outgoing && (this.animationEngine.cancelAnimation(this.outgoing.animationHandle, !1), this.resetElementInstantly(
|
|
@@ -2430,12 +2436,12 @@ class We {
|
|
|
2430
2436
|
if (this.incoming = this.startFocusAnimation(t, i, e), await Promise.all([
|
|
2431
2437
|
this.outgoing ? this.waitForAnimation(this.outgoing.animationHandle) : Promise.resolve(),
|
|
2432
2438
|
this.waitForAnimation(this.incoming.animationHandle)
|
|
2433
|
-
]), this.focusGeneration !==
|
|
2439
|
+
]), this.focusGeneration !== o) return;
|
|
2434
2440
|
if (this.outgoing) {
|
|
2435
2441
|
const s = this.outgoing.element;
|
|
2436
2442
|
this.removeFocusedStyling(s, this.outgoing.originalState.zIndex?.toString() || ""), this.outgoing = null, this.onUnfocusComplete?.(s);
|
|
2437
2443
|
}
|
|
2438
|
-
this.currentFocus = t, this.incoming = null, this.state =
|
|
2444
|
+
this.currentFocus = t, this.incoming = null, this.state = C.FOCUSED;
|
|
2439
2445
|
break;
|
|
2440
2446
|
}
|
|
2441
2447
|
}
|
|
@@ -2443,24 +2449,24 @@ class We {
|
|
|
2443
2449
|
* Unfocus current image, returning it to original position
|
|
2444
2450
|
*/
|
|
2445
2451
|
async unfocusImage() {
|
|
2446
|
-
if (this.state ===
|
|
2452
|
+
if (this.state === C.UNFOCUSING)
|
|
2447
2453
|
return;
|
|
2448
2454
|
const t = ++this.focusGeneration;
|
|
2449
2455
|
if (!this.currentFocus || !this.focusData) {
|
|
2450
|
-
if (this.incoming && this.state ===
|
|
2456
|
+
if (this.incoming && this.state === C.FOCUSING) {
|
|
2451
2457
|
const { transform: s, dimensions: r } = this.captureMidAnimationState(this.incoming.element);
|
|
2452
2458
|
if (this.animationEngine.cancelAllAnimations(this.incoming.element), this.outgoing = this.startUnfocusAnimation(
|
|
2453
2459
|
this.incoming.element,
|
|
2454
2460
|
this.incoming.originalState,
|
|
2455
2461
|
s,
|
|
2456
2462
|
r
|
|
2457
|
-
), this.incoming = null, this.state =
|
|
2463
|
+
), this.incoming = null, this.state = C.UNFOCUSING, await this.waitForAnimation(this.outgoing.animationHandle), this.focusGeneration !== t) return;
|
|
2458
2464
|
const a = this.outgoing.element;
|
|
2459
|
-
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);
|
|
2460
2466
|
}
|
|
2461
2467
|
return;
|
|
2462
2468
|
}
|
|
2463
|
-
if (this.state ===
|
|
2469
|
+
if (this.state === C.CROSS_ANIMATING && this.incoming) {
|
|
2464
2470
|
const { transform: s, dimensions: r } = this.captureMidAnimationState(this.incoming.element);
|
|
2465
2471
|
this.animationEngine.cancelAllAnimations(this.incoming.element);
|
|
2466
2472
|
const a = this.startUnfocusAnimation(
|
|
@@ -2475,13 +2481,13 @@ class We {
|
|
|
2475
2481
|
]), this.focusGeneration !== t) return;
|
|
2476
2482
|
let c = null;
|
|
2477
2483
|
this.outgoing && (c = this.outgoing.element, this.removeFocusedStyling(c, this.outgoing.originalState.zIndex?.toString() || ""));
|
|
2478
|
-
const
|
|
2479
|
-
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);
|
|
2480
2486
|
return;
|
|
2481
2487
|
}
|
|
2482
|
-
this.state =
|
|
2483
|
-
const i = this.currentFocus, e = this.focusData.originalState,
|
|
2484
|
-
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));
|
|
2485
2491
|
}
|
|
2486
2492
|
/**
|
|
2487
2493
|
* Swap focus from current image to a new one (alias for focusImage with cross-animation)
|
|
@@ -2499,7 +2505,7 @@ class We {
|
|
|
2499
2505
|
* Check if an image is currently focused (stable state)
|
|
2500
2506
|
*/
|
|
2501
2507
|
isFocused(t) {
|
|
2502
|
-
return this.currentFocus === t && this.state ===
|
|
2508
|
+
return this.currentFocus === t && this.state === C.FOCUSED;
|
|
2503
2509
|
}
|
|
2504
2510
|
/**
|
|
2505
2511
|
* Check if an image is the target of current focus animation
|
|
@@ -2520,9 +2526,9 @@ class We {
|
|
|
2520
2526
|
* Used during swipe gestures for visual feedback
|
|
2521
2527
|
*/
|
|
2522
2528
|
setDragOffset(t) {
|
|
2523
|
-
if (!this.currentFocus || !this.focusData || this.state !==
|
|
2524
|
-
const i = this.currentFocus, e = this.focusData.focusTransform,
|
|
2525
|
-
|
|
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(" ");
|
|
2526
2532
|
}
|
|
2527
2533
|
/**
|
|
2528
2534
|
* Clear the drag offset, optionally animating back to center
|
|
@@ -2530,9 +2536,9 @@ class We {
|
|
|
2530
2536
|
* @param duration - Animation duration in ms (default 150)
|
|
2531
2537
|
*/
|
|
2532
2538
|
clearDragOffset(t, i = 150) {
|
|
2533
|
-
if (!this.currentFocus || !this.focusData || this.state !==
|
|
2534
|
-
const e = this.currentFocus,
|
|
2535
|
-
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)`);
|
|
2536
2542
|
const c = s.join(" ");
|
|
2537
2543
|
t ? (e.style.transition = `transform ${i}ms ease-out`, e.style.transform = c, setTimeout(() => {
|
|
2538
2544
|
this.currentFocus === e && (e.style.transition = "none");
|
|
@@ -2560,10 +2566,10 @@ class We {
|
|
|
2560
2566
|
this.focusData.originalZIndex,
|
|
2561
2567
|
this.focusData.originalWidth,
|
|
2562
2568
|
this.focusData.originalHeight
|
|
2563
|
-
), this.state =
|
|
2569
|
+
), this.state = C.IDLE, this.currentFocus = null, this.focusData = null, this.outgoing = null, this.incoming = null;
|
|
2564
2570
|
}
|
|
2565
2571
|
}
|
|
2566
|
-
const Ge = 50, qe = 0.5,
|
|
2572
|
+
const Ge = 50, qe = 0.5, Ye = 20, Xe = 0.3, Ve = 150, Je = 30, rt = class rt {
|
|
2567
2573
|
constructor(t, i) {
|
|
2568
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);
|
|
2569
2575
|
}
|
|
@@ -2607,23 +2613,23 @@ const Ge = 50, qe = 0.5, Xe = 20, Ye = 0.3, Je = 150, Ve = 30, rt = class rt {
|
|
|
2607
2613
|
}
|
|
2608
2614
|
handleTouchMove(t) {
|
|
2609
2615
|
if (!this.touchState || t.touches.length !== 1) return;
|
|
2610
|
-
const i = t.touches[0], e = i.clientX - this.touchState.startX,
|
|
2611
|
-
if (this.touchState.isHorizontalSwipe === null && Math.sqrt(e * e +
|
|
2612
|
-
const a = Math.atan2(Math.abs(
|
|
2613
|
-
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;
|
|
2614
2620
|
}
|
|
2615
2621
|
if (this.touchState.isHorizontalSwipe !== !1 && this.touchState.isHorizontalSwipe === !0) {
|
|
2616
2622
|
t.preventDefault(), this.touchState.isDragging = !0, this.touchState.currentX = i.clientX;
|
|
2617
|
-
const s = e *
|
|
2623
|
+
const s = e * Xe;
|
|
2618
2624
|
this.callbacks.onDragOffset(s);
|
|
2619
2625
|
}
|
|
2620
2626
|
}
|
|
2621
2627
|
handleTouchEnd(t) {
|
|
2622
2628
|
if (!this.touchState) return;
|
|
2623
2629
|
this.recentTouchTimestamp = Date.now();
|
|
2624
|
-
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);
|
|
2625
2631
|
let r = !1;
|
|
2626
|
-
this.touchState.isHorizontalSwipe === !0 && this.touchState.isDragging && (s >= Ge ||
|
|
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;
|
|
2627
2633
|
}
|
|
2628
2634
|
handleTouchCancel(t) {
|
|
2629
2635
|
this.touchState?.isDragging && this.callbacks.onDragEnd(!1), this.touchState = null;
|
|
@@ -2645,7 +2651,7 @@ class Ke {
|
|
|
2645
2651
|
for (const i of this.sources)
|
|
2646
2652
|
if ("folders" in i)
|
|
2647
2653
|
for (const e of i.folders) {
|
|
2648
|
-
const
|
|
2654
|
+
const o = i.recursive !== void 0 ? i.recursive : !0, s = await this.loadFromFolder(e, t, o);
|
|
2649
2655
|
this._discoveredUrls.push(...s);
|
|
2650
2656
|
}
|
|
2651
2657
|
else if ("files" in i) {
|
|
@@ -2691,9 +2697,9 @@ class Ke {
|
|
|
2691
2697
|
// Alternative format
|
|
2692
2698
|
];
|
|
2693
2699
|
for (const e of i) {
|
|
2694
|
-
const
|
|
2695
|
-
if (
|
|
2696
|
-
return
|
|
2700
|
+
const o = t.match(e);
|
|
2701
|
+
if (o && o[1])
|
|
2702
|
+
return o[1];
|
|
2697
2703
|
}
|
|
2698
2704
|
return null;
|
|
2699
2705
|
}
|
|
@@ -2705,15 +2711,15 @@ class Ke {
|
|
|
2705
2711
|
* @returns Promise resolving to array of image URLs
|
|
2706
2712
|
*/
|
|
2707
2713
|
async loadFromFolder(t, i, e = !0) {
|
|
2708
|
-
const
|
|
2709
|
-
if (!
|
|
2714
|
+
const o = this.extractFolderId(t);
|
|
2715
|
+
if (!o)
|
|
2710
2716
|
throw new Error("Invalid Google Drive folder URL. Please check the URL format.");
|
|
2711
2717
|
if (!this.apiKey || this.apiKey === "YOUR_API_KEY_HERE")
|
|
2712
|
-
return this.loadImagesDirectly(
|
|
2718
|
+
return this.loadImagesDirectly(o, i);
|
|
2713
2719
|
try {
|
|
2714
|
-
return e ? await this.loadImagesRecursively(
|
|
2720
|
+
return e ? await this.loadImagesRecursively(o, i) : await this.loadImagesFromSingleFolder(o, i);
|
|
2715
2721
|
} catch (s) {
|
|
2716
|
-
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);
|
|
2717
2723
|
}
|
|
2718
2724
|
}
|
|
2719
2725
|
/**
|
|
@@ -2723,13 +2729,13 @@ class Ke {
|
|
|
2723
2729
|
* @returns Promise resolving to array of image URLs
|
|
2724
2730
|
*/
|
|
2725
2731
|
async loadImagesFromSingleFolder(t, i) {
|
|
2726
|
-
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);
|
|
2727
2733
|
if (!a.ok)
|
|
2728
2734
|
throw new Error(`API request failed: ${a.status} ${a.statusText}`);
|
|
2729
|
-
const
|
|
2735
|
+
const d = (await a.json()).files.filter(
|
|
2730
2736
|
(u) => u.mimeType.startsWith("image/") && i.isAllowed(u.name)
|
|
2731
2737
|
);
|
|
2732
|
-
return this.log(`Found ${
|
|
2738
|
+
return this.log(`Found ${d.length} images in folder ${t} (non-recursive)`), d.forEach((u) => {
|
|
2733
2739
|
e.push(`https://lh3.googleusercontent.com/d/${u.id}=s1600`), this.log(`Added file: ${u.name}`);
|
|
2734
2740
|
}), e;
|
|
2735
2741
|
}
|
|
@@ -2741,10 +2747,10 @@ class Ke {
|
|
|
2741
2747
|
*/
|
|
2742
2748
|
async loadFiles(t, i) {
|
|
2743
2749
|
const e = [];
|
|
2744
|
-
for (const
|
|
2745
|
-
const s = this.extractFileId(
|
|
2750
|
+
for (const o of t) {
|
|
2751
|
+
const s = this.extractFileId(o);
|
|
2746
2752
|
if (!s) {
|
|
2747
|
-
this.log(`Skipping invalid file URL: ${
|
|
2753
|
+
this.log(`Skipping invalid file URL: ${o}`);
|
|
2748
2754
|
continue;
|
|
2749
2755
|
}
|
|
2750
2756
|
if (this.apiKey && this.apiKey !== "YOUR_API_KEY_HERE")
|
|
@@ -2780,9 +2786,9 @@ class Ke {
|
|
|
2780
2786
|
// Generic id parameter
|
|
2781
2787
|
];
|
|
2782
2788
|
for (const e of i) {
|
|
2783
|
-
const
|
|
2784
|
-
if (
|
|
2785
|
-
return
|
|
2789
|
+
const o = t.match(e);
|
|
2790
|
+
if (o && o[1])
|
|
2791
|
+
return o[1];
|
|
2786
2792
|
}
|
|
2787
2793
|
return null;
|
|
2788
2794
|
}
|
|
@@ -2793,21 +2799,21 @@ class Ke {
|
|
|
2793
2799
|
* @returns Promise resolving to array of image URLs
|
|
2794
2800
|
*/
|
|
2795
2801
|
async loadImagesRecursively(t, i) {
|
|
2796
|
-
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);
|
|
2797
2803
|
if (!a.ok)
|
|
2798
2804
|
throw new Error(`API request failed: ${a.status} ${a.statusText}`);
|
|
2799
|
-
const c = await a.json(),
|
|
2800
|
-
(
|
|
2805
|
+
const c = await a.json(), d = c.files.filter(
|
|
2806
|
+
(f) => f.mimeType.startsWith("image/") && i.isAllowed(f.name)
|
|
2801
2807
|
), u = c.files.filter(
|
|
2802
|
-
(
|
|
2808
|
+
(f) => f.mimeType === "application/vnd.google-apps.folder"
|
|
2803
2809
|
);
|
|
2804
|
-
this.log(`Found ${c.files.length} total items in folder ${t}`), c.files.forEach((
|
|
2805
|
-
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}`);
|
|
2806
2812
|
});
|
|
2807
|
-
for (const
|
|
2808
|
-
this.log(`Loading images from subfolder: ${
|
|
2809
|
-
const
|
|
2810
|
-
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);
|
|
2811
2817
|
}
|
|
2812
2818
|
return e;
|
|
2813
2819
|
}
|
|
@@ -2820,10 +2826,10 @@ class Ke {
|
|
|
2820
2826
|
*/
|
|
2821
2827
|
async loadImagesDirectly(t, i) {
|
|
2822
2828
|
try {
|
|
2823
|
-
const e = `https://drive.google.com/embeddedfolderview?id=${t}`,
|
|
2824
|
-
if (!
|
|
2829
|
+
const e = `https://drive.google.com/embeddedfolderview?id=${t}`, o = await fetch(e, { mode: "cors" });
|
|
2830
|
+
if (!o.ok)
|
|
2825
2831
|
throw new Error("Cannot access folder directly (CORS or permissions issue)");
|
|
2826
|
-
const s = await
|
|
2832
|
+
const s = await o.text(), r = /\/file\/d\/([a-zA-Z0-9_-]+)/g, a = [...s.matchAll(r)];
|
|
2827
2833
|
return [...new Set(a.map((u) => u[1]))].map(
|
|
2828
2834
|
(u) => `https://drive.google.com/uc?export=view&id=${u}`
|
|
2829
2835
|
);
|
|
@@ -2916,13 +2922,13 @@ class Ze {
|
|
|
2916
2922
|
if (!Array.isArray(t))
|
|
2917
2923
|
return console.warn("URLs must be an array:", t), [];
|
|
2918
2924
|
const e = [];
|
|
2919
|
-
for (const
|
|
2920
|
-
const s =
|
|
2925
|
+
for (const o of t) {
|
|
2926
|
+
const s = o.split("/").pop() || o;
|
|
2921
2927
|
if (!i.isAllowed(s)) {
|
|
2922
|
-
this.log(`Skipping filtered URL: ${
|
|
2928
|
+
this.log(`Skipping filtered URL: ${o}`);
|
|
2923
2929
|
continue;
|
|
2924
2930
|
}
|
|
2925
|
-
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);
|
|
2926
2932
|
}
|
|
2927
2933
|
return e;
|
|
2928
2934
|
}
|
|
@@ -2936,16 +2942,16 @@ class Ze {
|
|
|
2936
2942
|
async processPath(t, i, e) {
|
|
2937
2943
|
if (!Array.isArray(i))
|
|
2938
2944
|
return console.warn("files must be an array:", i), [];
|
|
2939
|
-
const
|
|
2945
|
+
const o = [];
|
|
2940
2946
|
for (const s of i) {
|
|
2941
2947
|
if (!e.isAllowed(s)) {
|
|
2942
2948
|
this.log(`Skipping filtered file: ${s}`);
|
|
2943
2949
|
continue;
|
|
2944
2950
|
}
|
|
2945
2951
|
const r = this.constructUrl(t, s);
|
|
2946
|
-
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);
|
|
2947
2953
|
}
|
|
2948
|
-
return
|
|
2954
|
+
return o;
|
|
2949
2955
|
}
|
|
2950
2956
|
/**
|
|
2951
2957
|
* Process a JSON endpoint source
|
|
@@ -2956,17 +2962,17 @@ class Ze {
|
|
|
2956
2962
|
*/
|
|
2957
2963
|
async processJson(t, i) {
|
|
2958
2964
|
this.log(`Fetching JSON endpoint: ${t}`);
|
|
2959
|
-
const e = new AbortController(),
|
|
2965
|
+
const e = new AbortController(), o = setTimeout(() => e.abort(), 1e4);
|
|
2960
2966
|
try {
|
|
2961
2967
|
const s = await fetch(t, { signal: e.signal });
|
|
2962
|
-
if (clearTimeout(
|
|
2968
|
+
if (clearTimeout(o), !s.ok)
|
|
2963
2969
|
throw new Error(`HTTP ${s.status} fetching ${t}`);
|
|
2964
2970
|
const r = await s.json();
|
|
2965
2971
|
if (!r || !Array.isArray(r.images))
|
|
2966
2972
|
throw new Error('JSON source must return JSON with shape { "images": ["url1", "url2", ...] }');
|
|
2967
2973
|
return this.log(`JSON endpoint returned ${r.images.length} image(s)`), await this.processUrls(r.images, i);
|
|
2968
2974
|
} catch (s) {
|
|
2969
|
-
throw clearTimeout(
|
|
2975
|
+
throw clearTimeout(o), s instanceof Error && s.name === "AbortError" ? new Error(`Timeout fetching JSON endpoint: ${t}`) : s;
|
|
2970
2976
|
}
|
|
2971
2977
|
}
|
|
2972
2978
|
/**
|
|
@@ -2988,11 +2994,11 @@ class Ze {
|
|
|
2988
2994
|
if (!(t.startsWith(window.location.origin) || t.startsWith("/")))
|
|
2989
2995
|
return this.log(`Skipping validation for cross-origin URL: ${t}`), !0;
|
|
2990
2996
|
try {
|
|
2991
|
-
const e = new AbortController(),
|
|
2997
|
+
const e = new AbortController(), o = setTimeout(() => e.abort(), this.validationTimeout), s = await fetch(t, {
|
|
2992
2998
|
method: "HEAD",
|
|
2993
2999
|
signal: e.signal
|
|
2994
3000
|
});
|
|
2995
|
-
return clearTimeout(
|
|
3001
|
+
return clearTimeout(o), s.ok ? !0 : (this.log(`Validation failed for ${t}: HTTP ${s.status}`), !1);
|
|
2996
3002
|
} catch (e) {
|
|
2997
3003
|
return e instanceof Error && (e.name === "AbortError" ? this.log(`Validation timeout for ${t}`) : this.log(`Validation failed for ${t}:`, e.message)), !1;
|
|
2998
3004
|
}
|
|
@@ -3009,8 +3015,8 @@ class Ze {
|
|
|
3009
3015
|
return `${e}/${i}`;
|
|
3010
3016
|
if (typeof window > "u")
|
|
3011
3017
|
return `${e}/${i}`;
|
|
3012
|
-
const
|
|
3013
|
-
return `${
|
|
3018
|
+
const o = window.location.origin, r = (t.startsWith("/") ? t : "/" + t).replace(/\/$/, "");
|
|
3019
|
+
return `${o}${r}/${i}`;
|
|
3014
3020
|
}
|
|
3015
3021
|
/**
|
|
3016
3022
|
* Check if URL is absolute (contains protocol)
|
|
@@ -3044,16 +3050,16 @@ class Qe {
|
|
|
3044
3050
|
*/
|
|
3045
3051
|
async prepare(t) {
|
|
3046
3052
|
this._discoveredUrls = [], this.log(`Preparing ${this.loaders.length} loader(s) in parallel`);
|
|
3047
|
-
const i = this.loaders.map((e,
|
|
3048
|
-
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`);
|
|
3049
3055
|
}).catch((s) => {
|
|
3050
|
-
console.warn(`Loader ${
|
|
3056
|
+
console.warn(`Loader ${o} failed to prepare:`, s);
|
|
3051
3057
|
}));
|
|
3052
3058
|
await Promise.all(i);
|
|
3053
3059
|
for (const e of this.loaders)
|
|
3054
3060
|
if (e.isPrepared()) {
|
|
3055
|
-
const
|
|
3056
|
-
this._discoveredUrls.push(...
|
|
3061
|
+
const o = e.imageURLs();
|
|
3062
|
+
this._discoveredUrls.push(...o);
|
|
3057
3063
|
}
|
|
3058
3064
|
this._prepared = !0, this.log(`CompositeLoader prepared with ${this._discoveredUrls.length} total images`);
|
|
3059
3065
|
}
|
|
@@ -3209,18 +3215,18 @@ const ei = `
|
|
|
3209
3215
|
`;
|
|
3210
3216
|
function ii() {
|
|
3211
3217
|
if (typeof document > "u") return;
|
|
3212
|
-
const
|
|
3213
|
-
if (document.getElementById(
|
|
3218
|
+
const n = "fbn-ic-functional-styles";
|
|
3219
|
+
if (document.getElementById(n)) return;
|
|
3214
3220
|
const t = document.createElement("style");
|
|
3215
|
-
t.id =
|
|
3221
|
+
t.id = n, t.textContent = ei, document.head.appendChild(t);
|
|
3216
3222
|
}
|
|
3217
|
-
let
|
|
3223
|
+
let oi = class {
|
|
3218
3224
|
constructor(t = {}) {
|
|
3219
|
-
this.fullConfig = ie(t), t.container instanceof HTMLElement ? (this.containerRef = t.container, this.containerId = null) : (this.containerRef = null, this.containerId = t.container || "imageCloud"), this.imagesLoaded = !1, this.imageElements = [], this.imageLayouts = [], this.currentImageHeight = 225, this.currentFocusIndex = null, this.hoveredImage = null, this.resizeTimeout = null, this.displayQueue = [], this.queueInterval = null, this.loadGeneration = 0, this.loadingElAutoCreated = !1, this.errorElAutoCreated = !1, this.counterEl = null, this.counterElAutoCreated = !1, this.prevButtonEl = null, this.nextButtonEl = null, this.prevButtonElAutoCreated = !1, this.nextButtonElAutoCreated = !1, this.animationEngine = new ae(this.fullConfig.animation), this.layoutEngine = new Pe({
|
|
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({
|
|
3220
3226
|
layout: this.fullConfig.layout,
|
|
3221
3227
|
image: this.fullConfig.image
|
|
3222
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;
|
|
3223
|
-
const i = this.fullConfig.animation.entry ||
|
|
3229
|
+
const i = this.fullConfig.animation.entry || L.animation.entry;
|
|
3224
3230
|
this.entryAnimationEngine = new be(
|
|
3225
3231
|
i,
|
|
3226
3232
|
this.fullConfig.layout.algorithm
|
|
@@ -3229,15 +3235,24 @@ let ni = class {
|
|
|
3229
3235
|
e && e.type !== "none" ? this.idleAnimationEngine = new ye(
|
|
3230
3236
|
e,
|
|
3231
3237
|
i.timing?.duration ?? 600
|
|
3232
|
-
) : this.idleAnimationEngine = null, this.zoomEngine.setOnUnfocusCompleteCallback((
|
|
3233
|
-
this.idleAnimationEngine?.resumeForImage(
|
|
3234
|
-
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
|
+
}
|
|
3235
3250
|
requestAnimationFrame(() => {
|
|
3236
3251
|
if (s.matches(":hover") && this.fullConfig.styling?.hover) {
|
|
3237
|
-
const
|
|
3238
|
-
if (
|
|
3239
|
-
const
|
|
3240
|
-
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] };
|
|
3241
3256
|
}
|
|
3242
3257
|
}
|
|
3243
3258
|
});
|
|
@@ -3258,7 +3273,7 @@ let ni = class {
|
|
|
3258
3273
|
const t = this.fullConfig.loaders, i = this.fullConfig.config.loaders ?? {};
|
|
3259
3274
|
if (!t || t.length === 0)
|
|
3260
3275
|
throw new Error("No loaders configured. Provide `images`, `loaders`, or both.\n Example: imageCloud({ container: 'id', images: ['https://...'] })");
|
|
3261
|
-
const e = t.map((
|
|
3276
|
+
const e = t.map((o) => this.createLoaderFromEntry(o, i));
|
|
3262
3277
|
return e.length === 1 ? e[0] : new Qe({
|
|
3263
3278
|
loaders: e,
|
|
3264
3279
|
debugLogging: this.fullConfig.config.debug?.loaders
|
|
@@ -3269,7 +3284,7 @@ let ni = class {
|
|
|
3269
3284
|
*/
|
|
3270
3285
|
createLoaderFromEntry(t, i) {
|
|
3271
3286
|
if ("static" in t) {
|
|
3272
|
-
const e = t.static,
|
|
3287
|
+
const e = t.static, o = {
|
|
3273
3288
|
...e,
|
|
3274
3289
|
validateUrls: e.validateUrls ?? i.validateUrls,
|
|
3275
3290
|
validationTimeout: e.validationTimeout ?? i.validationTimeout,
|
|
@@ -3277,14 +3292,14 @@ let ni = class {
|
|
|
3277
3292
|
allowedExtensions: e.allowedExtensions ?? i.allowedExtensions,
|
|
3278
3293
|
debugLogging: e.debugLogging ?? this.fullConfig.config.debug?.loaders
|
|
3279
3294
|
};
|
|
3280
|
-
return new Ze(
|
|
3295
|
+
return new Ze(o);
|
|
3281
3296
|
} else if ("googleDrive" in t) {
|
|
3282
|
-
const e = t.googleDrive,
|
|
3297
|
+
const e = t.googleDrive, o = {
|
|
3283
3298
|
...e,
|
|
3284
3299
|
allowedExtensions: e.allowedExtensions ?? i.allowedExtensions,
|
|
3285
3300
|
debugLogging: e.debugLogging ?? this.fullConfig.config.debug?.loaders
|
|
3286
3301
|
};
|
|
3287
|
-
return new Ke(
|
|
3302
|
+
return new Ke(o);
|
|
3288
3303
|
} else
|
|
3289
3304
|
throw new Error(`Unknown loader entry: ${JSON.stringify(t)}`);
|
|
3290
3305
|
}
|
|
@@ -3302,7 +3317,7 @@ let ni = class {
|
|
|
3302
3317
|
onPrev: () => this.navigateToPreviousImage(),
|
|
3303
3318
|
onDragOffset: (t) => this.zoomEngine.setDragOffset(t),
|
|
3304
3319
|
onDragEnd: (t) => {
|
|
3305
|
-
t ? this.zoomEngine.clearDragOffset(!1) : this.zoomEngine.clearDragOffset(!0,
|
|
3320
|
+
t ? this.zoomEngine.clearDragOffset(!1) : this.zoomEngine.clearDragOffset(!0, Ve);
|
|
3306
3321
|
}
|
|
3307
3322
|
})), this.setupUI(), this.setupEventListeners(), this.logDebug("ImageCloud initialized"), await this.loadImages();
|
|
3308
3323
|
} catch (t) {
|
|
@@ -3357,7 +3372,7 @@ let ni = class {
|
|
|
3357
3372
|
navigateToNextImage() {
|
|
3358
3373
|
if (this.currentFocusIndex === null || this.imageElements.length === 0) return;
|
|
3359
3374
|
const t = (this.currentFocusIndex + 1) % this.imageLayouts.length, i = this.imageElements.find(
|
|
3360
|
-
(
|
|
3375
|
+
(o) => o.dataset.imageId === String(t)
|
|
3361
3376
|
);
|
|
3362
3377
|
if (!i) return;
|
|
3363
3378
|
const e = this.imageLayouts[t];
|
|
@@ -3369,7 +3384,7 @@ let ni = class {
|
|
|
3369
3384
|
navigateToPreviousImage() {
|
|
3370
3385
|
if (this.currentFocusIndex === null || this.imageElements.length === 0) return;
|
|
3371
3386
|
const t = (this.currentFocusIndex - 1 + this.imageLayouts.length) % this.imageLayouts.length, i = this.imageElements.find(
|
|
3372
|
-
(
|
|
3387
|
+
(o) => o.dataset.imageId === String(t)
|
|
3373
3388
|
);
|
|
3374
3389
|
if (!i) return;
|
|
3375
3390
|
const e = this.imageLayouts[t];
|
|
@@ -3385,8 +3400,8 @@ let ni = class {
|
|
|
3385
3400
|
}, 500));
|
|
3386
3401
|
}
|
|
3387
3402
|
getImageHeight() {
|
|
3388
|
-
const t = window.innerWidth, i = this.fullConfig.layout.responsive,
|
|
3389
|
-
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);
|
|
3390
3405
|
}
|
|
3391
3406
|
/**
|
|
3392
3407
|
* Get container bounds for layout calculations
|
|
@@ -3409,12 +3424,12 @@ let ni = class {
|
|
|
3409
3424
|
this.showError("No images found."), this.showLoading(!1);
|
|
3410
3425
|
return;
|
|
3411
3426
|
}
|
|
3412
|
-
const e = this.getContainerBounds(),
|
|
3413
|
-
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`);
|
|
3414
3429
|
const r = this.layoutEngine.calculateAdaptiveSize(
|
|
3415
3430
|
e,
|
|
3416
3431
|
t,
|
|
3417
|
-
|
|
3432
|
+
o,
|
|
3418
3433
|
s
|
|
3419
3434
|
);
|
|
3420
3435
|
this.logDebug(`Adaptive sizing result: height=${r.height}px`), await this.createImageCloud(i, r.height), this.showLoading(!1), this.imagesLoaded = !0;
|
|
@@ -3432,148 +3447,288 @@ let ni = class {
|
|
|
3432
3447
|
if (!this.containerEl) return;
|
|
3433
3448
|
const e = this.getContainerBounds();
|
|
3434
3449
|
this.currentImageHeight = i;
|
|
3435
|
-
const
|
|
3436
|
-
this.imageLayouts = s, this.
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
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 = {
|
|
3480
|
+
element: l,
|
|
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)
|
|
3448
3492
|
ge({
|
|
3449
3493
|
element: l,
|
|
3450
|
-
startPosition:
|
|
3451
|
-
endPosition:
|
|
3494
|
+
startPosition: { x: y, y: x },
|
|
3495
|
+
endPosition: { x: E, y: F },
|
|
3452
3496
|
pathConfig: this.entryAnimationEngine.getPathConfig(),
|
|
3453
|
-
duration:
|
|
3454
|
-
imageWidth:
|
|
3455
|
-
imageHeight:
|
|
3456
|
-
rotation:
|
|
3457
|
-
scale:
|
|
3497
|
+
duration: b.duration,
|
|
3498
|
+
imageWidth: k,
|
|
3499
|
+
imageHeight: D,
|
|
3500
|
+
rotation: R,
|
|
3501
|
+
scale: M,
|
|
3458
3502
|
rotationConfig: this.entryAnimationEngine.getRotationConfig(),
|
|
3459
|
-
startRotation:
|
|
3503
|
+
startRotation: T,
|
|
3460
3504
|
scaleConfig: this.entryAnimationEngine.getScaleConfig(),
|
|
3461
|
-
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
|
|
3462
3536
|
});
|
|
3463
|
-
|
|
3464
|
-
const
|
|
3465
|
-
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
|
+
}
|
|
3466
3555
|
}
|
|
3467
|
-
|
|
3468
|
-
|
|
3469
|
-
|
|
3470
|
-
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:`, {
|
|
3471
3559
|
left: l.style.left,
|
|
3472
3560
|
top: l.style.top,
|
|
3473
3561
|
width: l.style.width,
|
|
3474
3562
|
height: l.style.height,
|
|
3475
3563
|
computedWidth: l.offsetWidth,
|
|
3476
3564
|
computedHeight: l.offsetHeight,
|
|
3477
|
-
transform:
|
|
3565
|
+
transform: S,
|
|
3478
3566
|
pathType: this.entryAnimationEngine.getPathType()
|
|
3479
3567
|
});
|
|
3480
3568
|
}
|
|
3481
3569
|
if (this.idleAnimationEngine) {
|
|
3482
|
-
const
|
|
3483
|
-
this.idleAnimationEngine.register(l,
|
|
3570
|
+
const S = this.entryAnimationEngine.getTiming().duration;
|
|
3571
|
+
this.idleAnimationEngine.register(l, g, this.imageElements.length, S);
|
|
3484
3572
|
}
|
|
3485
|
-
}), r
|
|
3486
|
-
},
|
|
3573
|
+
}), r++, p());
|
|
3574
|
+
}, v = () => {
|
|
3487
3575
|
if (this.logDebug("Starting queue processing, enabled:", this.fullConfig.animation.queue.enabled), !this.fullConfig.animation.queue.enabled) {
|
|
3488
3576
|
for (; this.displayQueue.length > 0; ) {
|
|
3489
3577
|
const l = this.displayQueue.shift();
|
|
3490
|
-
l &&
|
|
3578
|
+
l && w(l);
|
|
3491
3579
|
}
|
|
3492
3580
|
return;
|
|
3493
3581
|
}
|
|
3494
3582
|
this.queueInterval !== null && clearInterval(this.queueInterval), this.queueInterval = window.setInterval(() => {
|
|
3495
|
-
if (
|
|
3583
|
+
if (o !== this.loadGeneration) {
|
|
3496
3584
|
this.queueInterval !== null && (clearInterval(this.queueInterval), this.queueInterval = null);
|
|
3497
3585
|
return;
|
|
3498
3586
|
}
|
|
3499
3587
|
if (this.displayQueue.length > 0) {
|
|
3500
3588
|
const l = this.displayQueue.shift();
|
|
3501
|
-
l &&
|
|
3589
|
+
l && w(l);
|
|
3502
3590
|
}
|
|
3503
|
-
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());
|
|
3504
3592
|
}, this.fullConfig.animation.queue.interval);
|
|
3505
3593
|
};
|
|
3506
3594
|
if ("IntersectionObserver" in window && this.containerEl) {
|
|
3507
|
-
const l = new IntersectionObserver((
|
|
3508
|
-
|
|
3509
|
-
h.isIntersecting && (
|
|
3595
|
+
const l = new IntersectionObserver((g) => {
|
|
3596
|
+
g.forEach((h) => {
|
|
3597
|
+
h.isIntersecting && (v(), l.disconnect());
|
|
3510
3598
|
});
|
|
3511
3599
|
}, { threshold: 0.1, rootMargin: "50px" });
|
|
3512
3600
|
l.observe(this.containerEl);
|
|
3513
3601
|
} else
|
|
3514
|
-
|
|
3515
|
-
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) => {
|
|
3516
3604
|
const h = document.createElement("div");
|
|
3517
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";
|
|
3518
|
-
const
|
|
3519
|
-
h.style.left = `${
|
|
3520
|
-
})), 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) => {
|
|
3521
3609
|
const h = document.createElement("img");
|
|
3522
|
-
h.referrerPolicy = "no-referrer", h.classList.add("fbn-ic-image"), this.fullConfig.interaction.dragging === !1 && (h.draggable = !1), h.dataset.imageId = String(
|
|
3523
|
-
const
|
|
3524
|
-
h.style.position = "absolute", h.style.width = "auto", h.style.height = `${i}px`, h.style.left = `${
|
|
3525
|
-
if (this.hoveredImage = { element: h, layout:
|
|
3526
|
-
const
|
|
3527
|
-
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);
|
|
3528
3620
|
}
|
|
3529
3621
|
}), h.addEventListener("mouseleave", () => {
|
|
3530
3622
|
if (this.hoveredImage = null, !this.zoomEngine.isInvolved(h)) {
|
|
3531
|
-
const
|
|
3532
|
-
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);
|
|
3533
3629
|
}
|
|
3534
|
-
}), h.addEventListener("click", (
|
|
3535
|
-
|
|
3630
|
+
}), h.addEventListener("click", (y) => {
|
|
3631
|
+
y.stopPropagation(), this.handleImageClick(h, b);
|
|
3536
3632
|
}), h.style.opacity = "0", h.style.transition = this.entryAnimationEngine.getTransitionCSS(), h.onload = () => {
|
|
3537
|
-
if (
|
|
3633
|
+
if (o !== this.loadGeneration)
|
|
3538
3634
|
return;
|
|
3539
|
-
const
|
|
3540
|
-
h.dataset.onloadCalled = "true", window.DEBUG_CLIPPATH && console.log(`[onload #${
|
|
3541
|
-
const
|
|
3542
|
-
|
|
3543
|
-
|
|
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,
|
|
3544
3640
|
e,
|
|
3545
|
-
|
|
3641
|
+
g,
|
|
3546
3642
|
t.length
|
|
3547
|
-
),
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
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,
|
|
3551
3647
|
i
|
|
3552
|
-
),
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3648
|
+
), k = this.entryAnimationEngine.buildStartTransform(
|
|
3649
|
+
R,
|
|
3650
|
+
E,
|
|
3651
|
+
b.rotation,
|
|
3652
|
+
b.scale,
|
|
3653
|
+
x,
|
|
3558
3654
|
i,
|
|
3559
|
-
|
|
3560
|
-
|
|
3655
|
+
M,
|
|
3656
|
+
T
|
|
3561
3657
|
);
|
|
3562
|
-
this.fullConfig.config.debug?.enabled &&
|
|
3563
|
-
finalPosition:
|
|
3564
|
-
imageSize:
|
|
3565
|
-
left:
|
|
3566
|
-
top:
|
|
3567
|
-
finalTransform:
|
|
3568
|
-
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,
|
|
3569
3665
|
renderedHeight: i
|
|
3570
|
-
}), h.style.transform =
|
|
3571
|
-
|
|
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
|
+
})();
|
|
3572
3727
|
});
|
|
3573
3728
|
}
|
|
3574
3729
|
async handleImageClick(t, i) {
|
|
3575
3730
|
if (!this.containerEl) return;
|
|
3576
|
-
const e = this.zoomEngine.isFocused(t),
|
|
3731
|
+
const e = this.zoomEngine.isFocused(t), o = {
|
|
3577
3732
|
width: this.containerEl.offsetWidth,
|
|
3578
3733
|
height: this.containerEl.offsetHeight
|
|
3579
3734
|
};
|
|
@@ -3582,7 +3737,15 @@ let ni = class {
|
|
|
3582
3737
|
else {
|
|
3583
3738
|
this.idleAnimationEngine?.pauseForImage(t);
|
|
3584
3739
|
const s = t.dataset.imageId;
|
|
3585
|
-
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
|
+
}
|
|
3586
3749
|
}
|
|
3587
3750
|
}
|
|
3588
3751
|
/**
|
|
@@ -3625,7 +3788,7 @@ let ni = class {
|
|
|
3625
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;
|
|
3626
3789
|
}
|
|
3627
3790
|
};
|
|
3628
|
-
const ai =
|
|
3791
|
+
const ai = kt({
|
|
3629
3792
|
name: "ImageCloud",
|
|
3630
3793
|
props: {
|
|
3631
3794
|
options: {
|
|
@@ -3633,27 +3796,27 @@ const ai = Ht({
|
|
|
3633
3796
|
required: !0
|
|
3634
3797
|
}
|
|
3635
3798
|
},
|
|
3636
|
-
setup(
|
|
3637
|
-
const i =
|
|
3638
|
-
function
|
|
3799
|
+
setup(n, { expose: t }) {
|
|
3800
|
+
const i = St(null), e = St(null);
|
|
3801
|
+
function o() {
|
|
3639
3802
|
if (!i.value) return;
|
|
3640
3803
|
e.value?.destroy();
|
|
3641
|
-
const s = new
|
|
3804
|
+
const s = new oi({
|
|
3642
3805
|
container: i.value,
|
|
3643
|
-
...
|
|
3806
|
+
...n.options
|
|
3644
3807
|
});
|
|
3645
3808
|
e.value = s, s.init().catch((r) => {
|
|
3646
3809
|
console.error("ImageCloud init failed:", r);
|
|
3647
3810
|
});
|
|
3648
3811
|
}
|
|
3649
|
-
return
|
|
3650
|
-
|
|
3651
|
-
}),
|
|
3812
|
+
return Ht(() => {
|
|
3813
|
+
o();
|
|
3814
|
+
}), Nt(() => {
|
|
3652
3815
|
e.value?.destroy(), e.value = null;
|
|
3653
3816
|
}), Bt(
|
|
3654
|
-
() =>
|
|
3817
|
+
() => n.options,
|
|
3655
3818
|
() => {
|
|
3656
|
-
|
|
3819
|
+
o();
|
|
3657
3820
|
},
|
|
3658
3821
|
{ deep: !0 }
|
|
3659
3822
|
), t({ instance: e }), () => jt("div", {
|