vistaview 0.6.5 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/vistaview.js CHANGED
@@ -1,31 +1,31 @@
1
- var W = Object.defineProperty;
2
- var A = (s, t, e) => t in s ? W(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
3
- var l = (s, t, e) => A(s, typeof t != "symbol" ? t + "" : t, e);
4
- function $(s) {
1
+ var F = Object.defineProperty;
2
+ var A = (s, t, e) => t in s ? F(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
3
+ var h = (s, t, e) => A(s, typeof t != "symbol" ? t + "" : t, e);
4
+ function S(s) {
5
5
  return s && !/^0(px|%|r?em|vw|vh|vmin|vmax|cm|mm|in|pt|pc|ex|ch)?$/i.test(s.trim()) && s;
6
6
  }
7
- function F(s) {
8
- const e = window.getComputedStyle(s).objectFit || "", { width: i, height: n } = s.getBoundingClientRect(), o = s.naturalWidth, a = s.naturalHeight;
7
+ function z(s) {
8
+ const e = window.getComputedStyle(s).objectFit || "", { width: n, height: i } = s.getBoundingClientRect(), o = s.naturalWidth, a = s.naturalHeight;
9
9
  if (!e)
10
- return { width: i, height: n };
10
+ return { width: n, height: i };
11
11
  if (!o || !a)
12
- return { width: i, height: n };
13
- const r = o / a, h = i / n;
12
+ return { width: n, height: i };
13
+ const r = o / a, l = n / i;
14
14
  switch (e) {
15
15
  case "fill":
16
- return { width: i, height: n };
16
+ return { width: n, height: i };
17
17
  case "none":
18
18
  return { width: o, height: a };
19
19
  case "contain":
20
- return r > h ? { width: i, height: i / r } : { width: n * r, height: n };
20
+ return r > l ? { width: n, height: n / r } : { width: i * r, height: i };
21
21
  case "cover":
22
- return r < h ? { width: i, height: i / r } : { width: n * r, height: n };
22
+ return r < l ? { width: n, height: n / r } : { width: i * r, height: i };
23
23
  case "scale-down": {
24
- const c = { width: o, height: a }, m = r > h ? { width: i, height: i / r } : { width: n * r, height: n };
24
+ const c = { width: o, height: a }, m = r > l ? { width: n, height: n / r } : { width: i * r, height: i };
25
25
  return m.width <= c.width && m.height <= c.height ? m : c;
26
26
  }
27
27
  }
28
- return { width: i, height: n };
28
+ return { width: n, height: i };
29
29
  }
30
30
  function D(s) {
31
31
  const t = getComputedStyle(s), e = s.getBoundingClientRect();
@@ -42,13 +42,13 @@ function D(s) {
42
42
  naturalHeight: s.naturalHeight
43
43
  };
44
44
  }
45
- function P(s) {
46
- const t = s.imageElm ? D(s.imageElm) : null, e = s.anchorElm ? D(s.anchorElm) : null, i = $(t == null ? void 0 : t.borderRadius), n = e && $(e == null ? void 0 : e.borderRadius), o = (n ? e == null ? void 0 : e.borderRadius : i ? t == null ? void 0 : t.borderRadius : "") || "";
45
+ function k(s) {
46
+ const t = s.imageElm ? D(s.imageElm) : null, e = s.anchorElm ? D(s.anchorElm) : null, n = S(t == null ? void 0 : t.borderRadius), i = e && S(e == null ? void 0 : e.borderRadius), o = (i ? e == null ? void 0 : e.borderRadius : n ? t == null ? void 0 : t.borderRadius : "") || "";
47
47
  return {
48
48
  fit: (t == null ? void 0 : t.objectFit) || (e == null ? void 0 : e.objectFit) || "",
49
49
  pos: (t == null ? void 0 : t.objectPosition) || "",
50
50
  br: o,
51
- overflow: n ? e.overflow : i ? t.overflow : "",
51
+ overflow: i ? e.overflow : n ? t.overflow : "",
52
52
  nw: (t == null ? void 0 : t.naturalWidth) || 0,
53
53
  nh: (t == null ? void 0 : t.naturalHeight) || 0,
54
54
  w: (e == null ? void 0 : e.width) || (t == null ? void 0 : t.width) || 0,
@@ -57,53 +57,53 @@ function P(s) {
57
57
  left: (e == null ? void 0 : e.left) || (t == null ? void 0 : t.left) || 0
58
58
  };
59
59
  }
60
- function H(s, t, e, i = !1) {
60
+ function W(s, t, e, n = !1) {
61
61
  const {
62
- fit: n,
62
+ fit: i,
63
63
  w: o,
64
64
  h: a,
65
65
  // this ones makes things hard. not used.
66
66
  // pos,
67
67
  // overflow,
68
68
  nw: r,
69
- nh: h,
69
+ nh: l,
70
70
  br: c,
71
71
  top: m,
72
- left: w
73
- } = P(s), b = Math.min(Math.max(w, -o), window.innerWidth + o) - window.innerWidth / 2 + o / 2, p = Math.min(Math.max(m, -a), window.innerHeight + a) - window.innerHeight / 2 + a / 2, d = e.style;
74
- d.width = `${o}px`, d.height = `${a}px`, d.objectFit = n, e.width = r, e.height = h, d.setProperty("--vvw-init-radius", `${c}`), d.setProperty("--vvw-pulse-radius", `calc(1.3 * ${c})`), d.setProperty("--vvw-init-x", `${b}px`), d.setProperty("--vvw-init-y", `${p}px`), i && (d.setProperty("--vvw-current-x", `${b}px`), d.setProperty("--vvw-current-y", `${p}px`));
75
- const v = F(s.imageElm), g = Math.min(o, v.width), f = Math.min(a, v.height), u = t.style;
76
- u.setProperty("--vvw-init-radius", `${c}`), u.setProperty("--vvw-init-w", `${g}px`), u.setProperty("--vvw-init-h", `${f}px`), i && (u.setProperty("--vvw-current-radius", `${c}`), u.setProperty("--vvw-current-w", `${g}px`), u.setProperty("--vvw-current-h", `${f}px`), t.dataset.vvwWidth = g.toString(), t.dataset.vvwHeight = f.toString());
72
+ left: p
73
+ } = k(s), L = Math.min(Math.max(p, -o), window.innerWidth + o) - window.innerWidth / 2 + o / 2, g = Math.min(Math.max(m, -a), window.innerHeight + a) - window.innerHeight / 2 + a / 2, d = e.style;
74
+ d.width = `${o}px`, d.height = `${a}px`, d.objectFit = i, e.width = r, e.height = l, d.setProperty("--vvw-init-radius", `${c}`), d.setProperty("--vvw-pulse-radius", `calc(1.3 * ${c})`), d.setProperty("--vvw-init-x", `${L}px`), d.setProperty("--vvw-init-y", `${g}px`), n && (d.setProperty("--vvw-current-x", `${L}px`), d.setProperty("--vvw-current-y", `${g}px`));
75
+ const u = z(s.imageElm), y = Math.min(o, u.width), f = Math.min(a, u.height), v = t.style;
76
+ v.setProperty("--vvw-init-radius", `${c}`), v.setProperty("--vvw-init-w", `${y}px`), v.setProperty("--vvw-init-h", `${f}px`), n && (v.setProperty("--vvw-current-radius", `${c}`), v.setProperty("--vvw-current-w", `${y}px`), v.setProperty("--vvw-current-h", `${f}px`), t.dataset.vvwWidth = y.toString(), t.dataset.vvwHeight = f.toString());
77
77
  }
78
- function S(s) {
79
- const t = window.innerWidth, e = window.innerHeight, i = s.naturalWidth, n = s.naturalHeight;
80
- if (!i || !n)
78
+ function M(s) {
79
+ const t = window.innerWidth, e = window.innerHeight, n = s.naturalWidth, i = s.naturalHeight;
80
+ if (!n || !i)
81
81
  throw new Error("Image natural dimensions are zero");
82
- if (i < t && n < e)
82
+ if (n < t && i < e)
83
83
  return {
84
- width: i,
85
- height: n
84
+ width: n,
85
+ height: i
86
86
  };
87
- const o = i / n, a = t / e;
88
- let r, h;
89
- return o > a ? (r = t, h = t / o) : (h = e, r = e * o), {
87
+ const o = n / i, a = t / e;
88
+ let r, l;
89
+ return o > a ? (r = t, l = t / o) : (l = e, r = e * o), {
90
90
  width: r,
91
- height: h
91
+ height: l
92
92
  };
93
93
  }
94
- function z(s, t, e) {
94
+ function q(s, t, e) {
95
95
  return Math.min(Math.max(s, t), e);
96
96
  }
97
- function L(s, t = 2) {
97
+ function C(s, t = 2) {
98
98
  const e = Math.pow(10, t);
99
99
  return Math.round(s * e) / e;
100
100
  }
101
- const q = '<svg viewBox="0 0 24 24"><path d="m15 18-6-6 6-6"/></svg>', k = '<svg viewBox="0 0 24 24"><path d="m9 18 6-6-6-6"/></svg>', R = '<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>', O = '<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>', Z = '<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>', Y = '<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>';
102
- let I = null;
103
- function X() {
104
- return I || (window.trustedTypes || (window.trustedTypes = {
101
+ const R = '<svg viewBox="0 0 24 24"><path d="m15 18-6-6 6-6"/></svg>', O = '<svg viewBox="0 0 24 24"><path d="m9 18 6-6-6-6"/></svg>', Z = '<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>', X = '<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>', N = '<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>', Y = '<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>';
102
+ let $ = null;
103
+ function B() {
104
+ return $ || (window.trustedTypes || (window.trustedTypes = {
105
105
  createPolicy: (s, t) => t
106
- }), I = window.trustedTypes.createPolicy("vistaView-policy", {
106
+ }), $ = window.trustedTypes.createPolicy("vistaView-policy", {
107
107
  createHTML: (s) => s,
108
108
  // HTML is generated by us, not user input
109
109
  createScript: () => {
@@ -112,34 +112,34 @@ function X() {
112
112
  createScriptURL: () => {
113
113
  throw new Error("Not implemented");
114
114
  }
115
- }), I);
115
+ }), $);
116
116
  }
117
- function M(s) {
118
- const e = X().createHTML(s), i = document.createElement("template");
119
- i.innerHTML = e;
120
- const n = i.content;
121
- return i.remove(), n;
117
+ function P(s) {
118
+ const e = B().createHTML(s), n = document.createElement("template");
119
+ n.innerHTML = e;
120
+ const i = n.content;
121
+ return n.remove(), i;
122
122
  }
123
- function N() {
123
+ function j() {
124
124
  return {
125
125
  name: "download",
126
126
  icon: Y,
127
127
  onClick: async (s) => {
128
128
  var o;
129
- const t = await fetch(s.src), e = await t.blob(), i = t.url, n = document.createElement("a");
130
- n.href = URL.createObjectURL(e), n.download = ((o = i.split("/").pop()) == null ? void 0 : o.split("?")[0].split("#")[0]) || "download", document.body.appendChild(n), n.click(), document.body.removeChild(n);
129
+ const t = await fetch(s.src), e = await t.blob(), n = t.url, i = document.createElement("a");
130
+ 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);
131
131
  }
132
132
  };
133
133
  }
134
- function B(s) {
134
+ function V(s) {
135
135
  if (typeof s == "string")
136
136
  switch (s) {
137
137
  case "zoomIn":
138
- return `<button aria-label="Zoom In" class="vvw-zoom-in vvw-ui">${R}</button>`;
138
+ return `<button aria-label="Zoom In" class="vvw-zoom-in vvw-ui">${Z}</button>`;
139
139
  case "zoomOut":
140
- return `<button aria-label="Zoom Out" disabled class="vvw-zoom-out vvw-ui">${O}</button>`;
140
+ return `<button aria-label="Zoom Out" disabled class="vvw-zoom-out vvw-ui">${X}</button>`;
141
141
  case "close":
142
- return `<button aria-label="Close" class="vvw-close vvw-ui">${Z}</button>`;
142
+ return `<button aria-label="Close" class="vvw-close vvw-ui">${N}</button>`;
143
143
  case "indexDisplay":
144
144
  return '<div class="vvw-index vvw-ui" aria-hidden="true"></div>';
145
145
  case "description":
@@ -147,133 +147,139 @@ function B(s) {
147
147
  default:
148
148
  return "";
149
149
  }
150
- return `<button aria-label="${s.description || s.name}" data-vvw-control="${s.name}">${s.icon}</button>`;
150
+ return `<button class="vvw-ui" aria-label="${s.description || s.name}" data-vvw-control="${s.name}">${s.icon}</button>`;
151
151
  }
152
- function j(s, t) {
152
+ function U(s, t) {
153
153
  const e = document.createElement("div");
154
154
  e.className = "vvw-item", e.dataset.vvwPos = `${t !== void 0 ? t : ""}`, e.dataset.vvwIdx = s.index.toString(), e.appendChild(
155
- M(
155
+ P(
156
156
  `<img class="vvw-img-lo" src="${s.thumb || s.src}" alt="${s.alt || ""}" />
157
157
  <img class="vvw-img-hi" src="${s.src}" alt="${s.alt || ""}" />`
158
158
  )
159
159
  );
160
- const i = e.querySelector("img.vvw-img-lo"), n = e.querySelector("img.vvw-img-hi");
161
- return H(s, n, i, t === 0), e;
160
+ const n = e.querySelector("img.vvw-img-lo"), i = e.querySelector("img.vvw-img-hi");
161
+ return W(s, i, n, t === 0), e;
162
162
  }
163
- function U({
163
+ function K({
164
164
  controls: s
165
165
  }) {
166
- const t = (i) => i ? i.map(B).join("") : "";
167
- return M(
166
+ const t = (n) => n ? n.map(V).join("") : "";
167
+ return P(
168
168
  `<div class="vvw-root" id="vvw-root">
169
169
  <div class="vvw-container">
170
170
  <div class="vvw-bg"></div>
171
171
  <div class="vvw-image-container"></div>
172
- <div class="vvw-top-bar vvw-ui"><div>${t(s == null ? void 0 : s.topLeft)}</div><div>${t(s == null ? void 0 : s.topCenter)}</div><div>${t(s == null ? void 0 : s.topRight)}</div></div>
173
- <div class="vvw-bottom-bar vvw-ui"><div>${t(s == null ? void 0 : s.bottomLeft)}</div><div>${t(s == null ? void 0 : s.bottomCenter)}</div><div>${t(s == null ? void 0 : s.bottomRight)}</div></div>
174
- <div class="vvw-prev vvw-ui"><button aria-label="Previous">${q}</button></div>
175
- <div class="vvw-next vvw-ui"><button aria-label="Next">${k}</button></div>
172
+ <div class="vvw-top-bar"><div>${t(s == null ? void 0 : s.topLeft)}</div><div>${t(s == null ? void 0 : s.topCenter)}</div><div>${t(s == null ? void 0 : s.topRight)}</div></div>
173
+ <div class="vvw-bottom-bar"><div>${t(s == null ? void 0 : s.bottomLeft)}</div><div>${t(s == null ? void 0 : s.bottomCenter)}</div><div>${t(s == null ? void 0 : s.bottomRight)}</div></div>
174
+ <div class="vvw-prev vvw-ui"><button aria-label="Previous">${R}</button></div>
175
+ <div class="vvw-next vvw-ui"><button aria-label="Next">${O}</button></div>
176
176
  </div>
177
177
  </div>`
178
178
  );
179
179
  }
180
- const T = {
180
+ const H = {
181
181
  // debug, don't remove
182
182
  // animationDurationBase: 1000,
183
183
  animationDurationBase: 333,
184
- zoomStep: 500,
185
184
  maxZoomLevel: 2,
186
- touchSpeedThreshold: 0.5,
187
185
  preloads: 1,
188
186
  keyboardListeners: !0,
189
187
  arrowOnSmallScreens: !1,
190
188
  rapidLimit: 222,
191
189
  controls: {
192
190
  topLeft: ["indexDisplay"],
193
- topRight: ["zoomIn", "zoomOut", N(), "close"],
191
+ topRight: ["zoomIn", "zoomOut", j(), "close"],
194
192
  bottomLeft: ["description"]
195
193
  }
196
194
  };
197
- function K(s) {
198
- }
199
195
  function _(s) {
200
- const t = s.options.preloads;
201
- s.imageContainer.style.width = `${(t * 2 + 1) * 100}vw`, s.imageContainer.style.left = `-${t * 100}vw`, s.imageContainer.style.display = "flex", G(s);
202
196
  }
203
197
  function G(s) {
204
- let t = { x: 0, y: 0 }, e = { x: 0, y: 0 }, i = null;
205
- s.registerPointerListener((n) => {
206
- if (!n.hasInternalExecution && !(n.pointers.length > 1)) {
207
- if (n.event === "down" && (t = { x: n.pointer.x, y: n.pointer.y }, e = { x: n.pointer.x, y: n.pointer.y }), n.event === "move") {
208
- e = { x: n.pointer.x, y: n.pointer.y };
209
- const o = e.x - t.x, a = e.y - t.y;
210
- if (!i && Math.abs(a) > Math.abs(o) || i === "y") {
211
- const r = a / window.innerHeight * 100;
212
- s.imageContainer.style.transition = "none", s.imageContainer.style.transform = `translateY(${r}vh)`, i = "y";
213
- } else if (!i && Math.abs(o) > Math.abs(a) || i === "x") {
214
- const r = o / window.innerWidth * 100;
215
- s.imageContainer.style.transition = "none", s.imageContainer.style.transform = `translateX(${r}vw)`, i = "x";
198
+ const t = s.options.preloads;
199
+ s.imageContainer.style.width = `${(t * 2 + 1) * 100}vw`, s.imageContainer.style.left = `-${t * 100}vw`, s.imageContainer.style.display = "flex", J(s);
200
+ }
201
+ function J(s) {
202
+ let t = { x: 0, y: 0 }, e = { x: 0, y: 0 }, n = null;
203
+ s.registerPointerListener((i) => {
204
+ var o;
205
+ if (!i.hasInternalExecution && !(i.pointers.length > 1)) {
206
+ if (i.event === "down" && (t = { x: i.pointer.x, y: i.pointer.y }, e = { x: i.pointer.x, y: i.pointer.y }, (o = i.abortController) == null || o.abort()), i.event === "move") {
207
+ e = { x: i.pointer.x, y: i.pointer.y };
208
+ const a = e.x - t.x, r = e.y - t.y;
209
+ if (!n && Math.abs(r) > Math.abs(a) || n === "y") {
210
+ const l = r / window.innerHeight * 100;
211
+ s.imageContainer.style.transition = "none", s.imageContainer.style.transform = `translateY(${l}vh)`, n = "y";
212
+ } else if (!n && Math.abs(a) > Math.abs(r) || n === "x") {
213
+ const l = a / window.innerWidth * 100;
214
+ s.imageContainer.style.transition = "none", s.imageContainer.style.transform = `translateX(${l}vw)`, n = "x";
216
215
  }
217
216
  }
218
- if (n.event === "up" || n.event === "cancel") {
219
- let o = function(a) {
220
- var r;
221
- (r = s.imageContainer) == null || r.addEventListener("transitionend", function h() {
222
- var c;
223
- (c = s.imageContainer) == null || c.removeEventListener("transitionend", h), s.imageContainer.style.transition = "", s.imageContainer.style.transform = "";
224
- }), s.imageContainer.style.transition = "transform 222ms ease", s.imageContainer.style.transform = a;
217
+ if (i.event === "up" || i.event === "cancel") {
218
+ let a = function(r) {
219
+ var l;
220
+ (l = s.imageContainer) == null || l.addEventListener("transitionend", function c() {
221
+ var m;
222
+ (m = s.imageContainer) == null || m.removeEventListener("transitionend", c), s.imageContainer.style.transition = "", s.imageContainer.style.transform = "";
223
+ }), s.imageContainer.style.transition = "transform 222ms ease", s.imageContainer.style.transform = r;
225
224
  };
226
- if (i === "y") {
227
- const a = e.y - t.y, r = n.pointer.movementY, h = 8;
228
- s.imageContainer.style.transition = "", a > 0 && Math.abs(r) > h || a < 0 && Math.abs(r) > h ? (s.imageContainer.style.transition = "transform 222ms ease", s.imageContainer.style.transform = "translateY(0vh)", s.close()) : o("translateY(0vh)");
225
+ if (n === "y") {
226
+ const r = e.y - t.y;
227
+ Math.abs(r) > 144 ? (s.imageContainer.style.transition = "transform 222ms ease", s.imageContainer.style.transform = "translateY(0vh)", s.close()) : a("translateY(0vh)");
229
228
  }
230
- if (i === "x") {
231
- const a = e.x - t.x, r = n.pointer.movementX, h = 8;
232
- s.imageContainer.style.transition = "", a > 0 && Math.abs(r) > h ? s.prev() : a < 0 && Math.abs(r) > h ? s.next() : o("translateX(0vw)");
229
+ if (n === "x") {
230
+ const r = e.x - t.x, l = i.pointer.movementX, c = 1;
231
+ s.imageContainer.style.transition = "", r > 0 && Math.abs(l) > c ? s.prev() : r < 0 && Math.abs(l) > c ? s.next() : a("translateX(0vw)");
233
232
  }
234
- i = null, t = { x: 0, y: 0 }, e = { x: 0, y: 0 };
233
+ n = null, t = { x: 0, y: 0 }, e = { x: 0, y: 0 };
235
234
  }
236
235
  }
237
236
  });
238
237
  }
239
- function J(s) {
238
+ function Q(s) {
240
239
  }
241
- async function Q({
240
+ function tt({
242
241
  vistaView: { isReducedMotion: s },
243
242
  htmlElements: { to: t },
244
- index: { from: e, to: i },
245
- vistaView: { elements: n, imageContainer: o, options: a }
243
+ index: { from: e, to: n },
244
+ vistaView: { elements: i, imageContainer: o, options: a }
246
245
  }, r) {
247
- if (!t || r.aborted || s || !(Math.abs(i - e) === 1 || e === 0 && i === n.length - 1 || e === n.length - 1 && i === 0))
248
- return;
249
- const c = Math.round(a.animationDurationBase * 100) / 100;
250
- return new Promise((m) => {
251
- o.addEventListener(
252
- "transitionend",
253
- () => {
254
- m(() => {
255
- o.style.transition = "", o.style.transform = "";
256
- });
246
+ if (!(!t || r.aborted || s || !(Math.abs(n - e) === 1 || e === 0 && n === i.length - 1 || e === i.length - 1 && n === 0)))
247
+ return {
248
+ cleanup: () => {
249
+ o.style.transition = "", o.style.transform = "";
257
250
  },
258
- { once: !0 }
259
- );
260
- const w = i === e + 1 || e === n.length - 1 && i === 0 ? "translateX(-100vw)" : "translateX(100vw)";
261
- o.style.transition = `transform ${c}ms ease`, o.style.transform = w;
262
- });
251
+ transitionEnded: new Promise((c) => {
252
+ o.addEventListener(
253
+ "transitionend",
254
+ () => {
255
+ c();
256
+ },
257
+ { once: !0 }
258
+ ), o.addEventListener(
259
+ "transitioncancel",
260
+ () => {
261
+ r.aborted && c();
262
+ },
263
+ { once: !0 }
264
+ );
265
+ const m = Math.round(a.animationDurationBase * 100) / 100, p = n === e + 1 || e === i.length - 1 && n === 0 ? "translateX(-100vw)" : "translateX(100vw)";
266
+ o.style.transition = `transform ${m}ms ease`, o.style.transform = p;
267
+ })
268
+ };
263
269
  }
264
- class V {
270
+ class et {
265
271
  constructor({ elm: t, listeners: e }) {
266
- l(this, "pointers", []);
267
- l(this, "elm");
268
- l(this, "listeners", []);
269
- l(this, "lastPointerDownId", null);
270
- l(this, "removeLastPointer", () => {
272
+ h(this, "pointers", []);
273
+ h(this, "elm");
274
+ h(this, "listeners", []);
275
+ h(this, "lastPointerDownId", null);
276
+ h(this, "removeLastPointer", () => {
271
277
  if (this.pointers.length && this.lastPointerDownId !== null) {
272
278
  const t = this.pointers.findIndex((e) => e.id === this.lastPointerDownId);
273
279
  t !== -1 && this.pointers.splice(t, 1);
274
280
  }
275
281
  });
276
- l(this, "onPointerDown", (t) => {
282
+ h(this, "onPointerDown", (t) => {
277
283
  if (!this.listeners.length || t.button !== 0) return;
278
284
  t.preventDefault(), this.lastPointerDownId = t.pointerId, window.addEventListener("contextmenu", this.removeLastPointer, { once: !0 }), window.addEventListener("auxclick", this.removeLastPointer, { once: !0 });
279
285
  let e = {
@@ -284,7 +290,7 @@ class V {
284
290
  id: t.pointerId
285
291
  };
286
292
  this.pointers.push(e), this.listeners.forEach(
287
- (i) => i({
293
+ (n) => n({
288
294
  event: "down",
289
295
  pointer: e,
290
296
  pointers: this.pointers,
@@ -292,12 +298,12 @@ class V {
292
298
  })
293
299
  );
294
300
  });
295
- l(this, "onPointerMove", (t) => {
301
+ h(this, "onPointerMove", (t) => {
296
302
  if (!this.listeners.length) return;
297
303
  t.preventDefault();
298
- const e = this.pointers.find((i) => i.id === t.pointerId);
304
+ const e = this.pointers.find((n) => n.id === t.pointerId);
299
305
  e && (e.movementX = t.movementX, e.movementY = t.movementY, e.x = t.clientX, e.y = t.clientY, this.listeners.forEach(
300
- (i) => i({
306
+ (n) => n({
301
307
  event: "move",
302
308
  pointer: e,
303
309
  pointers: this.pointers,
@@ -305,39 +311,39 @@ class V {
305
311
  })
306
312
  ));
307
313
  });
308
- l(this, "onPointerUp", (t) => {
314
+ h(this, "onPointerUp", (t) => {
309
315
  if (!this.listeners.length || t.button !== 0 || (window.removeEventListener("contextmenu", this.removeLastPointer), window.removeEventListener("auxclick", this.removeLastPointer), t.target instanceof Node && !this.elm.contains(t.target) && t.target !== document.querySelector("html") && t.target !== document))
310
316
  return;
311
317
  t.preventDefault();
312
318
  const e = this.pointers.findIndex((o) => o.id === t.pointerId);
313
319
  if (e === -1) return;
314
- const i = this.pointers[e];
315
- i.x = t.clientX, i.y = t.clientY;
316
- const n = this.pointers.length;
320
+ const n = this.pointers[e];
321
+ n.x = t.clientX, n.y = t.clientY;
322
+ const i = this.pointers.length;
317
323
  this.pointers.splice(e, 1), this.listeners.forEach(
318
324
  (o) => o({
319
325
  event: "up",
320
- pointer: i,
326
+ pointer: n,
321
327
  pointers: this.pointers,
322
- lastPointerLen: n
328
+ lastPointerLen: i
323
329
  })
324
330
  );
325
331
  });
326
- l(this, "onPointerCancel", (t) => {
332
+ h(this, "onPointerCancel", (t) => {
327
333
  if (!this.listeners.length || t.target instanceof Node && !this.elm.contains(t.target) && t.target !== document.querySelector("html") && t.target !== document)
328
334
  return;
329
335
  t.preventDefault();
330
336
  const e = this.pointers.findIndex((o) => o.id === t.pointerId);
331
337
  if (e === -1) return;
332
- const i = this.pointers[e];
333
- i.x = t.clientX, i.y = t.clientY;
334
- const n = this.pointers.length;
338
+ const n = this.pointers[e];
339
+ n.x = t.clientX, n.y = t.clientY;
340
+ const i = this.pointers.length;
335
341
  this.pointers.splice(e, 1), this.listeners.forEach(
336
342
  (o) => o({
337
343
  event: "cancel",
338
- pointer: i,
344
+ pointer: n,
339
345
  pointers: this.pointers,
340
- lastPointerLen: n
346
+ lastPointerLen: i
341
347
  })
342
348
  );
343
349
  });
@@ -356,13 +362,13 @@ class V {
356
362
  this.listeners = this.listeners.filter((e) => e !== t);
357
363
  }
358
364
  getPointerDistance(t, e) {
359
- const i = t.x - e.x, n = t.y - e.y;
360
- return Math.sqrt(i * i + n * n);
365
+ const n = t.x - e.x, i = t.y - e.y;
366
+ return Math.sqrt(n * n + i * i);
361
367
  }
362
368
  getCentroid() {
363
369
  if (this.pointers.length === 0) return null;
364
370
  const t = this.pointers.reduce(
365
- (e, i) => (e.x += i.x, e.y += i.y, e),
371
+ (e, n) => (e.x += n.x, e.y += n.y, e),
366
372
  { x: 0, y: 0 }
367
373
  );
368
374
  return {
@@ -371,20 +377,20 @@ class V {
371
377
  };
372
378
  }
373
379
  }
374
- class tt {
380
+ class it {
375
381
  constructor(t, e) {
376
- l(this, "maxZoomLevel");
377
- l(this, "image", null);
378
- l(this, "rect", null);
379
- l(this, "initialCenter", { x: 0, y: 0 });
380
- l(this, "maxDimension", { width: 0 });
381
- l(this, "minDimension", { initialWidth: 0, initialHeight: 0, minWidth: 0, closingWidth: 0 });
382
- l(this, "accumulatedTranslate", { x: 0, y: 0 });
382
+ h(this, "maxZoomLevel");
383
+ h(this, "image", null);
384
+ h(this, "rect", null);
385
+ h(this, "initialCenter", { x: 0, y: 0 });
386
+ h(this, "maxDimension", { width: 0 });
387
+ h(this, "minDimension", { initialWidth: 0, initialHeight: 0, minWidth: 0, closingWidth: 0 });
388
+ h(this, "accumulatedTranslate", { x: 0, y: 0 });
383
389
  // state
384
- l(this, "scale", 1);
385
- l(this, "translate", { x: 0, y: 0 });
386
- l(this, "onScale", null);
387
- l(this, "animationTimestamp", 0);
390
+ h(this, "scale", 1);
391
+ h(this, "translate", { x: 0, y: 0 });
392
+ h(this, "onScale", null);
393
+ h(this, "animationTimestamp", 0);
388
394
  this.maxZoomLevel = t, this.onScale = e;
389
395
  }
390
396
  clean() {
@@ -398,10 +404,10 @@ class tt {
398
404
  width: t.naturalWidth * this.maxZoomLevel
399
405
  }, !t.dataset.vvwWidth || !t.dataset.vvwHeight)
400
406
  throw new Error("VistaImageState: Image dataset vvwWidth or vvwHeight not set.");
401
- const e = parseFloat(t.dataset.vvwWidth), i = parseFloat(t.dataset.vvwHeight);
407
+ const e = parseFloat(t.dataset.vvwWidth), n = parseFloat(t.dataset.vvwHeight);
402
408
  this.minDimension = {
403
409
  initialWidth: e,
404
- initialHeight: i,
410
+ initialHeight: n,
405
411
  minWidth: e * 0.1,
406
412
  closingWidth: e * 0.5
407
413
  }, this.accumulatedTranslate = { x: 0, y: 0 };
@@ -410,81 +416,81 @@ class tt {
410
416
  this.initialCenter = t || { x: window.innerWidth / 2, y: window.innerHeight / 2 };
411
417
  }
412
418
  move(t) {
413
- this.image && (this.rect || (this.rect = this.image.getBoundingClientRect()), this.translate.x = L(t.x - this.initialCenter.x), this.translate.y = L(t.y - this.initialCenter.y), this.image.style.transform = `translate3d(${this.translate.x}px, ${this.translate.y}px, 0px) scale(${this.scale})`);
419
+ this.image && (this.rect || (this.rect = this.image.getBoundingClientRect()), this.translate.x = C(t.x - this.initialCenter.x), this.translate.y = C(t.y - this.initialCenter.y), this.image.style.transform = `translate3d(${this.translate.x}px, ${this.translate.y}px, 0px) scale(${this.scale})`);
414
420
  }
415
- snapToTargetIfClose(t, e, i = 1) {
416
- return Math.abs(t - e) <= i && (t = e), t;
421
+ snapToTargetIfClose(t, e, n = 1) {
422
+ return Math.abs(t - e) <= n && (t = e), t;
417
423
  }
418
424
  scaleMove(t, e) {
419
425
  if (!this.image) return;
420
426
  this.rect || (this.rect = this.image.getBoundingClientRect()), e || (e = this.initialCenter);
421
- const i = this.snapToTargetIfClose(
422
- z(this.rect.width * t, this.minDimension.minWidth, this.maxDimension.width),
427
+ const n = this.snapToTargetIfClose(
428
+ q(this.rect.width * t, this.minDimension.minWidth, this.maxDimension.width),
423
429
  this.minDimension.initialWidth
424
430
  );
425
431
  this.onScale && this.onScale({
426
- scale: i / (this.maxDimension.width / this.maxZoomLevel),
427
- isMax: i >= this.maxDimension.width,
428
- isMin: i <= this.minDimension.initialWidth
429
- }), this.scale = L(i / this.rect.width);
430
- const n = this.rect.left + this.rect.width / 2, o = this.rect.top + this.rect.height / 2, a = this.initialCenter.x - n, r = this.initialCenter.y - o, h = a * (1 - this.scale), c = r * (1 - this.scale), m = e.x - this.initialCenter.x, w = e.y - this.initialCenter.y;
431
- this.translate.x = L(h + m), this.translate.y = L(c + w), this.image.style.transform = `translate3d(${this.translate.x}px, ${this.translate.y}px, 0px) scale(${this.scale})`, i <= this.minDimension.closingWidth ? this.image.style.opacity = "0.5" : this.image.style.opacity = "";
432
+ scale: n / (this.maxDimension.width / this.maxZoomLevel),
433
+ isMax: n >= this.maxDimension.width,
434
+ isMin: n <= this.minDimension.initialWidth
435
+ }), this.scale = C(n / this.rect.width);
436
+ const i = this.rect.left + this.rect.width / 2, o = this.rect.top + this.rect.height / 2, a = this.initialCenter.x - i, r = this.initialCenter.y - o, l = a * (1 - this.scale), c = r * (1 - this.scale), m = e.x - this.initialCenter.x, p = e.y - this.initialCenter.y;
437
+ this.translate.x = C(l + m), this.translate.y = C(c + p), this.image.style.transform = `translate3d(${this.translate.x}px, ${this.translate.y}px, 0px) scale(${this.scale})`, n <= this.minDimension.closingWidth ? this.image.style.opacity = "0.5" : this.image.style.opacity = "";
432
438
  }
433
439
  moveAndNormalize(t) {
434
- let e = 0, i = !1;
435
- const n = ({ x: o, y: a }) => {
436
- if (i)
440
+ let e = 0, n = !1;
441
+ const i = ({ x: o, y: a }) => {
442
+ if (n)
437
443
  return;
438
444
  if (Math.abs(o) < 1e-3 && Math.abs(a) < 1e-3)
439
445
  return this.normalize();
440
446
  o *= 0.9, a *= 0.9;
441
447
  const r = this.image.getBoundingClientRect();
442
- this.translate.x = L(this.translate.x + o), this.translate.y = L(this.translate.y + a), r.right < window.innerWidth / 2 && (this.translate.x += (window.innerWidth / 2 - r.right) * 0.1, o *= 0.7), r.left > window.innerWidth / 2 && (this.translate.x -= (r.left - window.innerWidth / 2) * 0.1, o *= 0.7), r.bottom < window.innerHeight / 2 && (this.translate.y += (window.innerHeight / 2 - r.bottom) * 0.1, a *= 0.7), r.top > window.innerHeight / 2 && (this.translate.y -= (r.top - window.innerHeight / 2) * 0.1, a *= 0.7), this.image.style.transform = `translate3d(${this.translate.x}px, ${this.translate.y}px, 0px) scale(${this.scale})`, e = requestAnimationFrame(() => n({ x: o, y: a }));
448
+ this.translate.x = C(this.translate.x + o), this.translate.y = C(this.translate.y + a), r.right < window.innerWidth / 2 && (this.translate.x += (window.innerWidth / 2 - r.right) * 0.1, o *= 0.7), r.left > window.innerWidth / 2 && (this.translate.x -= (r.left - window.innerWidth / 2) * 0.1, o *= 0.7), r.bottom < window.innerHeight / 2 && (this.translate.y += (window.innerHeight / 2 - r.bottom) * 0.1, a *= 0.7), r.top > window.innerHeight / 2 && (this.translate.y -= (r.top - window.innerHeight / 2) * 0.1, a *= 0.7), this.image.style.transform = `translate3d(${this.translate.x}px, ${this.translate.y}px, 0px) scale(${this.scale})`, e = requestAnimationFrame(() => i({ x: o, y: a }));
443
449
  };
444
- return n({
450
+ return i({
445
451
  x: t.movementX,
446
452
  y: t.movementY
447
453
  }), () => {
448
- i = !0, cancelAnimationFrame(e), this.normalize(!1);
454
+ n = !0, cancelAnimationFrame(e), this.normalize(!1);
449
455
  };
450
456
  }
451
457
  animateZoom(t) {
452
458
  if (!this.image) return;
453
459
  this.rect || (this.rect = this.image.getBoundingClientRect());
454
- const e = Date.now(), i = this.image;
455
- this.rect.width * t < this.minDimension.closingWidth || i.width < Math.floor(this.minDimension.initialWidth) || (i.addEventListener(
460
+ const e = Date.now(), n = this.image;
461
+ this.rect.width * t < this.minDimension.closingWidth || n.width < Math.floor(this.minDimension.initialWidth) || (n.addEventListener(
456
462
  "transitionend",
457
463
  () => {
458
- this.animationTimestamp === e && i && (i.style.transition = "", this.normalize());
464
+ this.animationTimestamp === e && n && (n.style.transition = "", this.normalize());
459
465
  },
460
466
  { once: !0 }
461
- ), i.style.transition || (i.style.transition = "all 222ms ease"), this.animationTimestamp = e, this.scaleMove(t));
467
+ ), n.style.transition || (n.style.transition = "all 222ms ease"), this.animationTimestamp = e, this.scaleMove(t));
462
468
  }
463
469
  normalize(t = !0) {
464
470
  if (!this.image || !this.rect) return;
465
471
  const e = this.snapToTargetIfClose(
466
472
  this.rect.width * this.scale,
467
473
  this.minDimension.initialWidth
468
- ), i = this.snapToTargetIfClose(
474
+ ), n = this.snapToTargetIfClose(
469
475
  this.rect.height * this.scale,
470
476
  this.minDimension.initialHeight
471
477
  );
472
- if (this.image.style.width = `${e}px`, this.image.style.height = `${i}px`, this.scale = 1, this.image.style.opacity = "", this.accumulatedTranslate.x += this.translate.x, this.accumulatedTranslate.y += this.translate.y, this.image.style.left = `calc(50% + ${this.accumulatedTranslate.x}px)`, this.image.style.top = `calc(50% + ${this.accumulatedTranslate.y}px)`, this.translate = { x: 0, y: 0 }, this.image.style.transform = "", this.rect = this.image.getBoundingClientRect(), e <= this.minDimension.closingWidth)
478
+ if (this.image.style.width = `${e}px`, this.image.style.height = `${n}px`, this.scale = 1, this.image.style.opacity = "", this.accumulatedTranslate.x += this.translate.x, this.accumulatedTranslate.y += this.translate.y, this.image.style.left = `calc(50% + ${this.accumulatedTranslate.x}px)`, this.image.style.top = `calc(50% + ${this.accumulatedTranslate.y}px)`, this.translate = { x: 0, y: 0 }, this.image.style.transform = "", this.rect = this.image.getBoundingClientRect(), e <= this.minDimension.closingWidth)
473
479
  return this.clean(), !0;
474
480
  if (e < this.minDimension.initialWidth)
475
481
  this.accumulatedTranslate.x = 0, this.accumulatedTranslate.y = 0, requestAnimationFrame(() => {
476
- const n = this.image;
477
- n && (n.addEventListener(
482
+ const i = this.image;
483
+ i && (i.addEventListener(
478
484
  "transitionend",
479
485
  () => {
480
- n && (this.clean(), this.rect = null);
486
+ i && (this.clean(), this.rect = null);
481
487
  },
482
488
  { once: !0 }
483
- ), n.style.transition = "all 222ms ease", n.style.width = `${this.minDimension.initialWidth}px`, n.style.height = `${this.minDimension.initialHeight}px`, n.style.left = "50%", n.style.top = "50%");
489
+ ), i.style.transition = "all 222ms ease", i.style.width = `${this.minDimension.initialWidth}px`, i.style.height = `${this.minDimension.initialHeight}px`, i.style.left = "50%", i.style.top = "50%");
484
490
  });
485
491
  else if (t) {
486
- let n = !1;
487
- if (this.rect.right < window.innerWidth / 2 && (n = !0, this.accumulatedTranslate.x += window.innerWidth / 2 - this.rect.right), this.rect.left > window.innerWidth / 2 && (n = !0, this.accumulatedTranslate.x -= this.rect.left - window.innerWidth / 2), this.rect.bottom < window.innerHeight / 2 && (n = !0, this.accumulatedTranslate.y += window.innerHeight / 2 - this.rect.bottom), this.rect.top > window.innerHeight / 2 && (n = !0, this.accumulatedTranslate.y -= this.rect.top - window.innerHeight / 2), n) {
492
+ let i = !1;
493
+ if (this.rect.right < window.innerWidth / 2 && (i = !0, this.accumulatedTranslate.x += window.innerWidth / 2 - this.rect.right), this.rect.left > window.innerWidth / 2 && (i = !0, this.accumulatedTranslate.x -= this.rect.left - window.innerWidth / 2), this.rect.bottom < window.innerHeight / 2 && (i = !0, this.accumulatedTranslate.y += window.innerHeight / 2 - this.rect.bottom), this.rect.top > window.innerHeight / 2 && (i = !0, this.accumulatedTranslate.y -= this.rect.top - window.innerHeight / 2), i) {
488
494
  const o = this.image;
489
495
  o.addEventListener(
490
496
  "transitionend",
@@ -498,12 +504,12 @@ class tt {
498
504
  }
499
505
  }
500
506
  }
501
- class et {
507
+ class nt {
502
508
  constructor() {
503
- l(this, "fiolast", {});
509
+ h(this, "fiolast", {});
504
510
  }
505
511
  // first in out
506
- fio(t, e, i = 50) {
512
+ fio(t, e, n = 50) {
507
513
  const o = Date.now() - (this.fiolast[e] ?? 0), a = () => {
508
514
  this.fiolast[e] = Date.now(), t();
509
515
  };
@@ -511,38 +517,40 @@ class et {
511
517
  a();
512
518
  return;
513
519
  }
514
- o >= i && a();
520
+ o >= n && a();
515
521
  }
516
522
  }
517
523
  const x = {
518
524
  somethingOpened: null
519
525
  };
520
- class it {
526
+ class st {
521
527
  constructor(t, e = {}) {
522
- l(this, "options");
523
- l(this, "elements");
524
- l(this, "isReducedMotion");
525
- l(this, "currentIndex", -1);
526
- l(this, "currentChildren", null);
527
- l(this, "setupFunction", K);
528
- l(this, "initFunction", _);
529
- l(this, "closeFunction", J);
530
- l(this, "transitionFunction", Q);
531
- l(this, "pointers", null);
532
- l(this, "imageState");
533
- l(this, "root", null);
534
- l(this, "imageContainer", null);
535
- l(this, "onClickElements", (t) => {
528
+ h(this, "options");
529
+ h(this, "elements");
530
+ h(this, "isReducedMotion");
531
+ h(this, "currentIndex", -1);
532
+ h(this, "currentChildren", null);
533
+ h(this, "setupFunction", _);
534
+ h(this, "initFunction", G);
535
+ h(this, "closeFunction", Q);
536
+ h(this, "transitionFunction", tt);
537
+ h(this, "pointers", null);
538
+ h(this, "imageState");
539
+ h(this, "imageTransitions", /* @__PURE__ */ new Map());
540
+ h(this, "root", null);
541
+ h(this, "imageContainer", null);
542
+ h(this, "onClickElements", (t) => {
536
543
  t.preventDefault();
537
544
  const e = t.currentTarget;
538
545
  e.dataset.vistaIdx && this.open(parseInt(e.dataset.vistaIdx));
539
546
  });
540
- l(this, "defaultOnClickHandler", (t) => t.preventDefault());
541
- l(this, "abortController", null);
542
- l(this, "throttle", new et());
543
- l(this, "lastSwapTime", 0);
544
- l(this, "isZoomedIn", !1);
545
- l(this, "onKeyDown", (t) => {
547
+ h(this, "defaultOnClickHandler", (t) => t.preventDefault());
548
+ h(this, "abortController", null);
549
+ h(this, "throttle", new nt());
550
+ h(this, "lastSwapTime", 0);
551
+ h(this, "transitionCleanup", null);
552
+ h(this, "isZoomedIn", !1);
553
+ h(this, "onKeyDown", (t) => {
546
554
  switch (t.key) {
547
555
  case "ArrowLeft":
548
556
  t.preventDefault(), this.prev();
@@ -561,7 +569,7 @@ class it {
561
569
  break;
562
570
  }
563
571
  });
564
- l(this, "onScroll", (t) => {
572
+ h(this, "onScroll", (t) => {
565
573
  t.preventDefault();
566
574
  const e = t.deltaY;
567
575
  this.imageState.setInitialCenter({
@@ -569,29 +577,29 @@ class it {
569
577
  y: t.clientY
570
578
  }), e < 0 ? this.zoomIn() : e > 0 && this.zoomOut();
571
579
  });
572
- l(this, "onResizeHandler", () => {
580
+ h(this, "onResizeHandler", () => {
573
581
  this.currentChildren.htmls.forEach((t, e) => {
574
- const i = this.currentChildren.images[e], n = t.querySelector("img.vvw-img-hi"), o = t.querySelector("img.vvw-img-lo");
575
- if (H(i, n, o, !1), n.classList.contains("vvw--loaded")) {
576
- const { width: a, height: r } = S(n);
577
- n.style.setProperty("--vvw-current-w", `${a}px`), n.style.setProperty("--vvw-current-h", `${r}px`), n.dataset.vvwWidth = a.toString(), n.dataset.vvwHeight = r.toString();
582
+ const n = this.currentChildren.images[e], i = t.querySelector("img.vvw-img-hi"), o = t.querySelector("img.vvw-img-lo");
583
+ if (W(n, i, o, !1), i.classList.contains("vvw--loaded")) {
584
+ const { width: a, height: r } = M(i);
585
+ i.style.setProperty("--vvw-current-w", `${a}px`), i.style.setProperty("--vvw-current-h", `${r}px`), i.dataset.vvwWidth = a.toString(), i.dataset.vvwHeight = r.toString();
578
586
  }
579
587
  });
580
588
  });
581
589
  /// POINTERS
582
- l(this, "pointerListeners", []);
583
- l(this, "getInternalPointerListener", () => {
590
+ h(this, "pointerListeners", []);
591
+ h(this, "getInternalPointerListener", () => {
584
592
  const t = this.imageState;
585
- let e = 0, i = !1, n = () => {
593
+ let e = 0, n = !1, i = () => {
586
594
  };
587
595
  return (o) => {
588
596
  if (o.event === "down") {
589
- if (n(), this.isZoomedIn && o.pointers.length === 1) {
597
+ if (i(), this.isZoomedIn && o.pointers.length === 1) {
590
598
  const a = this.pointers.getCentroid();
591
599
  t.setInitialCenter(a);
592
600
  }
593
601
  if (o.pointers.length >= 2) {
594
- i = !0;
602
+ n = !0;
595
603
  const a = this.pointers.getCentroid();
596
604
  e = this.pointers.getPointerDistance(o.pointers[0], o.pointers[1]), t.setInitialCenter(a);
597
605
  }
@@ -600,87 +608,97 @@ class it {
600
608
  const a = this.pointers.getCentroid();
601
609
  t.move(a);
602
610
  }
603
- if (o.pointers.length >= 2 && i) {
611
+ if (o.pointers.length >= 2 && n) {
604
612
  const a = this.pointers.getCentroid(), r = this.pointers.getPointerDistance(o.pointers[0], o.pointers[1]);
605
613
  t.scaleMove(r / e, a);
606
614
  }
607
- } else (o.event === "up" || o.event === "cancel") && (i || this.isZoomedIn) && (i ? (i = !1, t.normalize() && requestAnimationFrame(() => {
615
+ } else (o.event === "up" || o.event === "cancel") && (n || this.isZoomedIn) && (n ? (n = !1, t.normalize() && requestAnimationFrame(() => {
608
616
  this.close();
609
- })) : this.isZoomedIn && o.pointers.length === 0 && (n = t.moveAndNormalize(o.pointer)));
617
+ })) : this.isZoomedIn && o.pointers.length === 0 && (i = t.moveAndNormalize(o.pointer)));
610
618
  this.pointerListeners.forEach(
611
619
  (a) => a({
612
620
  ...o,
613
- hasInternalExecution: this.isZoomedIn || i
621
+ hasInternalExecution: this.isZoomedIn || n,
622
+ abortController: this.abortController
614
623
  })
615
624
  );
616
625
  };
617
626
  });
618
627
  this.elements = t, this.options = {
619
- ...T,
628
+ ...H,
620
629
  ...e,
621
630
  controls: {
622
- ...T.controls,
631
+ ...H.controls,
623
632
  ...e.controls
624
633
  }
625
- }, this.imageState = new tt(
634
+ }, this.imageState = new it(
626
635
  this.options.maxZoomLevel,
627
- (i) => {
628
- var n, o, a, r, h, c;
629
- i.isMin ? (this.isZoomedIn = !1, (n = this.qs(".vvw-zoom-out")) == null || n.setAttribute("disabled", "true"), (o = this.qs('.vvw-item[data-vvw-idx="' + this.currentIndex + '"]')) == null || o.style.setProperty(
636
+ (n) => {
637
+ var i, o, a, r, l, c;
638
+ n.isMin ? (this.isZoomedIn = !1, (i = this.qs(".vvw-zoom-out")) == null || i.setAttribute("disabled", "true"), (o = this.qs('.vvw-item[data-vvw-idx="' + this.currentIndex + '"]')) == null || o.style.setProperty(
630
639
  "pointer-events",
631
640
  "none"
632
641
  )) : (this.isZoomedIn = !0, (a = this.qs(".vvw-zoom-out")) == null || a.removeAttribute("disabled"), (r = this.qs('.vvw-item[data-vvw-idx="' + this.currentIndex + '"]')) == null || r.style.setProperty(
633
642
  "pointer-events",
634
643
  "auto"
635
- )), i.isMax ? (h = this.qs(".vvw-zoom-in")) == null || h.setAttribute("disabled", "true") : (c = this.qs(".vvw-zoom-in")) == null || c.removeAttribute("disabled");
644
+ )), n.isMax ? (l = this.qs(".vvw-zoom-in")) == null || l.setAttribute("disabled", "true") : (c = this.qs(".vvw-zoom-in")) == null || c.removeAttribute("disabled");
636
645
  }
637
- ), this.options.setupFunction && (this.setupFunction = this.options.setupFunction), this.options.closeFunction && (this.closeFunction = this.options.closeFunction), this.options.initFunction && (this.initFunction = this.options.initFunction), this.options.transitionFunction && (this.transitionFunction = this.options.transitionFunction), this.isReducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches, this.elements instanceof NodeList && this.elements.forEach((i, n) => {
638
- i.dataset.vistaIdx = n.toString(), i.addEventListener("click", this.defaultOnClickHandler), i.addEventListener("pointerup", this.onClickElements);
646
+ ), this.options.setupFunction && (this.setupFunction = this.options.setupFunction), this.options.closeFunction && (this.closeFunction = this.options.closeFunction), this.options.initFunction && (this.initFunction = this.options.initFunction), this.options.transitionFunction && (this.transitionFunction = this.options.transitionFunction), this.isReducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches, this.elements instanceof NodeList && this.elements.forEach((n, i) => {
647
+ n.dataset.vistaIdx = i.toString(), n.addEventListener("click", this.defaultOnClickHandler), n.addEventListener("pointerup", this.onClickElements);
639
648
  });
640
649
  }
641
650
  qs(t) {
642
651
  return this.root ? this.root.querySelector(t) : null;
643
652
  }
644
653
  async swap(t, e) {
645
- const i = this.options.preloads || 0, n = this.currentIndex, { htmls: o, images: a } = this.getChildElements(i, n), r = this.imageContainer, h = this.currentChildren, c = {
646
- htmlElements: { from: h.htmls, to: o },
647
- images: { from: h.images, to: a },
654
+ const n = this.options.preloads || 0, i = this.currentIndex, { htmls: o, images: a } = this.getChildElements(n, i), r = this.imageContainer, l = this.currentChildren, c = {
655
+ htmlElements: { from: l.htmls, to: o },
656
+ images: { from: l.images, to: a },
648
657
  index: { from: t, to: this.currentIndex },
649
658
  via: e || { next: !1, prev: !1 },
650
659
  vistaView: this
651
660
  };
652
661
  this.setupFunction(c), this.currentChildren = { htmls: o, images: a }, this.displayActiveIndex();
653
- const m = this.abortController.signal, w = performance.now(), b = w - this.lastSwapTime < this.options.rapidLimit;
654
- let p = null;
655
- b || (p = await this.transitionFunction(c, m)), this.lastSwapTime = w;
656
- const d = o[Math.floor(o.length / 2)].dataset.vvwIdx, v = r.querySelector(
662
+ const m = this.abortController.signal;
663
+ if (performance.now() - this.lastSwapTime < this.options.rapidLimit) {
664
+ r.innerHTML = "", this.transitionCleanup && this.transitionCleanup(), o.forEach((b) => {
665
+ r.appendChild(b);
666
+ }), this.lastSwapTime = performance.now(), this.waitForImagesToLoad(), this.options.onImageView && this.options.onImageView(c);
667
+ return;
668
+ }
669
+ const g = this.transitionFunction(c, m);
670
+ g && (this.transitionCleanup = g.cleanup, await g.transitionEnded), this.lastSwapTime = performance.now();
671
+ const d = o[Math.floor(o.length / 2)].dataset.vvwIdx, u = r.querySelector(
657
672
  `.vvw-item[data-vvw-idx="${d}"] img.vvw-img-hi`
658
- ), g = v.getAttribute("style") || "", f = v.classList.contains("vvw--loaded"), u = v.width, C = v.height;
659
- this.imageState.reset(), r.innerHTML = "", p instanceof Function && p(), o.forEach((E) => {
660
- const y = E.querySelector("img.vvw-img-hi");
661
- E.dataset.vvwPos === "0" && !m.aborted && g && f && // ready &&
662
- u && C && (y.classList.add("vvw--loaded"), y.classList.add("vvw--ready"), y.setAttribute("style", g), y.width = u, y.height = C, y.dataset.vvwWidth = u.toString(), y.dataset.vvwHeight = C.toString()), r.appendChild(E), y.classList.contains("vvw--ready") && (this.imageState.setCurrentImage(y), this.imageState.setInitialCenter());
673
+ ), y = this.imageTransitions.get(u);
674
+ this.imageTransitions.delete(u);
675
+ const f = u.getAttribute("style") || "", v = u.classList.contains("vvw--loaded"), E = u.classList.contains("vvw--ready"), I = u.width, T = u.height;
676
+ this.imageState.reset(), r.innerHTML = "", this.transitionCleanup && this.transitionCleanup(), o.forEach((b) => {
677
+ const w = b.querySelector("img.vvw-img-hi");
678
+ b.dataset.vvwPos === "0" && !m.aborted && f && I && T && (v && (w.classList.add("vvw--loaded"), w.dataset.vvwWidth = u.dataset.vvwWidth || "", w.dataset.vvwHeight = u.dataset.vvwHeight || ""), E && (w.classList.add("vvw--ready"), w.width = I, w.height = T), w.setAttribute("style", f)), r.appendChild(b), b.dataset.vvwPos === "0" && !m.aborted && E ? (this.imageState.setCurrentImage(w), this.imageState.setInitialCenter()) : b.dataset.vvwPos === "0" && !m.aborted && f && I && T && v && y && (this.imageTransitions.set(w, y), this.transitionImage(w, () => {
679
+ this.imageState.setCurrentImage(w), this.imageState.setInitialCenter(), w.classList.add("vvw--ready");
680
+ }));
663
681
  }), this.waitForImagesToLoad(), this.options.onImageView && this.options.onImageView(c);
664
682
  }
665
683
  getChildElements(t, e) {
666
- const i = [], n = [];
684
+ const n = [], i = [];
667
685
  for (let o = -t; o <= t; o++) {
668
- const a = (e + o + this.elements.length) % this.elements.length, r = this.elements[a], h = r instanceof HTMLImageElement ? r : r instanceof HTMLAnchorElement && r.querySelector("img") || void 0, c = r instanceof HTMLElement ? {
686
+ const a = (e + o + this.elements.length) % this.elements.length, r = this.elements[a], l = r instanceof HTMLImageElement ? r : r instanceof HTMLAnchorElement && r.querySelector("img") || void 0, c = r instanceof HTMLElement ? {
669
687
  index: a,
670
- imageElm: h instanceof HTMLImageElement ? h : void 0,
688
+ imageElm: l instanceof HTMLImageElement ? l : void 0,
671
689
  anchorElm: r instanceof HTMLAnchorElement ? r : void 0,
672
690
  src: r.dataset.vistaviewSrc || r.getAttribute("href") || r.getAttribute("src") || "",
673
- thumb: r.dataset.vistaviewThumb || (h instanceof HTMLImageElement ? h.getAttribute("src") : void 0) || r.getAttribute("href") || void 0,
674
- alt: h instanceof HTMLImageElement && h.getAttribute("alt") || void 0
691
+ thumb: r.dataset.vistaviewThumb || (l instanceof HTMLImageElement ? l.getAttribute("src") : void 0) || r.getAttribute("href") || void 0,
692
+ alt: l instanceof HTMLImageElement && l.getAttribute("alt") || void 0
675
693
  } : {
676
694
  index: a,
677
695
  ...r
678
696
  };
679
- n.push(c), i.push(j(c, o));
697
+ i.push(c), n.push(U(c, o));
680
698
  }
681
699
  return {
682
- htmls: i,
683
- images: n
700
+ htmls: n,
701
+ images: i
684
702
  };
685
703
  }
686
704
  zoomIn() {
@@ -704,45 +722,56 @@ class it {
704
722
  displayActiveIndex() {
705
723
  var a;
706
724
  const t = this.currentIndex;
707
- this.elements instanceof NodeList && this.elements.forEach((r, h) => {
708
- r.style.opacity = "", h === t && (r.style.opacity = "0");
725
+ this.elements instanceof NodeList && this.elements.forEach((r, l) => {
726
+ r.style.opacity = "", l === t && (r.style.opacity = "0");
709
727
  });
710
- const e = this.qs(".vvw-index"), i = `${t + 1}`, n = `${this.elements.length}`;
711
- e && (e.textContent = `${i} / ${n}`);
728
+ const e = this.qs(".vvw-index"), n = `${t + 1}`, i = `${this.elements.length}`;
729
+ e && (e.textContent = `${n} / ${i}`);
712
730
  const o = this.qs(".vvw-desc");
713
731
  if (o) {
714
- const r = (a = this.currentChildren) == null ? void 0 : a.images.find((c) => c.index === t), h = (r == null ? void 0 : r.alt) || "";
715
- h ? (o.textContent = h, o.setAttribute("aria-label", `Image ${i} of ${n}: ${h}`)) : (o.textContent = "", o.setAttribute("aria-label", `Image ${i} of ${n}`));
732
+ const r = (a = this.currentChildren) == null ? void 0 : a.images.find((c) => c.index === t), l = (r == null ? void 0 : r.alt) || "";
733
+ l ? (o.textContent = l, o.setAttribute("aria-label", `Image ${n} of ${i}: ${l}`)) : (o.textContent = "", o.setAttribute("aria-label", `Image ${n} of ${i}`));
716
734
  }
717
735
  }
736
+ transitionImage(t, e) {
737
+ const n = this.imageTransitions.get(t);
738
+ n && requestAnimationFrame(() => {
739
+ const { current: i, target: o } = n, a = {
740
+ width: i.width + (o.width - i.width) * 0.1,
741
+ height: i.height + (o.height - i.height) * 0.1,
742
+ radius: i.radius + (o.radius - i.radius) * 0.1
743
+ };
744
+ Math.abs(a.width - o.width) < 0.5 && Math.abs(a.height - o.height) < 0.5 && Math.abs(a.radius - o.radius) < 0.5 ? (t.style.setProperty("--vvw-current-w", `${o.width}px`), t.style.setProperty("--vvw-current-h", `${o.height}px`), t.style.setProperty("--vvw-current-radius", `${o.radius}px`), this.imageTransitions.delete(t), e()) : (t.style.setProperty("--vvw-current-w", `${a.width}px`), t.style.setProperty("--vvw-current-h", `${a.height}px`), t.style.setProperty("--vvw-current-radius", `${a.radius}px`), this.imageTransitions.set(t, { current: a, target: o }), this.transitionImage(t, e));
745
+ });
746
+ }
718
747
  waitForImagesToLoad() {
719
- this.imageContainer.querySelectorAll("img.vvw-img-hi:not(.vvw--loaded)").forEach((i) => {
720
- const n = i, o = () => {
721
- var r;
722
- n.width = n.naturalWidth, n.height = n.naturalHeight;
723
- const a = (r = n.parentElement) == null ? void 0 : r.matches(`[data-vvw-idx="${this.currentIndex}"]`);
724
- n.addEventListener(
725
- "transitionend",
726
- () => {
727
- a && (this.imageState.setCurrentImage(n), this.imageState.setInitialCenter()), n.classList.add("vvw--ready");
748
+ this.imageContainer.querySelectorAll("img.vvw-img-hi:not(.vvw--loaded)").forEach((n) => {
749
+ const i = n, o = () => {
750
+ var c;
751
+ i.width = i.naturalWidth, i.height = i.naturalHeight;
752
+ const a = (c = i.parentElement) == null ? void 0 : c.matches(`[data-vvw-idx="${this.currentIndex}"]`), { width: r, height: l } = M(i);
753
+ i.dataset.vvwWidth = r.toString(), i.dataset.vvwHeight = l.toString(), i.classList.add("vvw--loaded"), this.imageTransitions.set(i, {
754
+ current: {
755
+ width: i.style.getPropertyValue("--vvw-current-w") ? parseFloat(i.style.getPropertyValue("--vvw-current-w")) : 0,
756
+ height: i.style.getPropertyValue("--vvw-current-h") ? parseFloat(i.style.getPropertyValue("--vvw-current-h")) : 0,
757
+ radius: i.style.getPropertyValue("--vvw-current-radius") ? parseFloat(i.style.getPropertyValue("--vvw-current-radius")) : 0
728
758
  },
729
- { once: !0 }
730
- ), n.classList.add("vvw--loaded"), requestAnimationFrame(() => {
731
- const { width: h, height: c } = S(n);
732
- n.style.setProperty("--vvw-current-w", `${h}px`), n.style.setProperty("--vvw-current-h", `${c}px`), n.dataset.vvwWidth = h.toString(), n.dataset.vvwHeight = c.toString(), n.style.setProperty("--vvw-current-radius", "0px");
759
+ target: { width: r, height: l, radius: 0 }
760
+ }), this.transitionImage(i, () => {
761
+ a && (this.imageState.setCurrentImage(i), this.imageState.setInitialCenter()), i.classList.add("vvw--ready");
733
762
  });
734
763
  };
735
- if (n.complete && n.naturalWidth !== 0) {
764
+ if (i.complete && i.naturalWidth !== 0) {
736
765
  o();
737
766
  return;
738
767
  }
739
- n.addEventListener("load", () => {
768
+ i.addEventListener("load", () => {
740
769
  o();
741
- }), n.addEventListener("error", () => {
770
+ }), i.addEventListener("error", () => {
742
771
  var r;
743
- n.classList.add("vvw--loaderror");
772
+ i.classList.add("vvw--loaderror");
744
773
  const a = document.createElement("p");
745
- a.className = "vvw-img-err", a.setAttribute("role", "alert"), a.textContent = "Error loading image", (r = n.parentNode) == null || r.appendChild(a);
774
+ a.className = "vvw-img-err", a.setAttribute("role", "alert"), a.textContent = "Error loading image", (r = i.parentNode) == null || r.appendChild(a);
746
775
  });
747
776
  });
748
777
  }
@@ -754,17 +783,17 @@ class it {
754
783
  }
755
784
  /// OPEN
756
785
  open(t = 0) {
757
- var c, m, w, b, p;
786
+ var c, m, p, L, g;
758
787
  if (x.somethingOpened)
759
788
  return;
760
789
  x.somethingOpened = this, this.currentIndex = t, document.body.style.overflow = "hidden";
761
- const e = U({
790
+ const e = K({
762
791
  controls: this.options.controls
763
792
  });
764
793
  if (document.body.prepend(e), this.root = document.body.querySelector("#vvw-root"), !this.root)
765
794
  throw new Error("Failed to setup VistaView root element.");
766
- this.imageContainer = this.qs(".vvw-image-container"), this.options.animationDurationBase && this.root.style.setProperty("--vvw-anim-dur", `${this.options.animationDurationBase}`), this.options.initialZIndex !== void 0 && this.root.style.setProperty("--vvw-init-z", `${this.options.initialZIndex}`);
767
- const i = this.options.preloads || 0, n = t, { images: o, htmls: a } = this.getChildElements(i, n), r = {
795
+ this.imageContainer = this.qs(".vvw-image-container"), this.options.animationDurationBase && this.root.style.setProperty("--vvw-anim-dur", `${this.options.animationDurationBase}`), this.options.initialZIndex !== void 0 && this.root.style.setProperty("--vvw-init-z", `${this.options.initialZIndex ?? 0}`), this.options.arrowOnSmallScreens && this.root.classList.add("vvw-arrow-sm");
796
+ const n = this.options.preloads || 0, i = t, { images: o, htmls: a } = this.getChildElements(n, i), r = {
768
797
  htmlElements: { from: null, to: a },
769
798
  images: { from: null, to: o },
770
799
  index: { from: null, to: this.currentIndex },
@@ -773,11 +802,11 @@ class it {
773
802
  };
774
803
  this.setupFunction(r), this.currentChildren = { htmls: a, images: o }, a.forEach((d) => {
775
804
  this.imageContainer.appendChild(d);
776
- }), (c = this.qs(".vvw-close")) == null || c.addEventListener("click", () => this.close()), (m = this.qs(".vvw-zoom-in")) == null || m.addEventListener("click", () => this.zoomIn()), (w = this.qs(".vvw-zoom-out")) == null || w.addEventListener("click", () => this.zoomOut()), (b = this.qs(".vvw-prev>button")) == null || b.addEventListener("click", () => this.prev()), (p = this.qs(".vvw-next>button")) == null || p.addEventListener("click", () => this.next()), window.addEventListener("keydown", this.onKeyDown), window.addEventListener("wheel", this.onScroll, { passive: !1 }), window.addEventListener("resize", this.onResizeHandler), this.pointers = new V({
805
+ }), (c = this.qs(".vvw-close")) == null || c.addEventListener("click", () => this.close()), (m = this.qs(".vvw-zoom-in")) == null || m.addEventListener("click", () => this.zoomIn()), (p = this.qs(".vvw-zoom-out")) == null || p.addEventListener("click", () => this.zoomOut()), (L = this.qs(".vvw-prev>button")) == null || L.addEventListener("click", () => this.prev()), (g = this.qs(".vvw-next>button")) == null || g.addEventListener("click", () => this.next()), this.options.keyboardListeners && window.addEventListener("keydown", this.onKeyDown), window.addEventListener("wheel", this.onScroll, { passive: !1 }), window.addEventListener("resize", this.onResizeHandler), this.pointers = new et({
777
806
  elm: this.imageContainer,
778
807
  listeners: [this.getInternalPointerListener()]
779
808
  });
780
- const h = {};
809
+ const l = {};
781
810
  [
782
811
  ...this.options.controls.topLeft || [],
783
812
  ...this.options.controls.topRight || [],
@@ -786,26 +815,24 @@ class it {
786
815
  ...this.options.controls.bottomLeft || [],
787
816
  ...this.options.controls.bottomRight || []
788
817
  ].forEach((d) => {
789
- typeof d != "string" && (h[d.name] = d);
818
+ typeof d != "string" && (l[d.name] = d);
790
819
  }), this.root.querySelectorAll("button[data-vvw-control]").forEach((d) => {
791
- const v = d;
792
- v.addEventListener("click", (g) => {
793
- const f = g.currentTarget.dataset.vvwControl, u = h[f], C = this.currentChildren.images.find(
794
- (E) => E.index === this.currentIndex
820
+ const u = d;
821
+ u.addEventListener("click", (y) => {
822
+ const f = y.currentTarget.dataset.vvwControl, v = l[f], E = this.currentChildren.images.find(
823
+ (I) => I.index === this.currentIndex
795
824
  );
796
- u && C && (u.onClick.constructor.name === "AsyncFunction" ? (v.classList.add("vvw--loading"), u.onClick(C, this).finally(() => {
797
- v.classList.remove("vvw--loading");
798
- })) : u.onClick(C, this));
825
+ v && E && (v.onClick.constructor.name === "AsyncFunction" ? (u.classList.add("vvw--loading"), v.onClick(E, this).finally(() => {
826
+ u.classList.remove("vvw--loading");
827
+ })) : v.onClick(E, this));
799
828
  });
800
829
  }), this.initFunction(this), requestAnimationFrame(() => {
801
830
  var d;
802
831
  (d = this.root) == null || d.addEventListener(
803
832
  "transitionend",
804
833
  () => {
805
- var v, g;
806
- (v = this.root) == null || v.classList.add("vvw--settled"), this.waitForImagesToLoad(), (g = this.qs(".vvw-bg")) == null || g.addEventListener("click", (f) => {
807
- f.preventDefault(), this.close();
808
- }), this.imageState.reset();
834
+ var u;
835
+ (u = this.root) == null || u.classList.add("vvw--settled"), this.waitForImagesToLoad(), this.imageState.reset();
809
836
  },
810
837
  { once: !0 }
811
838
  ), this.root.classList.add("vvw--active"), this.displayActiveIndex(), this.options.onOpen && this.options.onOpen(this), this.options.onImageView && this.options.onImageView(r);
@@ -814,15 +841,15 @@ class it {
814
841
  /// CLOSE
815
842
  async close(t = !0) {
816
843
  x.somethingOpened === this && this.root && (t ? await new Promise((e) => {
817
- let n = 0;
844
+ let i = 0;
818
845
  this.root.addEventListener("transitionend", (o) => {
819
- o.target === this.root && (n++, n === 2 && this.elements instanceof NodeList && this.elements.forEach((a) => {
846
+ o.target === this.root && (i++, i === 2 && this.elements instanceof NodeList && this.elements.forEach((a) => {
820
847
  a.style.opacity = "";
821
- }), n === 3 && e(null));
848
+ }), i === 3 && e(null));
822
849
  }), this.root.classList.add("vvw--closing");
823
850
  }) : this.elements instanceof NodeList && this.elements.forEach((e) => {
824
851
  e.style.opacity = "";
825
- }), window.removeEventListener("keydown", this.onKeyDown), window.removeEventListener("resize", this.onResizeHandler), window.removeEventListener("wheel", this.onScroll), this.unregisterPointerListeners(), this.pointers.removeListeners(), this.root.remove(), this.root = null, this.imageContainer = null, this.currentChildren = null, this.currentIndex = -1, document.body.style.overflow = "", x.somethingOpened = null, this.closeFunction(this), this.options.onClose && this.options.onClose(this));
852
+ }), this.options.keyboardListeners && window.removeEventListener("keydown", this.onKeyDown), window.removeEventListener("resize", this.onResizeHandler), window.removeEventListener("wheel", this.onScroll), this.unregisterPointerListeners(), this.pointers.removeListeners(), this.root.remove(), this.root = null, this.imageContainer = null, this.currentChildren = null, this.currentIndex = -1, document.body.style.overflow = "", x.somethingOpened = null, this.closeFunction(this), this.options.onClose && this.options.onClose(this));
826
853
  }
827
854
  next() {
828
855
  if (x.somethingOpened !== this)
@@ -847,48 +874,48 @@ class it {
847
874
  view(t, e) {
848
875
  if (x.somethingOpened !== this || t < 0 || t >= this.elements.length)
849
876
  return;
850
- const i = this.currentIndex;
877
+ const n = this.currentIndex;
851
878
  this.currentIndex = t;
852
- const n = this.abortController;
853
- n == null || n.abort(), this.abortController = new AbortController(), this.swap(i, e);
879
+ const i = this.abortController;
880
+ i == null || i.abort(), this.abortController = new AbortController(), this.swap(n, e);
854
881
  }
855
882
  }
856
- function nt(s) {
883
+ function ot(s) {
857
884
  let t = null;
858
885
  if (typeof s == "string" ? t = document.querySelectorAll(s) : s instanceof NodeList && (t = s), t)
859
886
  for (let e = 0; e < t.length; e++) {
860
- const i = t[e];
861
- if (!(i.dataset.vistaviewSrc || i.getAttribute("href") || i.getAttribute("src") || ""))
887
+ const n = t[e];
888
+ if (!(n.dataset.vistaviewSrc || n.getAttribute("href") || n.getAttribute("src") || ""))
862
889
  return `Element at index ${e} is missing 'src' / 'data-vistaview-src' / 'href' attribute.`;
863
890
  }
864
891
  else {
865
892
  const e = s;
866
- for (let i = 0; i < e.length; i++)
867
- if (!e[i].src)
868
- return `Element at index ${i} is missing 'src' attribute.`;
893
+ for (let n = 0; n < e.length; n++)
894
+ if (!e[n].src)
895
+ return `Element at index ${n} is missing 'src' attribute.`;
869
896
  }
870
897
  return t || s;
871
898
  }
872
- function ot({ elements: s, ...t }) {
899
+ function at({ elements: s, ...t }) {
873
900
  if (!s) throw new Error("No elements");
874
- let e = nt(s);
901
+ let e = ot(s);
875
902
  if (typeof e == "string")
876
903
  return null;
877
- const i = new it(e, t);
904
+ const n = new st(e, t);
878
905
  return {
879
- open: (n = 0) => i.open(n),
880
- close: () => i.close(),
881
- next: () => i.next(),
882
- prev: () => i.prev(),
883
- destroy: () => i.destroy(),
884
- getCurrentIndex: () => i.getCurrentIndex(),
885
- view: (n) => {
886
- i.view(n);
906
+ open: (i = 0) => n.open(i),
907
+ close: () => n.close(),
908
+ next: () => n.next(),
909
+ prev: () => n.prev(),
910
+ destroy: () => n.destroy(),
911
+ getCurrentIndex: () => n.getCurrentIndex(),
912
+ view: (i) => {
913
+ n.view(i);
887
914
  }
888
915
  };
889
916
  }
890
917
  export {
891
- T as DefaultOptions,
892
- ot as vistaView,
893
- N as vistaViewDownload
918
+ H as DefaultOptions,
919
+ at as vistaView,
920
+ j as vistaViewDownload
894
921
  };