vistaview 0.7.8 → 0.10.10
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 +276 -97
- package/dist/extensions/dailymotion-video.d.ts +2 -0
- package/dist/extensions/dailymotion-video.js +80 -0
- package/dist/extensions/dailymotion-video.umd.js +1 -0
- package/dist/extensions/download.d.ts +2 -0
- package/dist/extensions/download.js +35 -0
- package/dist/extensions/download.umd.js +1 -0
- package/dist/extensions/google-maps.d.ts +2 -0
- package/dist/extensions/google-maps.js +94 -0
- package/dist/extensions/google-maps.umd.js +1 -0
- package/dist/extensions/image-story.d.ts +2 -0
- package/dist/extensions/image-story.js +621 -0
- package/dist/extensions/image-story.umd.js +2 -0
- package/dist/extensions/logger.d.ts +2 -0
- package/dist/extensions/logger.js +23 -0
- package/dist/extensions/logger.umd.js +1 -0
- package/dist/extensions/mapbox.d.ts +2 -0
- package/dist/extensions/mapbox.js +124 -0
- package/dist/extensions/mapbox.umd.js +1 -0
- package/dist/extensions/openstreetmap.d.ts +2 -0
- package/dist/extensions/openstreetmap.js +125 -0
- package/dist/extensions/openstreetmap.umd.js +1 -0
- package/dist/extensions/streamable-video.d.ts +2 -0
- package/dist/extensions/streamable-video.js +76 -0
- package/dist/extensions/streamable-video.umd.js +1 -0
- package/dist/extensions/vidyard-video.d.ts +2 -0
- package/dist/extensions/vidyard-video.js +80 -0
- package/dist/extensions/vidyard-video.umd.js +1 -0
- package/dist/extensions/vimeo-video.d.ts +2 -0
- package/dist/extensions/vimeo-video.js +76 -0
- package/dist/extensions/vimeo-video.umd.js +1 -0
- package/dist/extensions/wistia-video.d.ts +2 -0
- package/dist/extensions/wistia-video.js +85 -0
- package/dist/extensions/wistia-video.umd.js +1 -0
- package/dist/extensions/youtube-video.d.ts +2 -0
- package/dist/extensions/youtube-video.js +88 -0
- package/dist/extensions/youtube-video.umd.js +1 -0
- package/dist/lib/components.d.ts +1 -3
- package/dist/lib/components.d.ts.map +1 -1
- package/dist/lib/defaults/image-setup.d.ts +3 -0
- package/dist/lib/defaults/image-setup.d.ts.map +1 -0
- package/dist/lib/defaults/init.d.ts.map +1 -1
- package/dist/lib/defaults/open.d.ts +3 -0
- package/dist/lib/defaults/open.d.ts.map +1 -0
- package/dist/lib/defaults/options.d.ts.map +1 -1
- package/dist/lib/defaults/transition.d.ts +1 -1
- package/dist/lib/defaults/transition.d.ts.map +1 -1
- package/dist/lib/extensions/dailymotion-video.d.ts +34 -0
- package/dist/lib/extensions/dailymotion-video.d.ts.map +1 -0
- package/dist/lib/extensions/download.d.ts +3 -0
- package/dist/lib/extensions/download.d.ts.map +1 -0
- package/dist/lib/extensions/google-maps.d.ts +49 -0
- package/dist/lib/extensions/google-maps.d.ts.map +1 -0
- package/dist/lib/extensions/image-story.d.ts +12 -0
- package/dist/lib/extensions/image-story.d.ts.map +1 -0
- package/dist/lib/extensions/logger.d.ts +3 -0
- package/dist/lib/extensions/logger.d.ts.map +1 -0
- package/dist/lib/extensions/mapbox.d.ts +53 -0
- package/dist/lib/extensions/mapbox.d.ts.map +1 -0
- package/dist/lib/extensions/openstreetmap.d.ts +51 -0
- package/dist/lib/extensions/openstreetmap.d.ts.map +1 -0
- package/dist/lib/extensions/streamable-video.d.ts +32 -0
- package/dist/lib/extensions/streamable-video.d.ts.map +1 -0
- package/dist/lib/extensions/vidyard-video.d.ts +33 -0
- package/dist/lib/extensions/vidyard-video.d.ts.map +1 -0
- package/dist/lib/extensions/vimeo-video.d.ts +36 -0
- package/dist/lib/extensions/vimeo-video.d.ts.map +1 -0
- package/dist/lib/extensions/wistia-video.d.ts +34 -0
- package/dist/lib/extensions/wistia-video.d.ts.map +1 -0
- package/dist/lib/extensions/youtube-video.d.ts +38 -0
- package/dist/lib/extensions/youtube-video.d.ts.map +1 -0
- package/dist/lib/main.d.ts +2 -2
- package/dist/lib/main.d.ts.map +1 -1
- package/dist/lib/types.d.ts +134 -42
- package/dist/lib/types.d.ts.map +1 -1
- package/dist/lib/utils/get-fitted-size.d.ts +5 -0
- package/dist/lib/utils/get-fitted-size.d.ts.map +1 -0
- package/dist/lib/utils/get-full-size-dim.d.ts +5 -0
- package/dist/lib/utils/get-full-size-dim.d.ts.map +1 -0
- package/dist/lib/utils/get-style.d.ts +5 -0
- package/dist/lib/utils/get-style.d.ts.map +1 -0
- package/dist/lib/utils/index.d.ts +3 -0
- package/dist/lib/utils/index.d.ts.map +1 -0
- package/dist/lib/utils/is-not-zero-css.d.ts +2 -0
- package/dist/lib/utils/is-not-zero-css.d.ts.map +1 -0
- package/dist/lib/utils/parse-element.d.ts +3 -0
- package/dist/lib/utils/parse-element.d.ts.map +1 -0
- package/dist/lib/vista-box.d.ts +107 -0
- package/dist/lib/vista-box.d.ts.map +1 -0
- package/dist/lib/vista-hires-transition.d.ts +32 -0
- package/dist/lib/vista-hires-transition.d.ts.map +1 -0
- package/dist/lib/vista-image-event.d.ts +23 -0
- package/dist/lib/vista-image-event.d.ts.map +1 -0
- package/dist/lib/vista-image.d.ts +33 -0
- package/dist/lib/vista-image.d.ts.map +1 -0
- package/dist/lib/{pointers.d.ts → vista-pointers.d.ts} +1 -1
- package/dist/lib/vista-pointers.d.ts.map +1 -0
- package/dist/lib/vista-state.d.ts +18 -0
- package/dist/lib/vista-state.d.ts.map +1 -0
- package/dist/lib/vista-view.d.ts +25 -28
- package/dist/lib/vista-view.d.ts.map +1 -1
- package/dist/react.d.ts +9 -9
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +59 -49
- package/dist/solid.d.ts +8 -11
- package/dist/solid.d.ts.map +1 -1
- package/dist/solid.js +28 -32
- package/dist/style.css +1 -1
- package/dist/styles/autumn-amber.css +1 -0
- package/dist/styles/autumn-amber.d.ts +1 -0
- package/dist/styles/cotton-candy.css +1 -0
- package/dist/styles/cotton-candy.d.ts +1 -0
- package/dist/styles/dark-rounded.css +1 -1
- package/dist/styles/ember-glow.css +1 -0
- package/dist/styles/ember-glow.d.ts +1 -0
- package/dist/styles/extensions/image-story.css +1 -0
- package/dist/styles/extensions/image-story.d.ts +1 -0
- package/dist/styles/forest-moss.css +1 -0
- package/dist/styles/forest-moss.d.ts +1 -0
- package/dist/styles/green-lake.css +1 -0
- package/dist/styles/green-lake.d.ts +1 -0
- package/dist/styles/ice-crystal.css +1 -0
- package/dist/styles/ice-crystal.d.ts +1 -0
- package/dist/styles/lavender-fields.css +1 -0
- package/dist/styles/lavender-fields.d.ts +1 -0
- package/dist/styles/midnight-gold.css +1 -0
- package/dist/styles/midnight-gold.d.ts +1 -0
- package/dist/styles/midnight-ocean.css +1 -0
- package/dist/styles/midnight-ocean.d.ts +1 -0
- package/dist/styles/mint-chocolate.css +1 -0
- package/dist/styles/mint-chocolate.d.ts +1 -0
- package/dist/styles/neon-nights.css +1 -0
- package/dist/styles/neon-nights.d.ts +1 -0
- package/dist/styles/paper-light.css +1 -0
- package/dist/styles/paper-light.d.ts +1 -0
- package/dist/styles/retro-arcade.css +1 -0
- package/dist/styles/retro-arcade.d.ts +1 -0
- package/dist/styles/soft-neutral.css +1 -0
- package/dist/styles/soft-neutral.d.ts +1 -0
- package/dist/styles/stark-minimal.css +1 -0
- package/dist/styles/stark-minimal.d.ts +1 -0
- package/dist/styles/strawberry.css +1 -0
- package/dist/styles/strawberry.d.ts +1 -0
- package/dist/svelte.d.ts +11 -2
- package/dist/svelte.d.ts.map +1 -1
- package/dist/svelte.js +36 -14
- package/dist/vista-box-CQvGrjln.js +318 -0
- package/dist/vistaview.d.ts +9 -2
- package/dist/vistaview.d.ts.map +1 -1
- package/dist/vistaview.js +719 -686
- package/dist/vistaview.umd.js +14 -7
- package/dist/vue.d.ts +28 -9
- package/dist/vue.d.ts.map +1 -1
- package/dist/vue.js +43 -24
- package/package.json +8 -3
- package/dist/lib/defaults/setup.d.ts +0 -3
- package/dist/lib/defaults/setup.d.ts.map +0 -1
- package/dist/lib/errors.d.ts +0 -4
- package/dist/lib/errors.d.ts.map +0 -1
- package/dist/lib/image-state.d.ts +0 -40
- package/dist/lib/image-state.d.ts.map +0 -1
- package/dist/lib/pointers.d.ts.map +0 -1
- package/dist/lib/utils.d.ts +0 -27
- package/dist/lib/utils.d.ts.map +0 -1
package/dist/vistaview.js
CHANGED
|
@@ -1,109 +1,27 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return { width: r, height: a };
|
|
19
|
-
case "contain":
|
|
20
|
-
return o > l ? { width: i, height: i / o } : { width: n * o, height: n };
|
|
21
|
-
case "cover":
|
|
22
|
-
return o < l ? { width: i, height: i / o } : { width: n * o, height: n };
|
|
23
|
-
case "scale-down": {
|
|
24
|
-
const c = { width: r, height: a }, d = o > l ? { width: i, height: i / o } : { width: n * o, height: n };
|
|
25
|
-
return d.width <= c.width && d.height <= c.height ? d : c;
|
|
26
|
-
}
|
|
1
|
+
var S = Object.defineProperty;
|
|
2
|
+
var D = (s, t, e) => t in s ? S(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
|
|
3
|
+
var r = (s, t, e) => D(s, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import { V as T, a as L } from "./vista-box-CQvGrjln.js";
|
|
5
|
+
const I = {
|
|
6
|
+
// debug, don't remove
|
|
7
|
+
// animationDurationBase: 1000,
|
|
8
|
+
animationDurationBase: 333,
|
|
9
|
+
maxZoomLevel: 2,
|
|
10
|
+
preloads: 1,
|
|
11
|
+
keyboardListeners: !0,
|
|
12
|
+
arrowOnSmallScreens: !1,
|
|
13
|
+
rapidLimit: 222,
|
|
14
|
+
controls: {
|
|
15
|
+
topLeft: ["indexDisplay"],
|
|
16
|
+
topRight: ["zoomIn", "zoomOut", "close"],
|
|
17
|
+
bottomLeft: ["description"]
|
|
27
18
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
function
|
|
31
|
-
|
|
32
|
-
return {
|
|
33
|
-
objectFit: t.objectFit,
|
|
34
|
-
borderRadius: t.borderRadius,
|
|
35
|
-
objectPosition: t.objectPosition,
|
|
36
|
-
overflow: t.overflow,
|
|
37
|
-
top: e.top,
|
|
38
|
-
left: e.left,
|
|
39
|
-
width: e.width,
|
|
40
|
-
height: e.height,
|
|
41
|
-
naturalWidth: s.naturalWidth,
|
|
42
|
-
naturalHeight: s.naturalHeight
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
function z(s) {
|
|
46
|
-
const t = s.imageElm ? D(s.imageElm) : null, e = s.anchorElm ? D(s.anchorElm) : null, i = T(t == null ? void 0 : t.borderRadius), n = e && T(e == null ? void 0 : e.borderRadius), r = (n ? e == null ? void 0 : e.borderRadius : i ? t == null ? void 0 : t.borderRadius : "") || "";
|
|
47
|
-
return {
|
|
48
|
-
fit: (t == null ? void 0 : t.objectFit) || (e == null ? void 0 : e.objectFit) || "",
|
|
49
|
-
pos: (t == null ? void 0 : t.objectPosition) || "",
|
|
50
|
-
br: r,
|
|
51
|
-
overflow: n ? e.overflow : i ? t.overflow : "",
|
|
52
|
-
nw: (t == null ? void 0 : t.naturalWidth) || 0,
|
|
53
|
-
nh: (t == null ? void 0 : t.naturalHeight) || 0,
|
|
54
|
-
w: (e == null ? void 0 : e.width) || (t == null ? void 0 : t.width) || 0,
|
|
55
|
-
h: (e == null ? void 0 : e.height) || (t == null ? void 0 : t.height) || 0,
|
|
56
|
-
top: (e == null ? void 0 : e.top) || (t == null ? void 0 : t.top) || 0,
|
|
57
|
-
left: (e == null ? void 0 : e.left) || (t == null ? void 0 : t.left) || 0
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
function W(s, t, e, i = !1) {
|
|
61
|
-
const {
|
|
62
|
-
fit: n,
|
|
63
|
-
w: r,
|
|
64
|
-
h: a,
|
|
65
|
-
// this ones makes things hard. not used.
|
|
66
|
-
// pos,
|
|
67
|
-
// overflow,
|
|
68
|
-
nw: o,
|
|
69
|
-
nh: l,
|
|
70
|
-
br: c,
|
|
71
|
-
top: d,
|
|
72
|
-
left: p
|
|
73
|
-
} = z(s), x = Math.min(Math.max(p, -r), window.innerWidth + r) - window.innerWidth / 2 + r / 2, g = Math.min(Math.max(d, -a), window.innerHeight + a) - window.innerHeight / 2 + a / 2, m = e.style;
|
|
74
|
-
m.width = `${r}px`, m.height = `${a}px`, m.objectFit = n, e.width = o, e.height = l, m.setProperty("--vvw-init-radius", `${c}`), m.setProperty("--vvw-pulse-radius", `calc(1.3 * ${c})`), m.setProperty("--vvw-init-x", `${x}px`), m.setProperty("--vvw-init-y", `${g}px`), i && (m.setProperty("--vvw-current-x", `${x}px`), m.setProperty("--vvw-current-y", `${g}px`));
|
|
75
|
-
const u = R(s.imageElm), b = Math.min(r, u.width), f = Math.min(a, u.height), v = t.style;
|
|
76
|
-
v.setProperty("--vvw-init-radius", `${c}`), v.setProperty("--vvw-init-w", `${b}px`), v.setProperty("--vvw-init-h", `${f}px`), i && (v.setProperty("--vvw-current-radius", `${c}`), v.setProperty("--vvw-current-w", `${b}px`), v.setProperty("--vvw-current-h", `${f}px`), t.dataset.vvwWidth = b.toString(), t.dataset.vvwHeight = f.toString());
|
|
77
|
-
}
|
|
78
|
-
function H(s) {
|
|
79
|
-
const t = window.innerWidth, e = window.innerHeight, i = s.naturalWidth, n = s.naturalHeight;
|
|
80
|
-
if (!i || !n)
|
|
81
|
-
throw new Error("Image natural dimensions are zero");
|
|
82
|
-
if (i < t && n < e)
|
|
83
|
-
return {
|
|
84
|
-
width: i,
|
|
85
|
-
height: n
|
|
86
|
-
};
|
|
87
|
-
const r = i / n, a = t / e;
|
|
88
|
-
let o, l;
|
|
89
|
-
return r > a ? (o = t, l = t / r) : (l = e, o = e * r), {
|
|
90
|
-
width: o,
|
|
91
|
-
height: l
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
function q(s, t, e) {
|
|
95
|
-
return Math.min(Math.max(s, t), e);
|
|
96
|
-
}
|
|
97
|
-
function L(s, t = 2) {
|
|
98
|
-
const e = Math.pow(10, t);
|
|
99
|
-
return Math.round(s * e) / e;
|
|
100
|
-
}
|
|
101
|
-
const k = '<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>', N = '<svg viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"/><line x1="21" x2="16.65" y1="21" y2="16.65"/><line x1="8" x2="14" y1="11" y2="11"/></svg>', X = '<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 = {
|
|
19
|
+
}, 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>', q = '<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>', M = '<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>', H = '<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>';
|
|
20
|
+
let E = null;
|
|
21
|
+
function W() {
|
|
22
|
+
return E || (window.trustedTypes || (window.trustedTypes = {
|
|
105
23
|
createPolicy: (s, t) => t
|
|
106
|
-
}),
|
|
24
|
+
}), E = window.trustedTypes.createPolicy("vistaView-policy", {
|
|
107
25
|
createHTML: (s) => s,
|
|
108
26
|
// HTML is generated by us, not user input
|
|
109
27
|
createScript: () => {
|
|
@@ -112,174 +30,404 @@ function B() {
|
|
|
112
30
|
createScriptURL: () => {
|
|
113
31
|
throw new Error("Not implemented");
|
|
114
32
|
}
|
|
115
|
-
}),
|
|
33
|
+
}), E);
|
|
116
34
|
}
|
|
117
|
-
function
|
|
118
|
-
const e =
|
|
35
|
+
function F(s) {
|
|
36
|
+
const e = W().createHTML(s), i = document.createElement("template");
|
|
119
37
|
i.innerHTML = e;
|
|
120
38
|
const n = i.content;
|
|
121
39
|
return i.remove(), n;
|
|
122
40
|
}
|
|
123
|
-
function
|
|
124
|
-
return {
|
|
125
|
-
name: "download",
|
|
126
|
-
icon: Y,
|
|
127
|
-
onClick: async (s) => {
|
|
128
|
-
var r;
|
|
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 = ((r = i.split("/").pop()) == null ? void 0 : r.split("?")[0].split("#")[0]) || "download", document.body.appendChild(n), n.click(), document.body.removeChild(n);
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
function V(s) {
|
|
41
|
+
function A(s) {
|
|
135
42
|
if (typeof s == "string")
|
|
136
43
|
switch (s) {
|
|
137
44
|
case "zoomIn":
|
|
138
|
-
return `<button aria-label="Zoom In" class="vvw-zoom-in
|
|
45
|
+
return `<div class="vvw-ui"><button aria-label="Zoom In" class="vvw-zoom-in">${q}</button></div>`;
|
|
139
46
|
case "zoomOut":
|
|
140
|
-
return `<button aria-label="Zoom Out" disabled class="vvw-zoom-out
|
|
47
|
+
return `<div class="vvw-ui"><button aria-label="Zoom Out" disabled class="vvw-zoom-out">${M}</button></div>`;
|
|
141
48
|
case "close":
|
|
142
|
-
return `<button aria-label="Close" class="vvw-close
|
|
49
|
+
return `<div class="vvw-ui"><button aria-label="Close" class="vvw-close">${H}</button></div>`;
|
|
143
50
|
case "indexDisplay":
|
|
144
51
|
return '<div class="vvw-index vvw-ui" aria-hidden="true"></div>';
|
|
145
52
|
case "description":
|
|
146
53
|
return '<div class="vvw-desc vvw-ui" role="status" aria-live="polite" aria-atomic="true"></div>';
|
|
147
54
|
default:
|
|
148
|
-
return "";
|
|
55
|
+
return console.warn(`Unknown default control: ${s}. Will return empty string.`), "";
|
|
149
56
|
}
|
|
150
|
-
return `<
|
|
57
|
+
return `<div class="vvw-ext vvw-ui" aria-label="${s.description || s.name}" data-vvw-control="${s.name}"></div>`;
|
|
151
58
|
}
|
|
152
|
-
function
|
|
153
|
-
const e = document.createElement("div");
|
|
154
|
-
e.className = "vvw-item", e.dataset.vvwPos = `${t !== void 0 ? t : ""}`, e.dataset.vvwIdx = s.index.toString(), e.appendChild(
|
|
155
|
-
P(
|
|
156
|
-
`<img class="vvw-img-lo" src="${s.thumb || s.src}" alt="${s.alt || ""}" />
|
|
157
|
-
<img class="vvw-img-hi" src="${s.src}" alt="${s.alt || ""}" />`
|
|
158
|
-
)
|
|
159
|
-
);
|
|
160
|
-
const i = e.querySelector("img.vvw-img-lo"), n = e.querySelector("img.vvw-img-hi");
|
|
161
|
-
return W(s, n, i, t === 0), e;
|
|
162
|
-
}
|
|
163
|
-
function _({
|
|
59
|
+
function $({
|
|
164
60
|
controls: s
|
|
165
61
|
}) {
|
|
166
|
-
const t = (i) => i ? i.map(
|
|
167
|
-
return P(
|
|
62
|
+
const t = (i) => i ? i.map(A).join("") : "", e = F(
|
|
168
63
|
`<div class="vvw-root" id="vvw-root">
|
|
169
64
|
<div class="vvw-container">
|
|
170
65
|
<div class="vvw-bg"></div>
|
|
171
66
|
<div class="vvw-image-container"></div>
|
|
172
|
-
<div class="vvw-top-bar"
|
|
173
|
-
|
|
174
|
-
|
|
67
|
+
<div class="vvw-top-bar">
|
|
68
|
+
<div>${t(s == null ? void 0 : s.topLeft)}</div>
|
|
69
|
+
<div>${t(s == null ? void 0 : s.topCenter)}</div>
|
|
70
|
+
<div>${t(s == null ? void 0 : s.topRight)}</div>
|
|
71
|
+
</div>
|
|
72
|
+
<div class="vvw-bottom-bar">
|
|
73
|
+
<div>${t(s == null ? void 0 : s.bottomLeft)}</div>
|
|
74
|
+
<div>${t(s == null ? void 0 : s.bottomCenter)}</div>
|
|
75
|
+
<div>${t(s == null ? void 0 : s.bottomRight)}</div>
|
|
76
|
+
</div>
|
|
77
|
+
<div class="vvw-prev vvw-ui"><button aria-label="Previous">${R}</button></div>
|
|
175
78
|
<div class="vvw-next vvw-ui"><button aria-label="Next">${O}</button></div>
|
|
176
79
|
</div>
|
|
177
80
|
</div>`
|
|
178
81
|
);
|
|
82
|
+
return [
|
|
83
|
+
...(s == null ? void 0 : s.topLeft) || [],
|
|
84
|
+
...(s == null ? void 0 : s.topCenter) || [],
|
|
85
|
+
...(s == null ? void 0 : s.topRight) || [],
|
|
86
|
+
...(s == null ? void 0 : s.bottomLeft) || [],
|
|
87
|
+
...(s == null ? void 0 : s.bottomCenter) || [],
|
|
88
|
+
...(s == null ? void 0 : s.bottomRight) || []
|
|
89
|
+
].forEach((i) => {
|
|
90
|
+
if (typeof i != "string" && i.control) {
|
|
91
|
+
const n = e.querySelector(`[data-vvw-control="${i.name}"]`), o = i.control();
|
|
92
|
+
n && o && n.appendChild(o);
|
|
93
|
+
}
|
|
94
|
+
}), e;
|
|
179
95
|
}
|
|
180
|
-
|
|
181
|
-
// debug, don't remove
|
|
182
|
-
// animationDurationBase: 1000,
|
|
183
|
-
animationDurationBase: 333,
|
|
184
|
-
maxZoomLevel: 2,
|
|
185
|
-
preloads: 1,
|
|
186
|
-
keyboardListeners: !0,
|
|
187
|
-
arrowOnSmallScreens: !1,
|
|
188
|
-
rapidLimit: 222,
|
|
189
|
-
controls: {
|
|
190
|
-
topLeft: ["indexDisplay"],
|
|
191
|
-
topRight: ["zoomIn", "zoomOut", j(), "close"],
|
|
192
|
-
bottomLeft: ["description"]
|
|
193
|
-
}
|
|
194
|
-
};
|
|
195
|
-
function K(s) {
|
|
96
|
+
function k(s) {
|
|
196
97
|
}
|
|
197
|
-
function
|
|
198
|
-
|
|
199
|
-
s.imageContainer.style.width = `${(t * 2 + 1) * 100}vw`, s.imageContainer.style.left = `-${t * 100}vw`, s.imageContainer.style.display = "flex", J(s);
|
|
98
|
+
function V(s) {
|
|
99
|
+
N(s);
|
|
200
100
|
}
|
|
201
|
-
function
|
|
101
|
+
function N(s) {
|
|
202
102
|
let t = { x: 0, y: 0 }, e = { x: 0, y: 0 }, i = null;
|
|
203
103
|
s.registerPointerListener((n) => {
|
|
204
|
-
var
|
|
104
|
+
var o;
|
|
205
105
|
if (!n.hasInternalExecution && !(n.pointers.length > 1)) {
|
|
206
|
-
if (n.event === "down" && (t = { x: n.pointer.x, y: n.pointer.y }, e = { x: n.pointer.x, y: n.pointer.y }, (
|
|
106
|
+
if (n.event === "down" && (t = { x: n.pointer.x, y: n.pointer.y }, e = { x: n.pointer.x, y: n.pointer.y }, (o = n.abortController) == null || o.abort()), n.event === "move") {
|
|
207
107
|
e = { x: n.pointer.x, y: n.pointer.y };
|
|
208
|
-
const a = e.x - t.x,
|
|
209
|
-
if (!i && Math.abs(
|
|
210
|
-
const l =
|
|
108
|
+
const a = e.x - t.x, h = e.y - t.y;
|
|
109
|
+
if (!i && Math.abs(h) > Math.abs(a) || i === "y") {
|
|
110
|
+
const l = h / window.innerHeight * 100;
|
|
211
111
|
s.imageContainer.style.transition = "none", s.imageContainer.style.transform = `translateY(${l}vh)`, i = "y";
|
|
212
|
-
} else if (!i && Math.abs(a) > Math.abs(
|
|
112
|
+
} else if (!i && Math.abs(a) > Math.abs(h) || i === "x" && n.state.elmLength > 1) {
|
|
213
113
|
const l = a / window.innerWidth * 100;
|
|
214
114
|
s.imageContainer.style.transition = "none", s.imageContainer.style.transform = `translateX(${l}vw)`, i = "x";
|
|
215
115
|
}
|
|
216
116
|
}
|
|
217
117
|
if (n.event === "up" || n.event === "cancel") {
|
|
218
|
-
let a = function(
|
|
118
|
+
let a = function(h) {
|
|
219
119
|
var l;
|
|
220
|
-
(l = s.imageContainer) == null || l.addEventListener("transitionend", function
|
|
221
|
-
var
|
|
222
|
-
(
|
|
223
|
-
}), s.imageContainer.style.transition = "transform 222ms ease", s.imageContainer.style.transform =
|
|
120
|
+
(l = s.imageContainer) == null || l.addEventListener("transitionend", function d() {
|
|
121
|
+
var p;
|
|
122
|
+
(p = s.imageContainer) == null || p.removeEventListener("transitionend", d), s.imageContainer.style.transition = "", s.imageContainer.style.transform = "";
|
|
123
|
+
}), s.imageContainer.style.transition = "transform 222ms ease", s.imageContainer.style.transform = h;
|
|
224
124
|
};
|
|
225
125
|
if (i === "y") {
|
|
226
|
-
const
|
|
227
|
-
Math.abs(
|
|
126
|
+
const h = e.y - t.y;
|
|
127
|
+
Math.abs(h) > 144 ? (s.imageContainer.style.transition = "transform 222ms ease", s.imageContainer.style.transform = "translateY(0vh)", s.close()) : a("translateY(0vh)");
|
|
228
128
|
}
|
|
229
|
-
if (i === "x") {
|
|
230
|
-
const
|
|
231
|
-
s.imageContainer.style.transition = "",
|
|
129
|
+
if (i === "x" && n.state.elmLength > 1) {
|
|
130
|
+
const h = e.x - t.x;
|
|
131
|
+
s.imageContainer.style.transition = "", h > 64 ? s.prev() : h < -64 ? s.next() : a("translateX(0vw)");
|
|
232
132
|
}
|
|
233
133
|
i = null, t = { x: 0, y: 0 }, e = { x: 0, y: 0 };
|
|
234
134
|
}
|
|
235
135
|
}
|
|
236
136
|
});
|
|
237
137
|
}
|
|
238
|
-
function
|
|
138
|
+
function B(s) {
|
|
139
|
+
const t = s.options.preloads;
|
|
140
|
+
s.imageContainer.style.width = `${(t * 2 + 1) * 100}vw`, s.imageContainer.style.left = `-${t * 100}vw`, s.imageContainer.style.display = "flex";
|
|
141
|
+
}
|
|
142
|
+
function U(s) {
|
|
239
143
|
}
|
|
240
|
-
function
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
index: { from: e, to: i },
|
|
244
|
-
vistaView: { elements: n, imageContainer: r, options: a }
|
|
245
|
-
}, o) {
|
|
246
|
-
if (!(!t || o.aborted || s || !(Math.abs(i - e) === 1 || e === 0 && i === n.length - 1 || e === n.length - 1 && i === 0)))
|
|
144
|
+
function X({ vistaView: s, htmlElements: { to: t }, index: { from: e, to: i } }, n) {
|
|
145
|
+
const { imageContainer: o, options: a } = s, { isReducedMotion: h } = s.state;
|
|
146
|
+
if (!(!t || n.aborted || h || !(Math.abs(i - e) === 1 || e === 0 && i === s.state.elmLength - 1 || e === s.state.elmLength - 1 && i === 0)))
|
|
247
147
|
return {
|
|
248
148
|
cleanup: () => {
|
|
249
|
-
|
|
149
|
+
o.style.transition = "", o.style.transform = "";
|
|
250
150
|
},
|
|
251
|
-
transitionEnded: new Promise((
|
|
252
|
-
|
|
151
|
+
transitionEnded: new Promise((d) => {
|
|
152
|
+
o.addEventListener(
|
|
253
153
|
"transitionend",
|
|
254
154
|
() => {
|
|
255
|
-
|
|
155
|
+
d();
|
|
256
156
|
},
|
|
257
157
|
{ once: !0 }
|
|
258
|
-
),
|
|
158
|
+
), o.addEventListener(
|
|
259
159
|
"transitioncancel",
|
|
260
160
|
() => {
|
|
261
|
-
|
|
161
|
+
n.aborted && d();
|
|
262
162
|
},
|
|
263
163
|
{ once: !0 }
|
|
264
164
|
);
|
|
265
|
-
const
|
|
266
|
-
|
|
165
|
+
const p = Math.round(a.animationDurationBase * 100) / 100, u = i === e + 1 || e === s.state.elmLength - 1 && i === 0 ? "translateX(-100vw)" : "translateX(100vw)";
|
|
166
|
+
o.style.transition = `transform ${p}ms ease`, o.style.transform = u;
|
|
267
167
|
})
|
|
268
168
|
};
|
|
269
169
|
}
|
|
270
|
-
|
|
170
|
+
function z(s) {
|
|
171
|
+
const t = window.innerWidth, e = window.innerHeight, i = s.naturalWidth, n = s.naturalHeight;
|
|
172
|
+
if (!i || !n)
|
|
173
|
+
throw console.error("Error", s), new Error("Image natural dimensions are zero");
|
|
174
|
+
if (i < t && n < e)
|
|
175
|
+
return {
|
|
176
|
+
width: i,
|
|
177
|
+
height: n
|
|
178
|
+
};
|
|
179
|
+
const o = i / n, a = t / e;
|
|
180
|
+
let h, l;
|
|
181
|
+
return o > a ? (h = t, l = t / o) : (l = e, h = e * o), {
|
|
182
|
+
width: h,
|
|
183
|
+
height: l
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
class Y extends T {
|
|
187
|
+
constructor(e) {
|
|
188
|
+
super(e);
|
|
189
|
+
r(this, "element");
|
|
190
|
+
r(this, "rect", null);
|
|
191
|
+
r(this, "animateNormalizeTimeout", null);
|
|
192
|
+
const i = document.createElement("img");
|
|
193
|
+
i.alt = this.config.alt || "", i.classList.add("vvw-img-hi"), this.element = i, i.onerror = (n) => {
|
|
194
|
+
this.isLoadedRejected(n);
|
|
195
|
+
}, i.src = this.config.src, i.decode().then(() => {
|
|
196
|
+
this.onLoad();
|
|
197
|
+
}).catch((n) => {
|
|
198
|
+
this.isLoadedRejected(n);
|
|
199
|
+
}), this.setSizes({
|
|
200
|
+
stableSize: !1,
|
|
201
|
+
initDimension: !0
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
onWidthChange(e) {
|
|
205
|
+
super.onWidthChange(e);
|
|
206
|
+
const i = this.getFromParsedSrcSet(e);
|
|
207
|
+
if (i && this.element.src !== i) {
|
|
208
|
+
const n = new Image();
|
|
209
|
+
n.onload = () => {
|
|
210
|
+
n.decode().then(() => {
|
|
211
|
+
this.isCancelled || (this.element.src = i);
|
|
212
|
+
});
|
|
213
|
+
}, n.src = i;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
onLoad() {
|
|
217
|
+
if (this.isCancelled) return;
|
|
218
|
+
const e = this.element;
|
|
219
|
+
e.width = e.naturalWidth, e.height = e.naturalHeight, this.maxW = e.naturalWidth * this.maxZoomLevel;
|
|
220
|
+
const { width: i, height: n } = z(e);
|
|
221
|
+
this.fullH = n, this.fullW = i, this.minW = this.fullW * 0.5, this.isLoadedResolved(!0);
|
|
222
|
+
}
|
|
223
|
+
getFullSizeDim() {
|
|
224
|
+
return z(this.element);
|
|
225
|
+
}
|
|
226
|
+
normalize() {
|
|
227
|
+
super.normalize();
|
|
228
|
+
const e = this.element;
|
|
229
|
+
e.style.objectFit = "cover", e.style.borderRadius = "0";
|
|
230
|
+
}
|
|
231
|
+
// Used by: VistaImageEvent
|
|
232
|
+
scaleMove(e, i, n = !1) {
|
|
233
|
+
if (!this.isReady || !this.element) return;
|
|
234
|
+
this.rect || (this.rect = this.element.getBoundingClientRect()), i || (i = this.initPointerCenter);
|
|
235
|
+
const o = this.rect.left + this.rect.width / 2, a = this.rect.top + this.rect.height / 2, h = this.initPointerCenter.x - o, l = this.initPointerCenter.y - a, d = h * (1 - e), p = l * (1 - e), u = i.x - this.initPointerCenter.x, v = i.y - this.initPointerCenter.y;
|
|
236
|
+
n ? L.start({
|
|
237
|
+
vistaImage: this,
|
|
238
|
+
target: {
|
|
239
|
+
transform: {
|
|
240
|
+
x: d + u,
|
|
241
|
+
y: p + v,
|
|
242
|
+
scale: e
|
|
243
|
+
}
|
|
244
|
+
},
|
|
245
|
+
onComplete: () => {
|
|
246
|
+
this.setFinalTransform();
|
|
247
|
+
},
|
|
248
|
+
shouldWait: () => !1
|
|
249
|
+
}) : this.state.transform = {
|
|
250
|
+
x: d + u,
|
|
251
|
+
y: p + v,
|
|
252
|
+
scale: e
|
|
253
|
+
};
|
|
254
|
+
const m = this.element.getBoundingClientRect().width * e;
|
|
255
|
+
this.isZoomedIn = m > this.fullW, this.state.lessThanMinWidth = m <= this.minW, this.onScale({
|
|
256
|
+
vistaImage: this,
|
|
257
|
+
scale: m / this.fullW,
|
|
258
|
+
isMax: m >= this.maxW,
|
|
259
|
+
isMin: m <= this.fullW
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
animateZoom(e, i) {
|
|
263
|
+
this.state.width * e < this.minW || this.scaleMove(e, i, !0);
|
|
264
|
+
}
|
|
265
|
+
// Used by: VistaImageEvent
|
|
266
|
+
momentumThrow(e) {
|
|
267
|
+
if (!this.isReady)
|
|
268
|
+
return () => {
|
|
269
|
+
};
|
|
270
|
+
if (!this.isThrowing)
|
|
271
|
+
return this.setFinalTransform(), () => {
|
|
272
|
+
};
|
|
273
|
+
if (Math.abs(e.x) < 0.1 && Math.abs(e.y) < 0.1) {
|
|
274
|
+
const n = this.element.getBoundingClientRect();
|
|
275
|
+
return L.start({
|
|
276
|
+
vistaImage: this,
|
|
277
|
+
target: {
|
|
278
|
+
transform: {
|
|
279
|
+
x: n.right < window.innerWidth / 2 ? this.state.transform.x + (window.innerWidth / 2 - n.right) : n.left > window.innerWidth / 2 ? this.state.transform.x - (n.left - window.innerWidth / 2) : this.state.transform.x,
|
|
280
|
+
y: n.bottom < window.innerHeight / 2 ? this.state.transform.y + (window.innerHeight / 2 - n.bottom) : n.top > window.innerHeight / 2 ? this.state.transform.y - (n.top - window.innerHeight / 2) : this.state.transform.y
|
|
281
|
+
}
|
|
282
|
+
},
|
|
283
|
+
onComplete: () => {
|
|
284
|
+
this.isThrowing = !1, this.setFinalTransform();
|
|
285
|
+
},
|
|
286
|
+
shouldWait: () => !1
|
|
287
|
+
}), () => {
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
return requestAnimationFrame(() => {
|
|
291
|
+
if (!this.isThrowing) return this.momentumThrow({ x: 0, y: 0 });
|
|
292
|
+
const i = this.element, n = this.state.transform;
|
|
293
|
+
n.x += e.x, n.y += e.y;
|
|
294
|
+
const o = i.getBoundingClientRect();
|
|
295
|
+
n.x = n.x + e.x, n.y = n.y + e.y, o.right < window.innerWidth / 2 && (n.x += (window.innerWidth / 2 - o.right) * 0.1, e.x *= 0.7), o.left > window.innerWidth / 2 && (n.x -= (o.left - window.innerWidth / 2) * 0.1, e.x *= 0.7), o.bottom < window.innerHeight / 2 && (n.y += (window.innerHeight / 2 - o.bottom) * 0.1, e.y *= 0.7), o.top > window.innerHeight / 2 && (n.y -= (o.top - window.innerHeight / 2) * 0.1, e.y *= 0.7), this.state.transform = n, this.momentumThrow({
|
|
296
|
+
x: e.x * 0.9,
|
|
297
|
+
y: e.y * 0.9
|
|
298
|
+
});
|
|
299
|
+
}), () => {
|
|
300
|
+
L.stop(this), this.isThrowing = !1, this.setFinalTransform();
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
animateNormalize() {
|
|
304
|
+
this.animateNormalizeTimeout && clearTimeout(this.animateNormalizeTimeout), this.animateNormalizeTimeout = setTimeout(() => {
|
|
305
|
+
L.start({
|
|
306
|
+
vistaImage: this,
|
|
307
|
+
target: {
|
|
308
|
+
width: this.fullW,
|
|
309
|
+
height: this.fullH,
|
|
310
|
+
translate: { x: 0, y: 0 },
|
|
311
|
+
transform: { x: 0, y: 0, scale: 1 }
|
|
312
|
+
},
|
|
313
|
+
onComplete: () => {
|
|
314
|
+
this.setFinalTransform();
|
|
315
|
+
},
|
|
316
|
+
shouldWait: () => !1
|
|
317
|
+
});
|
|
318
|
+
}, 50);
|
|
319
|
+
}
|
|
320
|
+
// Used by: VistaImageEvent
|
|
321
|
+
setFinalTransform() {
|
|
322
|
+
if (!this.isReady) return;
|
|
323
|
+
this.rect = null, super.setFinalTransform({ propagateEvent: !1 });
|
|
324
|
+
const e = this.state.width <= this.minW;
|
|
325
|
+
if (this.state.width > this.maxW)
|
|
326
|
+
this.animateZoom(this.maxW / this.state.width);
|
|
327
|
+
else if (!e && this.state.width < this.fullW)
|
|
328
|
+
this.animateNormalize();
|
|
329
|
+
else if (this.pos === 0) {
|
|
330
|
+
const i = this.toObject();
|
|
331
|
+
this.vistaView.options.onContentChange && this.vistaView.options.onContentChange(i, this.vistaView), this.vistaView.state.extensions.forEach((n) => {
|
|
332
|
+
n.onContentChange && n.onContentChange(i, this.vistaView);
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
return {
|
|
336
|
+
close: e,
|
|
337
|
+
cancel: () => L.stop(this)
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
class Z {
|
|
342
|
+
constructor() {
|
|
343
|
+
r(this, "fiolast", {});
|
|
344
|
+
}
|
|
345
|
+
// first in out
|
|
346
|
+
fio(t, e, i = 50) {
|
|
347
|
+
const o = Date.now() - (this.fiolast[e] ?? 0), a = () => {
|
|
348
|
+
this.fiolast[e] = Date.now(), t();
|
|
349
|
+
};
|
|
350
|
+
if (!this.fiolast[e]) {
|
|
351
|
+
a();
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
o >= i && a();
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
class j {
|
|
358
|
+
constructor() {
|
|
359
|
+
r(this, "open", !1);
|
|
360
|
+
r(this, "settled", !1);
|
|
361
|
+
r(this, "closing", !1);
|
|
362
|
+
r(this, "zoomedIn", !1);
|
|
363
|
+
r(this, "children", {
|
|
364
|
+
htmls: [],
|
|
365
|
+
images: []
|
|
366
|
+
});
|
|
367
|
+
r(this, "currentIndex", -1);
|
|
368
|
+
r(this, "elmLength", 0);
|
|
369
|
+
r(this, "abortController", new AbortController());
|
|
370
|
+
r(this, "isReducedMotion", !1);
|
|
371
|
+
r(this, "extensions", /* @__PURE__ */ new Set());
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
function P(s) {
|
|
375
|
+
return s && !/^0(px|%|r?em|vw|vh|vmin|vmax|cm|mm|in|pt|pc|ex|ch)?$/i.test(s.trim()) && s;
|
|
376
|
+
}
|
|
377
|
+
function _(s) {
|
|
378
|
+
const t = s instanceof HTMLAnchorElement ? s : null, e = s instanceof HTMLImageElement ? s : t == null ? void 0 : t.querySelector("img"), i = t ? getComputedStyle(t) : null, n = e ? getComputedStyle(e) : null;
|
|
379
|
+
let o = "0px", a = n ? n.objectFit : "contain";
|
|
380
|
+
return i && P(i.borderRadius) ? o = i.borderRadius : n && P(n.borderRadius) && (o = n.borderRadius), {
|
|
381
|
+
borderRadius: o,
|
|
382
|
+
objectFit: a
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
function K(s) {
|
|
386
|
+
const t = s.split(",").map((i) => i.trim()), e = [];
|
|
387
|
+
for (const i of t) {
|
|
388
|
+
const [n, o] = i.split(" ").map((a) => a.trim());
|
|
389
|
+
if (n && o && o.endsWith("w")) {
|
|
390
|
+
const a = parseInt(o.slice(0, -1), 10);
|
|
391
|
+
isNaN(a) || e.push({ src: n, width: a });
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
return e;
|
|
395
|
+
}
|
|
396
|
+
function G(s) {
|
|
397
|
+
const t = s instanceof HTMLImageElement ? s : s.querySelector("img"), e = s.dataset.vistaviewSrc || s.getAttribute("href") || s.getAttribute("src") || (t == null ? void 0 : t.getAttribute("src")) || "", i = s.dataset.vistaviewSrcset || s.getAttribute("srcset") || (t == null ? void 0 : t.getAttribute("srcset")) || "";
|
|
398
|
+
if (!e && !i)
|
|
399
|
+
throw console.error("VistaView Error:", s), new Error("VistaView: Element must have href, src, or srcSet");
|
|
400
|
+
const n = i ? K(i) : void 0, o = _(s);
|
|
401
|
+
return {
|
|
402
|
+
config: {
|
|
403
|
+
src: e,
|
|
404
|
+
alt: s.dataset.vistaviewAlt || s.getAttribute("alt") || (t == null ? void 0 : t.getAttribute("alt")) || "",
|
|
405
|
+
srcSet: i || void 0
|
|
406
|
+
},
|
|
407
|
+
parsedSrcSet: n != null && n.length ? n : void 0,
|
|
408
|
+
origin: {
|
|
409
|
+
anchor: s instanceof HTMLAnchorElement ? s : void 0,
|
|
410
|
+
image: t,
|
|
411
|
+
src: e,
|
|
412
|
+
srcSet: i,
|
|
413
|
+
borderRadius: o.borderRadius,
|
|
414
|
+
objectFit: o.objectFit
|
|
415
|
+
}
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
class J {
|
|
271
419
|
constructor({ elm: t, listeners: e }) {
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
420
|
+
r(this, "pointers", []);
|
|
421
|
+
r(this, "elm");
|
|
422
|
+
r(this, "listeners", []);
|
|
423
|
+
r(this, "lastPointerDownId", null);
|
|
424
|
+
r(this, "removeLastPointer", () => {
|
|
277
425
|
if (this.pointers.length && this.lastPointerDownId !== null) {
|
|
278
426
|
const t = this.pointers.findIndex((e) => e.id === this.lastPointerDownId);
|
|
279
427
|
t !== -1 && this.pointers.splice(t, 1);
|
|
280
428
|
}
|
|
281
429
|
});
|
|
282
|
-
|
|
430
|
+
r(this, "onPointerDown", (t) => {
|
|
283
431
|
if (!this.listeners.length || t.button !== 0) return;
|
|
284
432
|
t.preventDefault(), this.lastPointerDownId = t.pointerId, window.addEventListener("contextmenu", this.removeLastPointer, { once: !0 }), window.addEventListener("auxclick", this.removeLastPointer, { once: !0 });
|
|
285
433
|
let e = {
|
|
@@ -298,7 +446,7 @@ class et {
|
|
|
298
446
|
})
|
|
299
447
|
);
|
|
300
448
|
});
|
|
301
|
-
|
|
449
|
+
r(this, "onPointerMove", (t) => {
|
|
302
450
|
if (!this.listeners.length) return;
|
|
303
451
|
t.preventDefault();
|
|
304
452
|
const e = this.pointers.find((i) => i.id === t.pointerId);
|
|
@@ -311,17 +459,17 @@ class et {
|
|
|
311
459
|
})
|
|
312
460
|
));
|
|
313
461
|
});
|
|
314
|
-
|
|
462
|
+
r(this, "onPointerUp", (t) => {
|
|
315
463
|
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))
|
|
316
464
|
return;
|
|
317
465
|
t.preventDefault();
|
|
318
|
-
const e = this.pointers.findIndex((
|
|
466
|
+
const e = this.pointers.findIndex((o) => o.id === t.pointerId);
|
|
319
467
|
if (e === -1) return;
|
|
320
468
|
const i = this.pointers[e];
|
|
321
469
|
i.x = t.clientX, i.y = t.clientY;
|
|
322
470
|
const n = this.pointers.length;
|
|
323
471
|
this.pointers.splice(e, 1), this.listeners.forEach(
|
|
324
|
-
(
|
|
472
|
+
(o) => o({
|
|
325
473
|
event: "up",
|
|
326
474
|
pointer: i,
|
|
327
475
|
pointers: this.pointers,
|
|
@@ -329,17 +477,17 @@ class et {
|
|
|
329
477
|
})
|
|
330
478
|
);
|
|
331
479
|
});
|
|
332
|
-
|
|
480
|
+
r(this, "onPointerCancel", (t) => {
|
|
333
481
|
if (!this.listeners.length || t.target instanceof Node && !this.elm.contains(t.target) && t.target !== document.querySelector("html") && t.target !== document)
|
|
334
482
|
return;
|
|
335
483
|
t.preventDefault();
|
|
336
|
-
const e = this.pointers.findIndex((
|
|
484
|
+
const e = this.pointers.findIndex((o) => o.id === t.pointerId);
|
|
337
485
|
if (e === -1) return;
|
|
338
486
|
const i = this.pointers[e];
|
|
339
487
|
i.x = t.clientX, i.y = t.clientY;
|
|
340
488
|
const n = this.pointers.length;
|
|
341
489
|
this.pointers.splice(e, 1), this.listeners.forEach(
|
|
342
|
-
(
|
|
490
|
+
(o) => o({
|
|
343
491
|
event: "cancel",
|
|
344
492
|
pointer: i,
|
|
345
493
|
pointers: this.pointers,
|
|
@@ -377,534 +525,370 @@ class et {
|
|
|
377
525
|
};
|
|
378
526
|
}
|
|
379
527
|
}
|
|
380
|
-
class
|
|
381
|
-
constructor(t
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
h(this, "scale", 1);
|
|
391
|
-
h(this, "translate", { x: 0, y: 0 });
|
|
392
|
-
h(this, "onScale", null);
|
|
393
|
-
h(this, "animationTimestamp", 0);
|
|
394
|
-
this.maxZoomLevel = t, this.onScale = e;
|
|
395
|
-
}
|
|
396
|
-
clean() {
|
|
397
|
-
this.image && (this.image.style.transform = "", this.image.style.width = "", this.image.style.height = "", this.image.style.top = "", this.image.style.left = "", this.image.style.opacity = "");
|
|
398
|
-
}
|
|
399
|
-
reset() {
|
|
400
|
-
this.clean(), this.image = null, this.rect = null, this.initialCenter = { x: window.innerWidth / 2, y: window.innerHeight / 2 }, this.maxDimension = { width: 0 }, this.minDimension = { initialWidth: 0, initialHeight: 0, minWidth: 0, closingWidth: 0 }, this.accumulatedTranslate = { x: 0, y: 0 }, this.scale = 1, this.translate = { x: 0, y: 0 };
|
|
401
|
-
}
|
|
402
|
-
setCurrentImage(t) {
|
|
403
|
-
if (this.rect = null, this.image = t, this.maxDimension = {
|
|
404
|
-
width: t.naturalWidth * this.maxZoomLevel
|
|
405
|
-
}, !t.dataset.vvwWidth || !t.dataset.vvwHeight)
|
|
406
|
-
throw new Error("VistaImageState: Image dataset vvwWidth or vvwHeight not set.");
|
|
407
|
-
const e = parseFloat(t.dataset.vvwWidth), i = parseFloat(t.dataset.vvwHeight);
|
|
408
|
-
this.minDimension = {
|
|
409
|
-
initialWidth: e,
|
|
410
|
-
initialHeight: i,
|
|
411
|
-
minWidth: e * 0.1,
|
|
412
|
-
closingWidth: e * 0.5
|
|
413
|
-
}, this.accumulatedTranslate = { x: 0, y: 0 };
|
|
414
|
-
}
|
|
415
|
-
setInitialCenter(t) {
|
|
416
|
-
this.initialCenter = t || { x: window.innerWidth / 2, y: window.innerHeight / 2 };
|
|
417
|
-
}
|
|
418
|
-
move(t) {
|
|
419
|
-
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})`);
|
|
420
|
-
}
|
|
421
|
-
snapToTargetIfClose(t, e, i = 1) {
|
|
422
|
-
return Math.abs(t - e) <= i && (t = e), t;
|
|
423
|
-
}
|
|
424
|
-
scaleMove(t, e) {
|
|
425
|
-
if (!this.image) return;
|
|
426
|
-
this.rect || (this.rect = this.image.getBoundingClientRect()), e || (e = this.initialCenter);
|
|
427
|
-
const i = this.snapToTargetIfClose(
|
|
428
|
-
q(this.rect.width * t, this.minDimension.minWidth, this.maxDimension.width),
|
|
429
|
-
this.minDimension.initialWidth
|
|
430
|
-
);
|
|
431
|
-
this.onScale && this.onScale({
|
|
432
|
-
scale: i / (this.maxDimension.width / this.maxZoomLevel),
|
|
433
|
-
isMax: i >= this.maxDimension.width,
|
|
434
|
-
isMin: i <= this.minDimension.initialWidth
|
|
435
|
-
}), this.scale = L(i / this.rect.width);
|
|
436
|
-
const n = this.rect.left + this.rect.width / 2, r = this.rect.top + this.rect.height / 2, a = this.initialCenter.x - n, o = this.initialCenter.y - r, l = a * (1 - this.scale), c = o * (1 - this.scale), d = e.x - this.initialCenter.x, p = e.y - this.initialCenter.y;
|
|
437
|
-
this.translate.x = L(l + d), this.translate.y = L(c + p), 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 = "";
|
|
438
|
-
}
|
|
439
|
-
moveAndNormalize(t) {
|
|
440
|
-
let e = 0, i = !1;
|
|
441
|
-
const n = ({ x: r, y: a }) => {
|
|
442
|
-
if (i)
|
|
443
|
-
return;
|
|
444
|
-
if (Math.abs(r) < 1e-3 && Math.abs(a) < 1e-3)
|
|
445
|
-
return this.normalize();
|
|
446
|
-
r *= 0.9, a *= 0.9;
|
|
447
|
-
const o = this.image.getBoundingClientRect();
|
|
448
|
-
this.translate.x = L(this.translate.x + r), this.translate.y = L(this.translate.y + a), o.right < window.innerWidth / 2 && (this.translate.x += (window.innerWidth / 2 - o.right) * 0.1, r *= 0.7), o.left > window.innerWidth / 2 && (this.translate.x -= (o.left - window.innerWidth / 2) * 0.1, r *= 0.7), o.bottom < window.innerHeight / 2 && (this.translate.y += (window.innerHeight / 2 - o.bottom) * 0.1, a *= 0.7), o.top > window.innerHeight / 2 && (this.translate.y -= (o.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: r, y: a }));
|
|
449
|
-
};
|
|
450
|
-
return n({
|
|
451
|
-
x: t.movementX,
|
|
452
|
-
y: t.movementY
|
|
453
|
-
}), () => {
|
|
454
|
-
i = !0, cancelAnimationFrame(e), this.normalize(!1);
|
|
455
|
-
};
|
|
456
|
-
}
|
|
457
|
-
animateZoom(t) {
|
|
458
|
-
if (!this.image) return;
|
|
459
|
-
this.rect || (this.rect = this.image.getBoundingClientRect());
|
|
460
|
-
const e = Date.now(), i = this.image;
|
|
461
|
-
this.rect.width * t < this.minDimension.closingWidth || i.width < Math.floor(this.minDimension.initialWidth) || (i.addEventListener(
|
|
462
|
-
"transitionend",
|
|
463
|
-
() => {
|
|
464
|
-
this.animationTimestamp === e && i && (i.style.transition = "", this.normalize());
|
|
465
|
-
},
|
|
466
|
-
{ once: !0 }
|
|
467
|
-
), i.style.transition || (i.style.transition = "all 222ms ease"), this.animationTimestamp = e, this.scaleMove(t));
|
|
468
|
-
}
|
|
469
|
-
normalize(t = !0) {
|
|
470
|
-
if (!this.image || !this.rect) return;
|
|
471
|
-
const e = this.rect.width * this.scale, i = e <= this.minDimension.closingWidth, n = i ? e : this.snapToTargetIfClose(this.rect.width * this.scale, this.minDimension.initialWidth), r = i ? this.rect.height * this.scale : this.snapToTargetIfClose(this.rect.height * this.scale, this.minDimension.initialHeight);
|
|
472
|
-
if (this.image.style.width = `${n}px`, this.image.style.height = `${r}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(), i)
|
|
473
|
-
return !0;
|
|
474
|
-
if (n < this.minDimension.initialWidth)
|
|
475
|
-
this.accumulatedTranslate.x = 0, this.accumulatedTranslate.y = 0, requestAnimationFrame(() => {
|
|
476
|
-
const a = this.image;
|
|
477
|
-
a && (a.addEventListener(
|
|
478
|
-
"transitionend",
|
|
479
|
-
() => {
|
|
480
|
-
a && (this.clean(), this.rect = null);
|
|
481
|
-
},
|
|
482
|
-
{ once: !0 }
|
|
483
|
-
), a.style.transition = "all 222ms ease", a.style.width = `${this.minDimension.initialWidth}px`, a.style.height = `${this.minDimension.initialHeight}px`, a.style.left = "50%", a.style.top = "50%");
|
|
484
|
-
});
|
|
485
|
-
else if (t) {
|
|
486
|
-
let a = !1;
|
|
487
|
-
if (this.rect.right < window.innerWidth / 2 && (a = !0, this.accumulatedTranslate.x += window.innerWidth / 2 - this.rect.right), this.rect.left > window.innerWidth / 2 && (a = !0, this.accumulatedTranslate.x -= this.rect.left - window.innerWidth / 2), this.rect.bottom < window.innerHeight / 2 && (a = !0, this.accumulatedTranslate.y += window.innerHeight / 2 - this.rect.bottom), this.rect.top > window.innerHeight / 2 && (a = !0, this.accumulatedTranslate.y -= this.rect.top - window.innerHeight / 2), a) {
|
|
488
|
-
const o = this.image;
|
|
489
|
-
o.addEventListener(
|
|
490
|
-
"transitionend",
|
|
491
|
-
() => {
|
|
492
|
-
o && (o.style.transition = "", this.rect = null);
|
|
493
|
-
},
|
|
494
|
-
{ once: !0 }
|
|
495
|
-
), o.style.transition = "all 222ms ease", o.style.left = `calc(50% + ${this.accumulatedTranslate.x}px)`, o.style.top = `calc(50% + ${this.accumulatedTranslate.y}px)`;
|
|
496
|
-
} else
|
|
497
|
-
this.rect = null;
|
|
498
|
-
}
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
class nt {
|
|
502
|
-
constructor() {
|
|
503
|
-
h(this, "fiolast", {});
|
|
504
|
-
}
|
|
505
|
-
// first in out
|
|
506
|
-
fio(t, e, i = 50) {
|
|
507
|
-
const r = Date.now() - (this.fiolast[e] ?? 0), a = () => {
|
|
508
|
-
this.fiolast[e] = Date.now(), t();
|
|
509
|
-
};
|
|
510
|
-
if (!this.fiolast[e]) {
|
|
511
|
-
a();
|
|
512
|
-
return;
|
|
513
|
-
}
|
|
514
|
-
r >= i && a();
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
const C = {
|
|
518
|
-
somethingOpened: null
|
|
519
|
-
};
|
|
520
|
-
class st {
|
|
521
|
-
constructor(t, e = {}) {
|
|
522
|
-
h(this, "options");
|
|
523
|
-
h(this, "elements");
|
|
524
|
-
h(this, "isReducedMotion");
|
|
525
|
-
h(this, "currentIndex", -1);
|
|
526
|
-
h(this, "currentChildren", null);
|
|
527
|
-
h(this, "setupFunction", K);
|
|
528
|
-
h(this, "initFunction", G);
|
|
529
|
-
h(this, "closeFunction", Q);
|
|
530
|
-
h(this, "transitionFunction", tt);
|
|
531
|
-
h(this, "pointers", null);
|
|
532
|
-
h(this, "imageState");
|
|
533
|
-
h(this, "imageTransitions", /* @__PURE__ */ new Map());
|
|
534
|
-
h(this, "root", null);
|
|
535
|
-
h(this, "imageContainer", null);
|
|
536
|
-
h(this, "onClickElements", (t) => {
|
|
537
|
-
t.preventDefault();
|
|
538
|
-
const e = t.currentTarget;
|
|
539
|
-
e.dataset.vistaIdx && this.open(parseInt(e.dataset.vistaIdx));
|
|
528
|
+
class Q {
|
|
529
|
+
constructor(t) {
|
|
530
|
+
//
|
|
531
|
+
r(this, "pointers", null);
|
|
532
|
+
// Pinch gesture state
|
|
533
|
+
r(this, "lastDistance", 0);
|
|
534
|
+
r(this, "pinchMode", !1);
|
|
535
|
+
r(this, "lastPinchEndTime", 0);
|
|
536
|
+
r(this, "PINCH_COOLDOWN", 111);
|
|
537
|
+
r(this, "cancelMove", () => {
|
|
540
538
|
});
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
539
|
+
r(this, "pointerListeners", []);
|
|
540
|
+
r(this, "vvw");
|
|
541
|
+
// private vistaImage: VistaImage;
|
|
542
|
+
r(this, "imageContainer", null);
|
|
543
|
+
r(this, "isPinching", () => this.pinchMode || performance.now() - this.lastPinchEndTime < this.PINCH_COOLDOWN);
|
|
544
|
+
r(this, "internalPointerListener", (t) => {
|
|
545
|
+
const e = this.vvw.state.children.images.find((i) => i.pos === 0);
|
|
546
|
+
if (t.event === "down") {
|
|
547
|
+
if (this.cancelMove(), this.vvw.state.zoomedIn && t.pointers.length === 1 && !this.isPinching()) {
|
|
548
|
+
const i = this.pointers.getCentroid();
|
|
549
|
+
e.setInitialCenter(i);
|
|
550
|
+
}
|
|
551
|
+
if (t.pointers.length >= 2) {
|
|
552
|
+
this.pinchMode = !0;
|
|
553
|
+
const i = this.pointers.getCentroid();
|
|
554
|
+
this.lastDistance = this.pointers.getPointerDistance(t.pointers[0], t.pointers[1]), e.setInitialCenter(i);
|
|
555
|
+
}
|
|
556
|
+
} else if (t.event === "move") {
|
|
557
|
+
if (this.vvw.state.zoomedIn && t.pointers.length === 1 && t.lastPointerLen === 0 && !this.isPinching()) {
|
|
558
|
+
const i = this.pointers.getCentroid();
|
|
559
|
+
e.scaleMove(1, i);
|
|
560
|
+
}
|
|
561
|
+
if (t.pointers.length >= 2 && this.pinchMode) {
|
|
562
|
+
const i = this.pointers.getCentroid(), n = this.pointers.getPointerDistance(t.pointers[0], t.pointers[1]);
|
|
563
|
+
e.scaleMove(n / this.lastDistance, i);
|
|
564
|
+
}
|
|
565
|
+
} else if ((t.event === "up" || t.event === "cancel") && (this.pinchMode || this.vvw.state.zoomedIn))
|
|
566
|
+
if (this.pinchMode) {
|
|
567
|
+
this.lastPinchEndTime = performance.now(), this.pinchMode = !1;
|
|
568
|
+
const i = e.setFinalTransform();
|
|
569
|
+
i != null && i.cancel && (this.cancelMove = i.cancel), i != null && i.close && requestAnimationFrame(() => {
|
|
570
|
+
this.vvw.close();
|
|
571
|
+
});
|
|
572
|
+
} else this.vvw.state.zoomedIn && t.pointers.length === 0 && !this.isPinching() && (e.isThrowing = !0, this.cancelMove = e.momentumThrow({
|
|
573
|
+
x: t.pointer.movementX,
|
|
574
|
+
y: t.pointer.movementY
|
|
575
|
+
}));
|
|
576
|
+
this.pointerListeners.forEach(
|
|
577
|
+
(i) => i({
|
|
578
|
+
...t,
|
|
579
|
+
state: this.vvw.state,
|
|
580
|
+
hasInternalExecution: this.vvw.state.zoomedIn || this.isPinching(),
|
|
581
|
+
abortController: this.vvw.state.abortController
|
|
582
|
+
})
|
|
583
|
+
);
|
|
584
|
+
});
|
|
585
|
+
r(this, "onKeyDown", (t) => {
|
|
586
|
+
const e = this.vvw;
|
|
559
587
|
switch (t.key) {
|
|
560
588
|
case "ArrowLeft":
|
|
561
|
-
t.preventDefault(),
|
|
589
|
+
t.preventDefault(), e.prev();
|
|
562
590
|
break;
|
|
563
591
|
case "ArrowRight":
|
|
564
|
-
t.preventDefault(),
|
|
592
|
+
t.preventDefault(), e.next();
|
|
565
593
|
break;
|
|
566
594
|
case "ArrowUp":
|
|
567
|
-
t.preventDefault(),
|
|
595
|
+
t.preventDefault(), e.zoomIn();
|
|
568
596
|
break;
|
|
569
597
|
case "ArrowDown":
|
|
570
|
-
t.preventDefault(),
|
|
598
|
+
t.preventDefault(), e.zoomOut();
|
|
571
599
|
break;
|
|
572
600
|
case "Escape":
|
|
573
|
-
t.preventDefault(),
|
|
601
|
+
t.preventDefault(), e.close();
|
|
574
602
|
break;
|
|
575
603
|
}
|
|
576
604
|
});
|
|
577
|
-
|
|
605
|
+
r(this, "onScroll", (t) => {
|
|
578
606
|
t.preventDefault();
|
|
579
|
-
const e = t.deltaY;
|
|
580
|
-
|
|
607
|
+
const e = this.vvw, i = this.vvw.state.children.images.find((o) => o.pos === 0), n = t.deltaY;
|
|
608
|
+
i.setInitialCenter({
|
|
581
609
|
x: t.clientX,
|
|
582
610
|
y: t.clientY
|
|
583
|
-
}),
|
|
611
|
+
}), n < 0 ? e.zoomIn() : n > 0 && e.zoomOut();
|
|
584
612
|
});
|
|
585
|
-
|
|
586
|
-
this.
|
|
587
|
-
|
|
588
|
-
if (W(i, n, r, !1), n.classList.contains("vvw--loaded")) {
|
|
589
|
-
const { width: a, height: o } = H(n);
|
|
590
|
-
n.style.setProperty("--vvw-current-w", `${a}px`), n.style.setProperty("--vvw-current-h", `${o}px`), n.dataset.vvwWidth = a.toString(), n.dataset.vvwHeight = o.toString();
|
|
591
|
-
}
|
|
613
|
+
r(this, "onResizeHandler", () => {
|
|
614
|
+
this.vvw.state.children.images.forEach((t) => {
|
|
615
|
+
t.setSizes();
|
|
592
616
|
});
|
|
593
617
|
});
|
|
594
|
-
|
|
595
|
-
|
|
618
|
+
this.vvw = t;
|
|
619
|
+
}
|
|
620
|
+
// register external pointer listener
|
|
621
|
+
registerPointerListener(t) {
|
|
622
|
+
this.pointerListeners.push(t);
|
|
623
|
+
}
|
|
624
|
+
start(t) {
|
|
625
|
+
this.vvw.options.keyboardListeners && window.addEventListener("keydown", this.onKeyDown), this.imageContainer = t, this.imageContainer.addEventListener("wheel", this.onScroll, { passive: !1 }), window.addEventListener("resize", this.onResizeHandler), this.pointers = new J({
|
|
626
|
+
elm: t,
|
|
627
|
+
listeners: [this.internalPointerListener]
|
|
628
|
+
});
|
|
629
|
+
}
|
|
630
|
+
stop() {
|
|
631
|
+
this.vvw.options.keyboardListeners && window.removeEventListener("keydown", this.onKeyDown), window.removeEventListener("resize", this.onResizeHandler), this.imageContainer.removeEventListener("wheel", this.onScroll), this.pointers.removeListeners(), this.pointerListeners = [];
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
const y = {
|
|
635
|
+
somethingOpened: null
|
|
636
|
+
};
|
|
637
|
+
class tt {
|
|
638
|
+
constructor(t, e = {}) {
|
|
639
|
+
r(this, "options");
|
|
640
|
+
r(this, "state", new j());
|
|
641
|
+
r(this, "imageContainer", null);
|
|
642
|
+
r(this, "externalPointerListener", []);
|
|
643
|
+
r(this, "elements");
|
|
644
|
+
r(this, "eventHandlers", null);
|
|
645
|
+
r(this, "imageSetupFunction", k);
|
|
646
|
+
r(this, "initFunction", V);
|
|
647
|
+
r(this, "openFunction", B);
|
|
648
|
+
r(this, "closeFunction", U);
|
|
649
|
+
r(this, "transitionFunction", X);
|
|
650
|
+
r(this, "throttle", new Z());
|
|
651
|
+
r(this, "root", null);
|
|
652
|
+
r(this, "onClickElements", (t) => {
|
|
653
|
+
t.preventDefault();
|
|
654
|
+
const e = t.currentTarget;
|
|
655
|
+
e.dataset.vvwIdx && this.open(parseInt(e.dataset.vvwIdx));
|
|
656
|
+
});
|
|
657
|
+
r(this, "defaultOnClickHandler", (t) => t.preventDefault());
|
|
658
|
+
// ============================================================================
|
|
659
|
+
// SWAP LOGIC - handles image transitions between prev/next
|
|
660
|
+
// ============================================================================
|
|
661
|
+
r(this, "lastSwapTime", 0);
|
|
662
|
+
r(this, "isRapidSwap", !1);
|
|
663
|
+
r(this, "isRapidSwapRelease", 0);
|
|
664
|
+
r(this, "transitionCleanup", null);
|
|
665
|
+
// ============================================================================
|
|
666
|
+
// ACTIVATE/DEACTIVATE UI ELEMENTS
|
|
667
|
+
// ============================================================================
|
|
668
|
+
r(this, "tempDeactivatedUi", []);
|
|
669
|
+
r(this, "tempDeactivationRequestBy", null);
|
|
670
|
+
// ============================================================================
|
|
671
|
+
// ZOOM CONTROLS
|
|
672
|
+
// ============================================================================
|
|
673
|
+
r(this, "isZoomedIn", !1);
|
|
674
|
+
var i;
|
|
596
675
|
this.elements = t, this.options = {
|
|
597
|
-
...
|
|
676
|
+
...I,
|
|
598
677
|
...e,
|
|
599
678
|
controls: {
|
|
600
|
-
...
|
|
679
|
+
...I.controls,
|
|
601
680
|
...e.controls
|
|
602
681
|
}
|
|
603
|
-
}, this.
|
|
604
|
-
this.options.
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
682
|
+
}, this.options.imageSetupFunction && (this.imageSetupFunction = this.options.imageSetupFunction), this.options.closeFunction && (this.closeFunction = this.options.closeFunction), this.options.initFunction && (this.initFunction = this.options.initFunction), this.options.transitionFunction && (this.transitionFunction = this.options.transitionFunction), [
|
|
683
|
+
...this.options.controls.topLeft || [],
|
|
684
|
+
...this.options.controls.topRight || [],
|
|
685
|
+
...this.options.controls.topCenter || [],
|
|
686
|
+
...this.options.controls.bottomCenter || [],
|
|
687
|
+
...this.options.controls.bottomLeft || [],
|
|
688
|
+
...this.options.controls.bottomRight || []
|
|
689
|
+
].forEach((n) => {
|
|
690
|
+
typeof n != "string" && this.state.extensions.add(n);
|
|
691
|
+
}), (i = this.options.extensions) == null || i.forEach((n) => {
|
|
692
|
+
this.state.extensions.add(n);
|
|
693
|
+
}), this.state.isReducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches, this.reset(), this.initFunction(this);
|
|
612
694
|
}
|
|
613
|
-
|
|
614
|
-
|
|
695
|
+
reset() {
|
|
696
|
+
if (typeof this.elements == "string") {
|
|
697
|
+
const t = this.qsOrigin(this.elements);
|
|
698
|
+
this.state.elmLength = t.length, t.forEach((e, i) => {
|
|
699
|
+
const n = e;
|
|
700
|
+
n.dataset.vvwIdx = i.toString(), n.removeEventListener("click", this.defaultOnClickHandler), n.removeEventListener("pointerup", this.onClickElements), n.addEventListener("click", this.defaultOnClickHandler), n.addEventListener("pointerup", this.onClickElements);
|
|
701
|
+
});
|
|
702
|
+
} else
|
|
703
|
+
this.state.elmLength = this.elements.length;
|
|
615
704
|
}
|
|
616
705
|
// ============================================================================
|
|
617
|
-
// HELPER METHODS
|
|
706
|
+
// HELPER METHODS
|
|
618
707
|
// ============================================================================
|
|
708
|
+
qs(t) {
|
|
709
|
+
return this.root ? this.root.querySelector(t) : null;
|
|
710
|
+
}
|
|
711
|
+
qsOrigin(t) {
|
|
712
|
+
return document.querySelectorAll(t);
|
|
713
|
+
}
|
|
714
|
+
registerPointerListener(t) {
|
|
715
|
+
this.externalPointerListener.push(t);
|
|
716
|
+
}
|
|
619
717
|
getChildElements(t, e) {
|
|
620
|
-
const i = [], n = [];
|
|
621
|
-
for (let
|
|
622
|
-
const
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
718
|
+
const i = [], n = [], o = typeof this.elements == "string" ? this.qsOrigin(this.elements) : this.elements;
|
|
719
|
+
for (let a = -t; a <= t; a++) {
|
|
720
|
+
const h = (e + a + o.length) % o.length, l = o[h], p = {
|
|
721
|
+
elm: l instanceof HTMLElement ? G(l) : { config: l, origin: void 0, parsedSrcSet: void 0 },
|
|
722
|
+
pos: a,
|
|
723
|
+
index: h,
|
|
724
|
+
vistaView: this,
|
|
725
|
+
maxZoomLevel: this.options.maxZoomLevel,
|
|
726
|
+
transitionShouldWait: () => this.isRapidSwap,
|
|
727
|
+
onScale: ({
|
|
728
|
+
vistaImage: m,
|
|
729
|
+
isMin: c,
|
|
730
|
+
isMax: g
|
|
731
|
+
}) => {
|
|
732
|
+
var x, b, C, w;
|
|
733
|
+
m.index === this.state.currentIndex && (this.state.zoomedIn = !c, c ? (x = this.qs(".vvw-zoom-out")) == null || x.setAttribute("disabled", "true") : (b = this.qs(".vvw-zoom-out")) == null || b.removeAttribute("disabled"), g ? (C = this.qs(".vvw-zoom-in")) == null || C.setAttribute("disabled", "true") : (w = this.qs(".vvw-zoom-in")) == null || w.removeAttribute("disabled"));
|
|
734
|
+
}
|
|
632
735
|
};
|
|
633
|
-
|
|
736
|
+
let u = null;
|
|
737
|
+
this.state.extensions.forEach((m) => {
|
|
738
|
+
!u && m.onInitializeImage && (u = m.onInitializeImage(p));
|
|
739
|
+
});
|
|
740
|
+
const v = u ?? new Y(p), f = document.createElement("div");
|
|
741
|
+
f.className = "vvw-item", f.dataset.vvwPos = `${a}`, f.dataset.vvwIdx = `${h}`, v.thumb && f.appendChild(v.thumb), f.appendChild(v.element), i.push(v), n.push(f);
|
|
634
742
|
}
|
|
635
743
|
return {
|
|
636
|
-
htmls:
|
|
637
|
-
images:
|
|
744
|
+
htmls: n,
|
|
745
|
+
images: i
|
|
638
746
|
};
|
|
639
747
|
}
|
|
640
748
|
async swap(t, e) {
|
|
641
|
-
|
|
642
|
-
|
|
749
|
+
var f, m;
|
|
750
|
+
this.reactivateUi();
|
|
751
|
+
const i = this.options.preloads || 0, n = this.state.currentIndex, { htmls: o, images: a } = this.getChildElements(i, n), h = this.imageContainer, l = this.state.children, d = {
|
|
752
|
+
htmlElements: { from: l.htmls, to: o },
|
|
643
753
|
images: { from: l.images, to: a },
|
|
644
|
-
index: { from: t, to: this.currentIndex },
|
|
754
|
+
index: { from: t, to: this.state.currentIndex },
|
|
645
755
|
via: e || { next: !1, prev: !1 },
|
|
646
756
|
vistaView: this
|
|
647
757
|
};
|
|
648
|
-
this.
|
|
649
|
-
const
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
}
|
|
656
|
-
|
|
758
|
+
this.imageSetupFunction(d), this.state.zoomedIn = !1, (f = this.qs(".vvw-zoom-out")) == null || f.setAttribute("disabled", "true"), (m = this.qs(".vvw-zoom-in")) == null || m.removeAttribute("disabled");
|
|
759
|
+
const u = performance.now() - this.lastSwapTime < this.options.rapidLimit;
|
|
760
|
+
this.isRapidSwap = u;
|
|
761
|
+
const { images: v } = this.state.children;
|
|
762
|
+
if (this.state.children = { htmls: o, images: a }, this.displayCurrentInfo(), u)
|
|
763
|
+
v.forEach((c) => {
|
|
764
|
+
c.cancelPendingLoad(), c.destroy();
|
|
765
|
+
});
|
|
766
|
+
else {
|
|
767
|
+
const c = this.state.abortController.signal, g = this.transitionFunction(d, c);
|
|
768
|
+
g && (this.transitionCleanup = g.cleanup, await g.transitionEnded), this.lastSwapTime = performance.now(), v.forEach((w) => {
|
|
769
|
+
w.cancelPendingLoad();
|
|
770
|
+
});
|
|
771
|
+
const x = v.find((w) => w.index === n), b = x ? L.stop(x) : void 0, C = a.find((w) => w.index === n);
|
|
772
|
+
C && x && C.cloneStyleFrom(x, b), v.forEach((w) => {
|
|
773
|
+
w.destroy();
|
|
774
|
+
});
|
|
657
775
|
}
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
),
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
y.dataset.vvwPos === "0" && !d.aborted && f && I && S && (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 = S), w.setAttribute("style", f)), o.appendChild(y), y.dataset.vvwPos === "0" && !d.aborted && E ? (this.imageState.setCurrentImage(w), this.imageState.setInitialCenter()) : (
|
|
668
|
-
// for non-ready elements, restore animation state
|
|
669
|
-
y.dataset.vvwPos === "0" && !d.aborted && f && I && S && v && b && (this.imageTransitions.set(w, b), this.transitionImage(w, () => {
|
|
670
|
-
this.imageState.setCurrentImage(w), this.imageState.setInitialCenter(), w.classList.add("vvw--ready");
|
|
671
|
-
}))
|
|
672
|
-
);
|
|
673
|
-
}), this.isRapidSwap = !1, this.waitForImagesToLoad(), this.options.onImageView && this.options.onImageView(c);
|
|
674
|
-
}
|
|
675
|
-
zoomIn() {
|
|
676
|
-
this.throttle.fio(
|
|
677
|
-
() => {
|
|
678
|
-
this.imageState.animateZoom(1.68);
|
|
679
|
-
},
|
|
680
|
-
"zoom",
|
|
681
|
-
222
|
|
682
|
-
);
|
|
683
|
-
}
|
|
684
|
-
zoomOut() {
|
|
685
|
-
this.throttle.fio(
|
|
686
|
-
() => {
|
|
687
|
-
this.imageState.animateZoom(0.68);
|
|
688
|
-
},
|
|
689
|
-
"zoom",
|
|
690
|
-
222
|
|
691
|
-
);
|
|
776
|
+
h.innerHTML = "", this.transitionCleanup && this.transitionCleanup(), o.forEach((c) => {
|
|
777
|
+
h.appendChild(c);
|
|
778
|
+
}), a.forEach((c) => {
|
|
779
|
+
c.init();
|
|
780
|
+
}), u ? (this.isRapidSwapRelease && clearTimeout(this.isRapidSwapRelease), this.isRapidSwapRelease = setTimeout(() => {
|
|
781
|
+
this.isRapidSwap = !1;
|
|
782
|
+
}, 333)) : this.isRapidSwap = !1, this.options.onImageView && this.options.onImageView(d, this), this.state.extensions.forEach((c) => {
|
|
783
|
+
c.onImageView && c.onImageView(d, this);
|
|
784
|
+
});
|
|
692
785
|
}
|
|
693
786
|
// ============================================================================
|
|
694
787
|
// UI UPDATES
|
|
695
788
|
// ============================================================================
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
o.style.opacity = "", l === t && (o.style.opacity = "0");
|
|
789
|
+
displayCurrentInfo() {
|
|
790
|
+
const t = this.state.currentIndex;
|
|
791
|
+
typeof this.elements == "string" && this.qsOrigin(this.elements).forEach((a, h) => {
|
|
792
|
+
a.style.opacity = "", h === t && (a.style.opacity = "0");
|
|
701
793
|
});
|
|
702
|
-
const e = this.qs(".vvw-index"), i = `${t + 1}`, n = `${this.
|
|
794
|
+
const e = this.qs(".vvw-index"), i = `${t + 1}`, n = `${this.state.elmLength}`;
|
|
703
795
|
e && (e.textContent = `${i} / ${n}`);
|
|
704
|
-
const
|
|
705
|
-
if (
|
|
706
|
-
const
|
|
707
|
-
|
|
708
|
-
}
|
|
709
|
-
}
|
|
710
|
-
// ============================================================================
|
|
711
|
-
// IMAGE LOADING & TRANSITIONS
|
|
712
|
-
// ============================================================================
|
|
713
|
-
// to make image (.vvw-img-hi) transitions smoothly to target size
|
|
714
|
-
transitionImage(t, e) {
|
|
715
|
-
if (!t.classList.contains("vvw--load-cancelled")) {
|
|
716
|
-
if (this.isRapidSwap) {
|
|
717
|
-
requestAnimationFrame(() => {
|
|
718
|
-
this.transitionImage(t, e);
|
|
719
|
-
});
|
|
720
|
-
return;
|
|
721
|
-
}
|
|
722
|
-
requestAnimationFrame(() => {
|
|
723
|
-
const i = this.imageTransitions.get(t);
|
|
724
|
-
if (!i || t.classList.contains("vvw--load-cancelled")) return;
|
|
725
|
-
const { current: n, target: r } = i, a = {
|
|
726
|
-
width: n.width + (r.width - n.width) * 0.2,
|
|
727
|
-
height: n.height + (r.height - n.height) * 0.2,
|
|
728
|
-
radius: n.radius + (r.radius - n.radius) * 0.2
|
|
729
|
-
};
|
|
730
|
-
Math.abs(a.width - r.width) < 1 && Math.abs(a.height - r.height) < 1 && Math.abs(a.radius - r.radius) < 1 ? (t.style.setProperty("--vvw-current-w", `${r.width}px`), t.style.setProperty("--vvw-current-h", `${r.height}px`), t.style.setProperty("--vvw-current-radius", `${r.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: r }), this.transitionImage(
|
|
731
|
-
t,
|
|
732
|
-
e
|
|
733
|
-
/* false */
|
|
734
|
-
));
|
|
735
|
-
});
|
|
796
|
+
const o = this.qs(".vvw-desc");
|
|
797
|
+
if (o) {
|
|
798
|
+
const a = this.state.children.images.find((l) => l.index === t), h = (a == null ? void 0 : a.config.alt) || "";
|
|
799
|
+
h ? (o.textContent = h, o.setAttribute("aria-label", `Image ${i} of ${n}: ${h}`), o.style.opacity = "") : (o.textContent = "", o.setAttribute("aria-label", `Image ${i} of ${n}`), o.style.opacity = "0");
|
|
736
800
|
}
|
|
737
801
|
}
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
if (n.classList.contains("vvw--load-cancelled")) return;
|
|
745
|
-
n.width = n.naturalWidth, n.height = n.naturalHeight;
|
|
746
|
-
const { width: a, height: o } = H(n);
|
|
747
|
-
n.dataset.vvwWidth = a.toString(), n.dataset.vvwHeight = o.toString(), n.classList.add("vvw--loaded"), this.imageTransitions.set(n, {
|
|
748
|
-
current: {
|
|
749
|
-
width: n.style.getPropertyValue("--vvw-current-w") ? parseFloat(n.style.getPropertyValue("--vvw-current-w")) : 0,
|
|
750
|
-
height: n.style.getPropertyValue("--vvw-current-h") ? parseFloat(n.style.getPropertyValue("--vvw-current-h")) : 0,
|
|
751
|
-
radius: n.style.getPropertyValue("--vvw-current-radius") ? parseFloat(n.style.getPropertyValue("--vvw-current-radius")) : 0
|
|
752
|
-
},
|
|
753
|
-
target: { width: a, height: o, radius: 0 }
|
|
754
|
-
}), this.transitionImage(n, () => {
|
|
755
|
-
var c;
|
|
756
|
-
if (n.classList.contains("vvw--load-cancelled")) return;
|
|
757
|
-
((c = n.parentElement) == null ? void 0 : c.matches(
|
|
758
|
-
`[data-vvw-idx="${this.currentIndex}"][data-vvw-pos="0"]`
|
|
759
|
-
)) && (this.imageState.setCurrentImage(n), this.imageState.setInitialCenter()), n.classList.add("vvw--ready");
|
|
760
|
-
});
|
|
761
|
-
};
|
|
762
|
-
if (n.complete && n.naturalWidth !== 0) {
|
|
763
|
-
r();
|
|
764
|
-
return;
|
|
765
|
-
}
|
|
766
|
-
n.addEventListener("load", () => {
|
|
767
|
-
r();
|
|
768
|
-
}), n.addEventListener("error", () => {
|
|
769
|
-
var o;
|
|
770
|
-
n.classList.add("vvw--loaderror");
|
|
771
|
-
const a = document.createElement("p");
|
|
772
|
-
a.className = "vvw-img-err", a.setAttribute("role", "alert"), a.textContent = "Error loading image", (o = n.parentNode) == null || o.appendChild(a);
|
|
773
|
-
});
|
|
802
|
+
deactivateUi(t, e) {
|
|
803
|
+
t.forEach((i) => {
|
|
804
|
+
var n, o;
|
|
805
|
+
i === "zoomIn" ? (n = this.qs(".vvw-zoom-in")) == null || n.setAttribute("disabled", "true") : i === "zoomOut" && ((o = this.qs(".vvw-zoom-out")) == null || o.setAttribute("disabled", "true")), this.tempDeactivatedUi.push(i);
|
|
806
|
+
}), this.tempDeactivationRequestBy = e || null, this.state.extensions.forEach((i) => {
|
|
807
|
+
i.onDeactivateUi && i.onDeactivateUi(t, this.tempDeactivationRequestBy, this);
|
|
774
808
|
});
|
|
775
809
|
}
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
unregisterPointerListeners() {
|
|
784
|
-
this.pointerListeners = [];
|
|
785
|
-
}
|
|
786
|
-
// internal pointer listener
|
|
787
|
-
// this is a function, called at open
|
|
788
|
-
// the closure makes it easier to have local variables without polluting class scope
|
|
789
|
-
getInternalPointerListener() {
|
|
790
|
-
const t = this.imageState;
|
|
791
|
-
let e = 0, i = !1, n = 0;
|
|
792
|
-
const r = 33;
|
|
793
|
-
let a = () => {
|
|
794
|
-
};
|
|
795
|
-
function o() {
|
|
796
|
-
return i || performance.now() - n < r;
|
|
797
|
-
}
|
|
798
|
-
return (l) => {
|
|
799
|
-
if (l.event === "down") {
|
|
800
|
-
if (a(), this.isZoomedIn && l.pointers.length === 1 && !o()) {
|
|
801
|
-
const c = this.pointers.getCentroid();
|
|
802
|
-
t.setInitialCenter(c);
|
|
803
|
-
}
|
|
804
|
-
if (l.pointers.length >= 2) {
|
|
805
|
-
i = !0;
|
|
806
|
-
const c = this.pointers.getCentroid();
|
|
807
|
-
e = this.pointers.getPointerDistance(l.pointers[0], l.pointers[1]), t.setInitialCenter(c);
|
|
808
|
-
}
|
|
809
|
-
} else if (l.event === "move") {
|
|
810
|
-
if (this.isZoomedIn && l.pointers.length === 1 && l.lastPointerLen === 0 && !o()) {
|
|
811
|
-
const c = this.pointers.getCentroid();
|
|
812
|
-
t.move(c);
|
|
813
|
-
}
|
|
814
|
-
if (l.pointers.length >= 2 && i) {
|
|
815
|
-
const c = this.pointers.getCentroid(), d = this.pointers.getPointerDistance(l.pointers[0], l.pointers[1]);
|
|
816
|
-
t.scaleMove(d / e, c);
|
|
817
|
-
}
|
|
818
|
-
} else (l.event === "up" || l.event === "cancel") && (i || this.isZoomedIn) && (i ? (n = performance.now(), i = !1, t.normalize() && requestAnimationFrame(() => {
|
|
819
|
-
this.close();
|
|
820
|
-
})) : this.isZoomedIn && l.pointers.length === 0 && !o() && (a = t.moveAndNormalize(l.pointer)));
|
|
821
|
-
this.pointerListeners.forEach(
|
|
822
|
-
(c) => c({
|
|
823
|
-
...l,
|
|
824
|
-
hasInternalExecution: this.isZoomedIn || o(),
|
|
825
|
-
abortController: this.abortController
|
|
826
|
-
})
|
|
827
|
-
);
|
|
828
|
-
};
|
|
810
|
+
reactivateUi() {
|
|
811
|
+
this.tempDeactivatedUi.forEach((t) => {
|
|
812
|
+
var e, i;
|
|
813
|
+
t === "zoomIn" ? (e = this.qs(".vvw-zoom-in")) == null || e.removeAttribute("disabled") : t === "zoomOut" && ((i = this.qs(".vvw-zoom-out")) == null || i.removeAttribute("disabled"));
|
|
814
|
+
}), this.state.extensions.forEach((t) => {
|
|
815
|
+
t.onReactivateUi && t.onReactivateUi(this.tempDeactivatedUi, this.tempDeactivationRequestBy, this);
|
|
816
|
+
}), this.tempDeactivatedUi = [], this.tempDeactivationRequestBy = null;
|
|
829
817
|
}
|
|
830
818
|
// ============================================================================
|
|
831
819
|
// LIFECYCLE METHODS - open, close, destroy
|
|
832
820
|
// ============================================================================
|
|
833
821
|
// OPEN
|
|
834
822
|
open(t = 0) {
|
|
835
|
-
var
|
|
836
|
-
if (
|
|
823
|
+
var l, d, p, u, v, f, m;
|
|
824
|
+
if (y.somethingOpened) {
|
|
825
|
+
console.warn(
|
|
826
|
+
"Another VistaView instance is already opened. Close it first before opening a new one."
|
|
827
|
+
);
|
|
837
828
|
return;
|
|
838
|
-
|
|
839
|
-
|
|
829
|
+
}
|
|
830
|
+
y.somethingOpened = this, this.reset(), (t < 0 || t >= this.state.elmLength) && (t = (t % this.state.elmLength + this.state.elmLength) % this.state.elmLength), this.state.currentIndex = t, document.body.style.overflow = "hidden";
|
|
831
|
+
const e = $({
|
|
840
832
|
controls: this.options.controls
|
|
841
833
|
});
|
|
842
|
-
if (document.body.
|
|
834
|
+
if (document.body.append(e), this.root = document.body.querySelector("#vvw-root"), !this.root)
|
|
843
835
|
throw new Error("Failed to setup VistaView root element.");
|
|
844
836
|
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");
|
|
845
|
-
const i = this.options.preloads || 0, n = t, { images:
|
|
837
|
+
const i = this.options.preloads || 0, n = t, { images: o, htmls: a } = this.getChildElements(i, n), h = {
|
|
846
838
|
htmlElements: { from: null, to: a },
|
|
847
|
-
images: { from: null, to:
|
|
848
|
-
index: { from: null, to: this.currentIndex },
|
|
839
|
+
images: { from: null, to: o },
|
|
840
|
+
index: { from: null, to: this.state.currentIndex },
|
|
849
841
|
via: { next: !1, prev: !1 },
|
|
850
842
|
vistaView: this
|
|
851
843
|
};
|
|
852
|
-
this.
|
|
853
|
-
this.imageContainer.appendChild(
|
|
854
|
-
}),
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
[
|
|
860
|
-
...this.options.controls.topLeft || [],
|
|
861
|
-
...this.options.controls.topRight || [],
|
|
862
|
-
...this.options.controls.topCenter || [],
|
|
863
|
-
...this.options.controls.bottomCenter || [],
|
|
864
|
-
...this.options.controls.bottomLeft || [],
|
|
865
|
-
...this.options.controls.bottomRight || []
|
|
866
|
-
].forEach((m) => {
|
|
867
|
-
typeof m != "string" && (l[m.name] = m);
|
|
868
|
-
}), this.root.querySelectorAll("button[data-vvw-control]").forEach((m) => {
|
|
869
|
-
const u = m;
|
|
870
|
-
u.addEventListener("click", (b) => {
|
|
871
|
-
const f = b.currentTarget.dataset.vvwControl, v = l[f], E = this.currentChildren.images.find(
|
|
872
|
-
(I) => I.index === this.currentIndex
|
|
873
|
-
);
|
|
874
|
-
v && E && (v.onClick.constructor.name === "AsyncFunction" ? (u.classList.add("vvw--loading"), v.onClick(E, this).finally(() => {
|
|
875
|
-
u.classList.remove("vvw--loading");
|
|
876
|
-
})) : v.onClick(E, this));
|
|
877
|
-
});
|
|
878
|
-
}), this.initFunction(this), requestAnimationFrame(() => {
|
|
844
|
+
this.imageSetupFunction(h), this.state.children = { htmls: a, images: o }, a.forEach((c) => {
|
|
845
|
+
this.imageContainer.appendChild(c);
|
|
846
|
+
}), o.forEach((c) => {
|
|
847
|
+
c.init();
|
|
848
|
+
}), (l = this.qs(".vvw-close")) == null || l.addEventListener("click", () => this.close()), (d = this.qs(".vvw-zoom-in")) == null || d.addEventListener("click", () => this.zoomIn()), (p = this.qs(".vvw-zoom-out")) == null || p.addEventListener("click", () => this.zoomOut()), (u = this.qs(".vvw-prev>button")) == null || u.addEventListener("click", () => this.prev()), (v = this.qs(".vvw-next>button")) == null || v.addEventListener("click", () => this.next()), this.state.elmLength < 2 && ((f = this.qs(".vvw-prev")) == null || f.classList.add("vvw--hidden"), (m = this.qs(".vvw-next")) == null || m.classList.add("vvw--hidden")), this.openFunction(this), this.eventHandlers = new Q(this), this.externalPointerListener.forEach((c) => {
|
|
849
|
+
this.eventHandlers.registerPointerListener(c);
|
|
850
|
+
}), this.eventHandlers.start(this.imageContainer), requestAnimationFrame(() => {
|
|
879
851
|
requestAnimationFrame(() => {
|
|
880
|
-
var
|
|
881
|
-
(
|
|
852
|
+
var c;
|
|
853
|
+
(c = this.root) == null || c.addEventListener(
|
|
882
854
|
"transitionend",
|
|
883
855
|
() => {
|
|
884
|
-
var
|
|
885
|
-
(
|
|
856
|
+
var g;
|
|
857
|
+
(g = this.root) == null || g.classList.add("vvw--settled");
|
|
886
858
|
},
|
|
887
859
|
{ once: !0 }
|
|
888
|
-
), this.root.classList.add("vvw--active"), this.
|
|
860
|
+
), this.root.classList.add("vvw--active"), this.displayCurrentInfo(), this.options.onOpen && this.options.onOpen(this), this.options.onImageView && this.options.onImageView(h, this), this.state.extensions.forEach((g) => {
|
|
861
|
+
g.onOpen && g.onOpen(this), g.onImageView && g.onImageView(h, this);
|
|
862
|
+
});
|
|
889
863
|
});
|
|
890
864
|
});
|
|
891
865
|
}
|
|
892
866
|
/// CLOSE
|
|
893
867
|
async close(t = !0) {
|
|
894
|
-
|
|
868
|
+
y.somethingOpened === this && this.root && (this.eventHandlers.stop(), this.eventHandlers = null, this.state.children.images.forEach((e) => {
|
|
869
|
+
e.prepareClose();
|
|
870
|
+
}), t ? await new Promise((e) => {
|
|
895
871
|
let n = 0;
|
|
896
|
-
this.root.addEventListener("transitionend", (
|
|
897
|
-
|
|
872
|
+
this.root.addEventListener("transitionend", (o) => {
|
|
873
|
+
o.target === this.root && (n++, n === 2 && typeof this.elements == "string" && (this.state.children.images.forEach((a) => {
|
|
874
|
+
a.destroy();
|
|
875
|
+
}), this.qsOrigin(this.elements).forEach((a) => {
|
|
898
876
|
a.style.opacity = "";
|
|
899
|
-
}), n === 3 && e(null));
|
|
877
|
+
})), n === 3 && e(null));
|
|
900
878
|
}), this.root.classList.add("vvw--closing");
|
|
901
|
-
}) : this.elements
|
|
879
|
+
}) : typeof this.elements == "string" && (this.state.children.images.forEach((e) => {
|
|
880
|
+
e.destroy();
|
|
881
|
+
}), this.qsOrigin(this.elements).forEach((e) => {
|
|
902
882
|
e.style.opacity = "";
|
|
903
|
-
})
|
|
883
|
+
})), this.root.remove(), this.root = null, this.imageContainer = null, this.state.children = { htmls: [], images: [] }, this.state.currentIndex = -1, this.state.children.images.forEach((e) => {
|
|
884
|
+
e.destroy();
|
|
885
|
+
}), document.body.style.overflow = "", y.somethingOpened = null, this.closeFunction(this), this.options.onClose && this.options.onClose(this), this.state.extensions.forEach((e) => {
|
|
886
|
+
e.onClose && e.onClose(this);
|
|
887
|
+
}));
|
|
904
888
|
}
|
|
905
889
|
// DESTROY
|
|
906
890
|
destroy() {
|
|
907
|
-
this.close(!1), this.elements
|
|
891
|
+
this.close(!1), this.externalPointerListener = [], typeof this.elements == "string" && this.qsOrigin(this.elements).forEach((t) => {
|
|
908
892
|
t.removeAttribute("data-vista-idx"), t.removeEventListener("click", this.defaultOnClickHandler), t.removeEventListener("pointerup", this.onClickElements);
|
|
909
893
|
});
|
|
910
894
|
}
|
|
@@ -912,59 +896,101 @@ class st {
|
|
|
912
896
|
// NAVIGATION METHODS - next, prev, view
|
|
913
897
|
// ============================================================================
|
|
914
898
|
next() {
|
|
915
|
-
if (
|
|
899
|
+
if (y.somethingOpened !== this) {
|
|
900
|
+
console.warn("This VistaView instance is not opened.");
|
|
916
901
|
return;
|
|
917
|
-
|
|
902
|
+
}
|
|
903
|
+
const t = (this.state.currentIndex + 1) % this.state.elmLength;
|
|
918
904
|
this.view(t, { next: !0, prev: !1 });
|
|
919
905
|
}
|
|
920
906
|
prev() {
|
|
921
|
-
if (
|
|
907
|
+
if (y.somethingOpened !== this) {
|
|
908
|
+
console.warn("This VistaView instance is not opened.");
|
|
922
909
|
return;
|
|
923
|
-
|
|
910
|
+
}
|
|
911
|
+
const t = (this.state.currentIndex - 1 + this.state.elmLength) % this.state.elmLength;
|
|
924
912
|
this.view(t, { next: !1, prev: !0 });
|
|
925
913
|
}
|
|
926
914
|
view(t, e) {
|
|
927
|
-
if (
|
|
915
|
+
if (y.somethingOpened !== this) {
|
|
916
|
+
console.warn("This VistaView instance is not opened.");
|
|
917
|
+
return;
|
|
918
|
+
}
|
|
919
|
+
if (this.state.elmLength < 2)
|
|
928
920
|
return;
|
|
929
|
-
|
|
930
|
-
this.currentIndex
|
|
931
|
-
|
|
932
|
-
|
|
921
|
+
(t < 0 || t >= this.state.elmLength) && (t = (t % this.state.elmLength + this.state.elmLength) % this.state.elmLength);
|
|
922
|
+
const i = this.state.currentIndex;
|
|
923
|
+
this.state.currentIndex = t;
|
|
924
|
+
const n = this.state.abortController;
|
|
925
|
+
n == null || n.abort(), this.state.abortController = new AbortController(), this.swap(i, e);
|
|
926
|
+
}
|
|
927
|
+
zoomIn() {
|
|
928
|
+
if (y.somethingOpened !== this) {
|
|
929
|
+
console.warn("This VistaView instance is not opened.");
|
|
930
|
+
return;
|
|
931
|
+
}
|
|
932
|
+
this.tempDeactivatedUi.includes("zoomIn") || this.throttle.fio(
|
|
933
|
+
() => {
|
|
934
|
+
const t = this.state.children.images.find((e) => e.pos === 0);
|
|
935
|
+
t == null || t.animateZoom(1.68);
|
|
936
|
+
},
|
|
937
|
+
"zoom",
|
|
938
|
+
222
|
|
939
|
+
);
|
|
940
|
+
}
|
|
941
|
+
zoomOut() {
|
|
942
|
+
if (y.somethingOpened !== this) {
|
|
943
|
+
console.warn("This VistaView instance is not opened.");
|
|
944
|
+
return;
|
|
945
|
+
}
|
|
946
|
+
this.tempDeactivatedUi.includes("zoomOut") || this.throttle.fio(
|
|
947
|
+
() => {
|
|
948
|
+
const t = this.state.children.images.find((e) => e.pos === 0);
|
|
949
|
+
t == null || t.animateZoom(0.68);
|
|
950
|
+
},
|
|
951
|
+
"zoom",
|
|
952
|
+
222
|
|
953
|
+
);
|
|
933
954
|
}
|
|
934
|
-
// ============================================================================
|
|
935
|
-
// GETTERS
|
|
936
|
-
// ============================================================================
|
|
937
955
|
getCurrentIndex() {
|
|
938
|
-
return
|
|
956
|
+
return this.state.currentIndex;
|
|
939
957
|
}
|
|
940
958
|
}
|
|
941
|
-
function
|
|
959
|
+
function et(s) {
|
|
942
960
|
let t = null;
|
|
943
|
-
if (typeof s == "string"
|
|
961
|
+
if (typeof s == "string") {
|
|
962
|
+
if (t = document.querySelectorAll(s), t.length === 0)
|
|
963
|
+
return new Error("No elements found in node list.").toString();
|
|
944
964
|
for (let e = 0; e < t.length; e++) {
|
|
945
|
-
const i = t[e];
|
|
946
|
-
if (
|
|
947
|
-
return `
|
|
965
|
+
const i = t[e], n = i.tagName.toLowerCase();
|
|
966
|
+
if (n !== "img" && n !== "a")
|
|
967
|
+
return new Error(`Invalid element at index ${e}: expected <img>, <a>, got <${n}>`);
|
|
968
|
+
if (n === "a" && !(i.querySelector("img") !== null))
|
|
969
|
+
return new Error(`Invalid <a> element at index ${e}: must contain <img>`);
|
|
948
970
|
}
|
|
949
|
-
else {
|
|
971
|
+
} else {
|
|
950
972
|
const e = s;
|
|
951
973
|
for (let i = 0; i < e.length; i++)
|
|
952
974
|
if (!e[i].src)
|
|
953
|
-
return `
|
|
975
|
+
return new Error(`Invalid image data at index ${i}: must have 'src'`);
|
|
954
976
|
}
|
|
955
|
-
return
|
|
977
|
+
return s;
|
|
956
978
|
}
|
|
957
|
-
function
|
|
958
|
-
if (!s)
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
979
|
+
function st({ elements: s, ...t }) {
|
|
980
|
+
if (!s)
|
|
981
|
+
return console.error(s), console.error("no elements provided"), console.warn("VistaView: silently returning."), null;
|
|
982
|
+
let e = et(s);
|
|
983
|
+
if (e instanceof Error)
|
|
984
|
+
return console.error(e), console.warn("VistaView: silently returning."), null;
|
|
985
|
+
const i = new tt(e, t);
|
|
963
986
|
return {
|
|
964
987
|
open: (n = 0) => i.open(n),
|
|
988
|
+
reset: () => i.reset(),
|
|
965
989
|
close: () => i.close(),
|
|
966
990
|
next: () => i.next(),
|
|
967
991
|
prev: () => i.prev(),
|
|
992
|
+
zoomIn: () => i.zoomIn(),
|
|
993
|
+
zoomOut: () => i.zoomOut(),
|
|
968
994
|
destroy: () => i.destroy(),
|
|
969
995
|
getCurrentIndex: () => i.getCurrentIndex(),
|
|
970
996
|
view: (n) => {
|
|
@@ -973,11 +999,18 @@ function at({ elements: s, ...t }) {
|
|
|
973
999
|
};
|
|
974
1000
|
}
|
|
975
1001
|
export {
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
j as
|
|
1002
|
+
I as DefaultOptions,
|
|
1003
|
+
T as VistaBox,
|
|
1004
|
+
L as VistaHiresTransition,
|
|
1005
|
+
Y as VistaImage,
|
|
1006
|
+
Q as VistaImageEvent,
|
|
1007
|
+
J as VistaPointers,
|
|
1008
|
+
j as VistaState,
|
|
1009
|
+
tt as VistaView,
|
|
1010
|
+
U as close,
|
|
1011
|
+
k as imageSetup,
|
|
1012
|
+
V as init,
|
|
1013
|
+
B as open,
|
|
1014
|
+
X as transition,
|
|
1015
|
+
st as vistaView
|
|
983
1016
|
};
|