vistaview 0.10.14 → 0.10.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/vista-view.d.ts.map +1 -1
- package/dist/react.d.ts +2 -2
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +14 -14
- package/dist/solid.d.ts +2 -2
- package/dist/solid.d.ts.map +1 -1
- package/dist/solid.js +15 -15
- package/dist/svelte.d.ts +2 -2
- package/dist/svelte.d.ts.map +1 -1
- package/dist/svelte.js +12 -12
- package/dist/vistaview.js +150 -150
- package/dist/vistaview.umd.js +2 -2
- package/dist/vue.d.ts +2 -2
- package/dist/vue.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vista-view.d.ts","sourceRoot":"","sources":["../../src/lib/vista-view.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,QAAQ,EAGR,cAAc,EACd,gCAAgC,EAEjC,MAAM,SAAS,CAAC;AAYjB,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAI5C,eAAO,MAAM,gBAAgB,EAAE;IAAE,eAAe,EAAE,SAAS,GAAG,IAAI,CAAA;CAEjE,CAAC;AAEF,qBAAa,SAAS;IACpB,OAAO,EAAE,QAAQ,CAAC;IAClB,KAAK,aAAoB;IACzB,cAAc,EAAE,WAAW,GAAG,IAAI,CAAQ;IAC1C,uBAAuB,EAAE,CAAC,CAAC,CAAC,EAAE,gCAAgC,KAAK,IAAI,CAAC,EAAE,CAAM;IAEhF,OAAO,CAAC,QAAQ,CAA4B;IAC5C,OAAO,CAAC,aAAa,CAAgC;IAErD,OAAO,CAAC,kBAAkB,CAAiC;IAC3D,OAAO,CAAC,YAAY,CAAqB;IACzC,OAAO,CAAC,YAAY,CAAqB;IACzC,OAAO,CAAC,aAAa,CAAuB;IAC5C,OAAO,CAAC,kBAAkB,CAAiC;IAE3D,OAAO,CAAC,QAAQ,CAAkB;IAClC,OAAO,CAAC,IAAI,CAA4B;IAExC,OAAO,CAAC,eAAe,
|
|
1
|
+
{"version":3,"file":"vista-view.d.ts","sourceRoot":"","sources":["../../src/lib/vista-view.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,QAAQ,EAGR,cAAc,EACd,gCAAgC,EAEjC,MAAM,SAAS,CAAC;AAYjB,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAI5C,eAAO,MAAM,gBAAgB,EAAE;IAAE,eAAe,EAAE,SAAS,GAAG,IAAI,CAAA;CAEjE,CAAC;AAEF,qBAAa,SAAS;IACpB,OAAO,EAAE,QAAQ,CAAC;IAClB,KAAK,aAAoB;IACzB,cAAc,EAAE,WAAW,GAAG,IAAI,CAAQ;IAC1C,uBAAuB,EAAE,CAAC,CAAC,CAAC,EAAE,gCAAgC,KAAK,IAAI,CAAC,EAAE,CAAM;IAEhF,OAAO,CAAC,QAAQ,CAA4B;IAC5C,OAAO,CAAC,aAAa,CAAgC;IAErD,OAAO,CAAC,kBAAkB,CAAiC;IAC3D,OAAO,CAAC,YAAY,CAAqB;IACzC,OAAO,CAAC,YAAY,CAAqB;IACzC,OAAO,CAAC,aAAa,CAAuB;IAC5C,OAAO,CAAC,kBAAkB,CAAiC;IAE3D,OAAO,CAAC,QAAQ,CAAkB;IAClC,OAAO,CAAC,IAAI,CAA4B;IAExC,OAAO,CAAC,eAAe,CAKrB;IAEF,OAAO,CAAC,qBAAqB,CAAwD;gBAEzE,QAAQ,EAAE,MAAM,GAAG,cAAc,EAAE,EAAE,OAAO,GAAE,QAAa;IA4CvE,KAAK;IAoBL,EAAE,CAAC,CAAC,SAAS,WAAW,EAAE,QAAQ,EAAE,MAAM,GAAG,CAAC,GAAG,IAAI;IAIrD,QAAQ,CAAC,CAAC,SAAS,UAAU,CAAC,WAAW,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,CAAC;IAIhE,uBAAuB,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,gCAAgC,KAAK,IAAI,GAAG,IAAI;IAItF,OAAO,CAAC,gBAAgB;IAsFxB,OAAO,CAAC,YAAY,CAAK;IACzB,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,kBAAkB,CAAK;IAC/B,OAAO,CAAC,iBAAiB,CAA6B;YAExC,IAAI;IA4GlB,OAAO,CAAC,kBAAkB;IAyC1B,OAAO,CAAC,iBAAiB,CAAgB;IACzC,OAAO,CAAC,yBAAyB,CAAyB;IAC1D,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,SAAS,CAAC,EAAE,QAAQ;IAelD,OAAO,CAAC,YAAY;IAqBpB,IAAI,CAAC,UAAU,GAAE,MAAU,GAAG,IAAI;IA2H5B,KAAK,CAAC,OAAO,GAAE,OAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IA6EnD,OAAO,IAAI,IAAI;IAmBf,IAAI,IAAI,IAAI;IASZ,IAAI,IAAI,IAAI;IASZ,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE;QAAE,IAAI,EAAE,OAAO,CAAC;QAAC,IAAI,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI;IA+BjE,UAAU,EAAE,OAAO,CAAS;IAE5B,MAAM,IAAI,IAAI;IAoBd,OAAO,IAAI,IAAI;IAoBf,eAAe,IAAI,MAAM;CAG1B"}
|
package/dist/react.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import { VistaParamsNeo, VistaInterface } from './vistaview';
|
|
2
|
+
import { VistaParamsNeo, VistaInterface, VistaOpt } from './vistaview';
|
|
3
3
|
export declare function useVistaView(options: VistaParamsNeo): VistaInterface;
|
|
4
|
-
export interface VistaViewProps extends
|
|
4
|
+
export interface VistaViewProps extends VistaOpt {
|
|
5
5
|
children: ReactNode;
|
|
6
6
|
className?: string;
|
|
7
7
|
id?: string;
|
package/dist/react.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../src/react.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../src/react.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5E,wBAAgB,YAAY,CAAC,OAAO,EAAE,cAAc,GAAG,cAAc,CAuBpE;AAED,MAAM,WAAW,cAAe,SAAQ,QAAQ;IAC9C,QAAQ,EAAE,SAAS,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,eAAO,MAAM,SAAS,2GA6BrB,CAAC"}
|
package/dist/react.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { forwardRef as I, useRef as s, useId as w, useImperativeHandle as g, useEffect as
|
|
4
|
-
import { vistaView as
|
|
2
|
+
import { jsx as v } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef as I, useRef as s, useId as w, useImperativeHandle as g, useEffect as a, useCallback as t } from "react";
|
|
4
|
+
import { vistaView as d } from "./vistaview.js";
|
|
5
5
|
function z(c) {
|
|
6
6
|
const r = s(null);
|
|
7
|
-
return
|
|
7
|
+
return a(() => (r.current = d(c), () => {
|
|
8
8
|
var e;
|
|
9
9
|
(e = r.current) == null || e.destroy(), r.current = null;
|
|
10
10
|
}), []), {
|
|
@@ -51,18 +51,18 @@ function z(c) {
|
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
53
|
const R = I(
|
|
54
|
-
({ children: c, className: r, id: e, selector: n = "> a", ...
|
|
55
|
-
const
|
|
56
|
-
return g(
|
|
57
|
-
if (
|
|
58
|
-
return u.current =
|
|
59
|
-
...
|
|
60
|
-
elements:
|
|
54
|
+
({ children: c, className: r, id: e, selector: n = "> a", ...f }, m) => {
|
|
55
|
+
const l = s(null), u = s(null), p = w(), o = e || `vvw-gallery-${p.replace(/:/g, "")}`;
|
|
56
|
+
return g(m, () => u.current, []), a(() => {
|
|
57
|
+
if (l.current)
|
|
58
|
+
return u.current = d({
|
|
59
|
+
...f,
|
|
60
|
+
elements: `#${o} ${n}`
|
|
61
61
|
}), () => {
|
|
62
|
-
var
|
|
63
|
-
(
|
|
62
|
+
var i;
|
|
63
|
+
(i = u.current) == null || i.destroy(), u.current = null;
|
|
64
64
|
};
|
|
65
|
-
}, [o, n]), /* @__PURE__ */
|
|
65
|
+
}, [o, n]), /* @__PURE__ */ v("div", { ref: l, id: o, className: r, children: c });
|
|
66
66
|
}
|
|
67
67
|
);
|
|
68
68
|
export {
|
package/dist/solid.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { VistaParamsNeo, VistaInterface } from './vistaview';
|
|
1
|
+
import { VistaParamsNeo, VistaInterface, VistaOpt } from './vistaview';
|
|
2
2
|
export declare function useVistaView(options: VistaParamsNeo): VistaInterface;
|
|
3
|
-
export interface VistaViewOptions extends
|
|
3
|
+
export interface VistaViewOptions extends VistaOpt {
|
|
4
4
|
id?: string;
|
|
5
5
|
selector?: string;
|
|
6
6
|
ref?: (instance: VistaInterface) => void;
|
package/dist/solid.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"solid.d.ts","sourceRoot":"","sources":["../src/solid.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"solid.d.ts","sourceRoot":"","sources":["../src/solid.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5E,wBAAgB,YAAY,CAAC,OAAO,EAAE,cAAc,GAAG,cAAc,CAmBpE;AAED,MAAM,WAAW,gBAAiB,SAAQ,QAAQ;IAChD,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,CAAC,QAAQ,EAAE,cAAc,KAAK,IAAI,CAAC;CAC1C;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,gBAAgB,QAmB9E"}
|
package/dist/solid.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { onCleanup as
|
|
2
|
-
import { vistaView as
|
|
3
|
-
function y(
|
|
4
|
-
const o =
|
|
5
|
-
return
|
|
1
|
+
import { onCleanup as d, onMount as p } from "solid-js";
|
|
2
|
+
import { vistaView as u } from "./vistaview.js";
|
|
3
|
+
function y(t) {
|
|
4
|
+
const o = u(t);
|
|
5
|
+
return d(() => {
|
|
6
6
|
o == null || o.destroy();
|
|
7
7
|
}), {
|
|
8
|
-
open: (
|
|
8
|
+
open: (r = 0) => o == null ? void 0 : o.open(r),
|
|
9
9
|
close: () => (o == null ? void 0 : o.close()) ?? Promise.resolve(),
|
|
10
10
|
reset: () => o == null ? void 0 : o.reset(),
|
|
11
11
|
next: () => o == null ? void 0 : o.next(),
|
|
@@ -13,19 +13,19 @@ function y(r) {
|
|
|
13
13
|
zoomIn: () => o == null ? void 0 : o.zoomIn(),
|
|
14
14
|
zoomOut: () => o == null ? void 0 : o.zoomOut(),
|
|
15
15
|
getCurrentIndex: () => (o == null ? void 0 : o.getCurrentIndex()) ?? -1,
|
|
16
|
-
view: (
|
|
16
|
+
view: (r) => o == null ? void 0 : o.view(r),
|
|
17
17
|
destroy: () => o == null ? void 0 : o.destroy()
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
|
-
function g(
|
|
21
|
-
const { selector:
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
...
|
|
25
|
-
elements:
|
|
20
|
+
function g(t, o) {
|
|
21
|
+
const { selector: r = "> a", ref: l, ...v } = o, m = o.id || `vvw-gallery-${Math.random().toString(36).slice(2)}`;
|
|
22
|
+
t.id = m, p(() => {
|
|
23
|
+
const e = u({
|
|
24
|
+
...v,
|
|
25
|
+
elements: `#${m} ${r}`
|
|
26
26
|
});
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
l && e && l(e), d(() => {
|
|
28
|
+
e == null || e.destroy();
|
|
29
29
|
});
|
|
30
30
|
});
|
|
31
31
|
}
|
package/dist/svelte.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { VistaParamsNeo, VistaInterface } from './vistaview';
|
|
1
|
+
import { VistaParamsNeo, VistaInterface, VistaOpt } from './vistaview';
|
|
2
2
|
export declare function useVistaView(options: VistaParamsNeo): VistaInterface;
|
|
3
|
-
export interface VistaViewProps extends
|
|
3
|
+
export interface VistaViewProps extends VistaOpt {
|
|
4
4
|
id?: string;
|
|
5
5
|
class?: string;
|
|
6
6
|
selector?: string;
|
package/dist/svelte.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"svelte.d.ts","sourceRoot":"","sources":["../src/svelte.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"svelte.d.ts","sourceRoot":"","sources":["../src/svelte.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,wBAAgB,YAAY,CAAC,OAAO,EAAE,cAAc,GAAG,cAAc,CAmBpE;AAED,MAAM,WAAW,cAAe,SAAQ,QAAQ;IAC9C,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,cAAc,CAAC;CACtB;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,cAAc;;EA0BxE"}
|
package/dist/svelte.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { onDestroy as
|
|
2
|
-
import { vistaView as
|
|
1
|
+
import { onDestroy as y, onMount as f } from "svelte";
|
|
2
|
+
import { vistaView as u } from "./vistaview.js";
|
|
3
3
|
function w(e) {
|
|
4
|
-
const o =
|
|
5
|
-
return
|
|
4
|
+
const o = u(e);
|
|
5
|
+
return y(() => {
|
|
6
6
|
o == null || o.destroy();
|
|
7
7
|
}), {
|
|
8
8
|
open: (r = 0) => o == null ? void 0 : o.open(r),
|
|
@@ -19,16 +19,16 @@ function w(e) {
|
|
|
19
19
|
}
|
|
20
20
|
function x(e, o) {
|
|
21
21
|
let r = null;
|
|
22
|
-
const { selector:
|
|
23
|
-
e.id
|
|
24
|
-
function
|
|
25
|
-
r =
|
|
26
|
-
...
|
|
27
|
-
elements:
|
|
22
|
+
const { selector: d = "> a", ref: t, ...m } = o, l = o.id || `vvw-gallery-${Math.random().toString(36).slice(2)}`;
|
|
23
|
+
e.id = l;
|
|
24
|
+
function v() {
|
|
25
|
+
r = u({
|
|
26
|
+
...m,
|
|
27
|
+
elements: `#${l} ${d}`
|
|
28
28
|
}), t && r && Object.assign(t, r);
|
|
29
29
|
}
|
|
30
|
-
return
|
|
31
|
-
|
|
30
|
+
return f(() => {
|
|
31
|
+
v();
|
|
32
32
|
}), {
|
|
33
33
|
destroy() {
|
|
34
34
|
r == null || r.destroy(), r = null;
|
package/dist/vistaview.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var S = Object.defineProperty;
|
|
2
|
-
var D = (
|
|
3
|
-
var r = (
|
|
2
|
+
var D = (n, t, e) => t in n ? S(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
|
|
3
|
+
var r = (n, t, e) => D(n, typeof t != "symbol" ? t + "" : t, e);
|
|
4
4
|
import { V as T, a as L } from "./vista-box-CQvGrjln.js";
|
|
5
5
|
const I = {
|
|
6
6
|
// debug, don't remove
|
|
@@ -20,9 +20,9 @@ const I = {
|
|
|
20
20
|
let E = null;
|
|
21
21
|
function W() {
|
|
22
22
|
return E || (window.trustedTypes || (window.trustedTypes = {
|
|
23
|
-
createPolicy: (
|
|
23
|
+
createPolicy: (n, t) => t
|
|
24
24
|
}), E = window.trustedTypes.createPolicy("vistaView-policy", {
|
|
25
|
-
createHTML: (
|
|
25
|
+
createHTML: (n) => n,
|
|
26
26
|
// HTML is generated by us, not user input
|
|
27
27
|
createScript: () => {
|
|
28
28
|
throw new Error("Not implemented");
|
|
@@ -32,15 +32,15 @@ function W() {
|
|
|
32
32
|
}
|
|
33
33
|
}), E);
|
|
34
34
|
}
|
|
35
|
-
function F(
|
|
36
|
-
const e = W().createHTML(
|
|
35
|
+
function F(n) {
|
|
36
|
+
const e = W().createHTML(n), i = document.createElement("template");
|
|
37
37
|
i.innerHTML = e;
|
|
38
|
-
const
|
|
39
|
-
return i.remove(),
|
|
38
|
+
const s = i.content;
|
|
39
|
+
return i.remove(), s;
|
|
40
40
|
}
|
|
41
|
-
function A(
|
|
42
|
-
if (typeof
|
|
43
|
-
switch (
|
|
41
|
+
function A(n, t) {
|
|
42
|
+
if (typeof n == "string")
|
|
43
|
+
switch (n) {
|
|
44
44
|
case "zoomIn":
|
|
45
45
|
return `<div class="vvw-ui"><button aria-label="Zoom In" class="vvw-zoom-in">${q}</button></div>`;
|
|
46
46
|
case "zoomOut":
|
|
@@ -52,33 +52,33 @@ function A(s, t) {
|
|
|
52
52
|
case "description":
|
|
53
53
|
return '<div class="vvw-desc vvw-ui" role="status" aria-live="polite" aria-atomic="true"></div>';
|
|
54
54
|
default:
|
|
55
|
-
const e = t[
|
|
56
|
-
return e && e.control ? `<div class="vvw-ext vvw-ui" aria-label="${e.description || e.name}" data-vvw-control="${e.name}"></div>` : (console.warn(`Unknown control: ${
|
|
55
|
+
const e = t[n];
|
|
56
|
+
return e && e.control ? `<div class="vvw-ext vvw-ui" aria-label="${e.description || e.name}" data-vvw-control="${e.name}"></div>` : (console.warn(`Unknown control: ${n}. Will return empty string.`), "");
|
|
57
57
|
}
|
|
58
58
|
return "";
|
|
59
59
|
}
|
|
60
60
|
function $({
|
|
61
|
-
controls:
|
|
61
|
+
controls: n,
|
|
62
62
|
extensions: t
|
|
63
63
|
}) {
|
|
64
64
|
const e = {};
|
|
65
65
|
t.forEach((o) => {
|
|
66
66
|
e[o.name] = o;
|
|
67
67
|
});
|
|
68
|
-
const i = (o) => o ? o.map((a) => A(a, e)).join("") : "",
|
|
68
|
+
const i = (o) => o ? o.map((a) => A(a, e)).join("") : "", s = F(
|
|
69
69
|
`<div class="vvw-root" id="vvw-root">
|
|
70
70
|
<div class="vvw-container">
|
|
71
71
|
<div class="vvw-bg"></div>
|
|
72
72
|
<div class="vvw-image-container"></div>
|
|
73
73
|
<div class="vvw-top-bar">
|
|
74
|
-
<div>${i(
|
|
75
|
-
<div>${i(
|
|
76
|
-
<div>${i(
|
|
74
|
+
<div>${i(n == null ? void 0 : n.topLeft)}</div>
|
|
75
|
+
<div>${i(n == null ? void 0 : n.topCenter)}</div>
|
|
76
|
+
<div>${i(n == null ? void 0 : n.topRight)}</div>
|
|
77
77
|
</div>
|
|
78
78
|
<div class="vvw-bottom-bar">
|
|
79
|
-
<div>${i(
|
|
80
|
-
<div>${i(
|
|
81
|
-
<div>${i(
|
|
79
|
+
<div>${i(n == null ? void 0 : n.bottomLeft)}</div>
|
|
80
|
+
<div>${i(n == null ? void 0 : n.bottomCenter)}</div>
|
|
81
|
+
<div>${i(n == null ? void 0 : n.bottomRight)}</div>
|
|
82
82
|
</div>
|
|
83
83
|
<div class="vvw-prev vvw-ui"><button aria-label="Previous">${R}</button></div>
|
|
84
84
|
<div class="vvw-next vvw-ui"><button aria-label="Next">${O}</button></div>
|
|
@@ -86,71 +86,71 @@ function $({
|
|
|
86
86
|
</div>`
|
|
87
87
|
);
|
|
88
88
|
return [
|
|
89
|
-
...(
|
|
90
|
-
...(
|
|
91
|
-
...(
|
|
92
|
-
...(
|
|
93
|
-
...(
|
|
94
|
-
...(
|
|
89
|
+
...(n == null ? void 0 : n.topLeft) || [],
|
|
90
|
+
...(n == null ? void 0 : n.topCenter) || [],
|
|
91
|
+
...(n == null ? void 0 : n.topRight) || [],
|
|
92
|
+
...(n == null ? void 0 : n.bottomLeft) || [],
|
|
93
|
+
...(n == null ? void 0 : n.bottomCenter) || [],
|
|
94
|
+
...(n == null ? void 0 : n.bottomRight) || []
|
|
95
95
|
].forEach((o) => {
|
|
96
96
|
const a = e[o];
|
|
97
97
|
if (a && a.control) {
|
|
98
|
-
const h =
|
|
98
|
+
const h = s.querySelector(`[data-vvw-control="${a.name}"]`), l = a.control();
|
|
99
99
|
h && l && h.appendChild(l);
|
|
100
100
|
}
|
|
101
|
-
}),
|
|
101
|
+
}), s;
|
|
102
102
|
}
|
|
103
|
-
function k(
|
|
103
|
+
function k(n) {
|
|
104
104
|
}
|
|
105
|
-
function V(
|
|
106
|
-
N(
|
|
105
|
+
function V(n) {
|
|
106
|
+
N(n);
|
|
107
107
|
}
|
|
108
|
-
function N(
|
|
108
|
+
function N(n) {
|
|
109
109
|
let t = { x: 0, y: 0 }, e = { x: 0, y: 0 }, i = null;
|
|
110
|
-
|
|
110
|
+
n.registerPointerListener((s) => {
|
|
111
111
|
var o;
|
|
112
|
-
if (!
|
|
113
|
-
if (
|
|
114
|
-
e = { x:
|
|
112
|
+
if (!s.hasInternalExecution && !(s.pointers.length > 1)) {
|
|
113
|
+
if (s.event === "down" && (t = { x: s.pointer.x, y: s.pointer.y }, e = { x: s.pointer.x, y: s.pointer.y }, (o = s.abortController) == null || o.abort()), s.event === "move") {
|
|
114
|
+
e = { x: s.pointer.x, y: s.pointer.y };
|
|
115
115
|
const a = e.x - t.x, h = e.y - t.y;
|
|
116
116
|
if (!i && Math.abs(h) > Math.abs(a) || i === "y") {
|
|
117
117
|
const l = h / window.innerHeight * 100;
|
|
118
|
-
|
|
119
|
-
} else if (!i && Math.abs(a) > Math.abs(h) || i === "x" &&
|
|
118
|
+
n.imageContainer.style.transition = "none", n.imageContainer.style.transform = `translateY(${l}vh)`, i = "y";
|
|
119
|
+
} else if (!i && Math.abs(a) > Math.abs(h) || i === "x" && s.state.elmLength > 1) {
|
|
120
120
|
const l = a / window.innerWidth * 100;
|
|
121
|
-
|
|
121
|
+
n.imageContainer.style.transition = "none", n.imageContainer.style.transform = `translateX(${l}vw)`, i = "x";
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
|
-
if (
|
|
124
|
+
if (s.event === "up" || s.event === "cancel") {
|
|
125
125
|
let a = function(h) {
|
|
126
126
|
var l;
|
|
127
|
-
(l =
|
|
127
|
+
(l = n.imageContainer) == null || l.addEventListener("transitionend", function d() {
|
|
128
128
|
var p;
|
|
129
|
-
(p =
|
|
130
|
-
}),
|
|
129
|
+
(p = n.imageContainer) == null || p.removeEventListener("transitionend", d), n.imageContainer.style.transition = "", n.imageContainer.style.transform = "";
|
|
130
|
+
}), n.imageContainer.style.transition = "transform 222ms ease", n.imageContainer.style.transform = h;
|
|
131
131
|
};
|
|
132
132
|
if (i === "y") {
|
|
133
133
|
const h = e.y - t.y;
|
|
134
|
-
Math.abs(h) > 144 ? (
|
|
134
|
+
Math.abs(h) > 144 ? (n.imageContainer.style.transition = "transform 222ms ease", n.imageContainer.style.transform = "translateY(0vh)", n.close()) : a("translateY(0vh)");
|
|
135
135
|
}
|
|
136
|
-
if (i === "x" &&
|
|
136
|
+
if (i === "x" && s.state.elmLength > 1) {
|
|
137
137
|
const h = e.x - t.x;
|
|
138
|
-
|
|
138
|
+
n.imageContainer.style.transition = "", h > 64 ? n.prev() : h < -64 ? n.next() : a("translateX(0vw)");
|
|
139
139
|
}
|
|
140
140
|
i = null, t = { x: 0, y: 0 }, e = { x: 0, y: 0 };
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
});
|
|
144
144
|
}
|
|
145
|
-
function B(
|
|
146
|
-
const t =
|
|
147
|
-
|
|
145
|
+
function B(n) {
|
|
146
|
+
const t = n.options.preloads;
|
|
147
|
+
n.imageContainer.style.width = `${(t * 2 + 1) * 100}vw`, n.imageContainer.style.left = `-${t * 100}vw`, n.imageContainer.style.display = "flex";
|
|
148
148
|
}
|
|
149
|
-
function U(
|
|
149
|
+
function U(n) {
|
|
150
150
|
}
|
|
151
|
-
function X({ vistaView:
|
|
152
|
-
const { imageContainer: o, options: a } =
|
|
153
|
-
if (!(!t ||
|
|
151
|
+
function X({ vistaView: n, htmlElements: { to: t }, index: { from: e, to: i } }, s) {
|
|
152
|
+
const { imageContainer: o, options: a } = n, { isReducedMotion: h } = n.state;
|
|
153
|
+
if (!(!t || s.aborted || h || !(Math.abs(i - e) === 1 || e === 0 && i === n.state.elmLength - 1 || e === n.state.elmLength - 1 && i === 0)))
|
|
154
154
|
return {
|
|
155
155
|
cleanup: () => {
|
|
156
156
|
o.style.transition = "", o.style.transform = "";
|
|
@@ -165,25 +165,25 @@ function X({ vistaView: s, htmlElements: { to: t }, index: { from: e, to: i } },
|
|
|
165
165
|
), o.addEventListener(
|
|
166
166
|
"transitioncancel",
|
|
167
167
|
() => {
|
|
168
|
-
|
|
168
|
+
s.aborted && d();
|
|
169
169
|
},
|
|
170
170
|
{ once: !0 }
|
|
171
171
|
);
|
|
172
|
-
const p = Math.round(a.animationDurationBase * 100) / 100, u = i === e + 1 || e ===
|
|
172
|
+
const p = Math.round(a.animationDurationBase * 100) / 100, u = i === e + 1 || e === n.state.elmLength - 1 && i === 0 ? "translateX(-100vw)" : "translateX(100vw)";
|
|
173
173
|
o.style.transition = `transform ${p}ms ease`, o.style.transform = u;
|
|
174
174
|
})
|
|
175
175
|
};
|
|
176
176
|
}
|
|
177
|
-
function z(
|
|
178
|
-
const t = window.innerWidth, e = window.innerHeight, i =
|
|
179
|
-
if (!i || !
|
|
180
|
-
throw console.error("Error",
|
|
181
|
-
if (i < t &&
|
|
177
|
+
function z(n) {
|
|
178
|
+
const t = window.innerWidth, e = window.innerHeight, i = n.naturalWidth, s = n.naturalHeight;
|
|
179
|
+
if (!i || !s)
|
|
180
|
+
throw console.error("Error", n), new Error("Image natural dimensions are zero");
|
|
181
|
+
if (i < t && s < e)
|
|
182
182
|
return {
|
|
183
183
|
width: i,
|
|
184
|
-
height:
|
|
184
|
+
height: s
|
|
185
185
|
};
|
|
186
|
-
const o = i /
|
|
186
|
+
const o = i / s, a = t / e;
|
|
187
187
|
let h, l;
|
|
188
188
|
return o > a ? (h = t, l = t / o) : (l = e, h = e * o), {
|
|
189
189
|
width: h,
|
|
@@ -197,12 +197,12 @@ class Y extends T {
|
|
|
197
197
|
r(this, "rect", null);
|
|
198
198
|
r(this, "animateNormalizeTimeout", null);
|
|
199
199
|
const i = document.createElement("img");
|
|
200
|
-
i.alt = this.config.alt || "", i.classList.add("vvw-img-hi"), this.element = i, i.onerror = (
|
|
201
|
-
this.isLoadedRejected(
|
|
200
|
+
i.alt = this.config.alt || "", i.classList.add("vvw-img-hi"), this.element = i, i.onerror = (s) => {
|
|
201
|
+
this.isLoadedRejected(s);
|
|
202
202
|
}, i.src = this.config.src, i.decode().then(() => {
|
|
203
203
|
this.onLoad();
|
|
204
|
-
}).catch((
|
|
205
|
-
this.isLoadedRejected(
|
|
204
|
+
}).catch((s) => {
|
|
205
|
+
this.isLoadedRejected(s);
|
|
206
206
|
}), this.setSizes({
|
|
207
207
|
stableSize: !1,
|
|
208
208
|
initDimension: !0
|
|
@@ -212,20 +212,20 @@ class Y extends T {
|
|
|
212
212
|
super.onWidthChange(e);
|
|
213
213
|
const i = this.getFromParsedSrcSet(e);
|
|
214
214
|
if (i && this.element.src !== i) {
|
|
215
|
-
const
|
|
216
|
-
|
|
217
|
-
|
|
215
|
+
const s = new Image();
|
|
216
|
+
s.onload = () => {
|
|
217
|
+
s.decode().then(() => {
|
|
218
218
|
this.isCancelled || (this.element.src = i);
|
|
219
219
|
});
|
|
220
|
-
},
|
|
220
|
+
}, s.src = i;
|
|
221
221
|
}
|
|
222
222
|
}
|
|
223
223
|
onLoad() {
|
|
224
224
|
if (this.isCancelled) return;
|
|
225
225
|
const e = this.element;
|
|
226
226
|
e.width = e.naturalWidth, e.height = e.naturalHeight, this.maxW = e.naturalWidth * this.maxZoomLevel;
|
|
227
|
-
const { width: i, height:
|
|
228
|
-
this.fullH =
|
|
227
|
+
const { width: i, height: s } = z(e);
|
|
228
|
+
this.fullH = s, this.fullW = i, this.minW = this.fullW * 0.5, this.isLoadedResolved(!0);
|
|
229
229
|
}
|
|
230
230
|
getFullSizeDim() {
|
|
231
231
|
return z(this.element);
|
|
@@ -236,11 +236,11 @@ class Y extends T {
|
|
|
236
236
|
e.style.objectFit = "cover", e.style.borderRadius = "0";
|
|
237
237
|
}
|
|
238
238
|
// Used by: VistaImageEvent
|
|
239
|
-
scaleMove(e, i,
|
|
239
|
+
scaleMove(e, i, s = !1) {
|
|
240
240
|
if (!this.isReady || !this.element) return;
|
|
241
241
|
this.rect || (this.rect = this.element.getBoundingClientRect()), i || (i = this.initPointerCenter);
|
|
242
242
|
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;
|
|
243
|
-
|
|
243
|
+
s ? L.start({
|
|
244
244
|
vistaImage: this,
|
|
245
245
|
target: {
|
|
246
246
|
transform: {
|
|
@@ -278,13 +278,13 @@ class Y extends T {
|
|
|
278
278
|
return this.setFinalTransform(), () => {
|
|
279
279
|
};
|
|
280
280
|
if (Math.abs(e.x) < 0.1 && Math.abs(e.y) < 0.1) {
|
|
281
|
-
const
|
|
281
|
+
const s = this.element.getBoundingClientRect();
|
|
282
282
|
return L.start({
|
|
283
283
|
vistaImage: this,
|
|
284
284
|
target: {
|
|
285
285
|
transform: {
|
|
286
|
-
x:
|
|
287
|
-
y:
|
|
286
|
+
x: s.right < window.innerWidth / 2 ? this.state.transform.x + (window.innerWidth / 2 - s.right) : s.left > window.innerWidth / 2 ? this.state.transform.x - (s.left - window.innerWidth / 2) : this.state.transform.x,
|
|
287
|
+
y: s.bottom < window.innerHeight / 2 ? this.state.transform.y + (window.innerHeight / 2 - s.bottom) : s.top > window.innerHeight / 2 ? this.state.transform.y - (s.top - window.innerHeight / 2) : this.state.transform.y
|
|
288
288
|
}
|
|
289
289
|
},
|
|
290
290
|
onComplete: () => {
|
|
@@ -296,10 +296,10 @@ class Y extends T {
|
|
|
296
296
|
}
|
|
297
297
|
return requestAnimationFrame(() => {
|
|
298
298
|
if (!this.isThrowing) return this.momentumThrow({ x: 0, y: 0 });
|
|
299
|
-
const i = this.element,
|
|
300
|
-
|
|
299
|
+
const i = this.element, s = this.state.transform;
|
|
300
|
+
s.x += e.x, s.y += e.y;
|
|
301
301
|
const o = i.getBoundingClientRect();
|
|
302
|
-
|
|
302
|
+
s.x = s.x + e.x, s.y = s.y + e.y, o.right < window.innerWidth / 2 && (s.x += (window.innerWidth / 2 - o.right) * 0.1, e.x *= 0.7), o.left > window.innerWidth / 2 && (s.x -= (o.left - window.innerWidth / 2) * 0.1, e.x *= 0.7), o.bottom < window.innerHeight / 2 && (s.y += (window.innerHeight / 2 - o.bottom) * 0.1, e.y *= 0.7), o.top > window.innerHeight / 2 && (s.y -= (o.top - window.innerHeight / 2) * 0.1, e.y *= 0.7), this.state.transform = s, this.momentumThrow({
|
|
303
303
|
x: e.x * 0.9,
|
|
304
304
|
y: e.y * 0.9
|
|
305
305
|
});
|
|
@@ -335,8 +335,8 @@ class Y extends T {
|
|
|
335
335
|
this.animateNormalize();
|
|
336
336
|
else if (this.pos === 0) {
|
|
337
337
|
const i = this.toObject();
|
|
338
|
-
this.vistaView.options.onContentChange && this.vistaView.options.onContentChange(i, this.vistaView), this.vistaView.state.extensions.forEach((
|
|
339
|
-
|
|
338
|
+
this.vistaView.options.onContentChange && this.vistaView.options.onContentChange(i, this.vistaView), this.vistaView.state.extensions.forEach((s) => {
|
|
339
|
+
s.onContentChange && s.onContentChange(i, this.vistaView);
|
|
340
340
|
});
|
|
341
341
|
}
|
|
342
342
|
return {
|
|
@@ -378,42 +378,42 @@ class j {
|
|
|
378
378
|
r(this, "extensions", /* @__PURE__ */ new Set());
|
|
379
379
|
}
|
|
380
380
|
}
|
|
381
|
-
function P(
|
|
382
|
-
return
|
|
381
|
+
function P(n) {
|
|
382
|
+
return n && !/^0(px|%|r?em|vw|vh|vmin|vmax|cm|mm|in|pt|pc|ex|ch)?$/i.test(n.trim()) && n;
|
|
383
383
|
}
|
|
384
|
-
function _(
|
|
385
|
-
const t =
|
|
386
|
-
let o = "0px", a =
|
|
387
|
-
return i && P(i.borderRadius) ? o = i.borderRadius :
|
|
384
|
+
function _(n) {
|
|
385
|
+
const t = n instanceof HTMLAnchorElement ? n : null, e = n instanceof HTMLImageElement ? n : t == null ? void 0 : t.querySelector("img"), i = t ? getComputedStyle(t) : null, s = e ? getComputedStyle(e) : null;
|
|
386
|
+
let o = "0px", a = s ? s.objectFit : "contain";
|
|
387
|
+
return i && P(i.borderRadius) ? o = i.borderRadius : s && P(s.borderRadius) && (o = s.borderRadius), {
|
|
388
388
|
borderRadius: o,
|
|
389
389
|
objectFit: a
|
|
390
390
|
};
|
|
391
391
|
}
|
|
392
|
-
function K(
|
|
393
|
-
const t =
|
|
392
|
+
function K(n) {
|
|
393
|
+
const t = n.split(",").map((i) => i.trim()), e = [];
|
|
394
394
|
for (const i of t) {
|
|
395
|
-
const [
|
|
396
|
-
if (
|
|
395
|
+
const [s, o] = i.split(" ").map((a) => a.trim());
|
|
396
|
+
if (s && o && o.endsWith("w")) {
|
|
397
397
|
const a = parseInt(o.slice(0, -1), 10);
|
|
398
|
-
isNaN(a) || e.push({ src:
|
|
398
|
+
isNaN(a) || e.push({ src: s, width: a });
|
|
399
399
|
}
|
|
400
400
|
}
|
|
401
401
|
return e;
|
|
402
402
|
}
|
|
403
|
-
function G(
|
|
404
|
-
const t =
|
|
403
|
+
function G(n) {
|
|
404
|
+
const t = n instanceof HTMLImageElement ? n : n.querySelector("img"), e = n.dataset.vistaviewSrc || n.getAttribute("href") || n.getAttribute("src") || (t == null ? void 0 : t.getAttribute("src")) || "", i = n.dataset.vistaviewSrcset || n.getAttribute("srcset") || (t == null ? void 0 : t.getAttribute("srcset")) || "";
|
|
405
405
|
if (!e && !i)
|
|
406
|
-
throw console.error("VistaView Error:",
|
|
407
|
-
const
|
|
406
|
+
throw console.error("VistaView Error:", n), new Error("VistaView: Element must have href, src, or srcSet");
|
|
407
|
+
const s = i ? K(i) : void 0, o = _(n);
|
|
408
408
|
return {
|
|
409
409
|
config: {
|
|
410
410
|
src: e,
|
|
411
|
-
alt:
|
|
411
|
+
alt: n.dataset.vistaviewAlt || n.getAttribute("alt") || (t == null ? void 0 : t.getAttribute("alt")) || "",
|
|
412
412
|
srcSet: i || void 0
|
|
413
413
|
},
|
|
414
|
-
parsedSrcSet:
|
|
414
|
+
parsedSrcSet: s != null && s.length ? s : void 0,
|
|
415
415
|
origin: {
|
|
416
|
-
anchor:
|
|
416
|
+
anchor: n instanceof HTMLAnchorElement ? n : void 0,
|
|
417
417
|
image: t,
|
|
418
418
|
src: e,
|
|
419
419
|
srcSet: i,
|
|
@@ -474,13 +474,13 @@ class J {
|
|
|
474
474
|
if (e === -1) return;
|
|
475
475
|
const i = this.pointers[e];
|
|
476
476
|
i.x = t.clientX, i.y = t.clientY;
|
|
477
|
-
const
|
|
477
|
+
const s = this.pointers.length;
|
|
478
478
|
this.pointers.splice(e, 1), this.listeners.forEach(
|
|
479
479
|
(o) => o({
|
|
480
480
|
event: "up",
|
|
481
481
|
pointer: i,
|
|
482
482
|
pointers: this.pointers,
|
|
483
|
-
lastPointerLen:
|
|
483
|
+
lastPointerLen: s
|
|
484
484
|
})
|
|
485
485
|
);
|
|
486
486
|
});
|
|
@@ -492,13 +492,13 @@ class J {
|
|
|
492
492
|
if (e === -1) return;
|
|
493
493
|
const i = this.pointers[e];
|
|
494
494
|
i.x = t.clientX, i.y = t.clientY;
|
|
495
|
-
const
|
|
495
|
+
const s = this.pointers.length;
|
|
496
496
|
this.pointers.splice(e, 1), this.listeners.forEach(
|
|
497
497
|
(o) => o({
|
|
498
498
|
event: "cancel",
|
|
499
499
|
pointer: i,
|
|
500
500
|
pointers: this.pointers,
|
|
501
|
-
lastPointerLen:
|
|
501
|
+
lastPointerLen: s
|
|
502
502
|
})
|
|
503
503
|
);
|
|
504
504
|
});
|
|
@@ -517,8 +517,8 @@ class J {
|
|
|
517
517
|
this.listeners = this.listeners.filter((e) => e !== t);
|
|
518
518
|
}
|
|
519
519
|
getPointerDistance(t, e) {
|
|
520
|
-
const i = t.x - e.x,
|
|
521
|
-
return Math.sqrt(i * i +
|
|
520
|
+
const i = t.x - e.x, s = t.y - e.y;
|
|
521
|
+
return Math.sqrt(i * i + s * s);
|
|
522
522
|
}
|
|
523
523
|
getCentroid() {
|
|
524
524
|
if (this.pointers.length === 0) return null;
|
|
@@ -566,8 +566,8 @@ class Q {
|
|
|
566
566
|
e.scaleMove(1, i);
|
|
567
567
|
}
|
|
568
568
|
if (t.pointers.length >= 2 && this.pinchMode) {
|
|
569
|
-
const i = this.pointers.getCentroid(),
|
|
570
|
-
e.scaleMove(
|
|
569
|
+
const i = this.pointers.getCentroid(), s = this.pointers.getPointerDistance(t.pointers[0], t.pointers[1]);
|
|
570
|
+
e.scaleMove(s / this.lastDistance, i);
|
|
571
571
|
}
|
|
572
572
|
} else if ((t.event === "up" || t.event === "cancel") && (this.pinchMode || this.vvw.state.zoomedIn))
|
|
573
573
|
if (this.pinchMode) {
|
|
@@ -611,11 +611,11 @@ class Q {
|
|
|
611
611
|
});
|
|
612
612
|
r(this, "onScroll", (t) => {
|
|
613
613
|
t.preventDefault();
|
|
614
|
-
const e = this.vvw, i = this.vvw.state.children.images.find((o) => o.pos === 0),
|
|
614
|
+
const e = this.vvw, i = this.vvw.state.children.images.find((o) => o.pos === 0), s = t.deltaY;
|
|
615
615
|
i.setInitialCenter({
|
|
616
616
|
x: t.clientX,
|
|
617
617
|
y: t.clientY
|
|
618
|
-
}),
|
|
618
|
+
}), s < 0 ? e.zoomIn() : s > 0 && e.zoomOut();
|
|
619
619
|
});
|
|
620
620
|
r(this, "onResizeHandler", () => {
|
|
621
621
|
this.vvw.state.children.images.forEach((t) => {
|
|
@@ -658,8 +658,8 @@ class tt {
|
|
|
658
658
|
r(this, "root", null);
|
|
659
659
|
r(this, "onClickElements", (t) => {
|
|
660
660
|
t.preventDefault();
|
|
661
|
-
const e = t.currentTarget;
|
|
662
|
-
|
|
661
|
+
const e = this.qsOrigin(this.elements), i = Array.prototype.indexOf.call(e, t.currentTarget);
|
|
662
|
+
this.open(i);
|
|
663
663
|
});
|
|
664
664
|
r(this, "defaultOnClickHandler", (t) => t.preventDefault());
|
|
665
665
|
// ============================================================================
|
|
@@ -686,16 +686,16 @@ class tt {
|
|
|
686
686
|
...I.controls,
|
|
687
687
|
...e.controls
|
|
688
688
|
}
|
|
689
|
-
}, 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), (i = this.options.extensions) == null || i.forEach((
|
|
690
|
-
this.state.extensions.add(
|
|
689
|
+
}, 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), (i = this.options.extensions) == null || i.forEach((s) => {
|
|
690
|
+
this.state.extensions.add(s);
|
|
691
691
|
}), this.state.isReducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches, this.reset(), this.initFunction(this);
|
|
692
692
|
}
|
|
693
693
|
reset() {
|
|
694
694
|
if (typeof this.elements == "string") {
|
|
695
695
|
const t = this.qsOrigin(this.elements);
|
|
696
|
-
this.state.elmLength = t.length, t.forEach((e
|
|
697
|
-
const
|
|
698
|
-
|
|
696
|
+
this.state.elmLength = t.length, t.forEach((e) => {
|
|
697
|
+
const i = e;
|
|
698
|
+
i.removeEventListener("click", this.defaultOnClickHandler), i.removeEventListener("pointerup", this.onClickElements), i.addEventListener("click", this.defaultOnClickHandler), i.addEventListener("pointerup", this.onClickElements);
|
|
699
699
|
});
|
|
700
700
|
} else
|
|
701
701
|
this.state.elmLength = this.elements.length;
|
|
@@ -713,7 +713,7 @@ class tt {
|
|
|
713
713
|
this.externalPointerListener.push(t);
|
|
714
714
|
}
|
|
715
715
|
getChildElements(t, e) {
|
|
716
|
-
const i = [],
|
|
716
|
+
const i = [], s = [], o = typeof this.elements == "string" ? this.qsOrigin(this.elements) : this.elements;
|
|
717
717
|
for (let a = -t; a <= t; a++) {
|
|
718
718
|
const h = (e + a + o.length) % o.length, l = o[h], p = {
|
|
719
719
|
elm: l instanceof HTMLElement ? G(l) : { config: l, origin: void 0, parsedSrcSet: void 0 },
|
|
@@ -736,17 +736,17 @@ class tt {
|
|
|
736
736
|
!u && m.onInitializeImage && (u = m.onInitializeImage(p));
|
|
737
737
|
});
|
|
738
738
|
const v = u ?? new Y(p), f = document.createElement("div");
|
|
739
|
-
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),
|
|
739
|
+
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), s.push(f);
|
|
740
740
|
}
|
|
741
741
|
return {
|
|
742
|
-
htmls:
|
|
742
|
+
htmls: s,
|
|
743
743
|
images: i
|
|
744
744
|
};
|
|
745
745
|
}
|
|
746
746
|
async swap(t, e) {
|
|
747
747
|
var f, m;
|
|
748
748
|
this.reactivateUi();
|
|
749
|
-
const i = this.options.preloads || 0,
|
|
749
|
+
const i = this.options.preloads || 0, s = this.state.currentIndex, { htmls: o, images: a } = this.getChildElements(i, s), h = this.imageContainer, l = this.state.children, d = {
|
|
750
750
|
htmlElements: { from: l.htmls, to: o },
|
|
751
751
|
images: { from: l.images, to: a },
|
|
752
752
|
index: { from: t, to: this.state.currentIndex },
|
|
@@ -766,7 +766,7 @@ class tt {
|
|
|
766
766
|
g && (this.transitionCleanup = g.cleanup, await g.transitionEnded), this.lastSwapTime = performance.now(), v.forEach((w) => {
|
|
767
767
|
w.cancelPendingLoad();
|
|
768
768
|
});
|
|
769
|
-
const x = v.find((w) => w.index ===
|
|
769
|
+
const x = v.find((w) => w.index === s), b = x ? L.stop(x) : void 0, C = a.find((w) => w.index === s);
|
|
770
770
|
C && x && C.cloneStyleFrom(x, b), v.forEach((w) => {
|
|
771
771
|
w.destroy();
|
|
772
772
|
});
|
|
@@ -789,18 +789,18 @@ class tt {
|
|
|
789
789
|
typeof this.elements == "string" && this.qsOrigin(this.elements).forEach((a, h) => {
|
|
790
790
|
a.style.opacity = "", h === t && (a.style.opacity = "0");
|
|
791
791
|
});
|
|
792
|
-
const e = this.qs(".vvw-index"), i = `${t + 1}`,
|
|
793
|
-
e && (e.textContent = `${i} / ${
|
|
792
|
+
const e = this.qs(".vvw-index"), i = `${t + 1}`, s = `${this.state.elmLength}`;
|
|
793
|
+
e && (e.textContent = `${i} / ${s}`);
|
|
794
794
|
const o = this.qs(".vvw-desc");
|
|
795
795
|
if (o) {
|
|
796
796
|
const a = this.state.children.images.find((l) => l.index === t), h = (a == null ? void 0 : a.config.alt) || "";
|
|
797
|
-
h ? (o.textContent = h, o.setAttribute("aria-label", `Image ${i} of ${
|
|
797
|
+
h ? (o.textContent = h, o.setAttribute("aria-label", `Image ${i} of ${s}: ${h}`), o.style.opacity = "") : (o.textContent = "", o.setAttribute("aria-label", `Image ${i} of ${s}`), o.style.opacity = "0");
|
|
798
798
|
}
|
|
799
799
|
}
|
|
800
800
|
deactivateUi(t, e) {
|
|
801
801
|
t.forEach((i) => {
|
|
802
|
-
var
|
|
803
|
-
i === "zoomIn" ? (
|
|
802
|
+
var s, o;
|
|
803
|
+
i === "zoomIn" ? (s = this.qs(".vvw-zoom-in")) == null || s.setAttribute("disabled", "true") : i === "zoomOut" && ((o = this.qs(".vvw-zoom-out")) == null || o.setAttribute("disabled", "true")), this.tempDeactivatedUi.push(i);
|
|
804
804
|
}), this.tempDeactivationRequestBy = e || null, this.state.extensions.forEach((i) => {
|
|
805
805
|
i.onDeactivateUi && i.onDeactivateUi(t, this.tempDeactivationRequestBy, this);
|
|
806
806
|
});
|
|
@@ -833,7 +833,7 @@ class tt {
|
|
|
833
833
|
if (document.body.append(e), this.root = document.body.querySelector("#vvw-root"), !this.root)
|
|
834
834
|
throw new Error("Failed to setup VistaView root element.");
|
|
835
835
|
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");
|
|
836
|
-
const i = this.options.preloads || 0,
|
|
836
|
+
const i = this.options.preloads || 0, s = t, { images: o, htmls: a } = this.getChildElements(i, s), h = {
|
|
837
837
|
htmlElements: { from: null, to: a },
|
|
838
838
|
images: { from: null, to: o },
|
|
839
839
|
index: { from: null, to: this.state.currentIndex },
|
|
@@ -867,13 +867,13 @@ class tt {
|
|
|
867
867
|
y.somethingOpened === this && this.root && (this.eventHandlers.stop(), this.eventHandlers = null, this.state.children.images.forEach((e) => {
|
|
868
868
|
e.prepareClose();
|
|
869
869
|
}), t ? await new Promise((e) => {
|
|
870
|
-
let
|
|
870
|
+
let s = 0;
|
|
871
871
|
this.root.addEventListener("transitionend", (o) => {
|
|
872
|
-
o.target === this.root && (
|
|
872
|
+
o.target === this.root && (s++, s === 2 && typeof this.elements == "string" && (this.state.children.images.forEach((a) => {
|
|
873
873
|
a.destroy();
|
|
874
874
|
}), this.qsOrigin(this.elements).forEach((a) => {
|
|
875
875
|
a.style.opacity = "";
|
|
876
|
-
})),
|
|
876
|
+
})), s === 3 && e(null));
|
|
877
877
|
}), this.root.classList.add("vvw--closing");
|
|
878
878
|
}) : typeof this.elements == "string" && (this.state.children.images.forEach((e) => {
|
|
879
879
|
e.destroy();
|
|
@@ -920,8 +920,8 @@ class tt {
|
|
|
920
920
|
(t < 0 || t >= this.state.elmLength) && (t = (t % this.state.elmLength + this.state.elmLength) % this.state.elmLength);
|
|
921
921
|
const i = this.state.currentIndex;
|
|
922
922
|
this.state.currentIndex = t;
|
|
923
|
-
const
|
|
924
|
-
|
|
923
|
+
const s = this.state.abortController;
|
|
924
|
+
s == null || s.abort(), this.state.abortController = new AbortController(), this.swap(i, e);
|
|
925
925
|
}
|
|
926
926
|
zoomIn() {
|
|
927
927
|
if (y.somethingOpened !== this) {
|
|
@@ -955,35 +955,35 @@ class tt {
|
|
|
955
955
|
return this.state.currentIndex;
|
|
956
956
|
}
|
|
957
957
|
}
|
|
958
|
-
function et(
|
|
958
|
+
function et(n) {
|
|
959
959
|
let t = null;
|
|
960
|
-
if (typeof
|
|
961
|
-
if (t = document.querySelectorAll(
|
|
960
|
+
if (typeof n == "string") {
|
|
961
|
+
if (t = document.querySelectorAll(n), t.length === 0)
|
|
962
962
|
return new Error("No elements found in node list.").toString();
|
|
963
963
|
for (let e = 0; e < t.length; e++) {
|
|
964
|
-
const i = t[e],
|
|
965
|
-
if (
|
|
966
|
-
return new Error(`Invalid element at index ${e}: expected <img>, <a>, got <${
|
|
967
|
-
if (
|
|
964
|
+
const i = t[e], s = i.tagName.toLowerCase();
|
|
965
|
+
if (s !== "img" && s !== "a")
|
|
966
|
+
return new Error(`Invalid element at index ${e}: expected <img>, <a>, got <${s}>`);
|
|
967
|
+
if (s === "a" && !(i.querySelector("img") !== null))
|
|
968
968
|
return new Error(`Invalid <a> element at index ${e}: must contain <img>`);
|
|
969
969
|
}
|
|
970
970
|
} else {
|
|
971
|
-
const e =
|
|
971
|
+
const e = n;
|
|
972
972
|
for (let i = 0; i < e.length; i++)
|
|
973
973
|
if (!e[i].src)
|
|
974
974
|
return new Error(`Invalid image data at index ${i}: must have 'src'`);
|
|
975
975
|
}
|
|
976
|
-
return
|
|
976
|
+
return n;
|
|
977
977
|
}
|
|
978
|
-
function st({ elements:
|
|
979
|
-
if (!
|
|
980
|
-
return console.error(
|
|
981
|
-
let e = et(
|
|
978
|
+
function st({ elements: n, ...t }) {
|
|
979
|
+
if (!n)
|
|
980
|
+
return console.error(n), console.error("no elements provided"), console.warn("VistaView: silently returning."), null;
|
|
981
|
+
let e = et(n);
|
|
982
982
|
if (e instanceof Error)
|
|
983
983
|
return console.error(e), console.warn("VistaView: silently returning."), null;
|
|
984
984
|
const i = new tt(e, t);
|
|
985
985
|
return {
|
|
986
|
-
open: (
|
|
986
|
+
open: (s = 0) => i.open(s),
|
|
987
987
|
reset: () => i.reset(),
|
|
988
988
|
close: () => i.close(),
|
|
989
989
|
next: () => i.next(),
|
|
@@ -992,8 +992,8 @@ function st({ elements: s, ...t }) {
|
|
|
992
992
|
zoomOut: () => i.zoomOut(),
|
|
993
993
|
destroy: () => i.destroy(),
|
|
994
994
|
getCurrentIndex: () => i.getCurrentIndex(),
|
|
995
|
-
view: (
|
|
996
|
-
i.view(
|
|
995
|
+
view: (s) => {
|
|
996
|
+
i.view(s);
|
|
997
997
|
}
|
|
998
998
|
};
|
|
999
999
|
}
|
package/dist/vistaview.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(d,y){typeof exports=="object"&&typeof module<"u"?y(exports):typeof define=="function"&&define.amd?define(["exports"],y):(d=typeof globalThis<"u"?globalThis:d||self,y(d.VistaView=d.VistaView||{}))})(this,(function(d){"use strict";var nt=Object.defineProperty;var st=(d,y,I)=>y in d?nt(d,y,{enumerable:!0,configurable:!0,writable:!0,value:I}):d[y]=I;var a=(d,y,I)=>st(d,typeof y!="symbol"?y+"":y,I);const y={animationDurationBase:333,maxZoomLevel:2,preloads:1,keyboardListeners:!0,arrowOnSmallScreens:!1,rapidLimit:222,controls:{topLeft:["indexDisplay"],topRight:["zoomIn","zoomOut","close"],bottomLeft:["description"]}},I='<svg viewBox="0 0 24 24"><path d="m15 18-6-6 6-6"/></svg>',k='<svg viewBox="0 0 24 24"><path d="m9 18 6-6-6-6"/></svg>',j='<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>',B='<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>';let P=null;function Z(){return P||(window.trustedTypes||(window.trustedTypes={createPolicy:(s,t)=>t}),P=window.trustedTypes.createPolicy("vistaView-policy",{createHTML:s=>s,createScript:()=>{throw new Error("Not implemented")},createScriptURL:()=>{throw new Error("Not implemented")}}),P)}function U(s){const e=Z().createHTML(s),i=document.createElement("template");i.innerHTML=e;const n=i.content;return i.remove(),n}function X(s,t){if(typeof s=="string")switch(s){case"zoomIn":return`<div class="vvw-ui"><button aria-label="Zoom In" class="vvw-zoom-in">${j}</button></div>`;case"zoomOut":return`<div class="vvw-ui"><button aria-label="Zoom Out" disabled class="vvw-zoom-out">${N}</button></div>`;case"close":return`<div class="vvw-ui"><button aria-label="Close" class="vvw-close">${B}</button></div>`;case"indexDisplay":return'<div class="vvw-index vvw-ui" aria-hidden="true"></div>';case"description":return'<div class="vvw-desc vvw-ui" role="status" aria-live="polite" aria-atomic="true"></div>';default:const e=t[s];return e&&e.control?`<div class="vvw-ext vvw-ui" aria-label="${e.description||e.name}" data-vvw-control="${e.name}"></div>`:(console.warn(`Unknown control: ${s}. Will return empty string.`),"")}return""}function Y({controls:s,extensions:t}){const e={};t.forEach(o=>{e[o.name]=o});const i=o=>o?o.map(r=>X(r,e)).join(""):"",n=U(`<div class="vvw-root" id="vvw-root">
|
|
2
2
|
<div class="vvw-container">
|
|
3
3
|
<div class="vvw-bg"></div>
|
|
4
4
|
<div class="vvw-image-container"></div>
|
|
@@ -15,4 +15,4 @@
|
|
|
15
15
|
<div class="vvw-prev vvw-ui"><button aria-label="Previous">${I}</button></div>
|
|
16
16
|
<div class="vvw-next vvw-ui"><button aria-label="Next">${k}</button></div>
|
|
17
17
|
</div>
|
|
18
|
-
</div>`);return[...(s==null?void 0:s.topLeft)||[],...(s==null?void 0:s.topCenter)||[],...(s==null?void 0:s.topRight)||[],...(s==null?void 0:s.bottomLeft)||[],...(s==null?void 0:s.bottomCenter)||[],...(s==null?void 0:s.bottomRight)||[]].forEach(o=>{const r=e[o];if(r&&r.control){const l=n.querySelector(`[data-vvw-control="${r.name}"]`),h=r.control();l&&h&&l.appendChild(h)}}),n}function z(s){}function W(s){K(s)}function K(s){let t={x:0,y:0},e={x:0,y:0},i=null;s.registerPointerListener(n=>{var o;if(!n.hasInternalExecution&&!(n.pointers.length>1)){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"){e={x:n.pointer.x,y:n.pointer.y};const r=e.x-t.x,l=e.y-t.y;if(!i&&Math.abs(l)>Math.abs(r)||i==="y"){const h=l/window.innerHeight*100;s.imageContainer.style.transition="none",s.imageContainer.style.transform=`translateY(${h}vh)`,i="y"}else if(!i&&Math.abs(r)>Math.abs(l)||i==="x"&&n.state.elmLength>1){const h=r/window.innerWidth*100;s.imageContainer.style.transition="none",s.imageContainer.style.transform=`translateX(${h}vw)`,i="x"}}if(n.event==="up"||n.event==="cancel"){let r=function(l){var h;(h=s.imageContainer)==null||h.addEventListener("transitionend",function f(){var d;(d=s.imageContainer)==null||d.removeEventListener("transitionend",f),s.imageContainer.style.transition="",s.imageContainer.style.transform=""}),s.imageContainer.style.transition="transform 222ms ease",s.imageContainer.style.transform=l};if(i==="y"){const l=e.y-t.y;Math.abs(l)>144?(s.imageContainer.style.transition="transform 222ms ease",s.imageContainer.style.transform="translateY(0vh)",s.close()):r("translateY(0vh)")}if(i==="x"&&n.state.elmLength>1){const l=e.x-t.x;s.imageContainer.style.transition="",l>64?s.prev():l<-64?s.next():r("translateX(0vw)")}i=null,t={x:0,y:0},e={x:0,y:0}}}})}function R(s){const t=s.options.preloads;s.imageContainer.style.width=`${(t*2+1)*100}vw`,s.imageContainer.style.left=`-${t*100}vw`,s.imageContainer.style.display="flex"}function T(s){}function H({vistaView:s,htmlElements:{to:t},index:{from:e,to:i}},n){const{imageContainer:o,options:r}=s,{isReducedMotion:l}=s.state;if(!(!t||n.aborted||l||!(Math.abs(i-e)===1||e===0&&i===s.state.elmLength-1||e===s.state.elmLength-1&&i===0)))return{cleanup:()=>{o.style.transition="",o.style.transform=""},transitionEnded:new Promise(f=>{o.addEventListener("transitionend",()=>{f()},{once:!0}),o.addEventListener("transitioncancel",()=>{n.aborted&&f()},{once:!0});const d=Math.round(r.animationDurationBase*100)/100,u=i===e+1||e===s.state.elmLength-1&&i===0?"translateX(-100vw)":"translateX(100vw)";o.style.transition=`transform ${d}ms ease`,o.style.transform=u})}}function D(s){const t=window.innerWidth,e=window.innerHeight,i=s.naturalWidth,n=s.naturalHeight;if(!i||!n)throw console.error("Error",s),new Error("Image natural dimensions are zero");if(i<t&&n<e)return{width:i,height:n};const o=i/n,r=t/e;let l,h;return o>r?(l=t,h=t/o):(h=e,l=e*o),{width:l,height:h}}class x{static ease(t,e,i){const n=e-t,o=t+n*.2;return Math.abs(n)<i?e:o}static play(t,e,i){if(i()){requestAnimationFrame(()=>{this.play(t,e,i)});return}this.map.get(t)&&(t.element.classList.contains("vvw--load-cancelled")||requestAnimationFrame(()=>{var d,u,v,p,g,m,w,b,E,S;const n=this.map.get(t);if(!n||!t.element||t.element.classList.contains("vvw--load-cancelled"))return;const{current:o,target:r,log:l}=n;let h={};r.width!==void 0&&(h.width=this.ease(o._width,r.width,1)),r.height!==void 0&&(h.height=this.ease(o._height,r.height,1)),((d=r.transform)==null?void 0:d.x)!==void 0&&(h.transform=h.transform||{},h.transform.x=this.ease(o._transform.x,r.transform.x,1)),((u=r.transform)==null?void 0:u.y)!==void 0&&(h.transform=h.transform||{},h.transform.y=this.ease(o._transform.y,r.transform.y,1)),((v=r.transform)==null?void 0:v.scale)!==void 0&&(h.transform=h.transform||{},h.transform.scale=this.ease(o._transform.scale,r.transform.scale,.005)),((p=r.translate)==null?void 0:p.x)!==void 0&&(h.translate=h.translate||{},h.translate.x=this.ease(o._translate.x,r.translate.x,1)),((g=r.translate)==null?void 0:g.y)!==void 0&&(h.translate=h.translate||{},h.translate.y=this.ease(o._translate.y,r.translate.y,1)),h.width!==void 0&&(o.width=h.width),h.height!==void 0&&(o.height=h.height),h.translate&&(o.translate={...o.translate,...h.translate}),h.transform&&(o.transform={...o.transform,...h.transform}),(r.width===void 0||o._width===r.width)&&(r.height===void 0||o._height===r.height)&&(((m=r.transform)==null?void 0:m.x)===void 0||o._transform.x===r.transform.x)&&(((w=r.transform)==null?void 0:w.y)===void 0||o._transform.y===r.transform.y)&&(((b=r.transform)==null?void 0:b.scale)===void 0||o._transform.scale===r.transform.scale)&&(((E=r.translate)==null?void 0:E.x)===void 0||o._translate.x===r.translate.x)&&(((S=r.translate)==null?void 0:S.y)===void 0||o._translate.y===r.translate.y)?(this.map.delete(t),e()):(this.map.set(t,{current:o,target:r,log:l}),this.play(t,e,i))}))}static stop(t){const e=this.map.get(t);return this.map.delete(t),e}static start({vistaImage:t,target:e,onComplete:i,shouldWait:n}){this.stop(t),this.map.set(t,{current:t.state,target:e}),this.play(t,i,n)}}a(x,"map",new Map);function M(s){const e=window.getComputedStyle(s).objectFit||"",{width:i,height:n}=s.getBoundingClientRect(),o=s.naturalWidth,r=s.naturalHeight;if(!e)return{width:i,height:n};if(!o||!r)return{width:i,height:n};const l=o/r,h=i/n;switch(e){case"fill":return{width:i,height:n};case"none":return{width:o,height:r};case"contain":return l>h?{width:i,height:i/l}:{width:n*l,height:n};case"cover":return l<h?{width:i,height:i/l}:{width:n*l,height:n};case"scale-down":{const f={width:o,height:r},d=l>h?{width:i,height:i/l}:{width:n*l,height:n};return d.width<=f.width&&d.height<=f.height?d:f}}return{width:i,height:n}}class F{constructor(t){a(this,"state");a(this,"parsedSrcSet");a(this,"isReady",!1);a(this,"isThrowing",!1);a(this,"thumb",null);a(this,"pos");a(this,"index");a(this,"config");a(this,"origin");a(this,"initH",0);a(this,"initW",0);a(this,"fullH",0);a(this,"fullW",0);a(this,"maxW",0);a(this,"minW",0);a(this,"defaultWH",200);a(this,"isZoomedIn",!1);a(this,"isCancelled",!1);a(this,"isLoadedResolved",null);a(this,"isLoadedRejected",null);a(this,"isLoaded",new Promise((t,e)=>{this.isLoadedResolved=t,this.isLoadedRejected=e}));a(this,"replacement",null);a(this,"originalParent",null);a(this,"originalNextSibling",null);a(this,"originalStyle","");a(this,"thumbImage",null);a(this,"fittedSize",null);a(this,"maxZoomLevel");a(this,"vistaView");a(this,"transitionState",null);a(this,"transitionShouldWait",()=>!1);a(this,"initPointerCenter",{x:0,y:0});a(this,"onScale");var i;this.state=this.createState(),this.pos=t.pos,this.index=t.index,this.config=t.elm.config,this.parsedSrcSet=t.elm.parsedSrcSet,this.origin=t.elm.origin,this.maxZoomLevel=t.maxZoomLevel,this.vistaView=t.vistaView,this.onScale=t.onScale,t.transitionState&&(this.transitionState=t.transitionState),t.transitionShouldWait&&(this.transitionShouldWait=t.transitionShouldWait),this.initPointerCenter={x:window.innerWidth/2,y:window.innerHeight/2};const e=this.pos===0?(i=this.origin)==null?void 0:i.image:null;if(this.originalParent=(e==null?void 0:e.parentElement)||null,this.originalNextSibling=(e==null?void 0:e.nextSibling)||null,e&&this.originalParent){this.originalStyle=e.style.cssText,this.thumbImage=e;const n=e.cloneNode(!0);this.originalParent.insertBefore(n,e),this.replacement=n,this.thumb=document.createElement("div"),this.thumb.classList.add("vvw-img-lo");const{width:o,height:r}=this.thumbImage?M(this.thumbImage):{width:0,height:0};this.fittedSize={width:o,height:r},this.thumb.appendChild(e),e.style.width="100%",e.style.height="100%",e.style.objectFit=this.origin.objectFit}}createState(){const t=this;return{_t:this,_width:0,_height:0,_transform:{x:0,y:0,scale:1},_translate:{x:0,y:0},_lessThanMinWidth:!1,get width(){return this._width},set width(e){this._width=e,t.onWidthChange(e)},get height(){return this._height},set height(e){this._height=e,t.onHeightChange(e)},get transform(){return this._transform},set transform(e){this._transform=e,t.onTransformChange(e)},get translate(){return this._translate},set translate(e){this._translate=e,t.onTranslateChange(e)},get lessThanMinWidth(){return this._lessThanMinWidth},set lessThanMinWidth(e){this._lessThanMinWidth=e,t.onLessThanMinWidthChange(e)}}}onLessThanMinWidthChange(t){t?this.element.style.opacity="0.5":this.element.style.opacity=""}onTranslateChange(t){this.element.style.translate=`calc(-50% + ${t.x}px) calc(-50% + ${t.y}px)`}onTransformChange(t){const e=`translate3d(${t.x}px, ${t.y}px, 0px) scale3d(${t.scale}, ${t.scale}, 1)`;this.element.style.transform=e}onWidthChange(t){this.element.style.width=`${t}px`}onHeightChange(t){this.element.style.height=`${t}px`}onImageReady(){}animateZoom(t,e){}scaleMove(t,e,i){}momentumThrow(t){return()=>{}}async init(){await this.isLoaded;const t=this.element;this.transitionState&&this.transitionState.current.width&&this.transitionState.current.height?(this.state.width=this.transitionState.current.width,this.state.height=this.transitionState.current.height):t.classList.contains("vvw--loaded")||(this.state.width=this.initW,this.state.height=this.initH);const e=()=>{this.isCancelled||x.start({vistaImage:this,target:{width:this.fullW,height:this.fullH},onComplete:()=>{this.isCancelled||(this.isReady=!0,t.classList.add("vvw--ready"),this.onImageReady())},shouldWait:this.transitionShouldWait})};this.pos<-1||this.pos>1?(this.state.width=this.fullW,this.state.height=this.fullH,t.classList.add("vvw--loaded"),t.classList.add("vvw--ready"),this.isReady=!0):t.classList.contains("vvw--loaded")?t.classList.contains("vvw--ready")?(this.isReady=!0,this.onImageReady()):e():(t.classList.add("vvw--loaded"),setTimeout(()=>{this.isCancelled||e()},333))}getFullSizeDim(){const{width:t,height:e}=this.thumb.getBoundingClientRect(),i=t/e;let n=window.innerWidth,o=window.innerHeight;return i>window.innerWidth/window.innerHeight?o=n/i:n=o*i,{width:n,height:o}}setSizes(t={}){var l,h,f;const{stableSize:e=!0,initDimension:i}=t;if(!this.origin)return;const n=this.thumb;let o={width:this.defaultWH,height:this.defaultWH,top:0,left:0};if(n){o=(((l=this.origin)==null?void 0:l.anchor)||this.replacement).getBoundingClientRect();const d=n.style;d.width=o.width+"px",d.height=o.height+"px",d.top="50%",d.left="50%",d.translate="-50% -50%",d.position="fixed",d.objectFit=this.origin.objectFit,d.borderRadius=this.origin.borderRadius;const u=Math.min(Math.max(o.left,-o.width),window.innerWidth+o.width)-window.innerWidth/2+o.width/2,v=Math.min(Math.max(o.top,-o.height),window.innerHeight+o.height)-window.innerHeight/2+o.height/2;d.setProperty("--vvw-init-radius",d.borderRadius),d.setProperty("--vvw-pulse-radius",`calc(1.3 * ${d.borderRadius})`),d.setProperty("--vvw-init-x",`${u}px`),d.setProperty("--vvw-init-y",`${v}px`),i&&(d.setProperty("--vvw-current-x",`${u}px`),d.setProperty("--vvw-current-y",`${v}px`))}if(!i){const{width:d,height:u}=this.thumbImage?M(this.thumbImage):{width:0,height:0};this.fittedSize={width:d,height:u}}const r=this.element;if(this.initW=Math.min(((h=this.fittedSize)==null?void 0:h.width)??0,o.width),this.initH=Math.min(((f=this.fittedSize)==null?void 0:f.height)??0,o.height),r.style.setProperty("--vvw-init-w",this.initW+"px"),r.style.setProperty("--vvw-init-h",this.initH+"px"),r.style.setProperty("--vvw-init-radius",this.origin.borderRadius),r.style.objectFit="cover",!i){if(this.isReady&&!this.isCancelled){const{width:d,height:u}=this.getFullSizeDim();this.fullH=u,this.fullW=d,this.minW=this.fullW*.5}!this.isZoomedIn&&e&&this.normalize()}}normalize(){this.state.transform={x:0,y:0,scale:1},this.state.translate={x:0,y:0},this.state.width=this.fullW,this.state.height=this.fullH,this.isZoomedIn=!1}getFromParsedSrcSet(t){if(!this.parsedSrcSet||this.parsedSrcSet.length===0)return null;const e=t*(window.devicePixelRatio||1);let i=this.parsedSrcSet[this.parsedSrcSet.length-1];for(const n of this.parsedSrcSet)if(n.width>=e){i=n;break}return i.src}prepareClose(){x.stop(this),this.setFinalTransform()}cancelPendingLoad(){var t;this.isCancelled=!0,(t=this.element)==null||t.classList.add("vvw--load-cancelled")}setInitialCenter(t){this.initPointerCenter=t}destroy(){var t,e;this.originalParent&&this.thumbImage&&(this.thumbImage.style.cssText=this.originalStyle,this.originalNextSibling?this.originalParent.insertBefore(this.thumbImage,this.originalNextSibling):this.originalParent.appendChild(this.thumbImage)),this.originalParent=null,this.originalNextSibling=null,this.originalStyle="",this.thumbImage=null,this.replacement&&(this.replacement.remove(),this.replacement=null),(t=this.thumb)==null||t.remove(),(e=this.element)==null||e.remove(),this.thumb=null,this.origin=void 0,this.config={src:"",alt:""}}cloneStyleFrom(t,e){t!=null&&t.element&&(e&&(this.transitionState=e||null),t.element.classList.contains("vvw--loaded")&&(this.element.classList.add("vvw--loaded"),this.state.width=t.state.width,this.state.height=t.state.height),t.element.classList.contains("vvw--ready")&&this.element.classList.add("vvw--ready"))}toObject(){return structuredClone({config:{src:this.config.src,alt:this.config.alt,srcSet:this.config.srcSet},origin:this.origin?{src:this.origin.src,srcSet:this.origin.srcSet,borderRadius:this.origin.borderRadius,objectFit:this.origin.objectFit}:null,parsedSrcSet:this.parsedSrcSet,element:"src"in this.element?this.element.src:this.element.toString(),thumb:void 0,index:this.index,pos:this.pos,state:{width:this.state._width,height:this.state._height,transform:this.state._transform,translate:this.state._translate}})}setFinalTransform(t={}){const{propagateEvent:e=!0}=t;if(this.isReady){if(this.state.translate.x+=this.state.transform.x,this.state.translate.y+=this.state.transform.y,this.state.width*=this.state.transform.scale,this.state.height*=this.state.transform.scale,Math.abs(this.state.width-this.fullW)<1&&(this.state.width=this.fullW,this.state.height=this.fullH),Math.abs(this.state.translate.x)<1&&(this.state.translate.x=0),Math.abs(this.state.translate.y)<1&&(this.state.translate.y=0),this.state.translate={...this.state.translate},this.state.transform={x:0,y:0,scale:1},e){const i=this.toObject();this.vistaView.options.onContentChange&&this.vistaView.options.onContentChange(i,this.vistaView),this.vistaView.state.extensions.forEach(n=>{n.onContentChange&&n.onContentChange(i,this.vistaView)})}return{close:!0,cancel:()=>{}}}}}class O extends F{constructor(e){super(e);a(this,"element");a(this,"rect",null);a(this,"animateNormalizeTimeout",null);const i=document.createElement("img");i.alt=this.config.alt||"",i.classList.add("vvw-img-hi"),this.element=i,i.onerror=n=>{this.isLoadedRejected(n)},i.src=this.config.src,i.decode().then(()=>{this.onLoad()}).catch(n=>{this.isLoadedRejected(n)}),this.setSizes({stableSize:!1,initDimension:!0})}onWidthChange(e){super.onWidthChange(e);const i=this.getFromParsedSrcSet(e);if(i&&this.element.src!==i){const n=new Image;n.onload=()=>{n.decode().then(()=>{this.isCancelled||(this.element.src=i)})},n.src=i}}onLoad(){if(this.isCancelled)return;const e=this.element;e.width=e.naturalWidth,e.height=e.naturalHeight,this.maxW=e.naturalWidth*this.maxZoomLevel;const{width:i,height:n}=D(e);this.fullH=n,this.fullW=i,this.minW=this.fullW*.5,this.isLoadedResolved(!0)}getFullSizeDim(){return D(this.element)}normalize(){super.normalize();const e=this.element;e.style.objectFit="cover",e.style.borderRadius="0"}scaleMove(e,i,n=!1){if(!this.isReady||!this.element)return;this.rect||(this.rect=this.element.getBoundingClientRect()),i||(i=this.initPointerCenter);const o=this.rect.left+this.rect.width/2,r=this.rect.top+this.rect.height/2,l=this.initPointerCenter.x-o,h=this.initPointerCenter.y-r,f=l*(1-e),d=h*(1-e),u=i.x-this.initPointerCenter.x,v=i.y-this.initPointerCenter.y;n?x.start({vistaImage:this,target:{transform:{x:f+u,y:d+v,scale:e}},onComplete:()=>{this.setFinalTransform()},shouldWait:()=>!1}):this.state.transform={x:f+u,y:d+v,scale:e};const g=this.element.getBoundingClientRect().width*e;this.isZoomedIn=g>this.fullW,this.state.lessThanMinWidth=g<=this.minW,this.onScale({vistaImage:this,scale:g/this.fullW,isMax:g>=this.maxW,isMin:g<=this.fullW})}animateZoom(e,i){this.state.width*e<this.minW||this.scaleMove(e,i,!0)}momentumThrow(e){if(!this.isReady)return()=>{};if(!this.isThrowing)return this.setFinalTransform(),()=>{};if(Math.abs(e.x)<.1&&Math.abs(e.y)<.1){const n=this.element.getBoundingClientRect();return x.start({vistaImage:this,target:{transform:{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,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}},onComplete:()=>{this.isThrowing=!1,this.setFinalTransform()},shouldWait:()=>!1}),()=>{}}return requestAnimationFrame(()=>{if(!this.isThrowing)return this.momentumThrow({x:0,y:0});const i=this.element,n=this.state.transform;n.x+=e.x,n.y+=e.y;const o=i.getBoundingClientRect();n.x=n.x+e.x,n.y=n.y+e.y,o.right<window.innerWidth/2&&(n.x+=(window.innerWidth/2-o.right)*.1,e.x*=.7),o.left>window.innerWidth/2&&(n.x-=(o.left-window.innerWidth/2)*.1,e.x*=.7),o.bottom<window.innerHeight/2&&(n.y+=(window.innerHeight/2-o.bottom)*.1,e.y*=.7),o.top>window.innerHeight/2&&(n.y-=(o.top-window.innerHeight/2)*.1,e.y*=.7),this.state.transform=n,this.momentumThrow({x:e.x*.9,y:e.y*.9})}),()=>{x.stop(this),this.isThrowing=!1,this.setFinalTransform()}}animateNormalize(){this.animateNormalizeTimeout&&clearTimeout(this.animateNormalizeTimeout),this.animateNormalizeTimeout=setTimeout(()=>{x.start({vistaImage:this,target:{width:this.fullW,height:this.fullH,translate:{x:0,y:0},transform:{x:0,y:0,scale:1}},onComplete:()=>{this.setFinalTransform()},shouldWait:()=>!1})},50)}setFinalTransform(){if(!this.isReady)return;this.rect=null,super.setFinalTransform({propagateEvent:!1});const e=this.state.width<=this.minW;if(this.state.width>this.maxW)this.animateZoom(this.maxW/this.state.width);else if(!e&&this.state.width<this.fullW)this.animateNormalize();else if(this.pos===0){const i=this.toObject();this.vistaView.options.onContentChange&&this.vistaView.options.onContentChange(i,this.vistaView),this.vistaView.state.extensions.forEach(n=>{n.onContentChange&&n.onContentChange(i,this.vistaView)})}return{close:e,cancel:()=>x.stop(this)}}}class G{constructor(){a(this,"fiolast",{})}fio(t,e,i=50){const o=Date.now()-(this.fiolast[e]??0),r=()=>{this.fiolast[e]=Date.now(),t()};if(!this.fiolast[e]){r();return}o>=i&&r()}}class ${constructor(){a(this,"open",!1);a(this,"settled",!1);a(this,"closing",!1);a(this,"zoomedIn",!1);a(this,"children",{htmls:[],images:[]});a(this,"currentIndex",-1);a(this,"elmLength",0);a(this,"abortController",new AbortController);a(this,"isReducedMotion",!1);a(this,"extensions",new Set)}}function q(s){return s&&!/^0(px|%|r?em|vw|vh|vmin|vmax|cm|mm|in|pt|pc|ex|ch)?$/i.test(s.trim())&&s}function J(s){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;let o="0px",r=n?n.objectFit:"contain";return i&&q(i.borderRadius)?o=i.borderRadius:n&&q(n.borderRadius)&&(o=n.borderRadius),{borderRadius:o,objectFit:r}}function Q(s){const t=s.split(",").map(i=>i.trim()),e=[];for(const i of t){const[n,o]=i.split(" ").map(r=>r.trim());if(n&&o&&o.endsWith("w")){const r=parseInt(o.slice(0,-1),10);isNaN(r)||e.push({src:n,width:r})}}return e}function tt(s){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"))||"";if(!e&&!i)throw console.error("VistaView Error:",s),new Error("VistaView: Element must have href, src, or srcSet");const n=i?Q(i):void 0,o=J(s);return{config:{src:e,alt:s.dataset.vistaviewAlt||s.getAttribute("alt")||(t==null?void 0:t.getAttribute("alt"))||"",srcSet:i||void 0},parsedSrcSet:n!=null&&n.length?n:void 0,origin:{anchor:s instanceof HTMLAnchorElement?s:void 0,image:t,src:e,srcSet:i,borderRadius:o.borderRadius,objectFit:o.objectFit}}}class V{constructor({elm:t,listeners:e}){a(this,"pointers",[]);a(this,"elm");a(this,"listeners",[]);a(this,"lastPointerDownId",null);a(this,"removeLastPointer",()=>{if(this.pointers.length&&this.lastPointerDownId!==null){const t=this.pointers.findIndex(e=>e.id===this.lastPointerDownId);t!==-1&&this.pointers.splice(t,1)}});a(this,"onPointerDown",t=>{if(!this.listeners.length||t.button!==0)return;t.preventDefault(),this.lastPointerDownId=t.pointerId,window.addEventListener("contextmenu",this.removeLastPointer,{once:!0}),window.addEventListener("auxclick",this.removeLastPointer,{once:!0});let e={x:t.clientX,y:t.clientY,movementX:0,movementY:0,id:t.pointerId};this.pointers.push(e),this.listeners.forEach(i=>i({event:"down",pointer:e,pointers:this.pointers,lastPointerLen:this.pointers.length-1}))});a(this,"onPointerMove",t=>{if(!this.listeners.length)return;t.preventDefault();const e=this.pointers.find(i=>i.id===t.pointerId);e&&(e.movementX=t.movementX,e.movementY=t.movementY,e.x=t.clientX,e.y=t.clientY,this.listeners.forEach(i=>i({event:"move",pointer:e,pointers:this.pointers,lastPointerLen:this.pointers.length-1})))});a(this,"onPointerUp",t=>{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))return;t.preventDefault();const e=this.pointers.findIndex(o=>o.id===t.pointerId);if(e===-1)return;const i=this.pointers[e];i.x=t.clientX,i.y=t.clientY;const n=this.pointers.length;this.pointers.splice(e,1),this.listeners.forEach(o=>o({event:"up",pointer:i,pointers:this.pointers,lastPointerLen:n}))});a(this,"onPointerCancel",t=>{if(!this.listeners.length||t.target instanceof Node&&!this.elm.contains(t.target)&&t.target!==document.querySelector("html")&&t.target!==document)return;t.preventDefault();const e=this.pointers.findIndex(o=>o.id===t.pointerId);if(e===-1)return;const i=this.pointers[e];i.x=t.clientX,i.y=t.clientY;const n=this.pointers.length;this.pointers.splice(e,1),this.listeners.forEach(o=>o({event:"cancel",pointer:i,pointers:this.pointers,lastPointerLen:n}))});this.elm=t??document,e&&(this.listeners=e),this.startListeners()}startListeners(){this.elm.addEventListener("pointerdown",this.onPointerDown),this.elm.addEventListener("pointermove",this.onPointerMove),document.addEventListener("pointerup",this.onPointerUp),document.addEventListener("pointercancel",this.onPointerCancel)}removeListeners(){this.elm.removeEventListener("pointerdown",this.onPointerDown),this.elm.removeEventListener("pointermove",this.onPointerMove),document.removeEventListener("pointerup",this.onPointerUp),document.removeEventListener("pointercancel",this.onPointerCancel),this.pointers=[]}addEventListener(t){this.listeners.push(t)}removeEventListener(t){this.listeners=this.listeners.filter(e=>e!==t)}getPointerDistance(t,e){const i=t.x-e.x,n=t.y-e.y;return Math.sqrt(i*i+n*n)}getCentroid(){if(this.pointers.length===0)return null;const t=this.pointers.reduce((e,i)=>(e.x+=i.x,e.y+=i.y,e),{x:0,y:0});return{x:t.x/this.pointers.length,y:t.y/this.pointers.length}}}class _{constructor(t){a(this,"pointers",null);a(this,"lastDistance",0);a(this,"pinchMode",!1);a(this,"lastPinchEndTime",0);a(this,"PINCH_COOLDOWN",111);a(this,"cancelMove",()=>{});a(this,"pointerListeners",[]);a(this,"vvw");a(this,"imageContainer",null);a(this,"isPinching",()=>this.pinchMode||performance.now()-this.lastPinchEndTime<this.PINCH_COOLDOWN);a(this,"internalPointerListener",t=>{const e=this.vvw.state.children.images.find(i=>i.pos===0);if(t.event==="down"){if(this.cancelMove(),this.vvw.state.zoomedIn&&t.pointers.length===1&&!this.isPinching()){const i=this.pointers.getCentroid();e.setInitialCenter(i)}if(t.pointers.length>=2){this.pinchMode=!0;const i=this.pointers.getCentroid();this.lastDistance=this.pointers.getPointerDistance(t.pointers[0],t.pointers[1]),e.setInitialCenter(i)}}else if(t.event==="move"){if(this.vvw.state.zoomedIn&&t.pointers.length===1&&t.lastPointerLen===0&&!this.isPinching()){const i=this.pointers.getCentroid();e.scaleMove(1,i)}if(t.pointers.length>=2&&this.pinchMode){const i=this.pointers.getCentroid(),n=this.pointers.getPointerDistance(t.pointers[0],t.pointers[1]);e.scaleMove(n/this.lastDistance,i)}}else if((t.event==="up"||t.event==="cancel")&&(this.pinchMode||this.vvw.state.zoomedIn))if(this.pinchMode){this.lastPinchEndTime=performance.now(),this.pinchMode=!1;const i=e.setFinalTransform();i!=null&&i.cancel&&(this.cancelMove=i.cancel),i!=null&&i.close&&requestAnimationFrame(()=>{this.vvw.close()})}else this.vvw.state.zoomedIn&&t.pointers.length===0&&!this.isPinching()&&(e.isThrowing=!0,this.cancelMove=e.momentumThrow({x:t.pointer.movementX,y:t.pointer.movementY}));this.pointerListeners.forEach(i=>i({...t,state:this.vvw.state,hasInternalExecution:this.vvw.state.zoomedIn||this.isPinching(),abortController:this.vvw.state.abortController}))});a(this,"onKeyDown",t=>{const e=this.vvw;switch(t.key){case"ArrowLeft":t.preventDefault(),e.prev();break;case"ArrowRight":t.preventDefault(),e.next();break;case"ArrowUp":t.preventDefault(),e.zoomIn();break;case"ArrowDown":t.preventDefault(),e.zoomOut();break;case"Escape":t.preventDefault(),e.close();break}});a(this,"onScroll",t=>{t.preventDefault();const e=this.vvw,i=this.vvw.state.children.images.find(o=>o.pos===0),n=t.deltaY;i.setInitialCenter({x:t.clientX,y:t.clientY}),n<0?e.zoomIn():n>0&&e.zoomOut()});a(this,"onResizeHandler",()=>{this.vvw.state.children.images.forEach(t=>{t.setSizes()})});this.vvw=t}registerPointerListener(t){this.pointerListeners.push(t)}start(t){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 V({elm:t,listeners:[this.internalPointerListener]})}stop(){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=[]}}const C={somethingOpened:null};class A{constructor(t,e={}){a(this,"options");a(this,"state",new $);a(this,"imageContainer",null);a(this,"externalPointerListener",[]);a(this,"elements");a(this,"eventHandlers",null);a(this,"imageSetupFunction",z);a(this,"initFunction",W);a(this,"openFunction",R);a(this,"closeFunction",T);a(this,"transitionFunction",H);a(this,"throttle",new G);a(this,"root",null);a(this,"onClickElements",t=>{t.preventDefault();const e=t.currentTarget;e.dataset.vvwIdx&&this.open(parseInt(e.dataset.vvwIdx))});a(this,"defaultOnClickHandler",t=>t.preventDefault());a(this,"lastSwapTime",0);a(this,"isRapidSwap",!1);a(this,"isRapidSwapRelease",0);a(this,"transitionCleanup",null);a(this,"tempDeactivatedUi",[]);a(this,"tempDeactivationRequestBy",null);a(this,"isZoomedIn",!1);var i;this.elements=t,this.options={...y,...e,controls:{...y.controls,...e.controls}},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),(i=this.options.extensions)==null||i.forEach(n=>{this.state.extensions.add(n)}),this.state.isReducedMotion=window.matchMedia("(prefers-reduced-motion: reduce)").matches,this.reset(),this.initFunction(this)}reset(){if(typeof this.elements=="string"){const t=this.qsOrigin(this.elements);this.state.elmLength=t.length,t.forEach((e,i)=>{const n=e;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)})}else this.state.elmLength=this.elements.length}qs(t){return this.root?this.root.querySelector(t):null}qsOrigin(t){return document.querySelectorAll(t)}registerPointerListener(t){this.externalPointerListener.push(t)}getChildElements(t,e){const i=[],n=[],o=typeof this.elements=="string"?this.qsOrigin(this.elements):this.elements;for(let r=-t;r<=t;r++){const l=(e+r+o.length)%o.length,h=o[l],d={elm:h instanceof HTMLElement?tt(h):{config:h,origin:void 0,parsedSrcSet:void 0},pos:r,index:l,vistaView:this,maxZoomLevel:this.options.maxZoomLevel,transitionShouldWait:()=>this.isRapidSwap,onScale:({vistaImage:g,isMin:m,isMax:w})=>{var b,E,S,L;g.index===this.state.currentIndex&&(this.state.zoomedIn=!m,m?(b=this.qs(".vvw-zoom-out"))==null||b.setAttribute("disabled","true"):(E=this.qs(".vvw-zoom-out"))==null||E.removeAttribute("disabled"),w?(S=this.qs(".vvw-zoom-in"))==null||S.setAttribute("disabled","true"):(L=this.qs(".vvw-zoom-in"))==null||L.removeAttribute("disabled"))}};let u=null;this.state.extensions.forEach(g=>{!u&&g.onInitializeImage&&(u=g.onInitializeImage(d))});const v=u??new O(d),p=document.createElement("div");p.className="vvw-item",p.dataset.vvwPos=`${r}`,p.dataset.vvwIdx=`${l}`,v.thumb&&p.appendChild(v.thumb),p.appendChild(v.element),i.push(v),n.push(p)}return{htmls:n,images:i}}async swap(t,e){var p,g;this.reactivateUi();const i=this.options.preloads||0,n=this.state.currentIndex,{htmls:o,images:r}=this.getChildElements(i,n),l=this.imageContainer,h=this.state.children,f={htmlElements:{from:h.htmls,to:o},images:{from:h.images,to:r},index:{from:t,to:this.state.currentIndex},via:e||{next:!1,prev:!1},vistaView:this};this.imageSetupFunction(f),this.state.zoomedIn=!1,(p=this.qs(".vvw-zoom-out"))==null||p.setAttribute("disabled","true"),(g=this.qs(".vvw-zoom-in"))==null||g.removeAttribute("disabled");const u=performance.now()-this.lastSwapTime<this.options.rapidLimit;this.isRapidSwap=u;const{images:v}=this.state.children;if(this.state.children={htmls:o,images:r},this.displayCurrentInfo(),u)v.forEach(m=>{m.cancelPendingLoad(),m.destroy()});else{const m=this.state.abortController.signal,w=this.transitionFunction(f,m);w&&(this.transitionCleanup=w.cleanup,await w.transitionEnded),this.lastSwapTime=performance.now(),v.forEach(L=>{L.cancelPendingLoad()});const b=v.find(L=>L.index===n),E=b?x.stop(b):void 0,S=r.find(L=>L.index===n);S&&b&&S.cloneStyleFrom(b,E),v.forEach(L=>{L.destroy()})}l.innerHTML="",this.transitionCleanup&&this.transitionCleanup(),o.forEach(m=>{l.appendChild(m)}),r.forEach(m=>{m.init()}),u?(this.isRapidSwapRelease&&clearTimeout(this.isRapidSwapRelease),this.isRapidSwapRelease=setTimeout(()=>{this.isRapidSwap=!1},333)):this.isRapidSwap=!1,this.options.onImageView&&this.options.onImageView(f,this),this.state.extensions.forEach(m=>{m.onImageView&&m.onImageView(f,this)})}displayCurrentInfo(){const t=this.state.currentIndex;typeof this.elements=="string"&&this.qsOrigin(this.elements).forEach((r,l)=>{r.style.opacity="",l===t&&(r.style.opacity="0")});const e=this.qs(".vvw-index"),i=`${t+1}`,n=`${this.state.elmLength}`;e&&(e.textContent=`${i} / ${n}`);const o=this.qs(".vvw-desc");if(o){const r=this.state.children.images.find(h=>h.index===t),l=(r==null?void 0:r.config.alt)||"";l?(o.textContent=l,o.setAttribute("aria-label",`Image ${i} of ${n}: ${l}`),o.style.opacity=""):(o.textContent="",o.setAttribute("aria-label",`Image ${i} of ${n}`),o.style.opacity="0")}}deactivateUi(t,e){t.forEach(i=>{var n,o;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)}),this.tempDeactivationRequestBy=e||null,this.state.extensions.forEach(i=>{i.onDeactivateUi&&i.onDeactivateUi(t,this.tempDeactivationRequestBy,this)})}reactivateUi(){this.tempDeactivatedUi.forEach(t=>{var e,i;t==="zoomIn"?(e=this.qs(".vvw-zoom-in"))==null||e.removeAttribute("disabled"):t==="zoomOut"&&((i=this.qs(".vvw-zoom-out"))==null||i.removeAttribute("disabled"))}),this.state.extensions.forEach(t=>{t.onReactivateUi&&t.onReactivateUi(this.tempDeactivatedUi,this.tempDeactivationRequestBy,this)}),this.tempDeactivatedUi=[],this.tempDeactivationRequestBy=null}open(t=0){var h,f,d,u,v,p,g;if(C.somethingOpened){console.warn("Another VistaView instance is already opened. Close it first before opening a new one.");return}C.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";const e=Y({controls:this.options.controls,extensions:this.state.extensions});if(document.body.append(e),this.root=document.body.querySelector("#vvw-root"),!this.root)throw new Error("Failed to setup VistaView root element.");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");const i=this.options.preloads||0,n=t,{images:o,htmls:r}=this.getChildElements(i,n),l={htmlElements:{from:null,to:r},images:{from:null,to:o},index:{from:null,to:this.state.currentIndex},via:{next:!1,prev:!1},vistaView:this};this.imageSetupFunction(l),this.state.children={htmls:r,images:o},r.forEach(m=>{this.imageContainer.appendChild(m)}),o.forEach(m=>{m.init()}),(h=this.qs(".vvw-close"))==null||h.addEventListener("click",()=>this.close()),(f=this.qs(".vvw-zoom-in"))==null||f.addEventListener("click",()=>this.zoomIn()),(d=this.qs(".vvw-zoom-out"))==null||d.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&&((p=this.qs(".vvw-prev"))==null||p.classList.add("vvw--hidden"),(g=this.qs(".vvw-next"))==null||g.classList.add("vvw--hidden")),this.openFunction(this),this.eventHandlers=new _(this),this.externalPointerListener.forEach(m=>{this.eventHandlers.registerPointerListener(m)}),this.eventHandlers.start(this.imageContainer),requestAnimationFrame(()=>{requestAnimationFrame(()=>{var m;(m=this.root)==null||m.addEventListener("transitionend",()=>{var w;(w=this.root)==null||w.classList.add("vvw--settled")},{once:!0}),this.root.classList.add("vvw--active"),this.displayCurrentInfo(),this.options.onOpen&&this.options.onOpen(this),this.options.onImageView&&this.options.onImageView(l,this),this.state.extensions.forEach(w=>{w.onOpen&&w.onOpen(this),w.onImageView&&w.onImageView(l,this)})})})}async close(t=!0){C.somethingOpened===this&&this.root&&(this.eventHandlers.stop(),this.eventHandlers=null,this.state.children.images.forEach(e=>{e.prepareClose()}),t?await new Promise(e=>{let n=0;this.root.addEventListener("transitionend",o=>{o.target===this.root&&(n++,n===2&&typeof this.elements=="string"&&(this.state.children.images.forEach(r=>{r.destroy()}),this.qsOrigin(this.elements).forEach(r=>{r.style.opacity=""})),n===3&&e(null))}),this.root.classList.add("vvw--closing")}):typeof this.elements=="string"&&(this.state.children.images.forEach(e=>{e.destroy()}),this.qsOrigin(this.elements).forEach(e=>{e.style.opacity=""})),this.root.remove(),this.root=null,this.imageContainer=null,this.state.children={htmls:[],images:[]},this.state.currentIndex=-1,this.state.children.images.forEach(e=>{e.destroy()}),document.body.style.overflow="",C.somethingOpened=null,this.closeFunction(this),this.options.onClose&&this.options.onClose(this),this.state.extensions.forEach(e=>{e.onClose&&e.onClose(this)}))}destroy(){this.close(!1),this.externalPointerListener=[],typeof this.elements=="string"&&this.qsOrigin(this.elements).forEach(t=>{t.removeAttribute("data-vista-idx"),t.removeEventListener("click",this.defaultOnClickHandler),t.removeEventListener("pointerup",this.onClickElements)})}next(){if(C.somethingOpened!==this){console.warn("This VistaView instance is not opened.");return}const t=(this.state.currentIndex+1)%this.state.elmLength;this.view(t,{next:!0,prev:!1})}prev(){if(C.somethingOpened!==this){console.warn("This VistaView instance is not opened.");return}const t=(this.state.currentIndex-1+this.state.elmLength)%this.state.elmLength;this.view(t,{next:!1,prev:!0})}view(t,e){if(C.somethingOpened!==this){console.warn("This VistaView instance is not opened.");return}if(this.state.elmLength<2)return;(t<0||t>=this.state.elmLength)&&(t=(t%this.state.elmLength+this.state.elmLength)%this.state.elmLength);const i=this.state.currentIndex;this.state.currentIndex=t;const n=this.state.abortController;n==null||n.abort(),this.state.abortController=new AbortController,this.swap(i,e)}zoomIn(){if(C.somethingOpened!==this){console.warn("This VistaView instance is not opened.");return}this.tempDeactivatedUi.includes("zoomIn")||this.throttle.fio(()=>{const t=this.state.children.images.find(e=>e.pos===0);t==null||t.animateZoom(1.68)},"zoom",222)}zoomOut(){if(C.somethingOpened!==this){console.warn("This VistaView instance is not opened.");return}this.tempDeactivatedUi.includes("zoomOut")||this.throttle.fio(()=>{const t=this.state.children.images.find(e=>e.pos===0);t==null||t.animateZoom(.68)},"zoom",222)}getCurrentIndex(){return this.state.currentIndex}}function et(s){let t=null;if(typeof s=="string"){if(t=document.querySelectorAll(s),t.length===0)return new Error("No elements found in node list.").toString();for(let e=0;e<t.length;e++){const i=t[e],n=i.tagName.toLowerCase();if(n!=="img"&&n!=="a")return new Error(`Invalid element at index ${e}: expected <img>, <a>, got <${n}>`);if(n==="a"&&!(i.querySelector("img")!==null))return new Error(`Invalid <a> element at index ${e}: must contain <img>`)}}else{const e=s;for(let i=0;i<e.length;i++)if(!e[i].src)return new Error(`Invalid image data at index ${i}: must have 'src'`)}return s}function it({elements:s,...t}){if(!s)return console.error(s),console.error("no elements provided"),console.warn("VistaView: silently returning."),null;let e=et(s);if(e instanceof Error)return console.error(e),console.warn("VistaView: silently returning."),null;const i=new A(e,t);return{open:(n=0)=>i.open(n),reset:()=>i.reset(),close:()=>i.close(),next:()=>i.next(),prev:()=>i.prev(),zoomIn:()=>i.zoomIn(),zoomOut:()=>i.zoomOut(),destroy:()=>i.destroy(),getCurrentIndex:()=>i.getCurrentIndex(),view:n=>{i.view(n)}}}c.DefaultOptions=y,c.VistaBox=F,c.VistaHiresTransition=x,c.VistaImage=O,c.VistaImageEvent=_,c.VistaPointers=V,c.VistaState=$,c.VistaView=A,c.close=T,c.imageSetup=z,c.init=W,c.open=R,c.transition=H,c.vistaView=it,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})}));
|
|
18
|
+
</div>`);return[...(s==null?void 0:s.topLeft)||[],...(s==null?void 0:s.topCenter)||[],...(s==null?void 0:s.topRight)||[],...(s==null?void 0:s.bottomLeft)||[],...(s==null?void 0:s.bottomCenter)||[],...(s==null?void 0:s.bottomRight)||[]].forEach(o=>{const r=e[o];if(r&&r.control){const l=n.querySelector(`[data-vvw-control="${r.name}"]`),h=r.control();l&&h&&l.appendChild(h)}}),n}function z(s){}function W(s){K(s)}function K(s){let t={x:0,y:0},e={x:0,y:0},i=null;s.registerPointerListener(n=>{var o;if(!n.hasInternalExecution&&!(n.pointers.length>1)){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"){e={x:n.pointer.x,y:n.pointer.y};const r=e.x-t.x,l=e.y-t.y;if(!i&&Math.abs(l)>Math.abs(r)||i==="y"){const h=l/window.innerHeight*100;s.imageContainer.style.transition="none",s.imageContainer.style.transform=`translateY(${h}vh)`,i="y"}else if(!i&&Math.abs(r)>Math.abs(l)||i==="x"&&n.state.elmLength>1){const h=r/window.innerWidth*100;s.imageContainer.style.transition="none",s.imageContainer.style.transform=`translateX(${h}vw)`,i="x"}}if(n.event==="up"||n.event==="cancel"){let r=function(l){var h;(h=s.imageContainer)==null||h.addEventListener("transitionend",function f(){var c;(c=s.imageContainer)==null||c.removeEventListener("transitionend",f),s.imageContainer.style.transition="",s.imageContainer.style.transform=""}),s.imageContainer.style.transition="transform 222ms ease",s.imageContainer.style.transform=l};if(i==="y"){const l=e.y-t.y;Math.abs(l)>144?(s.imageContainer.style.transition="transform 222ms ease",s.imageContainer.style.transform="translateY(0vh)",s.close()):r("translateY(0vh)")}if(i==="x"&&n.state.elmLength>1){const l=e.x-t.x;s.imageContainer.style.transition="",l>64?s.prev():l<-64?s.next():r("translateX(0vw)")}i=null,t={x:0,y:0},e={x:0,y:0}}}})}function R(s){const t=s.options.preloads;s.imageContainer.style.width=`${(t*2+1)*100}vw`,s.imageContainer.style.left=`-${t*100}vw`,s.imageContainer.style.display="flex"}function T(s){}function H({vistaView:s,htmlElements:{to:t},index:{from:e,to:i}},n){const{imageContainer:o,options:r}=s,{isReducedMotion:l}=s.state;if(!(!t||n.aborted||l||!(Math.abs(i-e)===1||e===0&&i===s.state.elmLength-1||e===s.state.elmLength-1&&i===0)))return{cleanup:()=>{o.style.transition="",o.style.transform=""},transitionEnded:new Promise(f=>{o.addEventListener("transitionend",()=>{f()},{once:!0}),o.addEventListener("transitioncancel",()=>{n.aborted&&f()},{once:!0});const c=Math.round(r.animationDurationBase*100)/100,u=i===e+1||e===s.state.elmLength-1&&i===0?"translateX(-100vw)":"translateX(100vw)";o.style.transition=`transform ${c}ms ease`,o.style.transform=u})}}function D(s){const t=window.innerWidth,e=window.innerHeight,i=s.naturalWidth,n=s.naturalHeight;if(!i||!n)throw console.error("Error",s),new Error("Image natural dimensions are zero");if(i<t&&n<e)return{width:i,height:n};const o=i/n,r=t/e;let l,h;return o>r?(l=t,h=t/o):(h=e,l=e*o),{width:l,height:h}}class x{static ease(t,e,i){const n=e-t,o=t+n*.2;return Math.abs(n)<i?e:o}static play(t,e,i){if(i()){requestAnimationFrame(()=>{this.play(t,e,i)});return}this.map.get(t)&&(t.element.classList.contains("vvw--load-cancelled")||requestAnimationFrame(()=>{var c,u,v,p,g,m,w,b,E,S;const n=this.map.get(t);if(!n||!t.element||t.element.classList.contains("vvw--load-cancelled"))return;const{current:o,target:r,log:l}=n;let h={};r.width!==void 0&&(h.width=this.ease(o._width,r.width,1)),r.height!==void 0&&(h.height=this.ease(o._height,r.height,1)),((c=r.transform)==null?void 0:c.x)!==void 0&&(h.transform=h.transform||{},h.transform.x=this.ease(o._transform.x,r.transform.x,1)),((u=r.transform)==null?void 0:u.y)!==void 0&&(h.transform=h.transform||{},h.transform.y=this.ease(o._transform.y,r.transform.y,1)),((v=r.transform)==null?void 0:v.scale)!==void 0&&(h.transform=h.transform||{},h.transform.scale=this.ease(o._transform.scale,r.transform.scale,.005)),((p=r.translate)==null?void 0:p.x)!==void 0&&(h.translate=h.translate||{},h.translate.x=this.ease(o._translate.x,r.translate.x,1)),((g=r.translate)==null?void 0:g.y)!==void 0&&(h.translate=h.translate||{},h.translate.y=this.ease(o._translate.y,r.translate.y,1)),h.width!==void 0&&(o.width=h.width),h.height!==void 0&&(o.height=h.height),h.translate&&(o.translate={...o.translate,...h.translate}),h.transform&&(o.transform={...o.transform,...h.transform}),(r.width===void 0||o._width===r.width)&&(r.height===void 0||o._height===r.height)&&(((m=r.transform)==null?void 0:m.x)===void 0||o._transform.x===r.transform.x)&&(((w=r.transform)==null?void 0:w.y)===void 0||o._transform.y===r.transform.y)&&(((b=r.transform)==null?void 0:b.scale)===void 0||o._transform.scale===r.transform.scale)&&(((E=r.translate)==null?void 0:E.x)===void 0||o._translate.x===r.translate.x)&&(((S=r.translate)==null?void 0:S.y)===void 0||o._translate.y===r.translate.y)?(this.map.delete(t),e()):(this.map.set(t,{current:o,target:r,log:l}),this.play(t,e,i))}))}static stop(t){const e=this.map.get(t);return this.map.delete(t),e}static start({vistaImage:t,target:e,onComplete:i,shouldWait:n}){this.stop(t),this.map.set(t,{current:t.state,target:e}),this.play(t,i,n)}}a(x,"map",new Map);function M(s){const e=window.getComputedStyle(s).objectFit||"",{width:i,height:n}=s.getBoundingClientRect(),o=s.naturalWidth,r=s.naturalHeight;if(!e)return{width:i,height:n};if(!o||!r)return{width:i,height:n};const l=o/r,h=i/n;switch(e){case"fill":return{width:i,height:n};case"none":return{width:o,height:r};case"contain":return l>h?{width:i,height:i/l}:{width:n*l,height:n};case"cover":return l<h?{width:i,height:i/l}:{width:n*l,height:n};case"scale-down":{const f={width:o,height:r},c=l>h?{width:i,height:i/l}:{width:n*l,height:n};return c.width<=f.width&&c.height<=f.height?c:f}}return{width:i,height:n}}class F{constructor(t){a(this,"state");a(this,"parsedSrcSet");a(this,"isReady",!1);a(this,"isThrowing",!1);a(this,"thumb",null);a(this,"pos");a(this,"index");a(this,"config");a(this,"origin");a(this,"initH",0);a(this,"initW",0);a(this,"fullH",0);a(this,"fullW",0);a(this,"maxW",0);a(this,"minW",0);a(this,"defaultWH",200);a(this,"isZoomedIn",!1);a(this,"isCancelled",!1);a(this,"isLoadedResolved",null);a(this,"isLoadedRejected",null);a(this,"isLoaded",new Promise((t,e)=>{this.isLoadedResolved=t,this.isLoadedRejected=e}));a(this,"replacement",null);a(this,"originalParent",null);a(this,"originalNextSibling",null);a(this,"originalStyle","");a(this,"thumbImage",null);a(this,"fittedSize",null);a(this,"maxZoomLevel");a(this,"vistaView");a(this,"transitionState",null);a(this,"transitionShouldWait",()=>!1);a(this,"initPointerCenter",{x:0,y:0});a(this,"onScale");var i;this.state=this.createState(),this.pos=t.pos,this.index=t.index,this.config=t.elm.config,this.parsedSrcSet=t.elm.parsedSrcSet,this.origin=t.elm.origin,this.maxZoomLevel=t.maxZoomLevel,this.vistaView=t.vistaView,this.onScale=t.onScale,t.transitionState&&(this.transitionState=t.transitionState),t.transitionShouldWait&&(this.transitionShouldWait=t.transitionShouldWait),this.initPointerCenter={x:window.innerWidth/2,y:window.innerHeight/2};const e=this.pos===0?(i=this.origin)==null?void 0:i.image:null;if(this.originalParent=(e==null?void 0:e.parentElement)||null,this.originalNextSibling=(e==null?void 0:e.nextSibling)||null,e&&this.originalParent){this.originalStyle=e.style.cssText,this.thumbImage=e;const n=e.cloneNode(!0);this.originalParent.insertBefore(n,e),this.replacement=n,this.thumb=document.createElement("div"),this.thumb.classList.add("vvw-img-lo");const{width:o,height:r}=this.thumbImage?M(this.thumbImage):{width:0,height:0};this.fittedSize={width:o,height:r},this.thumb.appendChild(e),e.style.width="100%",e.style.height="100%",e.style.objectFit=this.origin.objectFit}}createState(){const t=this;return{_t:this,_width:0,_height:0,_transform:{x:0,y:0,scale:1},_translate:{x:0,y:0},_lessThanMinWidth:!1,get width(){return this._width},set width(e){this._width=e,t.onWidthChange(e)},get height(){return this._height},set height(e){this._height=e,t.onHeightChange(e)},get transform(){return this._transform},set transform(e){this._transform=e,t.onTransformChange(e)},get translate(){return this._translate},set translate(e){this._translate=e,t.onTranslateChange(e)},get lessThanMinWidth(){return this._lessThanMinWidth},set lessThanMinWidth(e){this._lessThanMinWidth=e,t.onLessThanMinWidthChange(e)}}}onLessThanMinWidthChange(t){t?this.element.style.opacity="0.5":this.element.style.opacity=""}onTranslateChange(t){this.element.style.translate=`calc(-50% + ${t.x}px) calc(-50% + ${t.y}px)`}onTransformChange(t){const e=`translate3d(${t.x}px, ${t.y}px, 0px) scale3d(${t.scale}, ${t.scale}, 1)`;this.element.style.transform=e}onWidthChange(t){this.element.style.width=`${t}px`}onHeightChange(t){this.element.style.height=`${t}px`}onImageReady(){}animateZoom(t,e){}scaleMove(t,e,i){}momentumThrow(t){return()=>{}}async init(){await this.isLoaded;const t=this.element;this.transitionState&&this.transitionState.current.width&&this.transitionState.current.height?(this.state.width=this.transitionState.current.width,this.state.height=this.transitionState.current.height):t.classList.contains("vvw--loaded")||(this.state.width=this.initW,this.state.height=this.initH);const e=()=>{this.isCancelled||x.start({vistaImage:this,target:{width:this.fullW,height:this.fullH},onComplete:()=>{this.isCancelled||(this.isReady=!0,t.classList.add("vvw--ready"),this.onImageReady())},shouldWait:this.transitionShouldWait})};this.pos<-1||this.pos>1?(this.state.width=this.fullW,this.state.height=this.fullH,t.classList.add("vvw--loaded"),t.classList.add("vvw--ready"),this.isReady=!0):t.classList.contains("vvw--loaded")?t.classList.contains("vvw--ready")?(this.isReady=!0,this.onImageReady()):e():(t.classList.add("vvw--loaded"),setTimeout(()=>{this.isCancelled||e()},333))}getFullSizeDim(){const{width:t,height:e}=this.thumb.getBoundingClientRect(),i=t/e;let n=window.innerWidth,o=window.innerHeight;return i>window.innerWidth/window.innerHeight?o=n/i:n=o*i,{width:n,height:o}}setSizes(t={}){var l,h,f;const{stableSize:e=!0,initDimension:i}=t;if(!this.origin)return;const n=this.thumb;let o={width:this.defaultWH,height:this.defaultWH,top:0,left:0};if(n){o=(((l=this.origin)==null?void 0:l.anchor)||this.replacement).getBoundingClientRect();const c=n.style;c.width=o.width+"px",c.height=o.height+"px",c.top="50%",c.left="50%",c.translate="-50% -50%",c.position="fixed",c.objectFit=this.origin.objectFit,c.borderRadius=this.origin.borderRadius;const u=Math.min(Math.max(o.left,-o.width),window.innerWidth+o.width)-window.innerWidth/2+o.width/2,v=Math.min(Math.max(o.top,-o.height),window.innerHeight+o.height)-window.innerHeight/2+o.height/2;c.setProperty("--vvw-init-radius",c.borderRadius),c.setProperty("--vvw-pulse-radius",`calc(1.3 * ${c.borderRadius})`),c.setProperty("--vvw-init-x",`${u}px`),c.setProperty("--vvw-init-y",`${v}px`),i&&(c.setProperty("--vvw-current-x",`${u}px`),c.setProperty("--vvw-current-y",`${v}px`))}if(!i){const{width:c,height:u}=this.thumbImage?M(this.thumbImage):{width:0,height:0};this.fittedSize={width:c,height:u}}const r=this.element;if(this.initW=Math.min(((h=this.fittedSize)==null?void 0:h.width)??0,o.width),this.initH=Math.min(((f=this.fittedSize)==null?void 0:f.height)??0,o.height),r.style.setProperty("--vvw-init-w",this.initW+"px"),r.style.setProperty("--vvw-init-h",this.initH+"px"),r.style.setProperty("--vvw-init-radius",this.origin.borderRadius),r.style.objectFit="cover",!i){if(this.isReady&&!this.isCancelled){const{width:c,height:u}=this.getFullSizeDim();this.fullH=u,this.fullW=c,this.minW=this.fullW*.5}!this.isZoomedIn&&e&&this.normalize()}}normalize(){this.state.transform={x:0,y:0,scale:1},this.state.translate={x:0,y:0},this.state.width=this.fullW,this.state.height=this.fullH,this.isZoomedIn=!1}getFromParsedSrcSet(t){if(!this.parsedSrcSet||this.parsedSrcSet.length===0)return null;const e=t*(window.devicePixelRatio||1);let i=this.parsedSrcSet[this.parsedSrcSet.length-1];for(const n of this.parsedSrcSet)if(n.width>=e){i=n;break}return i.src}prepareClose(){x.stop(this),this.setFinalTransform()}cancelPendingLoad(){var t;this.isCancelled=!0,(t=this.element)==null||t.classList.add("vvw--load-cancelled")}setInitialCenter(t){this.initPointerCenter=t}destroy(){var t,e;this.originalParent&&this.thumbImage&&(this.thumbImage.style.cssText=this.originalStyle,this.originalNextSibling?this.originalParent.insertBefore(this.thumbImage,this.originalNextSibling):this.originalParent.appendChild(this.thumbImage)),this.originalParent=null,this.originalNextSibling=null,this.originalStyle="",this.thumbImage=null,this.replacement&&(this.replacement.remove(),this.replacement=null),(t=this.thumb)==null||t.remove(),(e=this.element)==null||e.remove(),this.thumb=null,this.origin=void 0,this.config={src:"",alt:""}}cloneStyleFrom(t,e){t!=null&&t.element&&(e&&(this.transitionState=e||null),t.element.classList.contains("vvw--loaded")&&(this.element.classList.add("vvw--loaded"),this.state.width=t.state.width,this.state.height=t.state.height),t.element.classList.contains("vvw--ready")&&this.element.classList.add("vvw--ready"))}toObject(){return structuredClone({config:{src:this.config.src,alt:this.config.alt,srcSet:this.config.srcSet},origin:this.origin?{src:this.origin.src,srcSet:this.origin.srcSet,borderRadius:this.origin.borderRadius,objectFit:this.origin.objectFit}:null,parsedSrcSet:this.parsedSrcSet,element:"src"in this.element?this.element.src:this.element.toString(),thumb:void 0,index:this.index,pos:this.pos,state:{width:this.state._width,height:this.state._height,transform:this.state._transform,translate:this.state._translate}})}setFinalTransform(t={}){const{propagateEvent:e=!0}=t;if(this.isReady){if(this.state.translate.x+=this.state.transform.x,this.state.translate.y+=this.state.transform.y,this.state.width*=this.state.transform.scale,this.state.height*=this.state.transform.scale,Math.abs(this.state.width-this.fullW)<1&&(this.state.width=this.fullW,this.state.height=this.fullH),Math.abs(this.state.translate.x)<1&&(this.state.translate.x=0),Math.abs(this.state.translate.y)<1&&(this.state.translate.y=0),this.state.translate={...this.state.translate},this.state.transform={x:0,y:0,scale:1},e){const i=this.toObject();this.vistaView.options.onContentChange&&this.vistaView.options.onContentChange(i,this.vistaView),this.vistaView.state.extensions.forEach(n=>{n.onContentChange&&n.onContentChange(i,this.vistaView)})}return{close:!0,cancel:()=>{}}}}}class O extends F{constructor(e){super(e);a(this,"element");a(this,"rect",null);a(this,"animateNormalizeTimeout",null);const i=document.createElement("img");i.alt=this.config.alt||"",i.classList.add("vvw-img-hi"),this.element=i,i.onerror=n=>{this.isLoadedRejected(n)},i.src=this.config.src,i.decode().then(()=>{this.onLoad()}).catch(n=>{this.isLoadedRejected(n)}),this.setSizes({stableSize:!1,initDimension:!0})}onWidthChange(e){super.onWidthChange(e);const i=this.getFromParsedSrcSet(e);if(i&&this.element.src!==i){const n=new Image;n.onload=()=>{n.decode().then(()=>{this.isCancelled||(this.element.src=i)})},n.src=i}}onLoad(){if(this.isCancelled)return;const e=this.element;e.width=e.naturalWidth,e.height=e.naturalHeight,this.maxW=e.naturalWidth*this.maxZoomLevel;const{width:i,height:n}=D(e);this.fullH=n,this.fullW=i,this.minW=this.fullW*.5,this.isLoadedResolved(!0)}getFullSizeDim(){return D(this.element)}normalize(){super.normalize();const e=this.element;e.style.objectFit="cover",e.style.borderRadius="0"}scaleMove(e,i,n=!1){if(!this.isReady||!this.element)return;this.rect||(this.rect=this.element.getBoundingClientRect()),i||(i=this.initPointerCenter);const o=this.rect.left+this.rect.width/2,r=this.rect.top+this.rect.height/2,l=this.initPointerCenter.x-o,h=this.initPointerCenter.y-r,f=l*(1-e),c=h*(1-e),u=i.x-this.initPointerCenter.x,v=i.y-this.initPointerCenter.y;n?x.start({vistaImage:this,target:{transform:{x:f+u,y:c+v,scale:e}},onComplete:()=>{this.setFinalTransform()},shouldWait:()=>!1}):this.state.transform={x:f+u,y:c+v,scale:e};const g=this.element.getBoundingClientRect().width*e;this.isZoomedIn=g>this.fullW,this.state.lessThanMinWidth=g<=this.minW,this.onScale({vistaImage:this,scale:g/this.fullW,isMax:g>=this.maxW,isMin:g<=this.fullW})}animateZoom(e,i){this.state.width*e<this.minW||this.scaleMove(e,i,!0)}momentumThrow(e){if(!this.isReady)return()=>{};if(!this.isThrowing)return this.setFinalTransform(),()=>{};if(Math.abs(e.x)<.1&&Math.abs(e.y)<.1){const n=this.element.getBoundingClientRect();return x.start({vistaImage:this,target:{transform:{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,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}},onComplete:()=>{this.isThrowing=!1,this.setFinalTransform()},shouldWait:()=>!1}),()=>{}}return requestAnimationFrame(()=>{if(!this.isThrowing)return this.momentumThrow({x:0,y:0});const i=this.element,n=this.state.transform;n.x+=e.x,n.y+=e.y;const o=i.getBoundingClientRect();n.x=n.x+e.x,n.y=n.y+e.y,o.right<window.innerWidth/2&&(n.x+=(window.innerWidth/2-o.right)*.1,e.x*=.7),o.left>window.innerWidth/2&&(n.x-=(o.left-window.innerWidth/2)*.1,e.x*=.7),o.bottom<window.innerHeight/2&&(n.y+=(window.innerHeight/2-o.bottom)*.1,e.y*=.7),o.top>window.innerHeight/2&&(n.y-=(o.top-window.innerHeight/2)*.1,e.y*=.7),this.state.transform=n,this.momentumThrow({x:e.x*.9,y:e.y*.9})}),()=>{x.stop(this),this.isThrowing=!1,this.setFinalTransform()}}animateNormalize(){this.animateNormalizeTimeout&&clearTimeout(this.animateNormalizeTimeout),this.animateNormalizeTimeout=setTimeout(()=>{x.start({vistaImage:this,target:{width:this.fullW,height:this.fullH,translate:{x:0,y:0},transform:{x:0,y:0,scale:1}},onComplete:()=>{this.setFinalTransform()},shouldWait:()=>!1})},50)}setFinalTransform(){if(!this.isReady)return;this.rect=null,super.setFinalTransform({propagateEvent:!1});const e=this.state.width<=this.minW;if(this.state.width>this.maxW)this.animateZoom(this.maxW/this.state.width);else if(!e&&this.state.width<this.fullW)this.animateNormalize();else if(this.pos===0){const i=this.toObject();this.vistaView.options.onContentChange&&this.vistaView.options.onContentChange(i,this.vistaView),this.vistaView.state.extensions.forEach(n=>{n.onContentChange&&n.onContentChange(i,this.vistaView)})}return{close:e,cancel:()=>x.stop(this)}}}class G{constructor(){a(this,"fiolast",{})}fio(t,e,i=50){const o=Date.now()-(this.fiolast[e]??0),r=()=>{this.fiolast[e]=Date.now(),t()};if(!this.fiolast[e]){r();return}o>=i&&r()}}class q{constructor(){a(this,"open",!1);a(this,"settled",!1);a(this,"closing",!1);a(this,"zoomedIn",!1);a(this,"children",{htmls:[],images:[]});a(this,"currentIndex",-1);a(this,"elmLength",0);a(this,"abortController",new AbortController);a(this,"isReducedMotion",!1);a(this,"extensions",new Set)}}function $(s){return s&&!/^0(px|%|r?em|vw|vh|vmin|vmax|cm|mm|in|pt|pc|ex|ch)?$/i.test(s.trim())&&s}function J(s){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;let o="0px",r=n?n.objectFit:"contain";return i&&$(i.borderRadius)?o=i.borderRadius:n&&$(n.borderRadius)&&(o=n.borderRadius),{borderRadius:o,objectFit:r}}function Q(s){const t=s.split(",").map(i=>i.trim()),e=[];for(const i of t){const[n,o]=i.split(" ").map(r=>r.trim());if(n&&o&&o.endsWith("w")){const r=parseInt(o.slice(0,-1),10);isNaN(r)||e.push({src:n,width:r})}}return e}function tt(s){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"))||"";if(!e&&!i)throw console.error("VistaView Error:",s),new Error("VistaView: Element must have href, src, or srcSet");const n=i?Q(i):void 0,o=J(s);return{config:{src:e,alt:s.dataset.vistaviewAlt||s.getAttribute("alt")||(t==null?void 0:t.getAttribute("alt"))||"",srcSet:i||void 0},parsedSrcSet:n!=null&&n.length?n:void 0,origin:{anchor:s instanceof HTMLAnchorElement?s:void 0,image:t,src:e,srcSet:i,borderRadius:o.borderRadius,objectFit:o.objectFit}}}class V{constructor({elm:t,listeners:e}){a(this,"pointers",[]);a(this,"elm");a(this,"listeners",[]);a(this,"lastPointerDownId",null);a(this,"removeLastPointer",()=>{if(this.pointers.length&&this.lastPointerDownId!==null){const t=this.pointers.findIndex(e=>e.id===this.lastPointerDownId);t!==-1&&this.pointers.splice(t,1)}});a(this,"onPointerDown",t=>{if(!this.listeners.length||t.button!==0)return;t.preventDefault(),this.lastPointerDownId=t.pointerId,window.addEventListener("contextmenu",this.removeLastPointer,{once:!0}),window.addEventListener("auxclick",this.removeLastPointer,{once:!0});let e={x:t.clientX,y:t.clientY,movementX:0,movementY:0,id:t.pointerId};this.pointers.push(e),this.listeners.forEach(i=>i({event:"down",pointer:e,pointers:this.pointers,lastPointerLen:this.pointers.length-1}))});a(this,"onPointerMove",t=>{if(!this.listeners.length)return;t.preventDefault();const e=this.pointers.find(i=>i.id===t.pointerId);e&&(e.movementX=t.movementX,e.movementY=t.movementY,e.x=t.clientX,e.y=t.clientY,this.listeners.forEach(i=>i({event:"move",pointer:e,pointers:this.pointers,lastPointerLen:this.pointers.length-1})))});a(this,"onPointerUp",t=>{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))return;t.preventDefault();const e=this.pointers.findIndex(o=>o.id===t.pointerId);if(e===-1)return;const i=this.pointers[e];i.x=t.clientX,i.y=t.clientY;const n=this.pointers.length;this.pointers.splice(e,1),this.listeners.forEach(o=>o({event:"up",pointer:i,pointers:this.pointers,lastPointerLen:n}))});a(this,"onPointerCancel",t=>{if(!this.listeners.length||t.target instanceof Node&&!this.elm.contains(t.target)&&t.target!==document.querySelector("html")&&t.target!==document)return;t.preventDefault();const e=this.pointers.findIndex(o=>o.id===t.pointerId);if(e===-1)return;const i=this.pointers[e];i.x=t.clientX,i.y=t.clientY;const n=this.pointers.length;this.pointers.splice(e,1),this.listeners.forEach(o=>o({event:"cancel",pointer:i,pointers:this.pointers,lastPointerLen:n}))});this.elm=t??document,e&&(this.listeners=e),this.startListeners()}startListeners(){this.elm.addEventListener("pointerdown",this.onPointerDown),this.elm.addEventListener("pointermove",this.onPointerMove),document.addEventListener("pointerup",this.onPointerUp),document.addEventListener("pointercancel",this.onPointerCancel)}removeListeners(){this.elm.removeEventListener("pointerdown",this.onPointerDown),this.elm.removeEventListener("pointermove",this.onPointerMove),document.removeEventListener("pointerup",this.onPointerUp),document.removeEventListener("pointercancel",this.onPointerCancel),this.pointers=[]}addEventListener(t){this.listeners.push(t)}removeEventListener(t){this.listeners=this.listeners.filter(e=>e!==t)}getPointerDistance(t,e){const i=t.x-e.x,n=t.y-e.y;return Math.sqrt(i*i+n*n)}getCentroid(){if(this.pointers.length===0)return null;const t=this.pointers.reduce((e,i)=>(e.x+=i.x,e.y+=i.y,e),{x:0,y:0});return{x:t.x/this.pointers.length,y:t.y/this.pointers.length}}}class _{constructor(t){a(this,"pointers",null);a(this,"lastDistance",0);a(this,"pinchMode",!1);a(this,"lastPinchEndTime",0);a(this,"PINCH_COOLDOWN",111);a(this,"cancelMove",()=>{});a(this,"pointerListeners",[]);a(this,"vvw");a(this,"imageContainer",null);a(this,"isPinching",()=>this.pinchMode||performance.now()-this.lastPinchEndTime<this.PINCH_COOLDOWN);a(this,"internalPointerListener",t=>{const e=this.vvw.state.children.images.find(i=>i.pos===0);if(t.event==="down"){if(this.cancelMove(),this.vvw.state.zoomedIn&&t.pointers.length===1&&!this.isPinching()){const i=this.pointers.getCentroid();e.setInitialCenter(i)}if(t.pointers.length>=2){this.pinchMode=!0;const i=this.pointers.getCentroid();this.lastDistance=this.pointers.getPointerDistance(t.pointers[0],t.pointers[1]),e.setInitialCenter(i)}}else if(t.event==="move"){if(this.vvw.state.zoomedIn&&t.pointers.length===1&&t.lastPointerLen===0&&!this.isPinching()){const i=this.pointers.getCentroid();e.scaleMove(1,i)}if(t.pointers.length>=2&&this.pinchMode){const i=this.pointers.getCentroid(),n=this.pointers.getPointerDistance(t.pointers[0],t.pointers[1]);e.scaleMove(n/this.lastDistance,i)}}else if((t.event==="up"||t.event==="cancel")&&(this.pinchMode||this.vvw.state.zoomedIn))if(this.pinchMode){this.lastPinchEndTime=performance.now(),this.pinchMode=!1;const i=e.setFinalTransform();i!=null&&i.cancel&&(this.cancelMove=i.cancel),i!=null&&i.close&&requestAnimationFrame(()=>{this.vvw.close()})}else this.vvw.state.zoomedIn&&t.pointers.length===0&&!this.isPinching()&&(e.isThrowing=!0,this.cancelMove=e.momentumThrow({x:t.pointer.movementX,y:t.pointer.movementY}));this.pointerListeners.forEach(i=>i({...t,state:this.vvw.state,hasInternalExecution:this.vvw.state.zoomedIn||this.isPinching(),abortController:this.vvw.state.abortController}))});a(this,"onKeyDown",t=>{const e=this.vvw;switch(t.key){case"ArrowLeft":t.preventDefault(),e.prev();break;case"ArrowRight":t.preventDefault(),e.next();break;case"ArrowUp":t.preventDefault(),e.zoomIn();break;case"ArrowDown":t.preventDefault(),e.zoomOut();break;case"Escape":t.preventDefault(),e.close();break}});a(this,"onScroll",t=>{t.preventDefault();const e=this.vvw,i=this.vvw.state.children.images.find(o=>o.pos===0),n=t.deltaY;i.setInitialCenter({x:t.clientX,y:t.clientY}),n<0?e.zoomIn():n>0&&e.zoomOut()});a(this,"onResizeHandler",()=>{this.vvw.state.children.images.forEach(t=>{t.setSizes()})});this.vvw=t}registerPointerListener(t){this.pointerListeners.push(t)}start(t){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 V({elm:t,listeners:[this.internalPointerListener]})}stop(){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=[]}}const C={somethingOpened:null};class A{constructor(t,e={}){a(this,"options");a(this,"state",new q);a(this,"imageContainer",null);a(this,"externalPointerListener",[]);a(this,"elements");a(this,"eventHandlers",null);a(this,"imageSetupFunction",z);a(this,"initFunction",W);a(this,"openFunction",R);a(this,"closeFunction",T);a(this,"transitionFunction",H);a(this,"throttle",new G);a(this,"root",null);a(this,"onClickElements",t=>{t.preventDefault();const e=this.qsOrigin(this.elements),i=Array.prototype.indexOf.call(e,t.currentTarget);this.open(i)});a(this,"defaultOnClickHandler",t=>t.preventDefault());a(this,"lastSwapTime",0);a(this,"isRapidSwap",!1);a(this,"isRapidSwapRelease",0);a(this,"transitionCleanup",null);a(this,"tempDeactivatedUi",[]);a(this,"tempDeactivationRequestBy",null);a(this,"isZoomedIn",!1);var i;this.elements=t,this.options={...y,...e,controls:{...y.controls,...e.controls}},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),(i=this.options.extensions)==null||i.forEach(n=>{this.state.extensions.add(n)}),this.state.isReducedMotion=window.matchMedia("(prefers-reduced-motion: reduce)").matches,this.reset(),this.initFunction(this)}reset(){if(typeof this.elements=="string"){const t=this.qsOrigin(this.elements);this.state.elmLength=t.length,t.forEach(e=>{const i=e;i.removeEventListener("click",this.defaultOnClickHandler),i.removeEventListener("pointerup",this.onClickElements),i.addEventListener("click",this.defaultOnClickHandler),i.addEventListener("pointerup",this.onClickElements)})}else this.state.elmLength=this.elements.length}qs(t){return this.root?this.root.querySelector(t):null}qsOrigin(t){return document.querySelectorAll(t)}registerPointerListener(t){this.externalPointerListener.push(t)}getChildElements(t,e){const i=[],n=[],o=typeof this.elements=="string"?this.qsOrigin(this.elements):this.elements;for(let r=-t;r<=t;r++){const l=(e+r+o.length)%o.length,h=o[l],c={elm:h instanceof HTMLElement?tt(h):{config:h,origin:void 0,parsedSrcSet:void 0},pos:r,index:l,vistaView:this,maxZoomLevel:this.options.maxZoomLevel,transitionShouldWait:()=>this.isRapidSwap,onScale:({vistaImage:g,isMin:m,isMax:w})=>{var b,E,S,L;g.index===this.state.currentIndex&&(this.state.zoomedIn=!m,m?(b=this.qs(".vvw-zoom-out"))==null||b.setAttribute("disabled","true"):(E=this.qs(".vvw-zoom-out"))==null||E.removeAttribute("disabled"),w?(S=this.qs(".vvw-zoom-in"))==null||S.setAttribute("disabled","true"):(L=this.qs(".vvw-zoom-in"))==null||L.removeAttribute("disabled"))}};let u=null;this.state.extensions.forEach(g=>{!u&&g.onInitializeImage&&(u=g.onInitializeImage(c))});const v=u??new O(c),p=document.createElement("div");p.className="vvw-item",p.dataset.vvwPos=`${r}`,p.dataset.vvwIdx=`${l}`,v.thumb&&p.appendChild(v.thumb),p.appendChild(v.element),i.push(v),n.push(p)}return{htmls:n,images:i}}async swap(t,e){var p,g;this.reactivateUi();const i=this.options.preloads||0,n=this.state.currentIndex,{htmls:o,images:r}=this.getChildElements(i,n),l=this.imageContainer,h=this.state.children,f={htmlElements:{from:h.htmls,to:o},images:{from:h.images,to:r},index:{from:t,to:this.state.currentIndex},via:e||{next:!1,prev:!1},vistaView:this};this.imageSetupFunction(f),this.state.zoomedIn=!1,(p=this.qs(".vvw-zoom-out"))==null||p.setAttribute("disabled","true"),(g=this.qs(".vvw-zoom-in"))==null||g.removeAttribute("disabled");const u=performance.now()-this.lastSwapTime<this.options.rapidLimit;this.isRapidSwap=u;const{images:v}=this.state.children;if(this.state.children={htmls:o,images:r},this.displayCurrentInfo(),u)v.forEach(m=>{m.cancelPendingLoad(),m.destroy()});else{const m=this.state.abortController.signal,w=this.transitionFunction(f,m);w&&(this.transitionCleanup=w.cleanup,await w.transitionEnded),this.lastSwapTime=performance.now(),v.forEach(L=>{L.cancelPendingLoad()});const b=v.find(L=>L.index===n),E=b?x.stop(b):void 0,S=r.find(L=>L.index===n);S&&b&&S.cloneStyleFrom(b,E),v.forEach(L=>{L.destroy()})}l.innerHTML="",this.transitionCleanup&&this.transitionCleanup(),o.forEach(m=>{l.appendChild(m)}),r.forEach(m=>{m.init()}),u?(this.isRapidSwapRelease&&clearTimeout(this.isRapidSwapRelease),this.isRapidSwapRelease=setTimeout(()=>{this.isRapidSwap=!1},333)):this.isRapidSwap=!1,this.options.onImageView&&this.options.onImageView(f,this),this.state.extensions.forEach(m=>{m.onImageView&&m.onImageView(f,this)})}displayCurrentInfo(){const t=this.state.currentIndex;typeof this.elements=="string"&&this.qsOrigin(this.elements).forEach((r,l)=>{r.style.opacity="",l===t&&(r.style.opacity="0")});const e=this.qs(".vvw-index"),i=`${t+1}`,n=`${this.state.elmLength}`;e&&(e.textContent=`${i} / ${n}`);const o=this.qs(".vvw-desc");if(o){const r=this.state.children.images.find(h=>h.index===t),l=(r==null?void 0:r.config.alt)||"";l?(o.textContent=l,o.setAttribute("aria-label",`Image ${i} of ${n}: ${l}`),o.style.opacity=""):(o.textContent="",o.setAttribute("aria-label",`Image ${i} of ${n}`),o.style.opacity="0")}}deactivateUi(t,e){t.forEach(i=>{var n,o;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)}),this.tempDeactivationRequestBy=e||null,this.state.extensions.forEach(i=>{i.onDeactivateUi&&i.onDeactivateUi(t,this.tempDeactivationRequestBy,this)})}reactivateUi(){this.tempDeactivatedUi.forEach(t=>{var e,i;t==="zoomIn"?(e=this.qs(".vvw-zoom-in"))==null||e.removeAttribute("disabled"):t==="zoomOut"&&((i=this.qs(".vvw-zoom-out"))==null||i.removeAttribute("disabled"))}),this.state.extensions.forEach(t=>{t.onReactivateUi&&t.onReactivateUi(this.tempDeactivatedUi,this.tempDeactivationRequestBy,this)}),this.tempDeactivatedUi=[],this.tempDeactivationRequestBy=null}open(t=0){var h,f,c,u,v,p,g;if(C.somethingOpened){console.warn("Another VistaView instance is already opened. Close it first before opening a new one.");return}C.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";const e=Y({controls:this.options.controls,extensions:this.state.extensions});if(document.body.append(e),this.root=document.body.querySelector("#vvw-root"),!this.root)throw new Error("Failed to setup VistaView root element.");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");const i=this.options.preloads||0,n=t,{images:o,htmls:r}=this.getChildElements(i,n),l={htmlElements:{from:null,to:r},images:{from:null,to:o},index:{from:null,to:this.state.currentIndex},via:{next:!1,prev:!1},vistaView:this};this.imageSetupFunction(l),this.state.children={htmls:r,images:o},r.forEach(m=>{this.imageContainer.appendChild(m)}),o.forEach(m=>{m.init()}),(h=this.qs(".vvw-close"))==null||h.addEventListener("click",()=>this.close()),(f=this.qs(".vvw-zoom-in"))==null||f.addEventListener("click",()=>this.zoomIn()),(c=this.qs(".vvw-zoom-out"))==null||c.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&&((p=this.qs(".vvw-prev"))==null||p.classList.add("vvw--hidden"),(g=this.qs(".vvw-next"))==null||g.classList.add("vvw--hidden")),this.openFunction(this),this.eventHandlers=new _(this),this.externalPointerListener.forEach(m=>{this.eventHandlers.registerPointerListener(m)}),this.eventHandlers.start(this.imageContainer),requestAnimationFrame(()=>{requestAnimationFrame(()=>{var m;(m=this.root)==null||m.addEventListener("transitionend",()=>{var w;(w=this.root)==null||w.classList.add("vvw--settled")},{once:!0}),this.root.classList.add("vvw--active"),this.displayCurrentInfo(),this.options.onOpen&&this.options.onOpen(this),this.options.onImageView&&this.options.onImageView(l,this),this.state.extensions.forEach(w=>{w.onOpen&&w.onOpen(this),w.onImageView&&w.onImageView(l,this)})})})}async close(t=!0){C.somethingOpened===this&&this.root&&(this.eventHandlers.stop(),this.eventHandlers=null,this.state.children.images.forEach(e=>{e.prepareClose()}),t?await new Promise(e=>{let n=0;this.root.addEventListener("transitionend",o=>{o.target===this.root&&(n++,n===2&&typeof this.elements=="string"&&(this.state.children.images.forEach(r=>{r.destroy()}),this.qsOrigin(this.elements).forEach(r=>{r.style.opacity=""})),n===3&&e(null))}),this.root.classList.add("vvw--closing")}):typeof this.elements=="string"&&(this.state.children.images.forEach(e=>{e.destroy()}),this.qsOrigin(this.elements).forEach(e=>{e.style.opacity=""})),this.root.remove(),this.root=null,this.imageContainer=null,this.state.children={htmls:[],images:[]},this.state.currentIndex=-1,this.state.children.images.forEach(e=>{e.destroy()}),document.body.style.overflow="",C.somethingOpened=null,this.closeFunction(this),this.options.onClose&&this.options.onClose(this),this.state.extensions.forEach(e=>{e.onClose&&e.onClose(this)}))}destroy(){this.close(!1),this.externalPointerListener=[],typeof this.elements=="string"&&this.qsOrigin(this.elements).forEach(t=>{t.removeAttribute("data-vista-idx"),t.removeEventListener("click",this.defaultOnClickHandler),t.removeEventListener("pointerup",this.onClickElements)})}next(){if(C.somethingOpened!==this){console.warn("This VistaView instance is not opened.");return}const t=(this.state.currentIndex+1)%this.state.elmLength;this.view(t,{next:!0,prev:!1})}prev(){if(C.somethingOpened!==this){console.warn("This VistaView instance is not opened.");return}const t=(this.state.currentIndex-1+this.state.elmLength)%this.state.elmLength;this.view(t,{next:!1,prev:!0})}view(t,e){if(C.somethingOpened!==this){console.warn("This VistaView instance is not opened.");return}if(this.state.elmLength<2)return;(t<0||t>=this.state.elmLength)&&(t=(t%this.state.elmLength+this.state.elmLength)%this.state.elmLength);const i=this.state.currentIndex;this.state.currentIndex=t;const n=this.state.abortController;n==null||n.abort(),this.state.abortController=new AbortController,this.swap(i,e)}zoomIn(){if(C.somethingOpened!==this){console.warn("This VistaView instance is not opened.");return}this.tempDeactivatedUi.includes("zoomIn")||this.throttle.fio(()=>{const t=this.state.children.images.find(e=>e.pos===0);t==null||t.animateZoom(1.68)},"zoom",222)}zoomOut(){if(C.somethingOpened!==this){console.warn("This VistaView instance is not opened.");return}this.tempDeactivatedUi.includes("zoomOut")||this.throttle.fio(()=>{const t=this.state.children.images.find(e=>e.pos===0);t==null||t.animateZoom(.68)},"zoom",222)}getCurrentIndex(){return this.state.currentIndex}}function et(s){let t=null;if(typeof s=="string"){if(t=document.querySelectorAll(s),t.length===0)return new Error("No elements found in node list.").toString();for(let e=0;e<t.length;e++){const i=t[e],n=i.tagName.toLowerCase();if(n!=="img"&&n!=="a")return new Error(`Invalid element at index ${e}: expected <img>, <a>, got <${n}>`);if(n==="a"&&!(i.querySelector("img")!==null))return new Error(`Invalid <a> element at index ${e}: must contain <img>`)}}else{const e=s;for(let i=0;i<e.length;i++)if(!e[i].src)return new Error(`Invalid image data at index ${i}: must have 'src'`)}return s}function it({elements:s,...t}){if(!s)return console.error(s),console.error("no elements provided"),console.warn("VistaView: silently returning."),null;let e=et(s);if(e instanceof Error)return console.error(e),console.warn("VistaView: silently returning."),null;const i=new A(e,t);return{open:(n=0)=>i.open(n),reset:()=>i.reset(),close:()=>i.close(),next:()=>i.next(),prev:()=>i.prev(),zoomIn:()=>i.zoomIn(),zoomOut:()=>i.zoomOut(),destroy:()=>i.destroy(),getCurrentIndex:()=>i.getCurrentIndex(),view:n=>{i.view(n)}}}d.DefaultOptions=y,d.VistaBox=F,d.VistaHiresTransition=x,d.VistaImage=O,d.VistaImageEvent=_,d.VistaPointers=V,d.VistaState=q,d.VistaView=A,d.close=T,d.imageSetup=z,d.init=W,d.open=R,d.transition=H,d.vistaView=it,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})}));
|
package/dist/vue.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PropType } from 'vue';
|
|
2
|
-
import { VistaParamsNeo, VistaInterface } from './vistaview';
|
|
2
|
+
import { VistaParamsNeo, VistaInterface, VistaOpt } from './vistaview';
|
|
3
3
|
export declare function useVistaView(options: VistaParamsNeo): VistaInterface;
|
|
4
|
-
export interface VistaViewProps extends
|
|
4
|
+
export interface VistaViewProps extends VistaOpt {
|
|
5
5
|
id?: string;
|
|
6
6
|
class?: string;
|
|
7
7
|
selector?: string;
|
package/dist/vue.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vue.d.ts","sourceRoot":"","sources":["../src/vue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmD,KAAK,QAAQ,EAAE,MAAM,KAAK,CAAC;AAErF,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"vue.d.ts","sourceRoot":"","sources":["../src/vue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmD,KAAK,QAAQ,EAAE,MAAM,KAAK,CAAC;AAErF,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5E,wBAAgB,YAAY,CAAC,OAAO,EAAE,cAAc,GAAG,cAAc,CAwBpE;AAED,MAAM,WAAW,cAAe,SAAQ,QAAQ;IAC9C,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,eAAO,MAAM,SAAS;;;;;;;;gBAUG,QAAQ,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC;;;;;;;;;;;;;gBAAtC,QAAQ,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC;;;;;;;4EA0C7D,CAAC"}
|