vistaview 0.3.12 → 0.3.13

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