@frybynite/image-cloud 0.9.6 → 0.10.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/vue.d.ts CHANGED
@@ -883,6 +883,8 @@ declare class ImageCloud {
883
883
  export { ImageCloud }
884
884
  export { ImageCloud as ImageGallery }
885
885
 
886
+ export declare function imageCloud(options: ImageCloudOptions): Promise<ImageCloud>;
887
+
886
888
  export declare interface ImageCloudConfig {
887
889
  loaders: LoaderEntry[];
888
890
  config: ConfigSection;
package/dist/vue.js CHANGED
@@ -5,11 +5,11 @@ const mt = Object.freeze({
5
5
  md: "0 4px 16px rgba(0,0,0,0.4)",
6
6
  lg: "0 8px 32px rgba(0,0,0,0.5)",
7
7
  glow: "0 0 30px rgba(255,255,255,0.6)"
8
- }), At = Object.freeze({
8
+ }), Ct = 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
- }), Ct = Object.freeze({
12
+ }), At = 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 }),
@@ -95,7 +95,7 @@ const mt = Object.freeze({
95
95
  enabled: !1,
96
96
  centers: !1,
97
97
  loaders: !1
98
- }), Jt = Object.freeze({ maxAngle: 5, speed: 2e3, sync: "random" }), Kt = Object.freeze({ minScale: 0.95, maxScale: 1.05, speed: 2400, sync: "random" }), Zt = Object.freeze({ onRatio: 0.7, speed: 3e3, style: "snap" }), Qt = Object.freeze({ speed: 4e3, direction: "clockwise" }), $t = Object.freeze({ type: "none" }), A = Object.freeze({
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" }), C = Object.freeze({
99
99
  // Loader configuration (always an array, composite behavior is implicit)
100
100
  loaders: [],
101
101
  // Shared loader settings and debug config
@@ -276,59 +276,59 @@ function oe(o = {}) {
276
276
  loaders: n,
277
277
  config: r,
278
278
  image: ee(zt, e),
279
- layout: { ...A.layout },
280
- animation: { ...A.animation },
281
- interaction: { ...A.interaction },
282
- ui: { ...A.ui },
279
+ layout: { ...C.layout },
280
+ animation: { ...C.animation },
281
+ interaction: { ...C.interaction },
282
+ ui: { ...C.ui },
283
283
  styling: te(Ft, o.styling)
284
284
  };
285
285
  o.layout && (a.layout = {
286
- ...A.layout,
286
+ ...C.layout,
287
287
  ...o.layout
288
288
  }, o.layout.responsive && (a.layout.responsive = {
289
- ...A.layout.responsive,
290
- mobile: o.layout.responsive.mobile ? { ...A.layout.responsive.mobile, ...o.layout.responsive.mobile } : A.layout.responsive.mobile,
291
- tablet: o.layout.responsive.tablet ? { ...A.layout.responsive.tablet, ...o.layout.responsive.tablet } : A.layout.responsive.tablet
289
+ ...C.layout.responsive,
290
+ mobile: o.layout.responsive.mobile ? { ...C.layout.responsive.mobile, ...o.layout.responsive.mobile } : C.layout.responsive.mobile,
291
+ tablet: o.layout.responsive.tablet ? { ...C.layout.responsive.tablet, ...o.layout.responsive.tablet } : C.layout.responsive.tablet
292
292
  }), o.layout.spacing && (a.layout.spacing = {
293
- ...A.layout.spacing,
293
+ ...C.layout.spacing,
294
294
  ...o.layout.spacing
295
295
  })), o.animation && (a.animation = {
296
- ...A.animation,
296
+ ...C.animation,
297
297
  ...o.animation
298
298
  }, o.animation.easing && (a.animation.easing = {
299
- ...A.animation.easing,
299
+ ...C.animation.easing,
300
300
  ...o.animation.easing
301
301
  }), o.animation.queue && (a.animation.queue = {
302
- ...A.animation.queue,
302
+ ...C.animation.queue,
303
303
  ...o.animation.queue
304
304
  }), o.animation.entry && (a.animation.entry = {
305
- ...A.animation.entry,
305
+ ...C.animation.entry,
306
306
  ...o.animation.entry,
307
307
  start: o.animation.entry.start ? {
308
- ...A.animation.entry.start,
308
+ ...C.animation.entry.start,
309
309
  ...o.animation.entry.start,
310
- circular: o.animation.entry.start.circular ? { ...A.animation.entry.start.circular, ...o.animation.entry.start.circular } : A.animation.entry.start.circular
311
- } : A.animation.entry.start,
312
- timing: o.animation.entry.timing ? { ...A.animation.entry.timing, ...o.animation.entry.timing } : A.animation.entry.timing,
313
- path: o.animation.entry.path ? { ...yt, ...o.animation.entry.path } : A.animation.entry.path,
314
- rotation: o.animation.entry.rotation ? { ...vt, ...o.animation.entry.rotation } : A.animation.entry.rotation,
315
- scale: o.animation.entry.scale ? { ...Et, ...o.animation.entry.scale } : A.animation.entry.scale
310
+ circular: o.animation.entry.start.circular ? { ...C.animation.entry.start.circular, ...o.animation.entry.start.circular } : C.animation.entry.start.circular
311
+ } : C.animation.entry.start,
312
+ timing: o.animation.entry.timing ? { ...C.animation.entry.timing, ...o.animation.entry.timing } : C.animation.entry.timing,
313
+ path: o.animation.entry.path ? { ...yt, ...o.animation.entry.path } : C.animation.entry.path,
314
+ rotation: o.animation.entry.rotation ? { ...vt, ...o.animation.entry.rotation } : C.animation.entry.rotation,
315
+ scale: o.animation.entry.scale ? { ...Et, ...o.animation.entry.scale } : C.animation.entry.scale
316
316
  }), o.animation.idle && (a.animation.idle = {
317
317
  ...$t,
318
318
  ...o.animation.idle
319
319
  })), o.interaction && (a.interaction = {
320
- ...A.interaction,
320
+ ...C.interaction,
321
321
  ...o.interaction
322
322
  }, o.interaction.focus && (a.interaction.focus = {
323
- ...A.interaction.focus,
323
+ ...C.interaction.focus,
324
324
  ...o.interaction.focus
325
325
  }), o.interaction.navigation && (a.interaction.navigation = {
326
- ...A.interaction.navigation,
326
+ ...C.interaction.navigation,
327
327
  ...o.interaction.navigation
328
328
  }));
329
329
  const c = o.rendering?.ui;
330
330
  if (c && console.warn("[ImageCloud] rendering.ui is deprecated. Use top-level ui instead."), a.ui = {
331
- ...A.ui,
331
+ ...C.ui,
332
332
  ...c,
333
333
  ...o.ui
334
334
  }, a.config.debug = {
@@ -346,10 +346,10 @@ function oe(o = {}) {
346
346
  return a;
347
347
  }
348
348
  function se(o, t) {
349
- return { ...o ? At[o] : At.playful, ...t };
349
+ return { ...o ? Ct[o] : Ct.playful, ...t };
350
350
  }
351
351
  function ae(o, t) {
352
- return { ...o ? Ct[o] : Ct.gentle, ...t };
352
+ return { ...o ? At[o] : At.gentle, ...t };
353
353
  }
354
354
  function re(o, t) {
355
355
  return { ...o ? Rt[o] : Rt.gentle, ...t };
@@ -620,7 +620,7 @@ function pe(o) {
620
620
  }
621
621
  const z = performance.now(), L = -r / 2, _ = -a / 2;
622
622
  function O(H) {
623
- const N = H - z, C = Math.min(N / s, 1);
623
+ const N = H - z, A = Math.min(N / s, 1);
624
624
  let D;
625
625
  switch (p) {
626
626
  case "bounce": {
@@ -628,7 +628,7 @@ function pe(o) {
628
628
  n.bouncePreset,
629
629
  n.bounce
630
630
  );
631
- D = le(C, i, e, k);
631
+ D = le(A, i, e, k);
632
632
  break;
633
633
  }
634
634
  case "elastic": {
@@ -636,7 +636,7 @@ function pe(o) {
636
636
  n.elasticPreset,
637
637
  n.elastic
638
638
  );
639
- D = de(C, i, e, k);
639
+ D = de(A, i, e, k);
640
640
  break;
641
641
  }
642
642
  case "wave": {
@@ -644,20 +644,20 @@ function pe(o) {
644
644
  n.wavePreset,
645
645
  n.wave
646
646
  );
647
- D = ue(C, i, e, k);
647
+ D = ue(A, i, e, k);
648
648
  break;
649
649
  }
650
650
  default:
651
651
  D = {
652
- x: J(i.x, e.x, C),
653
- y: J(i.y, e.y, C)
652
+ x: J(i.x, e.x, A),
653
+ y: J(i.y, e.y, A)
654
654
  };
655
655
  }
656
656
  const W = D.x - e.x, U = D.y - e.y;
657
657
  let M;
658
- m ? M = ge(C, c, y) : f ? M = J(d, c, C) : M = c;
658
+ m ? M = ge(A, c, y) : f ? M = J(d, c, A) : M = c;
659
659
  let R;
660
- S ? R = me(C, l, w) : v ? R = J(b, l, C) : R = l, t.style.transform = `translate(${L}px, ${_}px) translate(${W}px, ${U}px) rotate(${M}deg) scale(${R})`, C < 1 ? requestAnimationFrame(O) : (t.style.transform = `translate(${L}px, ${_}px) rotate(${c}deg) scale(${l})`, u && u());
660
+ S ? R = me(A, l, w) : v ? R = J(b, l, A) : R = l, t.style.transform = `translate(${L}px, ${_}px) translate(${W}px, ${U}px) rotate(${M}deg) scale(${R})`, A < 1 ? requestAnimationFrame(O) : (t.style.transform = `translate(${L}px, ${_}px) rotate(${c}deg) scale(${l})`, u && u());
661
661
  }
662
662
  requestAnimationFrame(O);
663
663
  }
@@ -1274,7 +1274,7 @@ class xe {
1274
1274
  }
1275
1275
  let w = 1, I = 1;
1276
1276
  for (; w < t; ) {
1277
- const z = I / E, L = b > 0 ? 1 - z * b * 0.5 : 1, _ = Math.max(f * 0.8, S / E * 1.5 / p.tightness), O = I * _, H = O * 1.5, N = Math.PI * (3 * (H + O) - Math.sqrt((3 * H + O) * (H + 3 * O))), C = this.estimateWidth(f), D = Math.floor(N / (C * 0.7));
1277
+ const z = I / E, L = b > 0 ? 1 - z * b * 0.5 : 1, _ = Math.max(f * 0.8, S / E * 1.5 / p.tightness), O = I * _, H = O * 1.5, N = Math.PI * (3 * (H + O) - Math.sqrt((3 * H + O) * (H + 3 * O))), A = this.estimateWidth(f), D = Math.floor(N / (A * 0.7));
1278
1278
  if (D === 0) {
1279
1279
  I++;
1280
1280
  continue;
@@ -1366,7 +1366,7 @@ class Ie {
1366
1366
  p,
1367
1367
  l,
1368
1368
  a
1369
- ), y = a.stagger === "row", E = a.stagger === "column", v = y ? f + 0.5 : f, S = E ? m + 0.5 : m, w = (b - a.gap * (f - 1)) / v, I = (p - a.gap * (m - 1)) / S, z = y ? w / 2 : 0, L = E ? I / 2 : 0, _ = 1 + a.overlap, O = Math.min(w, I) * _, H = e.fixedHeight ? Math.min(e.fixedHeight, O) : O, N = f * w + (f - 1) * a.gap + z, C = m * I + (m - 1) * a.gap + L, D = c + (b - N) / 2, W = c + (p - C) / 2, U = f * m, M = a.columns !== "auto" && a.rows !== "auto", R = M && t > U;
1369
+ ), y = a.stagger === "row", E = a.stagger === "column", v = y ? f + 0.5 : f, S = E ? m + 0.5 : m, w = (b - a.gap * (f - 1)) / v, I = (p - a.gap * (m - 1)) / S, z = y ? w / 2 : 0, L = E ? I / 2 : 0, _ = 1 + a.overlap, O = Math.min(w, I) * _, H = e.fixedHeight ? Math.min(e.fixedHeight, O) : O, N = f * w + (f - 1) * a.gap + z, A = m * I + (m - 1) * a.gap + L, D = c + (b - N) / 2, W = c + (p - A) / 2, U = f * m, M = a.columns !== "auto" && a.rows !== "auto", R = M && t > U;
1370
1370
  typeof window < "u" && (window.__gridOverflowDebug = {
1371
1371
  gridConfigColumns: a.columns,
1372
1372
  gridConfigRows: a.rows,
@@ -1448,7 +1448,7 @@ class Ie {
1448
1448
  return Math.random() * (i - t) + t;
1449
1449
  }
1450
1450
  }
1451
- const Ae = Math.PI * (3 - Math.sqrt(5)), Ce = {
1451
+ const Ce = Math.PI * (3 - Math.sqrt(5)), Ae = {
1452
1452
  spiralType: "golden",
1453
1453
  direction: "counterclockwise",
1454
1454
  tightness: 1,
@@ -1467,14 +1467,14 @@ class Re {
1467
1467
  * @returns Array of layout objects with position, rotation, scale
1468
1468
  */
1469
1469
  generate(t, i, e = {}) {
1470
- const n = [], { width: s, height: r } = i, a = { ...Ce, ...this.config.spiral }, c = this.config.spacing.padding, l = e.fixedHeight ?? 200, u = this.imageConfig.rotation?.mode ?? "none", h = this.imageConfig.rotation?.range?.min ?? -15, d = this.imageConfig.rotation?.range?.max ?? 15, g = this.imageConfig.sizing?.variance?.min ?? 1, b = this.imageConfig.sizing?.variance?.max ?? 1, p = g !== 1 || b !== 1, f = this.config.scaleDecay ?? a.scaleDecay, m = s / 2, y = r / 2, E = Math.min(
1470
+ const n = [], { width: s, height: r } = i, a = { ...Ae, ...this.config.spiral }, c = this.config.spacing.padding, l = e.fixedHeight ?? 200, u = this.imageConfig.rotation?.mode ?? "none", h = this.imageConfig.rotation?.range?.min ?? -15, d = this.imageConfig.rotation?.range?.max ?? 15, g = this.imageConfig.sizing?.variance?.min ?? 1, b = this.imageConfig.sizing?.variance?.max ?? 1, p = g !== 1 || b !== 1, f = this.config.scaleDecay ?? a.scaleDecay, m = s / 2, y = r / 2, E = Math.min(
1471
1471
  m - c - l / 2,
1472
1472
  y - c - l / 2
1473
1473
  ), v = a.direction === "clockwise" ? -1 : 1;
1474
1474
  for (let S = 0; S < t; S++) {
1475
1475
  let w, I;
1476
1476
  if (a.spiralType === "golden")
1477
- w = S * Ae * v + a.startAngle, I = this.calculateGoldenRadius(S, t, E, a.tightness);
1477
+ w = S * Ce * v + a.startAngle, I = this.calculateGoldenRadius(S, t, E, a.tightness);
1478
1478
  else if (a.spiralType === "archimedean") {
1479
1479
  const P = S * 0.5 * a.tightness;
1480
1480
  w = P * v + a.startAngle, I = this.calculateArchimedeanRadius(P, t, E, a.tightness);
@@ -1482,7 +1482,7 @@ class Re {
1482
1482
  const P = S * 0.3 * a.tightness;
1483
1483
  w = P * v + a.startAngle, I = this.calculateLogarithmicRadius(P, t, E, a.tightness);
1484
1484
  }
1485
- const z = m + Math.cos(w) * I, L = y + Math.sin(w) * I, _ = I / E, O = f > 0 ? 1 - _ * f * 0.5 : 1, H = p ? this.random(g, b) : 1, N = O * H, C = l * N, W = C * 1.5 / 2, U = C / 2, M = c + W, R = s - c - W, k = c + U, q = r - c - U, T = Math.max(M, Math.min(z, R)), $ = Math.max(k, Math.min(L, q));
1485
+ const z = m + Math.cos(w) * I, L = y + Math.sin(w) * I, _ = I / E, O = f > 0 ? 1 - _ * f * 0.5 : 1, H = p ? this.random(g, b) : 1, N = O * H, A = l * N, W = A * 1.5 / 2, U = A / 2, M = c + W, R = s - c - W, k = c + U, q = r - c - U, T = Math.max(M, Math.min(z, R)), $ = Math.max(k, Math.min(L, q));
1486
1486
  let F = 0;
1487
1487
  if (u === "random") {
1488
1488
  const P = w * 180 / Math.PI % 360, B = this.random(h, d);
@@ -1495,7 +1495,7 @@ class Re {
1495
1495
  y: $,
1496
1496
  rotation: F,
1497
1497
  scale: N,
1498
- baseSize: C,
1498
+ baseSize: A,
1499
1499
  zIndex: X
1500
1500
  });
1501
1501
  }
@@ -1597,9 +1597,9 @@ class Le {
1597
1597
  }
1598
1598
  const _ = 1 + a.overlap * 0.5, O = 1 + a.overlap * 0.3;
1599
1599
  z /= _, L /= _;
1600
- const H = p ? this.random(g, b) : 1, N = O * H, C = l * N;
1600
+ const H = p ? this.random(g, b) : 1, N = O * H, A = l * N;
1601
1601
  let D = S.x + z, W = S.y + L;
1602
- const M = C * 1.5 / 2, R = C / 2;
1602
+ const M = A * 1.5 / 2, R = A / 2;
1603
1603
  D = Math.max(c + M, Math.min(D, s - c - M)), W = Math.max(c + R, Math.min(W, r - c - R));
1604
1604
  const k = u === "random" ? this.random(h, d) : 0, T = Math.sqrt(z * z + L * L) / S.spread, $ = Math.round((1 - T) * 50) + 1;
1605
1605
  n.push({
@@ -1608,7 +1608,7 @@ class Le {
1608
1608
  y: W,
1609
1609
  rotation: k,
1610
1610
  scale: N,
1611
- baseSize: C,
1611
+ baseSize: A,
1612
1612
  zIndex: $
1613
1613
  }), E++;
1614
1614
  }
@@ -1690,10 +1690,10 @@ class Me {
1690
1690
  const n = [], { width: s, height: r } = i, a = e.fixedHeight ?? 200, c = this.config.spacing.padding ?? 50, l = this.imageConfig.rotation?.mode ?? "none", u = this.imageConfig.rotation?.range?.min ?? -15, h = this.imageConfig.rotation?.range?.max ?? 15, d = this.imageConfig.sizing?.variance?.min ?? 1, g = this.imageConfig.sizing?.variance?.max ?? 1, b = d !== 1 || g !== 1, p = e.fixedHeight ?? a, f = {
1691
1691
  ...Gt,
1692
1692
  ...this.config.wave
1693
- }, { rows: m, amplitude: y, frequency: E, phaseShift: v, synchronization: S } = f, w = Math.ceil(t / m), L = p * 1.5 / 2, _ = c + L, O = s - c - L, H = O - _, N = w > 1 ? H / (w - 1) : 0, C = c + y + p / 2, D = r - c - y - p / 2, W = D - C, U = m > 1 ? W / (m - 1) : 0;
1693
+ }, { rows: m, amplitude: y, frequency: E, phaseShift: v, synchronization: S } = f, w = Math.ceil(t / m), L = p * 1.5 / 2, _ = c + L, O = s - c - L, H = O - _, N = w > 1 ? H / (w - 1) : 0, A = c + y + p / 2, D = r - c - y - p / 2, W = D - A, U = m > 1 ? W / (m - 1) : 0;
1694
1694
  let M = 0;
1695
1695
  for (let R = 0; R < m && M < t; R++) {
1696
- const k = m === 1 ? (C + D) / 2 : C + R * U;
1696
+ const k = m === 1 ? (A + D) / 2 : A + R * U;
1697
1697
  let q = 0;
1698
1698
  S === "offset" ? q = R * v : S === "alternating" && (q = R * Math.PI);
1699
1699
  for (let T = 0; T < w && M < t; T++) {
@@ -3256,7 +3256,7 @@ let si = class {
3256
3256
  layout: this.fullConfig.layout,
3257
3257
  image: this.fullConfig.image
3258
3258
  }), this.zoomEngine = new qe(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;
3259
- const i = this.fullConfig.animation.entry || A.animation.entry;
3259
+ const i = this.fullConfig.animation.entry || C.animation.entry;
3260
3260
  this.entryAnimationEngine = new ve(
3261
3261
  i,
3262
3262
  this.fullConfig.layout.algorithm
@@ -3293,7 +3293,7 @@ let si = class {
3293
3293
  createLoader() {
3294
3294
  const t = this.fullConfig.loaders, i = this.fullConfig.config.loaders ?? {};
3295
3295
  if (!t || t.length === 0)
3296
- throw new Error("No loaders configured. Provide `images`, `loaders`, or both.");
3296
+ throw new Error("No loaders configured. Provide `images`, `loaders`, or both.\n Example: imageCloud({ container: 'id', images: ['https://...'] })");
3297
3297
  const e = t.map((n) => this.createLoaderFromEntry(n, i));
3298
3298
  return e.length === 1 ? e[0] : new ei({
3299
3299
  loaders: e,
@@ -3332,7 +3332,7 @@ let si = class {
3332
3332
  if (oi(), this.containerRef)
3333
3333
  this.containerEl = this.containerRef;
3334
3334
  else if (this.containerEl = document.getElementById(this.containerId), !this.containerEl)
3335
- throw new Error(`Container #${this.containerId} not found`);
3335
+ throw new Error(`Container "#${this.containerId}" not found. Ensure an element with id="${this.containerId}" exists in the DOM before calling imageCloud().`);
3336
3336
  this.containerEl.classList.add("fbn-ic-gallery"), this.containerEl.setAttribute("tabindex", "0"), this.fullConfig.interaction.navigation?.swipe !== !1 && (this.swipeEngine = new bt(this.containerEl, {
3337
3337
  onNext: () => this.navigateToNextImage(),
3338
3338
  onPrev: () => this.navigateToPreviousImage(),
@@ -3342,7 +3342,7 @@ let si = class {
3342
3342
  }
3343
3343
  })), this.setupUI(), this.setupEventListeners(), this.logDebug("ImageCloud initialized"), await this.loadImages();
3344
3344
  } catch (t) {
3345
- console.error("Gallery initialization failed:", t), this.errorEl && t instanceof Error && this.showError("Gallery failed to initialize: " + t.message);
3345
+ console.error(`ImageCloud initialization failed (container: "${this.containerId ?? "element"}"):`, t), this.errorEl && t instanceof Error && this.showError("Gallery failed to initialize: " + t.message);
3346
3346
  }
3347
3347
  }
3348
3348
  setupUI() {