vistaview 0.3.5 → 0.3.7

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/vistaview.js CHANGED
@@ -1,26 +1,26 @@
1
- var Y = Object.defineProperty;
2
- var _ = (s, t, e) => t in s ? Y(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
3
- var p = (s, t, e) => _(s, typeof t != "symbol" ? t + "" : t, e);
4
- function A(s) {
5
- const t = getComputedStyle(s), e = s.getBoundingClientRect();
1
+ var X = Object.defineProperty;
2
+ var Y = (s, t, i) => t in s ? X(s, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : s[t] = i;
3
+ var w = (s, t, i) => Y(s, typeof t != "symbol" ? t + "" : t, i);
4
+ function z(s) {
5
+ const t = getComputedStyle(s), i = s.getBoundingClientRect();
6
6
  return {
7
7
  objectFit: t.objectFit,
8
8
  borderRadius: t.borderRadius,
9
9
  objectPosition: t.objectPosition,
10
10
  overflow: t.overflow,
11
- top: e.top,
12
- left: e.left,
13
- width: e.width,
14
- height: e.height,
11
+ top: i.top,
12
+ left: i.left,
13
+ width: i.width,
14
+ height: i.height,
15
15
  naturalWidth: s.naturalWidth,
16
16
  naturalHeight: s.naturalHeight
17
17
  };
18
18
  }
19
- let D = null;
20
- function B() {
21
- return D || (window.trustedTypes || (window.trustedTypes = {
19
+ let S = null;
20
+ function V() {
21
+ return S || (window.trustedTypes || (window.trustedTypes = {
22
22
  createPolicy: (s, t) => t
23
- }), D = window.trustedTypes.createPolicy("vistaView-policy", {
23
+ }), S = window.trustedTypes.createPolicy("vistaView-policy", {
24
24
  createHTML: (s) => s,
25
25
  // HTML is generated by us, not user input
26
26
  createScript: () => {
@@ -29,74 +29,74 @@ function B() {
29
29
  createScriptURL: () => {
30
30
  throw new Error("Not implemented");
31
31
  }
32
- }), D);
32
+ }), S);
33
33
  }
34
- function k(s) {
35
- const e = B().createHTML(s), n = document.createElement("template");
36
- n.innerHTML = e;
37
- const i = n.content;
38
- return n.remove(), i;
34
+ function W(s) {
35
+ const i = V().createHTML(s), n = document.createElement("template");
36
+ n.innerHTML = i;
37
+ const e = n.content;
38
+ return n.remove(), e;
39
39
  }
40
40
  function R(s) {
41
41
  return s && !/^0(px|%|r?em|vw|vh|vmin|vmax|cm|mm|in|pt|pc|ex|ch)?$/i.test(s.trim()) && s;
42
42
  }
43
- function H(s) {
44
- const e = window.getComputedStyle(s).objectFit || "", { width: n, height: i } = s.getBoundingClientRect(), o = s.naturalWidth, h = s.naturalHeight;
45
- if (!e)
46
- return { width: n, height: i };
47
- if (!o || !h)
48
- return { width: n, height: i };
49
- const r = o / h, a = n / i;
50
- switch (e) {
43
+ function B(s) {
44
+ const i = window.getComputedStyle(s).objectFit || "", { width: n, height: e } = s.getBoundingClientRect(), a = s.naturalWidth, d = s.naturalHeight;
45
+ if (!i)
46
+ return { width: n, height: e };
47
+ if (!a || !d)
48
+ return { width: n, height: e };
49
+ const o = a / d, l = n / e;
50
+ switch (i) {
51
51
  case "fill":
52
- return { width: n, height: i };
52
+ return { width: n, height: e };
53
53
  case "none":
54
- return { width: o, height: h };
54
+ return { width: a, height: d };
55
55
  case "contain":
56
- return r > a ? { width: n, height: n / r } : { width: i * r, height: i };
56
+ return o > l ? { width: n, height: n / o } : { width: e * o, height: e };
57
57
  case "cover":
58
- return r < a ? { width: n, height: n / r } : { width: i * r, height: i };
58
+ return o < l ? { width: n, height: n / o } : { width: e * o, height: e };
59
59
  case "scale-down": {
60
- const c = { width: o, height: h }, l = r > a ? { width: n, height: n / r } : { width: i * r, height: i };
61
- return l.width <= c.width && l.height <= c.height ? l : c;
60
+ const h = { width: a, height: d }, r = o > l ? { width: n, height: n / o } : { width: e * o, height: e };
61
+ return r.width <= h.width && r.height <= h.height ? r : h;
62
62
  }
63
63
  }
64
- return { width: n, height: i };
64
+ return { width: n, height: e };
65
65
  }
66
- function P(s) {
67
- const t = window.innerWidth, e = window.innerHeight, n = s.naturalWidth, i = s.naturalHeight;
68
- if (!n || !i)
66
+ function H(s) {
67
+ const t = window.innerWidth, i = window.innerHeight, n = s.naturalWidth, e = s.naturalHeight;
68
+ if (!n || !e)
69
69
  throw console.error("Error", s), new Error("Image natural dimensions are zero");
70
- if (n < t && i < e)
70
+ if (n < t && e < i)
71
71
  return {
72
72
  width: n,
73
- height: i
73
+ height: e
74
74
  };
75
- const o = n / i, h = t / e;
76
- let r, a;
77
- return o > h ? (r = t, a = t / o) : (a = e, r = e * o), {
78
- width: r,
79
- height: a
75
+ const a = n / e, d = t / i;
76
+ let o, l;
77
+ return a > d ? (o = t, l = t / a) : (l = i, o = i * a), {
78
+ width: o,
79
+ height: l
80
80
  };
81
81
  }
82
- function W(s, t) {
83
- const e = window.innerHeight, n = window.innerWidth, i = s, o = t, h = Math.max(0, (i - n) / 2) + n / 2, r = Math.max(0, (o - e) / 2) + e / 2, a = -h, c = -r;
82
+ function T(s, t) {
83
+ const i = window.innerHeight, n = window.innerWidth, e = s, a = t, d = Math.max(0, (e - n) / 2) + n / 2, o = Math.max(0, (a - i) / 2) + i / 2, l = -d, h = -o;
84
84
  return {
85
- maxDiffX: h,
86
- minDiffY: c,
87
- maxDiffY: r,
88
- minDiffX: a
85
+ maxDiffX: d,
86
+ minDiffY: h,
87
+ maxDiffY: o,
88
+ minDiffX: l
89
89
  };
90
90
  }
91
- const F = '<svg viewBox="0 0 24 24"><path d="m15 18-6-6 6-6"/></svg>', V = '<svg viewBox="0 0 24 24"><path d="m9 18 6-6-6-6"/></svg>', U = '<svg viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"/><line x1="21" x2="16.65" y1="21" y2="16.65"/><line x1="11" x2="11" y1="8" y2="14"/><line x1="8" x2="14" y1="11" y2="11"/></svg>', N = '<svg viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"/><line x1="21" x2="16.65" y1="21" y2="16.65"/><line x1="8" x2="14" y1="11" y2="11"/></svg>', j = '<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>', K = '<svg viewBox="0 0 24 24"><path d="M12 15V3"/><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><path d="m7 10 5 5 5-5"/></svg>';
91
+ const _ = '<svg viewBox="0 0 24 24"><path d="m15 18-6-6 6-6"/></svg>', F = '<svg viewBox="0 0 24 24"><path d="m9 18 6-6-6-6"/></svg>', N = '<svg viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"/><line x1="21" x2="16.65" y1="21" y2="16.65"/><line x1="11" x2="11" y1="8" y2="14"/><line x1="8" x2="14" y1="11" y2="11"/></svg>', U = '<svg viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"/><line x1="21" x2="16.65" y1="21" y2="16.65"/><line x1="8" x2="14" y1="11" y2="11"/></svg>', K = '<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>', j = '<svg viewBox="0 0 24 24"><path d="M12 15V3"/><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><path d="m7 10 5 5 5-5"/></svg>';
92
92
  function G() {
93
93
  return {
94
94
  name: "download",
95
- icon: K,
95
+ icon: j,
96
96
  onClick: async (s) => {
97
- var o;
98
- const t = await fetch(s.src), e = await t.blob(), n = t.url, i = document.createElement("a");
99
- i.href = URL.createObjectURL(e), i.download = ((o = n.split("/").pop()) == null ? void 0 : o.split("?")[0].split("#")[0]) || "download", document.body.appendChild(i), i.click(), document.body.removeChild(i);
97
+ var a;
98
+ const t = await fetch(s.src), i = await t.blob(), n = t.url, e = document.createElement("a");
99
+ e.href = URL.createObjectURL(i), e.download = ((a = n.split("/").pop()) == null ? void 0 : a.split("?")[0].split("#")[0]) || "download", document.body.appendChild(e), e.click(), document.body.removeChild(e);
100
100
  }
101
101
  };
102
102
  }
@@ -104,11 +104,11 @@ function J(s) {
104
104
  if (typeof s == "string")
105
105
  switch (s) {
106
106
  case "zoomIn":
107
- return `<button class="vistaview-zoom-in-btn">${U}</button>`;
107
+ return `<button class="vistaview-zoom-in-btn">${N}</button>`;
108
108
  case "zoomOut":
109
- return `<button disabled class="vistaview-zoom-out-btn">${N}</button>`;
109
+ return `<button disabled class="vistaview-zoom-out-btn">${U}</button>`;
110
110
  case "close":
111
- return `<button class="vistaview-close-btn">${j}</button>`;
111
+ return `<button class="vistaview-close-btn">${K}</button>`;
112
112
  case "indexDisplay":
113
113
  return '<div class="vistaview-index-display"></div>';
114
114
  case "description":
@@ -118,126 +118,167 @@ function J(s) {
118
118
  }
119
119
  return `<button data-vistaview-custom-control="${s.name}">${s.icon}</button>`;
120
120
  }
121
- function T(s, t) {
122
- var l, d;
123
- const e = s.imageElm ? getComputedStyle(s.imageElm) : null, n = (e == null ? void 0 : e.objectFit) || "", i = ((l = s.imageElm) == null ? void 0 : l.naturalWidth) || "", o = ((d = s.imageElm) == null ? void 0 : d.naturalHeight) || "", h = (e == null ? void 0 : e.width) || "", r = (e == null ? void 0 : e.height) || "", a = document.createElement("div");
124
- a.className = "vistaview-item", a.dataset.vistaviewPos = `${t !== void 0 ? t : ""}`, a.dataset.vistaviewIndex = s.index.toString();
125
- const c = k(`<img class="vistaview-image-lowres"
126
- style="${n ? `object-fit:${n};` : ""}${h ? `width:${h};` : ""}${r ? `height:${r};` : ""}"
121
+ function q(s, t) {
122
+ var r, c;
123
+ const i = s.imageElm ? getComputedStyle(s.imageElm) : null, n = (i == null ? void 0 : i.objectFit) || "", e = ((r = s.imageElm) == null ? void 0 : r.naturalWidth) || "", a = ((c = s.imageElm) == null ? void 0 : c.naturalHeight) || "", d = (i == null ? void 0 : i.width) || "", o = (i == null ? void 0 : i.height) || "", l = document.createElement("div");
124
+ l.className = "vistaview-item", l.dataset.vistaviewPos = `${t !== void 0 ? t : ""}`, l.dataset.vistaviewIndex = s.index.toString();
125
+ const h = W(`<img class="vistaview-image-lowres"
126
+ style="${n ? `object-fit:${n};` : ""}${d ? `width:${d};` : ""}${o ? `height:${o};` : ""}"
127
127
  src="${s.thumb || s.src}"
128
128
  alt="${s.alt || ""}"
129
- ${i ? `width="${i}"` : ""}
130
- ${o ? `height="${o}"` : ""}
129
+ ${e ? `width="${e}"` : ""}
130
+ ${a ? `height="${a}"` : ""}
131
131
  />
132
132
  <img class="vistaview-image-highres" src="${s.src}" alt="${s.alt || ""}" />`);
133
- return a.appendChild(c), a;
133
+ return l.appendChild(h), l;
134
134
  }
135
135
  function Q({
136
136
  controls: s,
137
137
  isReducedMotion: t
138
138
  }) {
139
- const e = (i) => i ? i.map(J).join("") : "";
140
- return k(
139
+ const i = (e) => e ? e.map(J).join("") : "";
140
+ return W(
141
141
  `<div class="vistaview-root${t ? " vistaview--reduced-motion" : ""}" id="vistaview-root">
142
142
  <div class="vistaview-container">
143
143
  <div class="vistaview-image-container"></div>
144
- <div class="vistaview-top-bar vistaview-ui"><div>${e(s == null ? void 0 : s.topLeft)}</div><div>${e(s == null ? void 0 : s.topCenter)}</div><div>${e(s == null ? void 0 : s.topRight)}</div></div>
145
- <div class="vistaview-bottom-bar vistaview-ui"><div>${e(s == null ? void 0 : s.bottomLeft)}</div><div>${e(s == null ? void 0 : s.bottomCenter)}</div><div>${e(s == null ? void 0 : s.bottomRight)}</div></div>
146
- <div class="vistaview-prev-btn vistaview-ui"><button>${F}</button></div>
147
- <div class="vistaview-next-btn vistaview-ui"><button>${V}</button></div>
144
+ <div class="vistaview-top-bar vistaview-ui"><div>${i(s == null ? void 0 : s.topLeft)}</div><div>${i(s == null ? void 0 : s.topCenter)}</div><div>${i(s == null ? void 0 : s.topRight)}</div></div>
145
+ <div class="vistaview-bottom-bar vistaview-ui"><div>${i(s == null ? void 0 : s.bottomLeft)}</div><div>${i(s == null ? void 0 : s.bottomCenter)}</div><div>${i(s == null ? void 0 : s.bottomRight)}</div></div>
146
+ <div class="vistaview-prev-btn vistaview-ui"><button>${_}</button></div>
147
+ <div class="vistaview-next-btn vistaview-ui"><button>${F}</button></div>
148
148
  </div>
149
149
  </div>`
150
150
  );
151
151
  }
152
- let S = null, $ = null, M = null, Z = null;
152
+ let A = null, $ = null, Z = null, M = null;
153
153
  function tt(s) {
154
154
  O(s);
155
- const t = s.imageContainerElm, e = s.elements.length;
155
+ const t = s.imageContainerElm, i = s.elements.length;
156
156
  if (!t) return;
157
- let n = 0, i = 0, o = 0, h = 0, r = null, a = 0, c = !1;
158
- S = (l) => {
159
- l.preventDefault(), l.stopPropagation(), s.isZoomed === !1 && (c = !0, n = l.pageX, i = l.pageY, o = l.pageX, h = l.pageY, a = Date.now(), r = null, t.setPointerCapture(l.pointerId));
160
- }, $ = (l) => {
161
- if (l.preventDefault(), l.stopPropagation(), s.isZoomed !== !1 || !c) return;
162
- const d = l.pageX - n, u = l.pageY - i;
163
- o = l.pageX, h = l.pageY, Math.abs(d) >= Math.abs(u) && (r === null || r === !0) ? (t.style.setProperty("--vistaview-pointer-diff-x", `${d}px`), r = !0) : Math.abs(u) > Math.abs(d) && (r === null || r === !1) && (t.style.setProperty("--vistaview-pointer-diff-y", `${u}px`), r = !1);
164
- }, Z = (l) => {
165
- if (l.preventDefault(), l.stopPropagation(), t.releasePointerCapture(l.pointerId), s.isZoomed !== !1 || !c) return;
166
- c = !1, r = null;
167
- const d = Array.from(t.querySelectorAll(".vistaview-item"));
168
- t.style.removeProperty("--vistaview-pointer-diff-x"), t.style.removeProperty("--vistaview-pointer-diff-y"), d.forEach((u) => {
169
- u.style.transition = "", u.style.translate = "";
157
+ let n = 0, e = 0, a = 0, d = 0, o = null, l = 0, h = !1;
158
+ A = (r) => {
159
+ r.preventDefault(), r.stopPropagation(), s.isZoomed === !1 && (h = !0, n = r.pageX, e = r.pageY, a = r.pageX, d = r.pageY, l = Date.now(), o = null, t.setPointerCapture(r.pointerId));
160
+ }, $ = (r) => {
161
+ if (r.preventDefault(), r.stopPropagation(), s.isZoomed !== !1 || !h) return;
162
+ const c = r.pageX - n, m = r.pageY - e;
163
+ a = r.pageX, d = r.pageY, Math.abs(c) >= Math.abs(m) && (o === null || o === !0) ? (t.style.setProperty("--vistaview-pointer-diff-x", `${c}px`), o = !0) : Math.abs(m) > Math.abs(c) && (o === null || o === !1) && (t.style.setProperty("--vistaview-pointer-diff-y", `${m}px`), o = !1);
164
+ }, M = (r) => {
165
+ if (r.preventDefault(), r.stopPropagation(), t.releasePointerCapture(r.pointerId), s.isZoomed !== !1 || !h) return;
166
+ h = !1, o = null;
167
+ const c = Array.from(t.querySelectorAll(".vistaview-item"));
168
+ t.style.removeProperty("--vistaview-pointer-diff-x"), t.style.removeProperty("--vistaview-pointer-diff-y"), c.forEach((m) => {
169
+ m.style.transition = "", m.style.translate = "";
170
170
  });
171
- }, M = (l) => {
172
- if (l.preventDefault(), l.stopPropagation(), t.releasePointerCapture(l.pointerId), s.isZoomed !== !1 || !c) return;
173
- c = !1;
174
- const d = Array.from(t.querySelectorAll(".vistaview-item")), u = o - n, v = h - i, g = Date.now() - a, m = u / g, E = v / g, f = s.options.touchSpeedThreshold || 0.5, y = d.find(
175
- (x) => x.dataset.vistaviewPos === "0"
176
- ), w = Number(y.dataset.vistaviewIndex), C = s.isReducedMotion;
177
- function b() {
178
- d[0].removeEventListener("transitionend", b), t.style.removeProperty("--vistaview-pointer-diff-x"), t.style.removeProperty("--vistaview-pointer-diff-y"), d.forEach((x) => {
179
- x.style.transition = "", x.style.translate = "";
171
+ }, Z = (r) => {
172
+ if (r.preventDefault(), r.stopPropagation(), t.releasePointerCapture(r.pointerId), s.isZoomed !== !1 || !h) return;
173
+ h = !1;
174
+ const c = Array.from(t.querySelectorAll(".vistaview-item")), m = a - n, f = d - e, u = Date.now() - l, v = m / u, y = f / u, p = s.options.touchSpeedThreshold || 0.5, x = c.find(
175
+ (E) => E.dataset.vistaviewPos === "0"
176
+ ), b = Number(x.dataset.vistaviewIndex);
177
+ function g() {
178
+ c[0].removeEventListener("transitionend", g), t.style.removeProperty("--vistaview-pointer-diff-x"), t.style.removeProperty("--vistaview-pointer-diff-y"), c.forEach((E) => {
179
+ E.style.transition = "", E.style.translate = "";
180
180
  });
181
181
  }
182
- function I(x = "0%", X = "0%") {
183
- d.forEach((z) => {
184
- z.style.transition = `translate ${s.options.animationDurationBase * 0.5}ms ease-out`, z.style.translate = `${x} ${X}`;
182
+ function I(E = "0%", L = "0%") {
183
+ c.forEach((D) => {
184
+ D.style.transition = `translate ${s.options.animationDurationBase * 0.5}ms ease-out`, D.style.translate = `${E} ${L}`;
185
185
  });
186
186
  }
187
- m < -f || m > f ? (d[0].addEventListener("transitionend", () => {
188
- s.isReducedMotion = !0, b(), s.view(
189
- m < -f ? (w + 1) % e : (w - 1 + e) % e,
190
- {
191
- next: m < -f,
192
- prev: m > f
193
- }
194
- ), s.isReducedMotion = C;
195
- }), I(m < -f ? "-100%" : "100%")) : E < -f || E > f ? (s.close(), I("0%", "0%")) : (d[0].addEventListener("transitionend", b), I("0%"));
196
- }, t.addEventListener("pointermove", $), t.addEventListener("pointerup", M), t.addEventListener("pointerdown", S), t.addEventListener("pointercancel", Z);
187
+ if (v < -p || v > p) {
188
+ let E = function() {
189
+ c[0].removeEventListener("transitionend", E), setTimeout(() => {
190
+ const L = s.isReducedMotion;
191
+ s.isReducedMotion = !0, g(), s.view(
192
+ v < -p ? (b + 1) % i : (b - 1 + i) % i,
193
+ {
194
+ next: v < -p,
195
+ prev: v > p
196
+ }
197
+ ), s.isReducedMotion = L;
198
+ }, 100);
199
+ };
200
+ I(v < -p ? "-100%" : "100%"), c[0].addEventListener("transitionend", E);
201
+ } else y < -p || y > p ? (s.close(), I("0%", "0%")) : (c[0].addEventListener("transitionend", g), I("0%"));
202
+ }, t.addEventListener("pointermove", $), t.addEventListener("pointerup", Z), t.addEventListener("pointerdown", A), t.addEventListener("pointercancel", M);
197
203
  }
198
204
  function O(s) {
199
205
  const t = s.imageContainerElm;
200
- t && ($ && t.removeEventListener("pointermove", $), M && t.removeEventListener("pointerup", M), S && t.removeEventListener("pointerdown", S), Z && t.removeEventListener("pointercancel", Z));
206
+ t && ($ && t.removeEventListener("pointermove", $), Z && t.removeEventListener("pointerup", Z), A && t.removeEventListener("pointerdown", A), M && t.removeEventListener("pointercancel", M));
201
207
  }
202
208
  const et = (s) => {
203
209
  tt(s);
204
210
  }, it = ({
205
211
  htmlElements: { to: s },
206
212
  index: { to: t },
207
- elements: e
213
+ elements: i
208
214
  }) => {
209
- e instanceof NodeList && t !== null && (e.forEach((n) => n.style.opacity = "1"), e[t].style.opacity = "0"), s && s.forEach((n) => {
210
- const i = Number(n.dataset.vistaviewPos);
211
- i !== 0 ? (n.style.zIndex = "1", n.style.left = 100 * i + "%") : n.style.zIndex = "2";
215
+ i instanceof NodeList && t !== null && (i.forEach((n) => n.style.opacity = "1"), i[t].style.opacity = "0"), s && s.forEach((n) => {
216
+ const e = Number(n.dataset.vistaviewPos);
217
+ e !== 0 ? (n.style.zIndex = "1", n.style.left = 100 * e + "%") : n.style.zIndex = "2";
212
218
  });
213
219
  }, nt = async ({
214
220
  htmlElements: { from: s, to: t },
215
- images: { to: e },
216
- via: { next: n, prev: i },
217
- container: o,
218
- options: h,
219
- isReducedMotion: r
221
+ images: { to: i },
222
+ via: { next: n, prev: e },
223
+ options: a,
224
+ isReducedMotion: d
220
225
  // index: { from: fromIndex, to: toIndex },
221
- }) => {
222
- if (!e) throw new Error("VistaView: images is null in defaultTransition()");
223
- if (r)
224
- return o.innerHTML = "", t.forEach((c) => {
225
- o.appendChild(c);
226
- }), e[e.length === 1 ? 0 : Math.floor(e.length / 2)];
227
- const a = s.filter((c) => c.dataset.vistaviewPos === "0" || (n ? c.dataset.vistaviewPos === "1" : c.dataset.vistaviewPos === "-1"));
228
- return await new Promise((c) => {
229
- function l() {
230
- o.innerHTML = "", t.forEach((d) => {
231
- o.appendChild(d);
232
- }), c(0);
226
+ }, o) => {
227
+ if (!i) throw new Error("VistaView: images is null in defaultTransition()");
228
+ const l = s.filter((h) => h.dataset.vistaviewPos === "0" || (n ? h.dataset.vistaviewPos === "1" : h.dataset.vistaviewPos === "-1"));
229
+ d || await new Promise((h, r) => {
230
+ let c = 0;
231
+ if (o.aborted) {
232
+ r(new P("Transition aborted"));
233
+ return;
233
234
  }
234
- a[a.length - 1].addEventListener("transitionend", l), a.forEach((d) => {
235
- d.style.transition = `translate ${h.animationDurationBase * 0.5}ms ease-out`, d.style.translate = n ? "-100%" : i ? "100%" : "0%";
235
+ const m = (f) => {
236
+ if (o.aborted) {
237
+ r(new P("Transition aborted"));
238
+ return;
239
+ }
240
+ if (f.currentTarget.removeEventListener("transitionend", m), c++, c < l.length) return;
241
+ const u = t == null ? void 0 : t.find((g) => g.dataset.vistaviewPos === "0"), v = u ? Number(u.dataset.vistaviewIndex) : 0, y = l.find((g) => Number(g.dataset.vistaviewIndex) === v), p = y == null ? void 0 : y.querySelector(
242
+ ".vistaview-image-highres"
243
+ );
244
+ if (!p) {
245
+ r(new Error("current image element not found"));
246
+ return;
247
+ }
248
+ if (!p.classList.contains("vistaview-image-loaded")) {
249
+ h(0);
250
+ return;
251
+ }
252
+ if (u == null || u.classList.add("vistaview-image-loaded"), p.classList.contains("vistaview-image-settled")) {
253
+ u == null || u.classList.add("vistaview-image-settled"), h(0);
254
+ return;
255
+ }
256
+ let x = 0;
257
+ const b = setInterval(() => {
258
+ if (o.aborted) {
259
+ clearInterval(b), r(new P("Transition aborted"));
260
+ return;
261
+ }
262
+ if (x++, x > a.animationDurationBase / 20 * 1.5) {
263
+ clearInterval(b), h(0);
264
+ return;
265
+ }
266
+ p.classList.contains("vistaview-image-settled") && (u == null || u.classList.add("vistaview-image-settled"), clearInterval(b), h(0));
267
+ }, 20);
268
+ };
269
+ l.forEach((f) => {
270
+ f.style.transition = `translate ${a.animationDurationBase * 0.5}ms ease-out`, f.style.translate = n ? "-100%" : e ? "100%" : "0%", f.addEventListener("transitionend", m);
236
271
  });
237
- }), e[e.length === 1 ? 0 : Math.floor(e.length / 2)];
272
+ });
238
273
  }, st = (s) => {
239
274
  s.elements instanceof NodeList && s.elements.forEach((t) => t.style.opacity = "1"), O(s);
240
- }, q = {
275
+ };
276
+ class P extends Error {
277
+ constructor(t) {
278
+ super(t), this.name = "VistaViewTransitionAbortedError";
279
+ }
280
+ }
281
+ const k = {
241
282
  detectReducedMotion: !0,
242
283
  // debug, don't remove
243
284
  // animationDurationBase: 1000,
@@ -253,22 +294,22 @@ const et = (s) => {
253
294
  topRight: ["zoomIn", "zoomOut", G(), "close"],
254
295
  bottomCenter: ["description"]
255
296
  }
256
- }, L = {
297
+ }, C = {
257
298
  somethingOpened: null
258
299
  };
259
300
  class ot {
260
- constructor(t, e) {
261
- p(this, "options");
262
- p(this, "elements");
263
- p(this, "isReducedMotion");
264
- p(this, "currentIndex", {
301
+ constructor(t, i) {
302
+ w(this, "options");
303
+ w(this, "elements");
304
+ w(this, "isReducedMotion");
305
+ w(this, "currentIndex", {
265
306
  _value: null,
266
307
  _vistaView: null,
267
308
  _via: { next: !1, prev: !1 },
268
309
  set value(t) {
269
310
  var n;
270
- const e = this._value;
271
- this._value = t, (n = this._vistaView) == null || n.swap(e, this._value);
311
+ const i = this._value;
312
+ this._value = t, (n = this._vistaView) == null || n.swap(i, this._value);
272
313
  },
273
314
  get value() {
274
315
  return this._value;
@@ -280,57 +321,50 @@ class ot {
280
321
  this._via = t;
281
322
  }
282
323
  });
283
- p(this, "rootElm", null);
284
- p(this, "imageContainerElm", null);
285
- p(this, "customControls", {});
286
- p(this, "currentImages", null);
287
- p(this, "currentItems", null);
288
- p(this, "navActive", !0);
289
- p(this, "isZoomed", !1);
290
- p(this, "onClickElements", []);
291
- p(this, "onResizeHandler", null);
292
- p(this, "onKeyDown", null);
293
- p(this, "userSetup", it);
294
- p(this, "userTransition", nt);
295
- p(this, "userClose", st);
296
- p(this, "userInit", et);
297
- p(this, "onZoomedPointerDown", null);
298
- p(this, "onZoomedPointerMove", null);
299
- p(this, "onZoomedPointerUp", null);
324
+ w(this, "rootElm", null);
325
+ w(this, "imageContainerElm", null);
326
+ w(this, "customControls", {});
327
+ w(this, "currentImages", null);
328
+ w(this, "currentItems", null);
329
+ w(this, "navActive", !0);
330
+ w(this, "isZoomed", !1);
331
+ w(this, "onClickElements", (t) => {
332
+ t.preventDefault();
333
+ const i = t.currentTarget;
334
+ i.dataset.vistaviewIndex && this.open(parseInt(i.dataset.vistaviewIndex));
335
+ });
336
+ w(this, "defaultOnClickHandler", (t) => t.preventDefault());
337
+ w(this, "onResizeHandler", null);
338
+ w(this, "onKeyDown", null);
339
+ w(this, "userSetup", it);
340
+ w(this, "userTransition", nt);
341
+ w(this, "userClose", st);
342
+ w(this, "userInit", et);
343
+ w(this, "onZoomedPointerDown", null);
344
+ w(this, "onZoomedPointerMove", null);
345
+ w(this, "onZoomedPointerUp", null);
346
+ w(this, "transitionAbortController", null);
300
347
  this.elements = t, this.currentIndex._vistaView = this, this.options = {
301
- ...q,
302
- ...e || {},
348
+ ...k,
349
+ ...i || {},
303
350
  controls: {
304
- ...q.controls,
305
- ...(e == null ? void 0 : e.controls) || {}
351
+ ...k.controls,
352
+ ...(i == null ? void 0 : i.controls) || {}
306
353
  }
307
- }, this.options.initFunction && (this.userInit = this.options.initFunction), this.options.transitionFunction && (this.userTransition = this.options.transitionFunction), this.options.closeFunction && (this.userClose = this.options.closeFunction), this.options.initFunction && (this.userInit = this.options.initFunction), this.isReducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches, this.elements instanceof NodeList && this.elements.forEach((n, i) => {
308
- this.onClickElements.push((o) => {
309
- o.preventDefault(), this.open(i);
310
- }), n.addEventListener("click", this.onClickElements[i]);
354
+ }, this.options.initFunction && (this.userInit = this.options.initFunction), this.options.transitionFunction && (this.userTransition = this.options.transitionFunction), this.options.closeFunction && (this.userClose = this.options.closeFunction), this.options.initFunction && (this.userInit = this.options.initFunction), this.isReducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches, this.elements instanceof NodeList && this.elements.forEach((n, e) => {
355
+ n.dataset.vistaviewIndex = e.toString(), n.addEventListener("click", this.defaultOnClickHandler), n.addEventListener("pointerup", this.onClickElements);
311
356
  });
312
357
  }
313
- async swap(t, e) {
314
- var c, l;
315
- if (!L.somethingOpened || t === e || t === null || this.elements.length === 1) return;
316
- if (!this.imageContainerElm)
358
+ async swap(t, i) {
359
+ var l, h;
360
+ if (!C.somethingOpened || t === i || t === null) return;
361
+ if (this.transitionAbortController && this.transitionAbortController.abort(), !this.imageContainerElm)
317
362
  throw new Error("VistaView: imageContainerElm is null in swap()");
318
363
  this.setIndexDisplay(), this.clearZoom();
319
- const { images: n, positions: i } = this.getCurrentIndexes(e), o = this.getImages(n), h = o.map((d, u) => T(d, i[u]));
320
- h.forEach((d, u) => {
321
- var m, E;
322
- const v = d.querySelector(".vistaview-image-highres"), g = o[u].imageElm;
323
- if (v.complete && v.naturalWidth > 0) {
324
- const { width: f, height: y } = H(g);
325
- f && y && (v.style.setProperty("--vistaview-fitted-width", `${f}px`), v.style.setProperty("--vistaview-fitted-height", `${y}px`)), v.classList.add("vistaview-image-loaded"), (m = d.querySelector(".vistaview-image-lowres")) == null || m.classList.add("vistaview-image--hidden");
326
- const { width: w, height: C } = P(v);
327
- v.style.width = `${w}px`, v.style.height = `${C}px`, v.width = v.naturalWidth, v.height = v.naturalHeight, (E = v.parentElement) != null && E.matches('[data-vistaview-pos="0"]') && this.updateZoomButtonsVisibility();
328
- }
329
- }), this.navActive = !1;
330
- const r = {
331
- htmlElements: { from: this.currentItems, to: h },
332
- images: { from: this.currentImages, to: o },
333
- index: { from: t, to: e },
364
+ const { images: n, positions: e } = this.getCurrentIndexes(i), a = this.getImages(n), d = a.map((r, c) => q(r, e[c])), o = {
365
+ htmlElements: { from: this.currentItems, to: d },
366
+ images: { from: this.currentImages, to: a },
367
+ index: { from: t, to: i },
334
368
  via: this.currentIndex.via,
335
369
  container: this.imageContainerElm,
336
370
  elements: this.elements,
@@ -339,117 +373,131 @@ class ot {
339
373
  isZoomed: this.isZoomed,
340
374
  options: this.options
341
375
  };
342
- this.userSetup(r);
343
- const a = await this.userTransition(r);
344
- this.navActive = !0, this.setInitialDimPos(a), this.currentImages = o, this.currentItems = h, this.loadImages(), this.setCurrentDescription(), (l = (c = this.options).onImageView) == null || l.call(c, r);
376
+ this.userSetup(o), this.transitionAbortController = new AbortController();
377
+ try {
378
+ await this.userTransition(o, this.transitionAbortController.signal);
379
+ } catch (r) {
380
+ r instanceof P || console.error(r);
381
+ }
382
+ this.imageContainerElm.innerHTML = "", d.forEach((r) => {
383
+ const c = r.dataset.vistaviewPos, m = r.dataset.vistaviewIndex;
384
+ if (c === "0") {
385
+ const f = this.currentItems.find((y) => y.dataset.vistaviewIndex === m), u = r.querySelector(".vistaview-image-highres"), v = f == null ? void 0 : f.querySelector(".vistaview-image-highres");
386
+ v && (u.setAttribute("class", v.getAttribute("class") || ""), u.setAttribute("style", v.getAttribute("style") || "")), this.imageContainerElm.appendChild(r);
387
+ } else
388
+ this.imageContainerElm.appendChild(r);
389
+ }), this.setInitialDimPos(), this.currentImages = a, this.currentItems = d, this.loadImages(), this.setCurrentDescription(), this.updateZoomButtonsVisibility(), (h = (l = this.options).onImageView) == null || h.call(l, o);
345
390
  }
346
391
  //
347
392
  setZoomed(t) {
348
- var e, n, i, o, h, r;
393
+ var i, n, e, a, d, o;
349
394
  if (this.isZoomed !== t) {
350
395
  if (this.isZoomed) {
351
- let a = this.isZoomed;
352
- if (a.classList.remove("vistaview-image--zooming"), this.onZoomedPointerDown && ((e = a.parentElement) == null || e.removeEventListener("pointerdown", this.onZoomedPointerDown), this.onZoomedPointerDown = null), this.onZoomedPointerMove && ((n = a.parentElement) == null || n.removeEventListener("pointermove", this.onZoomedPointerMove), this.onZoomedPointerMove = null), this.onZoomedPointerUp && ((i = a.parentElement) == null || i.removeEventListener("pointerup", this.onZoomedPointerUp), this.onZoomedPointerUp = null), a == null || a.style.removeProperty("--pointer-diff-x"), a == null || a.style.removeProperty("--pointer-diff-y"), setTimeout(() => {
353
- a == null || a.classList.remove("vistaview-image--zooming");
396
+ let l = this.isZoomed;
397
+ if (l.classList.remove("vistaview-image--zooming"), this.onZoomedPointerDown && ((i = l.parentElement) == null || i.removeEventListener("pointerdown", this.onZoomedPointerDown), this.onZoomedPointerDown = null), this.onZoomedPointerMove && ((n = l.parentElement) == null || n.removeEventListener("pointermove", this.onZoomedPointerMove), this.onZoomedPointerMove = null), this.onZoomedPointerUp && ((e = l.parentElement) == null || e.removeEventListener("pointerup", this.onZoomedPointerUp), this.onZoomedPointerUp = null), l == null || l.style.removeProperty("--pointer-diff-x"), l == null || l.style.removeProperty("--pointer-diff-y"), setTimeout(() => {
398
+ l == null || l.classList.remove("vistaview-image--zooming");
354
399
  }, 500), this.isZoomed = !1, !t) return;
355
400
  }
356
401
  if (t) {
357
402
  this.isZoomed = t, t.classList.add("vistaview-image--zooming"), t == null || t.style.setProperty("--pointer-diff-x", "0px"), t == null || t.style.setProperty("--pointer-diff-y", "0px");
358
- let a = !1, c = 0, l = 0, d = 0, u = 0, v = 0, g = 0;
359
- this.onZoomedPointerDown = (m) => {
360
- m.preventDefault(), m.stopPropagation(), a = !0, c = m.pageX, l = m.pageY, t.setPointerCapture(m.pointerId);
361
- }, this.onZoomedPointerMove = (m) => {
362
- if (!a) return;
363
- m.preventDefault(), v = m.pageX - c, g = m.pageY - l;
364
- const E = parseInt((t == null ? void 0 : t.dataset.vistaviewCurrentWidth) || "0"), f = parseInt((t == null ? void 0 : t.dataset.vistaviewCurrentHeight) || "0"), { maxDiffX: y, minDiffY: w, maxDiffY: C, minDiffX: b } = W(
365
- E,
366
- f
367
- ), I = Math.min(y, Math.max(b, d + v)), x = Math.min(C, Math.max(w, u + g));
368
- v = I - d, g = x - u, t == null || t.style.setProperty("--pointer-diff-x", `${I}px`), t == null || t.style.setProperty("--pointer-diff-y", `${x}px`);
369
- }, this.onZoomedPointerUp = (m) => {
370
- a = !1, t.releasePointerCapture(m.pointerId), d += v, u += g, v = 0, g = 0;
371
- }, (o = t == null ? void 0 : t.parentElement) == null || o.addEventListener("pointerdown", this.onZoomedPointerDown), (h = t == null ? void 0 : t.parentElement) == null || h.addEventListener("pointermove", this.onZoomedPointerMove), (r = t == null ? void 0 : t.parentElement) == null || r.addEventListener("pointerup", this.onZoomedPointerUp);
403
+ let l = !1, h = 0, r = 0, c = 0, m = 0, f = 0, u = 0;
404
+ this.onZoomedPointerDown = (v) => {
405
+ v.preventDefault(), v.stopPropagation(), l = !0, h = v.pageX, r = v.pageY, t.setPointerCapture(v.pointerId);
406
+ }, this.onZoomedPointerMove = (v) => {
407
+ if (!l) return;
408
+ v.preventDefault(), f = v.pageX - h, u = v.pageY - r;
409
+ const y = parseInt((t == null ? void 0 : t.dataset.vistaviewCurrentWidth) || "0"), p = parseInt((t == null ? void 0 : t.dataset.vistaviewCurrentHeight) || "0"), { maxDiffX: x, minDiffY: b, maxDiffY: g, minDiffX: I } = T(
410
+ y,
411
+ p
412
+ ), E = Math.min(x, Math.max(I, c + f)), L = Math.min(g, Math.max(b, m + u));
413
+ f = E - c, u = L - m, t == null || t.style.setProperty("--pointer-diff-x", `${E}px`), t == null || t.style.setProperty("--pointer-diff-y", `${L}px`);
414
+ }, this.onZoomedPointerUp = (v) => {
415
+ l = !1, t.releasePointerCapture(v.pointerId), c += f, m += u, f = 0, u = 0;
416
+ }, (a = t == null ? void 0 : t.parentElement) == null || a.addEventListener("pointerdown", this.onZoomedPointerDown), (d = t == null ? void 0 : t.parentElement) == null || d.addEventListener("pointermove", this.onZoomedPointerMove), (o = t == null ? void 0 : t.parentElement) == null || o.addEventListener("pointerup", this.onZoomedPointerUp);
372
417
  return;
373
418
  }
374
419
  }
375
420
  }
376
421
  zoomIn() {
377
- var o, h, r, a, c;
378
- const t = (o = this.rootElm) == null ? void 0 : o.querySelector(
422
+ var a, d, o, l, h;
423
+ const t = (a = this.rootElm) == null ? void 0 : a.querySelector(
379
424
  '[data-vistaview-pos="0"] .vistaview-image-highres'
380
- ), e = t.width, n = t.height;
381
- t.dataset.vistaviewInitialWidth || (t.dataset.vistaviewInitialWidth = e.toString()), t.dataset.vistaviewInitialHeight || (t.dataset.vistaviewInitialHeight = n.toString()), this.setZoomed(t);
382
- const i = (t.naturalWidth || 0) * this.options.maxZoomLevel;
383
- if (e && i && e < i) {
384
- const l = Math.min(e + this.options.zoomStep, i);
385
- t.style.width = `${l}px`;
386
- const d = l / e * n;
387
- t.style.height = `${d}px`, (r = (h = this.rootElm) == null ? void 0 : h.querySelector("button.vistaview-zoom-out-btn")) == null || r.removeAttribute("disabled"), t.dataset.vistaviewCurrentWidth = l.toString(), t.dataset.vistaviewCurrentHeight = d.toString(), l === i && ((c = (a = this.rootElm) == null ? void 0 : a.querySelector("button.vistaview-zoom-in-btn")) == null || c.setAttribute("disabled", "true"));
425
+ ), i = t.width, n = t.height;
426
+ t.dataset.vistaviewInitialWidth || (t.dataset.vistaviewInitialWidth = i.toString()), t.dataset.vistaviewInitialHeight || (t.dataset.vistaviewInitialHeight = n.toString()), this.setZoomed(t);
427
+ const e = (t.naturalWidth || 0) * this.options.maxZoomLevel;
428
+ if (i && e && i < e) {
429
+ const r = Math.min(i + this.options.zoomStep, e);
430
+ t.style.width = `${r}px`;
431
+ const c = r / i * n;
432
+ t.style.height = `${c}px`, (o = (d = this.rootElm) == null ? void 0 : d.querySelector("button.vistaview-zoom-out-btn")) == null || o.removeAttribute("disabled"), t.dataset.vistaviewCurrentWidth = r.toString(), t.dataset.vistaviewCurrentHeight = c.toString(), r === e && ((h = (l = this.rootElm) == null ? void 0 : l.querySelector("button.vistaview-zoom-in-btn")) == null || h.setAttribute("disabled", "true"));
388
433
  }
389
434
  }
390
435
  zoomOut() {
391
- var h, r, a, c, l;
392
- const t = (h = this.rootElm) == null ? void 0 : h.querySelector(
436
+ var d, o, l, h, r;
437
+ const t = (d = this.rootElm) == null ? void 0 : d.querySelector(
393
438
  '[data-vistaview-pos="0"] .vistaview-image-highres'
394
- ), e = t.width, n = t.height, i = t.dataset.vistaviewInitialWidth ? parseInt(t.dataset.vistaviewInitialWidth) : 0, o = (d) => {
395
- d.target === t && (t.classList.remove("vistaview-image--zooming-out"), t.removeEventListener("transitionend", o));
439
+ ), i = t.width, n = t.height, e = t.dataset.vistaviewInitialWidth ? parseInt(t.dataset.vistaviewInitialWidth) : 0, a = (c) => {
440
+ c.target === t && (t.classList.remove("vistaview-image--zooming-out"), t.removeEventListener("transitionend", a));
396
441
  };
397
- if (t.addEventListener("transitionend", o), t.classList.add("vistaview-image--zooming-out"), e && i && e > i) {
398
- const d = Math.max(e - this.options.zoomStep, i);
399
- t.style.width = `${d}px`;
400
- const u = d / e * n;
401
- t.style.height = `${u}px`, (a = (r = this.rootElm) == null ? void 0 : r.querySelector("button.vistaview-zoom-in-btn")) == null || a.removeAttribute("disabled"), t.dataset.vistaviewCurrentWidth = d.toString(), t.dataset.vistaviewCurrentHeight = u.toString();
402
- const { maxDiffX: v, minDiffY: g, maxDiffY: m, minDiffX: E } = W(d, u);
403
- let f = parseInt(
442
+ if (t.addEventListener("transitionend", a), t.classList.add("vistaview-image--zooming-out"), i && e && i > e) {
443
+ const c = Math.max(i - this.options.zoomStep, e);
444
+ t.style.width = `${c}px`;
445
+ const m = c / i * n;
446
+ t.style.height = `${m}px`, (l = (o = this.rootElm) == null ? void 0 : o.querySelector("button.vistaview-zoom-in-btn")) == null || l.removeAttribute("disabled"), t.dataset.vistaviewCurrentWidth = c.toString(), t.dataset.vistaviewCurrentHeight = m.toString();
447
+ const { maxDiffX: f, minDiffY: u, maxDiffY: v, minDiffX: y } = T(c, m);
448
+ let p = parseInt(
404
449
  (t == null ? void 0 : t.style.getPropertyValue("--pointer-diff-x").replace("px", "")) || "0"
405
- ), y = parseInt(
450
+ ), x = parseInt(
406
451
  (t == null ? void 0 : t.style.getPropertyValue("--pointer-diff-y").replace("px", "")) || "0"
407
452
  );
408
- f = Math.min(v, Math.max(E, f)), y = Math.min(m, Math.max(g, y)), t == null || t.style.setProperty("--pointer-diff-x", `${f}px`), t == null || t.style.setProperty("--pointer-diff-y", `${y}px`), d === i && ((l = (c = this.rootElm) == null ? void 0 : c.querySelector("button.vistaview-zoom-out-btn")) == null || l.setAttribute("disabled", "true"), t.removeAttribute("data-vistaview-current-width"), t.removeAttribute("data-vistaview-current-height"), t.removeAttribute("data-vistaview-initial-width"), t.removeAttribute("data-vistaview-initial-height"), this.setZoomed(!1));
453
+ p = Math.min(f, Math.max(y, p)), x = Math.min(v, Math.max(u, x)), t == null || t.style.setProperty("--pointer-diff-x", `${p}px`), t == null || t.style.setProperty("--pointer-diff-y", `${x}px`), c === e && ((r = (h = this.rootElm) == null ? void 0 : h.querySelector("button.vistaview-zoom-out-btn")) == null || r.setAttribute("disabled", "true"), t.removeAttribute("data-vistaview-current-width"), t.removeAttribute("data-vistaview-current-height"), t.removeAttribute("data-vistaview-initial-width"), t.removeAttribute("data-vistaview-initial-height"), this.setZoomed(!1));
409
454
  }
410
455
  }
411
456
  clearZoom() {
412
457
  }
413
458
  getImages(t) {
414
- return t.map((e, n) => {
415
- const i = this.elements[e];
416
- if (i instanceof HTMLElement) {
417
- const o = i.querySelector("img"), h = i.getAttribute("href") || "", r = i.getAttribute("src") || "", a = i.dataset.vistaviewSrc || h || r || (o == null ? void 0 : o.src) || "", c = i.dataset.vistaviewAlt || i.getAttribute("alt") || (o == null ? void 0 : o.alt) || "", l = i.dataset.vistaviewThumb || (o == null ? void 0 : o.src) || h || r || "";
459
+ return t.map((i, n) => {
460
+ const e = this.elements[i];
461
+ if (e instanceof HTMLElement) {
462
+ const a = e.querySelector("img"), d = e.getAttribute("href") || "", o = e.getAttribute("src") || "", l = e.dataset.vistaviewSrc || d || o || (a == null ? void 0 : a.src) || "", h = e.dataset.vistaviewAlt || e.getAttribute("alt") || (a == null ? void 0 : a.alt) || "", r = e.dataset.vistaviewThumb || (a == null ? void 0 : a.src) || d || o || "";
418
463
  return {
419
464
  index: t[n],
420
- src: a,
421
- alt: c,
422
- thumb: l,
423
- imageElm: i instanceof HTMLImageElement ? i : o,
424
- anchorElm: i instanceof HTMLAnchorElement ? i : void 0
465
+ src: l,
466
+ alt: h,
467
+ thumb: r,
468
+ imageElm: e instanceof HTMLImageElement ? e : a,
469
+ anchorElm: e instanceof HTMLAnchorElement ? e : void 0
425
470
  };
426
471
  } else
427
- return { index: t[n], ...i };
472
+ return { index: t[n], ...e };
428
473
  });
429
474
  }
430
- setInitialDimPos(t) {
475
+ setInitialDimPos() {
476
+ var h, r;
431
477
  if (!this.rootElm) return;
432
- const e = t.imageElm ? A(t.imageElm) : void 0, n = t.anchorElm ? A(t.anchorElm) : void 0, i = (n == null ? void 0 : n.width) || (e == null ? void 0 : e.width) || 0, o = (n == null ? void 0 : n.height) || (e == null ? void 0 : e.height) || 0, h = ((n == null ? void 0 : n.left) || (e == null ? void 0 : e.left) || 0) + i / 2, r = ((n == null ? void 0 : n.top) || (e == null ? void 0 : e.top) || 0) + o / 2;
433
- this.rootElm.style.setProperty("--vistaview-container-initial-width", i + "px"), this.rootElm.style.setProperty("--vistaview-container-initial-height", o + "px"), this.rootElm.style.setProperty("--vistaview-container-initial-top", r + "px"), this.rootElm.style.setProperty("--vistaview-container-initial-left", h + "px"), this.rootElm.style.setProperty(
478
+ const t = (h = this.rootElm.querySelector('[data-vistaview-pos="0"]')) == null ? void 0 : h.dataset.vistaviewIndex, i = ((r = this.currentImages) == null ? void 0 : r.find((c) => c.index === Number(t))) || null;
479
+ if (!i) return;
480
+ const n = i.imageElm ? z(i.imageElm) : void 0, e = i.anchorElm ? z(i.anchorElm) : void 0, a = (e == null ? void 0 : e.width) || (n == null ? void 0 : n.width) || 0, d = (e == null ? void 0 : e.height) || (n == null ? void 0 : n.height) || 0, o = ((e == null ? void 0 : e.left) || (n == null ? void 0 : n.left) || 0) + a / 2, l = ((e == null ? void 0 : e.top) || (n == null ? void 0 : n.top) || 0) + d / 2;
481
+ this.rootElm.style.setProperty("--vistaview-container-initial-width", a + "px"), this.rootElm.style.setProperty("--vistaview-container-initial-height", d + "px"), this.rootElm.style.setProperty("--vistaview-container-initial-top", l + "px"), this.rootElm.style.setProperty("--vistaview-container-initial-left", o + "px"), this.rootElm.style.setProperty(
434
482
  "--vistaview-image-border-radius",
435
- R(n == null ? void 0 : n.borderRadius) || R(e == null ? void 0 : e.borderRadius) || "0px"
483
+ R(e == null ? void 0 : e.borderRadius) || R(n == null ? void 0 : n.borderRadius) || "0px"
436
484
  );
437
485
  }
438
486
  updateZoomButtonsVisibility() {
439
- var i;
440
- const t = (i = this.rootElm) == null ? void 0 : i.querySelector(
487
+ var e;
488
+ const t = (e = this.rootElm) == null ? void 0 : e.querySelector(
441
489
  '[data-vistaview-pos="0"] img.vistaview-image-highres'
442
490
  );
443
491
  if (!t) return;
444
- const e = this;
492
+ const i = this;
445
493
  function n() {
446
- var l, d;
447
- const o = (l = e.rootElm) == null ? void 0 : l.querySelector(
494
+ var r, c;
495
+ const a = (r = i.rootElm) == null ? void 0 : r.querySelector(
448
496
  "button.vistaview-zoom-in-btn"
449
- ), h = (d = e.rootElm) == null ? void 0 : d.querySelector(
497
+ ), d = (c = i.rootElm) == null ? void 0 : c.querySelector(
450
498
  "button.vistaview-zoom-out-btn"
451
- ), r = parseInt(t.style.width) || t.width, a = t.naturalWidth * e.options.maxZoomLevel, c = r < a && a > 0;
452
- o && (o.style.display = c ? "" : "none"), h && (h.style.display = c ? "" : "none");
499
+ ), o = parseInt(t.style.width) || t.width, l = t.naturalWidth * i.options.maxZoomLevel, h = o < l && l > 0;
500
+ a && (a.style.display = h ? "" : "none"), d && (d.style.display = h ? "" : "none");
453
501
  }
454
502
  t.complete && t.naturalWidth > 0 ? n() : t.addEventListener("load", n);
455
503
  }
@@ -457,28 +505,38 @@ class ot {
457
505
  if (!this.rootElm) return;
458
506
  this.rootElm.querySelectorAll(
459
507
  ".vistaview-image-highres:not(.vistaview-image-loaded)"
460
- ).forEach((e, n) => {
461
- const i = e, h = this.currentImages[n].imageElm, r = { w: 0, h: 0 };
462
- if (h) {
463
- const { width: c, height: l } = H(h);
464
- r.w = Math.min(h.width, c), r.h = Math.min(h.height, l);
508
+ ).forEach((i, n) => {
509
+ const e = i, d = this.currentImages[n].imageElm, o = { w: 0, h: 0 };
510
+ if (d) {
511
+ const { width: h, height: r } = B(d);
512
+ o.w = Math.min(d.width, h), o.h = Math.min(d.height, r);
465
513
  }
466
- const a = (c = !1) => () => {
467
- var l;
468
- if (r.w && r.h && (i.style.width = `${r.w}px`, i.style.height = `${r.h}px`, i.style.setProperty("--vistaview-fitted-width", `${r.w}px`), i.style.setProperty("--vistaview-fitted-height", `${r.h}px`)), i.classList.add("vistaview-image-loaded"), i.width = i.naturalWidth, i.height = i.naturalHeight, c) {
469
- const { width: d, height: u } = P(i);
470
- i.style.width = `${d}px`, i.style.height = `${u}px`;
471
- } else
472
- setTimeout(() => {
473
- const { width: d, height: u } = P(i);
474
- i.style.width = `${d}px`, i.style.height = `${u}px`;
475
- }, 333);
476
- setTimeout(() => {
477
- var d, u;
478
- (u = (d = i.parentElement) == null ? void 0 : d.querySelector(".vistaview-image-lowres")) == null || u.classList.add("vistaview-image--hidden");
479
- }, 500), (l = e.parentElement) != null && l.matches('[data-vistaview-pos="0"]') && this.updateZoomButtonsVisibility();
514
+ const l = () => {
515
+ var r;
516
+ const h = () => {
517
+ var c;
518
+ o.w && o.h && (e.style.width = `${o.w}px`, e.style.height = `${o.h}px`, e.style.setProperty("--vistaview-fitted-width", `${o.w}px`), e.style.setProperty("--vistaview-fitted-height", `${o.h}px`)), e.classList.add("vistaview-image-loaded"), e.width = e.naturalWidth, e.height = e.naturalHeight, setTimeout(() => {
519
+ var y, p;
520
+ let m = 0;
521
+ const f = () => {
522
+ var x, b;
523
+ m++, !(m < 3) && (e.removeEventListener("transitionend", f), (b = (x = e.parentElement) == null ? void 0 : x.querySelector(".vistaview-image-lowres")) == null || b.classList.add("vistaview-image--hidden"), e.classList.add("vistaview-image-settled"));
524
+ };
525
+ e.addEventListener("transitionend", f);
526
+ const { width: u, height: v } = H(e);
527
+ e.style.width = `${u}px`, e.style.height = `${v}px`, o.w && o.h && u === o.w && v === o.h ? ((p = (y = e.parentElement) == null ? void 0 : y.querySelector(".vistaview-image-lowres")) == null || p.classList.add("vistaview-image--hidden"), e.classList.add("vistaview-image-settled")) : (e.style.width = `${u}px`, e.style.height = `${v}px`);
528
+ }, 100), (c = i.parentElement) != null && c.matches('[data-vistaview-pos="0"]') && this.updateZoomButtonsVisibility();
529
+ };
530
+ if ((r = this.rootElm) != null && r.classList.contains("vistaview--opened"))
531
+ h();
532
+ else {
533
+ const c = setInterval(() => {
534
+ var m;
535
+ (m = this.rootElm) != null && m.classList.contains("vistaview--opened") && (clearInterval(c), h());
536
+ }, 50);
537
+ }
480
538
  };
481
- i.complete && i.naturalWidth > 0 ? a(!0)() : i.onload = a(!1);
539
+ e.complete && e.naturalWidth > 0 ? l() : e.onload = l;
482
540
  });
483
541
  }
484
542
  setIndexDisplay() {
@@ -488,19 +546,19 @@ class ot {
488
546
  this.rootElm.querySelector(".vistaview-description").textContent = (this.currentImages[1] || this.currentImages[0]).alt || "";
489
547
  }
490
548
  getCurrentIndexes(t) {
491
- const e = this.options.preloads, n = this.elements.length, i = n < 1 || !e ? [t] : [
549
+ const i = this.options.preloads, n = this.elements.length, e = n < 1 || !i ? [t] : [
492
550
  .../* @__PURE__ */ new Set([
493
551
  ...Array.from(
494
- { length: e },
495
- (h, r) => ((t - e + r) % n + n) % n
552
+ { length: i },
553
+ (d, o) => ((t - i + o) % n + n) % n
496
554
  ),
497
555
  t,
498
- ...Array.from({ length: e }, (h, r) => (t + 1 + r) % n)
556
+ ...Array.from({ length: i }, (d, o) => (t + 1 + o) % n)
499
557
  ])
500
- ], o = n < 1 || !e ? [0] : i.map((h, r) => r - Math.floor(i.length / 2));
558
+ ], a = n < 1 || !i ? [0] : e.map((d, o) => o - Math.floor(e.length / 2));
501
559
  return {
502
- images: i,
503
- positions: o
560
+ images: e,
561
+ positions: a
504
562
  };
505
563
  }
506
564
  setKeyboardListeners() {
@@ -526,37 +584,36 @@ class ot {
526
584
  }
527
585
  setResizeListeners() {
528
586
  this.onResizeHandler = () => {
529
- var n;
530
- const t = this.currentImages[this.currentImages.length === 1 ? 0 : Math.floor(this.currentImages.length / 2)];
531
- this.setInitialDimPos(t);
532
- const e = (n = this.rootElm) == null ? void 0 : n.querySelectorAll(
587
+ var i;
588
+ this.setInitialDimPos();
589
+ const t = (i = this.rootElm) == null ? void 0 : i.querySelectorAll(
533
590
  ".vistaview-image-highres.vistaview-image-loaded"
534
591
  );
535
- e == null || e.forEach((i) => {
536
- const o = i, { width: h, height: r } = P(o);
537
- o.classList.contains("vistaview-image--zooming") ? (o.dataset.vistaviewInitialWidth = h.toString(), o.dataset.vistaviewInitialHeight = r.toString()) : (o.style.width = `${h}px`, o.style.height = `${r}px`);
592
+ t == null || t.forEach((n) => {
593
+ const e = n, { width: a, height: d } = H(e);
594
+ e.classList.contains("vistaview-image--zooming") ? (e.dataset.vistaviewInitialWidth = a.toString(), e.dataset.vistaviewInitialHeight = d.toString()) : (e.style.width = `${a}px`, e.style.height = `${d}px`);
538
595
  });
539
596
  }, window.addEventListener("resize", this.onResizeHandler);
540
597
  }
541
598
  open(t = 0) {
542
- var h, r, a, c, l, d, u, v, g, m, E, f, y;
543
- if (L.somethingOpened) {
599
+ var o, l, h, r, c, m, f, u, v, y, p, x, b;
600
+ if (C.somethingOpened) {
544
601
  console.error("VistaView: another instance is already opened. Returning.");
545
602
  return;
546
603
  }
547
- if (L.somethingOpened = this, this.currentIndex._value = t, document.body.prepend(
604
+ if (C.somethingOpened = this, this.currentIndex._value = t, document.body.prepend(
548
605
  Q({
549
606
  controls: this.options.controls,
550
607
  isReducedMotion: this.isReducedMotion
551
608
  })
552
- ), this.rootElm = document.querySelector("#vistaview-root"), this.imageContainerElm = ((h = this.rootElm) == null ? void 0 : h.querySelector(".vistaview-image-container")) || null, !this.rootElm || !this.imageContainerElm)
553
- throw L.somethingOpened = null, new Error("Failed to create VistaView element");
609
+ ), this.rootElm = document.querySelector("#vistaview-root"), this.imageContainerElm = ((o = this.rootElm) == null ? void 0 : o.querySelector(".vistaview-image-container")) || null, !this.rootElm || !this.imageContainerElm)
610
+ throw C.somethingOpened = null, new Error("Failed to create VistaView element");
554
611
  this.options.arrowOnSmallScreens || this.rootElm.classList.add("vistaview-no-arrows-sm");
555
- const { images: e, positions: n } = this.getCurrentIndexes(t);
556
- this.currentImages = this.getImages(e);
557
- const i = this.currentImages.map((w, C) => T(w, n[C]));
558
- this.currentItems = i;
559
- const o = {
612
+ const { images: i, positions: n } = this.getCurrentIndexes(t);
613
+ this.currentImages = this.getImages(i);
614
+ const e = this.currentImages.map((g, I) => q(g, n[I]));
615
+ this.currentItems = e;
616
+ const a = {
560
617
  htmlElements: { from: null, to: this.currentItems },
561
618
  images: { from: null, to: this.currentImages },
562
619
  index: { from: null, to: t },
@@ -568,25 +625,30 @@ class ot {
568
625
  isZoomed: this.isZoomed,
569
626
  options: this.options
570
627
  };
571
- this.userSetup(o), this.imageContainerElm.innerHTML = "", this.currentItems.forEach((w) => {
572
- this.imageContainerElm.appendChild(w);
573
- }), (r = this.rootElm.querySelector(".vistaview-close-btn")) == null || r.addEventListener("click", () => this.close()), (a = this.rootElm.querySelector(".vistaview-zoom-in-btn")) == null || a.addEventListener("click", () => this.zoomIn()), (c = this.rootElm.querySelector(".vistaview-zoom-out-btn")) == null || c.addEventListener("click", () => this.zoomOut()), (l = this.rootElm.querySelector(".vistaview-prev-btn>button")) == null || l.addEventListener("click", () => this.prev()), (d = this.rootElm.querySelector(".vistaview-next-btn>button")) == null || d.addEventListener("click", () => this.next()), [
628
+ this.userSetup(a), this.imageContainerElm.innerHTML = "", this.currentItems.forEach((g) => {
629
+ this.imageContainerElm.appendChild(g);
630
+ });
631
+ let d = 0;
632
+ this.rootElm.addEventListener("animationend", (g) => {
633
+ var I;
634
+ g.currentTarget === this.rootElm && (d++, d >= 2 && ((I = this.rootElm) == null || I.classList.add("vistaview--opened")));
635
+ }), (l = this.rootElm.querySelector(".vistaview-close-btn")) == null || l.addEventListener("click", () => this.close()), (h = this.rootElm.querySelector(".vistaview-zoom-in-btn")) == null || h.addEventListener("click", () => this.zoomIn()), (r = this.rootElm.querySelector(".vistaview-zoom-out-btn")) == null || r.addEventListener("click", () => this.zoomOut()), (c = this.rootElm.querySelector(".vistaview-prev-btn>button")) == null || c.addEventListener("click", () => this.prev()), (m = this.rootElm.querySelector(".vistaview-next-btn>button")) == null || m.addEventListener("click", () => this.next()), [
574
636
  ...this.options.controls.topLeft || [],
575
637
  ...this.options.controls.topRight || [],
576
638
  ...this.options.controls.topCenter || [],
577
639
  ...this.options.controls.bottomCenter || [],
578
640
  ...this.options.controls.bottomLeft || [],
579
641
  ...this.options.controls.bottomRight || []
580
- ].forEach((w) => {
581
- typeof w != "string" && (this.customControls[w.name] = w);
582
- }), this.rootElm.querySelectorAll("button[data-vistaview-custom-control]").forEach((w) => {
583
- w.addEventListener("click", (C) => {
584
- const b = this.customControls[C.currentTarget.dataset.vistaviewCustomControl], I = this.currentImages.find(
585
- (x) => x.index === this.currentIndex.value
642
+ ].forEach((g) => {
643
+ typeof g != "string" && (this.customControls[g.name] = g);
644
+ }), this.rootElm.querySelectorAll("button[data-vistaview-custom-control]").forEach((g) => {
645
+ g.addEventListener("click", (I) => {
646
+ const E = this.customControls[I.currentTarget.dataset.vistaviewCustomControl], L = this.currentImages.find(
647
+ (D) => D.index === this.currentIndex.value
586
648
  );
587
- b && I && (b.onClick.constructor.name === "AsyncFunction" ? (w.classList.add("vistaview-button--loading"), b.onClick(I).finally(() => {
588
- w.classList.remove("vistaview-button--loading");
589
- })) : b.onClick(I));
649
+ E && L && (E.onClick.constructor.name === "AsyncFunction" ? (g.classList.add("vistaview-button--loading"), E.onClick(L).finally(() => {
650
+ g.classList.remove("vistaview-button--loading");
651
+ })) : E.onClick(L));
590
652
  });
591
653
  }), this.options.animationDurationBase && this.rootElm.style.setProperty(
592
654
  "--vistaview-animation-duration",
@@ -594,23 +656,21 @@ class ot {
594
656
  ), this.options.initialZIndex !== void 0 && this.rootElm.style.setProperty(
595
657
  "--vistaview-initial-z-index",
596
658
  `${this.options.initialZIndex}`
597
- ), this.setInitialDimPos(
598
- this.currentImages[this.currentImages.length === 1 ? 0 : Math.floor(this.currentImages.length / 2)]
599
- ), this.setResizeListeners(), this.options.keyboardListeners && this.setKeyboardListeners(), this.elements.length === 1 && ((u = this.rootElm.querySelector(".vistaview-prev-btn")) == null || u.classList.add("vistaview-ui--none"), (v = this.rootElm.querySelector(".vistaview-next-btn")) == null || v.classList.add("vistaview-ui--none"), (g = this.rootElm.querySelector(".vistaview-index-display")) == null || g.classList.add("vistaview-ui--none")), this.rootElm && this.rootElm.classList.add("vistaview--initialized"), this.loadImages(), this.setCurrentDescription(), this.setIndexDisplay(), this.userInit(this), (E = (m = this.options).onOpen) == null || E.call(m, o), (y = (f = this.options).onImageView) == null || y.call(f, o);
659
+ ), this.setInitialDimPos(), this.setResizeListeners(), this.options.keyboardListeners && this.setKeyboardListeners(), this.elements.length === 1 && ((f = this.rootElm.querySelector(".vistaview-prev-btn")) == null || f.classList.add("vistaview-ui--none"), (u = this.rootElm.querySelector(".vistaview-next-btn")) == null || u.classList.add("vistaview-ui--none"), (v = this.rootElm.querySelector(".vistaview-index-display")) == null || v.classList.add("vistaview-ui--none")), this.rootElm && this.rootElm.classList.add("vistaview--initialized"), this.loadImages(), this.setCurrentDescription(), this.setIndexDisplay(), this.userInit(this), (p = (y = this.options).onOpen) == null || p.call(y, a), (b = (x = this.options).onImageView) == null || b.call(x, a);
600
660
  }
601
661
  async close(t = !0) {
602
- var n, i, o;
603
- if (L.somethingOpened !== this) return;
604
- t && ((n = this.rootElm) == null || n.classList.add("vistaview--closing"), await new Promise((h) => {
605
- var a;
606
- let r;
607
- (a = this.rootElm) == null || a.addEventListener("transitionend", (c) => {
608
- c.currentTarget === this.rootElm && (r && clearTimeout(r), r = setTimeout(() => {
609
- h();
662
+ var n, e, a;
663
+ if (C.somethingOpened !== this) return;
664
+ t && ((n = this.rootElm) == null || n.classList.add("vistaview--closing"), await new Promise((d) => {
665
+ var l;
666
+ let o;
667
+ (l = this.rootElm) == null || l.addEventListener("transitionend", (h) => {
668
+ h.currentTarget === this.rootElm && (o && clearTimeout(o), o = setTimeout(() => {
669
+ d();
610
670
  }, 333));
611
671
  });
612
672
  }));
613
- const e = {
673
+ const i = {
614
674
  htmlElements: { from: this.currentItems, to: null },
615
675
  images: { from: this.currentImages, to: null },
616
676
  index: { from: this.currentIndex.value, to: null },
@@ -622,62 +682,63 @@ class ot {
622
682
  isZoomed: this.isZoomed,
623
683
  options: this.options
624
684
  };
625
- this.userClose(this), (o = (i = this.options).onClose) == null || o.call(i, e), document.body.removeChild(this.rootElm), this.currentIndex._value = null, this.currentIndex._via = { next: !1, prev: !1 }, this.rootElm = null, this.imageContainerElm = null, this.currentImages = null, this.currentItems = null, this.navActive = !0, this.onResizeHandler && (window.removeEventListener("resize", this.onResizeHandler), this.onResizeHandler = null), this.onKeyDown && (window.removeEventListener("keydown", this.onKeyDown), this.onKeyDown = null), (this.onZoomedPointerDown || this.onZoomedPointerMove || this.onZoomedPointerUp) && (this.setZoomed(!1), this.onZoomedPointerDown = null, this.onZoomedPointerMove = null, this.onZoomedPointerUp = null), L.somethingOpened = null;
685
+ this.userClose(this), (a = (e = this.options).onClose) == null || a.call(e, i), document.body.removeChild(this.rootElm), this.currentIndex._value = null, this.currentIndex._via = { next: !1, prev: !1 }, this.rootElm = null, this.imageContainerElm = null, this.currentImages = null, this.currentItems = null, this.navActive = !0, this.onResizeHandler && (window.removeEventListener("resize", this.onResizeHandler), this.onResizeHandler = null), this.onKeyDown && (window.removeEventListener("keydown", this.onKeyDown), this.onKeyDown = null), (this.onZoomedPointerDown || this.onZoomedPointerMove || this.onZoomedPointerUp) && (this.setZoomed(!1), this.onZoomedPointerDown = null, this.onZoomedPointerMove = null, this.onZoomedPointerUp = null), this.transitionAbortController && (this.transitionAbortController.abort(), this.transitionAbortController = null), C.somethingOpened = null;
626
686
  }
627
687
  destroy() {
628
- this.close(!1), this.elements instanceof NodeList && this.elements.forEach((t, e) => {
629
- t.removeEventListener("click", this.onClickElements[e]);
688
+ this.close(!1), this.elements instanceof NodeList && this.elements.forEach((t) => {
689
+ t.dataset.vistaviewIndex && delete t.dataset.vistaviewIndex, t.removeEventListener("click", this.defaultOnClickHandler), t.removeEventListener("pointerup", this.onClickElements);
630
690
  });
631
691
  }
632
- view(t, e) {
633
- L.somethingOpened === this && this.navActive && (t < 0 && (t = this.elements.length - 1), t >= this.elements.length && (t = 0), this.currentIndex.via = e || { next: !1, prev: !1 }, this.currentIndex.value = t);
692
+ view(t, i) {
693
+ C.somethingOpened === this && this.navActive && (t < 0 && (t = this.elements.length - 1), t >= this.elements.length && (t = 0), this.currentIndex.via = i || { next: !1, prev: !1 }, this.currentIndex.value = t);
634
694
  }
635
695
  next() {
636
- L.somethingOpened === this && this.view(this.currentIndex.value + 1, { next: !0, prev: !1 });
696
+ C.somethingOpened === this && this.view(this.currentIndex.value + 1, { next: !0, prev: !1 });
637
697
  }
638
698
  prev() {
639
- L.somethingOpened === this && this.view(this.currentIndex.value - 1, { next: !1, prev: !0 });
699
+ C.somethingOpened === this && this.view(this.currentIndex.value - 1, { next: !1, prev: !0 });
640
700
  }
641
701
  getCurrentIndex() {
642
- return L.somethingOpened === this ? this.currentIndex.value : -1;
702
+ return C.somethingOpened === this ? this.currentIndex.value : -1;
643
703
  }
644
704
  }
645
705
  function rt(s) {
646
706
  let t = null;
647
707
  if (typeof s == "string" ? t = document.querySelectorAll(s) : s instanceof NodeList && (t = s), t)
648
- for (let e = 0; e < t.length; e++) {
649
- const n = t[e];
708
+ for (let i = 0; i < t.length; i++) {
709
+ const n = t[i];
650
710
  if (!(n.dataset.vistaviewSrc || n.getAttribute("href") || n.getAttribute("src") || ""))
651
- return `Element at index ${e} is missing 'src' / 'data-vistaview-src' / 'href' attribute.`;
711
+ return `Element at index ${i} is missing 'src' / 'data-vistaview-src' / 'href' attribute.`;
652
712
  }
653
713
  else {
654
- const e = s;
655
- for (let n = 0; n < e.length; n++)
656
- if (!e[n].src)
714
+ const i = s;
715
+ for (let n = 0; n < i.length; n++)
716
+ if (!i[n].src)
657
717
  return `Element at index ${n} is missing 'src' attribute.`;
658
718
  }
659
719
  return t || s;
660
720
  }
661
721
  function lt({ elements: s, ...t }) {
662
722
  if (!s) throw new Error("No elements");
663
- let e = rt(s);
664
- if (typeof e == "string")
665
- return console.error(e), console.warn("VistaView: silently returning."), null;
666
- const n = new ot(e, t);
723
+ let i = rt(s);
724
+ if (typeof i == "string")
725
+ return console.error(i), console.warn("VistaView: silently returning."), null;
726
+ const n = new ot(i, t);
667
727
  return {
668
- open: (i = 0) => n.open(i),
728
+ open: (e = 0) => n.open(e),
669
729
  close: () => n.close(),
670
730
  next: () => n.next(),
671
731
  prev: () => n.prev(),
672
732
  destroy: () => n.destroy(),
673
733
  getCurrentIndex: () => n.getCurrentIndex(),
674
- view: (i) => {
675
- n.view(i);
734
+ view: (e) => {
735
+ n.view(e);
676
736
  }
677
737
  };
678
738
  }
679
739
  export {
680
- q as DefaultOptions,
740
+ k as DefaultOptions,
741
+ P as VistaViewTransitionAbortedError,
681
742
  st as defaultClose,
682
743
  et as defaultInit,
683
744
  it as defaultSetup,