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/README.md +58 -26
- package/dist/lib/defaults/options.d.ts.map +1 -1
- package/dist/lib/defaults/transition.d.ts +4 -1
- package/dist/lib/defaults/transition.d.ts.map +1 -1
- package/dist/lib/types.d.ts +5 -3
- package/dist/lib/types.d.ts.map +1 -1
- package/dist/lib/vista-view.d.ts +3 -0
- package/dist/lib/vista-view.d.ts.map +1 -1
- package/dist/style.css +1 -0
- package/dist/style.d.ts +1 -0
- package/dist/styles/dark-rounded.css +1 -0
- package/dist/styles/dark-rounded.d.ts +1 -0
- package/dist/vistaview.d.ts.map +1 -1
- package/dist/vistaview.js +354 -327
- package/dist/vistaview.umd.js +7 -7
- package/package.json +3 -2
- package/dist/vistaview.css +0 -1
package/dist/vistaview.js
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
var
|
|
2
|
-
var A = (s, t, e) => t in s ?
|
|
3
|
-
var
|
|
4
|
-
function
|
|
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
|
|
8
|
-
const e = window.getComputedStyle(s).objectFit || "", { width:
|
|
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:
|
|
10
|
+
return { width: n, height: i };
|
|
11
11
|
if (!o || !a)
|
|
12
|
-
return { width:
|
|
13
|
-
const r = o / a,
|
|
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:
|
|
16
|
+
return { width: n, height: i };
|
|
17
17
|
case "none":
|
|
18
18
|
return { width: o, height: a };
|
|
19
19
|
case "contain":
|
|
20
|
-
return r >
|
|
20
|
+
return r > l ? { width: n, height: n / r } : { width: i * r, height: i };
|
|
21
21
|
case "cover":
|
|
22
|
-
return r <
|
|
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 >
|
|
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:
|
|
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
|
|
46
|
-
const t = s.imageElm ? D(s.imageElm) : null, e = s.anchorElm ? D(s.anchorElm) : null,
|
|
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:
|
|
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
|
|
60
|
+
function W(s, t, e, n = !1) {
|
|
61
61
|
const {
|
|
62
|
-
fit:
|
|
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:
|
|
69
|
+
nh: l,
|
|
70
70
|
br: c,
|
|
71
71
|
top: m,
|
|
72
|
-
left:
|
|
73
|
-
} =
|
|
74
|
-
d.width = `${o}px`, d.height = `${a}px`, d.objectFit =
|
|
75
|
-
const
|
|
76
|
-
|
|
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
|
|
79
|
-
const t = window.innerWidth, e = window.innerHeight,
|
|
80
|
-
if (!
|
|
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 (
|
|
82
|
+
if (n < t && i < e)
|
|
83
83
|
return {
|
|
84
|
-
width:
|
|
85
|
-
height:
|
|
84
|
+
width: n,
|
|
85
|
+
height: i
|
|
86
86
|
};
|
|
87
|
-
const o =
|
|
88
|
-
let r,
|
|
89
|
-
return o > a ? (r = t,
|
|
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:
|
|
91
|
+
height: l
|
|
92
92
|
};
|
|
93
93
|
}
|
|
94
|
-
function
|
|
94
|
+
function q(s, t, e) {
|
|
95
95
|
return Math.min(Math.max(s, t), e);
|
|
96
96
|
}
|
|
97
|
-
function
|
|
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
|
|
102
|
-
let
|
|
103
|
-
function
|
|
104
|
-
return
|
|
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
|
-
}),
|
|
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
|
-
}),
|
|
115
|
+
}), $);
|
|
116
116
|
}
|
|
117
|
-
function
|
|
118
|
-
const e =
|
|
119
|
-
|
|
120
|
-
const
|
|
121
|
-
return
|
|
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
|
|
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(),
|
|
130
|
-
|
|
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
|
|
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">${
|
|
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">${
|
|
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">${
|
|
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
|
|
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
|
-
|
|
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
|
|
161
|
-
return
|
|
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
|
|
163
|
+
function K({
|
|
164
164
|
controls: s
|
|
165
165
|
}) {
|
|
166
|
-
const t = (
|
|
167
|
-
return
|
|
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
|
|
173
|
-
<div class="vvw-bottom-bar
|
|
174
|
-
<div class="vvw-prev vvw-ui"><button aria-label="Previous">${
|
|
175
|
-
<div class="vvw-next vvw-ui"><button aria-label="Next">${
|
|
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
|
|
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",
|
|
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
|
-
|
|
205
|
-
s.
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
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 (
|
|
219
|
-
let
|
|
220
|
-
var
|
|
221
|
-
(
|
|
222
|
-
var
|
|
223
|
-
(
|
|
224
|
-
}), s.imageContainer.style.transition = "transform 222ms ease", s.imageContainer.style.transform =
|
|
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 (
|
|
227
|
-
const
|
|
228
|
-
|
|
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 (
|
|
231
|
-
const
|
|
232
|
-
s.imageContainer.style.transition = "",
|
|
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
|
-
|
|
233
|
+
n = null, t = { x: 0, y: 0 }, e = { x: 0, y: 0 };
|
|
235
234
|
}
|
|
236
235
|
}
|
|
237
236
|
});
|
|
238
237
|
}
|
|
239
|
-
function
|
|
238
|
+
function Q(s) {
|
|
240
239
|
}
|
|
241
|
-
|
|
240
|
+
function tt({
|
|
242
241
|
vistaView: { isReducedMotion: s },
|
|
243
242
|
htmlElements: { to: t },
|
|
244
|
-
index: { from: e, to:
|
|
245
|
-
vistaView: { elements:
|
|
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(
|
|
248
|
-
return
|
|
249
|
-
|
|
250
|
-
|
|
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
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
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
|
|
270
|
+
class et {
|
|
265
271
|
constructor({ elm: t, listeners: e }) {
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
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
|
-
|
|
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
|
-
(
|
|
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
|
-
|
|
301
|
+
h(this, "onPointerMove", (t) => {
|
|
296
302
|
if (!this.listeners.length) return;
|
|
297
303
|
t.preventDefault();
|
|
298
|
-
const e = this.pointers.find((
|
|
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
|
-
(
|
|
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
|
-
|
|
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
|
|
315
|
-
|
|
316
|
-
const
|
|
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:
|
|
326
|
+
pointer: n,
|
|
321
327
|
pointers: this.pointers,
|
|
322
|
-
lastPointerLen:
|
|
328
|
+
lastPointerLen: i
|
|
323
329
|
})
|
|
324
330
|
);
|
|
325
331
|
});
|
|
326
|
-
|
|
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
|
|
333
|
-
|
|
334
|
-
const
|
|
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:
|
|
344
|
+
pointer: n,
|
|
339
345
|
pointers: this.pointers,
|
|
340
|
-
lastPointerLen:
|
|
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
|
|
360
|
-
return Math.sqrt(
|
|
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,
|
|
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
|
|
380
|
+
class it {
|
|
375
381
|
constructor(t, e) {
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
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
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
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),
|
|
407
|
+
const e = parseFloat(t.dataset.vvwWidth), n = parseFloat(t.dataset.vvwHeight);
|
|
402
408
|
this.minDimension = {
|
|
403
409
|
initialWidth: e,
|
|
404
|
-
initialHeight:
|
|
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 =
|
|
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,
|
|
416
|
-
return Math.abs(t - e) <=
|
|
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
|
|
422
|
-
|
|
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:
|
|
427
|
-
isMax:
|
|
428
|
-
isMin:
|
|
429
|
-
}), this.scale =
|
|
430
|
-
const
|
|
431
|
-
this.translate.x =
|
|
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,
|
|
435
|
-
const
|
|
436
|
-
if (
|
|
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 =
|
|
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
|
|
450
|
+
return i({
|
|
445
451
|
x: t.movementX,
|
|
446
452
|
y: t.movementY
|
|
447
453
|
}), () => {
|
|
448
|
-
|
|
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(),
|
|
455
|
-
this.rect.width * t < this.minDimension.closingWidth ||
|
|
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 &&
|
|
464
|
+
this.animationTimestamp === e && n && (n.style.transition = "", this.normalize());
|
|
459
465
|
},
|
|
460
466
|
{ once: !0 }
|
|
461
|
-
),
|
|
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
|
-
),
|
|
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 = `${
|
|
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
|
|
477
|
-
|
|
482
|
+
const i = this.image;
|
|
483
|
+
i && (i.addEventListener(
|
|
478
484
|
"transitionend",
|
|
479
485
|
() => {
|
|
480
|
-
|
|
486
|
+
i && (this.clean(), this.rect = null);
|
|
481
487
|
},
|
|
482
488
|
{ once: !0 }
|
|
483
|
-
),
|
|
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
|
|
487
|
-
if (this.rect.right < window.innerWidth / 2 && (
|
|
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
|
|
507
|
+
class nt {
|
|
502
508
|
constructor() {
|
|
503
|
-
|
|
509
|
+
h(this, "fiolast", {});
|
|
504
510
|
}
|
|
505
511
|
// first in out
|
|
506
|
-
fio(t, e,
|
|
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 >=
|
|
520
|
+
o >= n && a();
|
|
515
521
|
}
|
|
516
522
|
}
|
|
517
523
|
const x = {
|
|
518
524
|
somethingOpened: null
|
|
519
525
|
};
|
|
520
|
-
class
|
|
526
|
+
class st {
|
|
521
527
|
constructor(t, e = {}) {
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
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
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
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
|
-
|
|
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
|
-
|
|
580
|
+
h(this, "onResizeHandler", () => {
|
|
573
581
|
this.currentChildren.htmls.forEach((t, e) => {
|
|
574
|
-
const
|
|
575
|
-
if (
|
|
576
|
-
const { width: a, height: r } =
|
|
577
|
-
|
|
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
|
-
|
|
583
|
-
|
|
590
|
+
h(this, "pointerListeners", []);
|
|
591
|
+
h(this, "getInternalPointerListener", () => {
|
|
584
592
|
const t = this.imageState;
|
|
585
|
-
let e = 0,
|
|
593
|
+
let e = 0, n = !1, i = () => {
|
|
586
594
|
};
|
|
587
595
|
return (o) => {
|
|
588
596
|
if (o.event === "down") {
|
|
589
|
-
if (
|
|
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
|
-
|
|
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 &&
|
|
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") && (
|
|
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 && (
|
|
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 ||
|
|
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
|
-
...
|
|
628
|
+
...H,
|
|
620
629
|
...e,
|
|
621
630
|
controls: {
|
|
622
|
-
...
|
|
631
|
+
...H.controls,
|
|
623
632
|
...e.controls
|
|
624
633
|
}
|
|
625
|
-
}, this.imageState = new
|
|
634
|
+
}, this.imageState = new it(
|
|
626
635
|
this.options.maxZoomLevel,
|
|
627
|
-
(
|
|
628
|
-
var
|
|
629
|
-
|
|
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
|
-
)),
|
|
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((
|
|
638
|
-
|
|
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
|
|
646
|
-
htmlElements: { from:
|
|
647
|
-
images: { from:
|
|
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
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
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
|
-
),
|
|
659
|
-
this.
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
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
|
|
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],
|
|
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:
|
|
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 || (
|
|
674
|
-
alt:
|
|
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
|
-
|
|
697
|
+
i.push(c), n.push(U(c, o));
|
|
680
698
|
}
|
|
681
699
|
return {
|
|
682
|
-
htmls:
|
|
683
|
-
images:
|
|
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,
|
|
708
|
-
r.style.opacity = "",
|
|
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"),
|
|
711
|
-
e && (e.textContent = `${
|
|
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),
|
|
715
|
-
|
|
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((
|
|
720
|
-
const
|
|
721
|
-
var
|
|
722
|
-
|
|
723
|
-
const a = (
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
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
|
-
{
|
|
730
|
-
),
|
|
731
|
-
|
|
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 (
|
|
764
|
+
if (i.complete && i.naturalWidth !== 0) {
|
|
736
765
|
o();
|
|
737
766
|
return;
|
|
738
767
|
}
|
|
739
|
-
|
|
768
|
+
i.addEventListener("load", () => {
|
|
740
769
|
o();
|
|
741
|
-
}),
|
|
770
|
+
}), i.addEventListener("error", () => {
|
|
742
771
|
var r;
|
|
743
|
-
|
|
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 =
|
|
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,
|
|
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 =
|
|
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
|
|
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()), (
|
|
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
|
|
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" && (
|
|
818
|
+
typeof d != "string" && (l[d.name] = d);
|
|
790
819
|
}), this.root.querySelectorAll("button[data-vvw-control]").forEach((d) => {
|
|
791
|
-
const
|
|
792
|
-
|
|
793
|
-
const f =
|
|
794
|
-
(
|
|
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
|
-
|
|
797
|
-
|
|
798
|
-
})) :
|
|
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
|
|
806
|
-
(
|
|
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
|
|
844
|
+
let i = 0;
|
|
818
845
|
this.root.addEventListener("transitionend", (o) => {
|
|
819
|
-
o.target === this.root && (
|
|
846
|
+
o.target === this.root && (i++, i === 2 && this.elements instanceof NodeList && this.elements.forEach((a) => {
|
|
820
847
|
a.style.opacity = "";
|
|
821
|
-
}),
|
|
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
|
|
877
|
+
const n = this.currentIndex;
|
|
851
878
|
this.currentIndex = t;
|
|
852
|
-
const
|
|
853
|
-
|
|
879
|
+
const i = this.abortController;
|
|
880
|
+
i == null || i.abort(), this.abortController = new AbortController(), this.swap(n, e);
|
|
854
881
|
}
|
|
855
882
|
}
|
|
856
|
-
function
|
|
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
|
|
861
|
-
if (!(
|
|
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
|
|
867
|
-
if (!e[
|
|
868
|
-
return `Element at index ${
|
|
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
|
|
899
|
+
function at({ elements: s, ...t }) {
|
|
873
900
|
if (!s) throw new Error("No elements");
|
|
874
|
-
let e =
|
|
901
|
+
let e = ot(s);
|
|
875
902
|
if (typeof e == "string")
|
|
876
903
|
return null;
|
|
877
|
-
const
|
|
904
|
+
const n = new st(e, t);
|
|
878
905
|
return {
|
|
879
|
-
open: (
|
|
880
|
-
close: () =>
|
|
881
|
-
next: () =>
|
|
882
|
-
prev: () =>
|
|
883
|
-
destroy: () =>
|
|
884
|
-
getCurrentIndex: () =>
|
|
885
|
-
view: (
|
|
886
|
-
|
|
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
|
-
|
|
892
|
-
|
|
893
|
-
|
|
918
|
+
H as DefaultOptions,
|
|
919
|
+
at as vistaView,
|
|
920
|
+
j as vistaViewDownload
|
|
894
921
|
};
|