vistaview 0.7.6 → 0.7.8
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/types.d.ts +1 -1
- package/dist/lib/types.d.ts.map +1 -1
- package/dist/lib/vista-view.d.ts +3 -3
- package/dist/lib/vista-view.d.ts.map +1 -1
- package/dist/vistaview.js +153 -114
- package/dist/vistaview.umd.js +3 -3
- package/package.json +1 -1
package/dist/lib/types.d.ts
CHANGED
|
@@ -111,6 +111,6 @@ export type VistaPointerListenerArgs = {
|
|
|
111
111
|
export type VistaPointerListener = (args: VistaPointerListenerArgs) => void;
|
|
112
112
|
export type VistaExternalPointerListenerArgs = VistaPointerListenerArgs & {
|
|
113
113
|
hasInternalExecution: boolean;
|
|
114
|
-
abortController: AbortController;
|
|
114
|
+
abortController: AbortController | null;
|
|
115
115
|
};
|
|
116
116
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/lib/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,MAAM,MAAM,aAAa,GAAG;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG;IACrB,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YA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I,EAAE,MAAM,IAAI,CAAC;IACjB,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,eAAe,EAAE,MAAM,MAAM,CAAC;IAC9B,IAAI,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,GAAG,CAAC,EAAE,WAAW,GAAG,QAAQ,CAAC;IAC7B,SAAS,CAAC,EAAE,oBAAoB,EAAE,CAAC;CACpC,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,QAAQ,CAAC;AAClE,MAAM,MAAM,wBAAwB,GAAG;IACrC,KAAK,EAAE,iBAAiB,CAAC;IACzB,OAAO,EAAE,YAAY,CAAC;IACtB,QAAQ,EAAE,YAAY,EAAE,CAAC;IACzB,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,CAAC,IAAI,EAAE,wBAAwB,KAAK,IAAI,CAAC;AAE5E,MAAM,MAAM,gCAAgC,GAAG,wBAAwB,GAAG;IACxE,oBAAoB,EAAE,OAAO,CAAC;IAC9B,eAAe,EAAE,eAAe,GAAG,IAAI,CAAC;CACzC,CAAC"}
|
package/dist/lib/vista-view.d.ts
CHANGED
|
@@ -23,12 +23,12 @@ export declare class VistaView {
|
|
|
23
23
|
private abortController;
|
|
24
24
|
private throttle;
|
|
25
25
|
constructor(elements: NodeListOf<HTMLElement> | VistaImg[], options?: VistaOpt);
|
|
26
|
+
private getChildElements;
|
|
26
27
|
private lastSwapTime;
|
|
27
28
|
private isRapidSwap;
|
|
28
29
|
private isRapidSwapRelease;
|
|
29
30
|
private transitionCleanup;
|
|
30
31
|
private swap;
|
|
31
|
-
private getChildElements;
|
|
32
32
|
isZoomedIn: boolean;
|
|
33
33
|
private zoomIn;
|
|
34
34
|
private zoomOut;
|
|
@@ -44,13 +44,13 @@ export declare class VistaView {
|
|
|
44
44
|
private getInternalPointerListener;
|
|
45
45
|
open(startIndex?: number): void;
|
|
46
46
|
close(animate?: boolean): Promise<void>;
|
|
47
|
+
destroy(): void;
|
|
47
48
|
next(): void;
|
|
48
49
|
prev(): void;
|
|
49
|
-
destroy(): void;
|
|
50
|
-
getCurrentIndex(): number;
|
|
51
50
|
view(index: number, via?: {
|
|
52
51
|
next: boolean;
|
|
53
52
|
prev: boolean;
|
|
54
53
|
}): void;
|
|
54
|
+
getCurrentIndex(): number;
|
|
55
55
|
}
|
|
56
56
|
//# sourceMappingURL=vista-view.d.ts.map
|
|
@@ -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,QAAQ,EAIR,gCAAgC,EACjC,MAAM,SAAS,CAAC;AAajB,eAAO,MAAM,gBAAgB,EAAE;IAAE,eAAe,EAAE,SAAS,GAAG,IAAI,CAAA;CAEjE,CAAC;AAEF,qBAAa,SAAS;IACpB,OAAO,EAAE,QAAQ,CAAC;IAClB,QAAQ,EAAE,UAAU,CAAC,WAAW,CAAC,GAAG,QAAQ,EAAE,CAAC;IAC/C,eAAe,EAAE,OAAO,CAAC;IAEzB,OAAO,CAAC,YAAY,CAAc;IAClC,OAAO,CAAC,eAAe,CAAmE;IAE1F,OAAO,CAAC,aAAa,CAAuB;IAC5C,OAAO,CAAC,YAAY,CAAqB;IACzC,OAAO,CAAC,aAAa,CAAuB;IAC5C,OAAO,CAAC,kBAAkB,CAAiC;IAC3D,OAAO,CAA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IAAI,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI;IAyBjE,eAAe,IAAI,MAAM;CAM1B"}
|
package/dist/vistaview.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
var F = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
var h = (s, t, e) =>
|
|
2
|
+
var A = (s, t, e) => t in s ? F(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
|
|
3
|
+
var h = (s, t, e) => A(s, typeof t != "symbol" ? t + "" : t, e);
|
|
4
4
|
function T(s) {
|
|
5
5
|
return s && !/^0(px|%|r?em|vw|vh|vmin|vmax|cm|mm|in|pt|pc|ex|ch)?$/i.test(s.trim()) && s;
|
|
6
6
|
}
|
|
7
|
-
function
|
|
7
|
+
function R(s) {
|
|
8
8
|
const e = window.getComputedStyle(s).objectFit || "", { width: i, height: n } = s.getBoundingClientRect(), r = s.naturalWidth, a = s.naturalHeight;
|
|
9
9
|
if (!e)
|
|
10
10
|
return { width: i, height: n };
|
|
@@ -72,7 +72,7 @@ function W(s, t, e, i = !1) {
|
|
|
72
72
|
left: p
|
|
73
73
|
} = z(s), x = Math.min(Math.max(p, -r), window.innerWidth + r) - window.innerWidth / 2 + r / 2, g = Math.min(Math.max(d, -a), window.innerHeight + a) - window.innerHeight / 2 + a / 2, m = e.style;
|
|
74
74
|
m.width = `${r}px`, m.height = `${a}px`, m.objectFit = n, e.width = o, e.height = l, m.setProperty("--vvw-init-radius", `${c}`), m.setProperty("--vvw-pulse-radius", `calc(1.3 * ${c})`), m.setProperty("--vvw-init-x", `${x}px`), m.setProperty("--vvw-init-y", `${g}px`), i && (m.setProperty("--vvw-current-x", `${x}px`), m.setProperty("--vvw-current-y", `${g}px`));
|
|
75
|
-
const u =
|
|
75
|
+
const u = R(s.imageElm), b = Math.min(r, u.width), f = Math.min(a, u.height), v = t.style;
|
|
76
76
|
v.setProperty("--vvw-init-radius", `${c}`), v.setProperty("--vvw-init-w", `${b}px`), v.setProperty("--vvw-init-h", `${f}px`), i && (v.setProperty("--vvw-current-radius", `${c}`), v.setProperty("--vvw-current-w", `${b}px`), v.setProperty("--vvw-current-h", `${f}px`), t.dataset.vvwWidth = b.toString(), t.dataset.vvwHeight = f.toString());
|
|
77
77
|
}
|
|
78
78
|
function H(s) {
|
|
@@ -91,14 +91,14 @@ function H(s) {
|
|
|
91
91
|
height: l
|
|
92
92
|
};
|
|
93
93
|
}
|
|
94
|
-
function
|
|
94
|
+
function q(s, t, e) {
|
|
95
95
|
return Math.min(Math.max(s, t), e);
|
|
96
96
|
}
|
|
97
97
|
function L(s, t = 2) {
|
|
98
98
|
const e = Math.pow(10, t);
|
|
99
99
|
return Math.round(s * e) / e;
|
|
100
100
|
}
|
|
101
|
-
const
|
|
101
|
+
const k = '<svg viewBox="0 0 24 24"><path d="m15 18-6-6 6-6"/></svg>', O = '<svg viewBox="0 0 24 24"><path d="m9 18 6-6-6-6"/></svg>', Z = '<svg viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"/><line x1="21" x2="16.65" y1="21" y2="16.65"/><line x1="11" x2="11" y1="8" y2="14"/><line x1="8" x2="14" y1="11" y2="11"/></svg>', N = '<svg viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"/><line x1="21" x2="16.65" y1="21" y2="16.65"/><line x1="8" x2="14" y1="11" y2="11"/></svg>', X = '<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>', Y = '<svg viewBox="0 0 24 24"><path d="M12 15V3"/><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><path d="m7 10 5 5 5-5"/></svg>';
|
|
102
102
|
let $ = null;
|
|
103
103
|
function B() {
|
|
104
104
|
return $ || (window.trustedTypes || (window.trustedTypes = {
|
|
@@ -171,7 +171,7 @@ function _({
|
|
|
171
171
|
<div class="vvw-image-container"></div>
|
|
172
172
|
<div class="vvw-top-bar"><div>${t(s == null ? void 0 : s.topLeft)}</div><div>${t(s == null ? void 0 : s.topCenter)}</div><div>${t(s == null ? void 0 : s.topRight)}</div></div>
|
|
173
173
|
<div class="vvw-bottom-bar"><div>${t(s == null ? void 0 : s.bottomLeft)}</div><div>${t(s == null ? void 0 : s.bottomCenter)}</div><div>${t(s == null ? void 0 : s.bottomRight)}</div></div>
|
|
174
|
-
<div class="vvw-prev vvw-ui"><button aria-label="Previous">${
|
|
174
|
+
<div class="vvw-prev vvw-ui"><button aria-label="Previous">${k}</button></div>
|
|
175
175
|
<div class="vvw-next vvw-ui"><button aria-label="Next">${O}</button></div>
|
|
176
176
|
</div>
|
|
177
177
|
</div>`
|
|
@@ -425,7 +425,7 @@ class it {
|
|
|
425
425
|
if (!this.image) return;
|
|
426
426
|
this.rect || (this.rect = this.image.getBoundingClientRect()), e || (e = this.initialCenter);
|
|
427
427
|
const i = this.snapToTargetIfClose(
|
|
428
|
-
|
|
428
|
+
q(this.rect.width * t, this.minDimension.minWidth, this.maxDimension.width),
|
|
429
429
|
this.minDimension.initialWidth
|
|
430
430
|
);
|
|
431
431
|
this.onScale && this.onScale({
|
|
@@ -541,11 +541,20 @@ class st {
|
|
|
541
541
|
h(this, "defaultOnClickHandler", (t) => t.preventDefault());
|
|
542
542
|
h(this, "abortController", null);
|
|
543
543
|
h(this, "throttle", new nt());
|
|
544
|
+
// ============================================================================
|
|
545
|
+
// SWAP LOGIC - handles image transitions between prev/next
|
|
546
|
+
// ============================================================================
|
|
544
547
|
h(this, "lastSwapTime", 0);
|
|
545
548
|
h(this, "isRapidSwap", !1);
|
|
546
549
|
h(this, "isRapidSwapRelease", 0);
|
|
547
550
|
h(this, "transitionCleanup", null);
|
|
551
|
+
// ============================================================================
|
|
552
|
+
// ZOOM CONTROLS
|
|
553
|
+
// ============================================================================
|
|
548
554
|
h(this, "isZoomedIn", !1);
|
|
555
|
+
// ============================================================================
|
|
556
|
+
// EVENT HANDLERS
|
|
557
|
+
// ============================================================================
|
|
549
558
|
h(this, "onKeyDown", (t) => {
|
|
550
559
|
switch (t.key) {
|
|
551
560
|
case "ArrowLeft":
|
|
@@ -584,47 +593,6 @@ class st {
|
|
|
584
593
|
});
|
|
585
594
|
/// POINTERS
|
|
586
595
|
h(this, "pointerListeners", []);
|
|
587
|
-
h(this, "getInternalPointerListener", () => {
|
|
588
|
-
const t = this.imageState;
|
|
589
|
-
let e = 0, i = !1, n = 0;
|
|
590
|
-
const r = 33;
|
|
591
|
-
let a = () => {
|
|
592
|
-
};
|
|
593
|
-
function o() {
|
|
594
|
-
return i || performance.now() - n < r;
|
|
595
|
-
}
|
|
596
|
-
return (l) => {
|
|
597
|
-
if (l.event === "down") {
|
|
598
|
-
if (a(), this.isZoomedIn && l.pointers.length === 1 && !o()) {
|
|
599
|
-
const c = this.pointers.getCentroid();
|
|
600
|
-
t.setInitialCenter(c);
|
|
601
|
-
}
|
|
602
|
-
if (l.pointers.length >= 2) {
|
|
603
|
-
i = !0;
|
|
604
|
-
const c = this.pointers.getCentroid();
|
|
605
|
-
e = this.pointers.getPointerDistance(l.pointers[0], l.pointers[1]), t.setInitialCenter(c);
|
|
606
|
-
}
|
|
607
|
-
} else if (l.event === "move") {
|
|
608
|
-
if (this.isZoomedIn && l.pointers.length === 1 && l.lastPointerLen === 0 && !o()) {
|
|
609
|
-
const c = this.pointers.getCentroid();
|
|
610
|
-
t.move(c);
|
|
611
|
-
}
|
|
612
|
-
if (l.pointers.length >= 2 && i) {
|
|
613
|
-
const c = this.pointers.getCentroid(), d = this.pointers.getPointerDistance(l.pointers[0], l.pointers[1]);
|
|
614
|
-
t.scaleMove(d / e, c);
|
|
615
|
-
}
|
|
616
|
-
} else (l.event === "up" || l.event === "cancel") && (i || this.isZoomedIn) && (i ? (n = performance.now(), i = !1, t.normalize() && requestAnimationFrame(() => {
|
|
617
|
-
this.close();
|
|
618
|
-
})) : this.isZoomedIn && l.pointers.length === 0 && !o() && (a = t.moveAndNormalize(l.pointer)));
|
|
619
|
-
this.pointerListeners.forEach(
|
|
620
|
-
(c) => c({
|
|
621
|
-
...l,
|
|
622
|
-
hasInternalExecution: this.isZoomedIn || o(),
|
|
623
|
-
abortController: this.abortController
|
|
624
|
-
})
|
|
625
|
-
);
|
|
626
|
-
};
|
|
627
|
-
});
|
|
628
596
|
this.elements = t, this.options = {
|
|
629
597
|
...M,
|
|
630
598
|
...e,
|
|
@@ -645,6 +613,30 @@ class st {
|
|
|
645
613
|
qs(t) {
|
|
646
614
|
return this.root ? this.root.querySelector(t) : null;
|
|
647
615
|
}
|
|
616
|
+
// ============================================================================
|
|
617
|
+
// HELPER METHODS used in open and swap
|
|
618
|
+
// ============================================================================
|
|
619
|
+
getChildElements(t, e) {
|
|
620
|
+
const i = [], n = [];
|
|
621
|
+
for (let r = -t; r <= t; r++) {
|
|
622
|
+
const a = (e + r + this.elements.length) % this.elements.length, o = this.elements[a], l = o instanceof HTMLImageElement ? o : o instanceof HTMLAnchorElement && o.querySelector("img") || void 0, c = o instanceof HTMLElement ? {
|
|
623
|
+
index: a,
|
|
624
|
+
imageElm: l instanceof HTMLImageElement ? l : void 0,
|
|
625
|
+
anchorElm: o instanceof HTMLAnchorElement ? o : void 0,
|
|
626
|
+
src: o.dataset.vistaviewSrc || o.getAttribute("href") || o.getAttribute("src") || "",
|
|
627
|
+
thumb: o.dataset.vistaviewThumb || (l instanceof HTMLImageElement ? l.getAttribute("src") : void 0) || o.getAttribute("href") || void 0,
|
|
628
|
+
alt: l instanceof HTMLImageElement && l.getAttribute("alt") || void 0
|
|
629
|
+
} : {
|
|
630
|
+
index: a,
|
|
631
|
+
...o
|
|
632
|
+
};
|
|
633
|
+
n.push(c), i.push(U(c, r));
|
|
634
|
+
}
|
|
635
|
+
return {
|
|
636
|
+
htmls: i,
|
|
637
|
+
images: n
|
|
638
|
+
};
|
|
639
|
+
}
|
|
648
640
|
async swap(t, e) {
|
|
649
641
|
const i = this.options.preloads || 0, n = this.currentIndex, { htmls: r, images: a } = this.getChildElements(i, n), o = this.imageContainer, l = this.currentChildren, c = {
|
|
650
642
|
htmlElements: { from: l.htmls, to: r },
|
|
@@ -672,36 +664,14 @@ class st {
|
|
|
672
664
|
const f = u.getAttribute("style") || "", v = u.classList.contains("vvw--loaded"), E = u.classList.contains("vvw--ready"), I = u.width, S = u.height;
|
|
673
665
|
this.imageState.reset(), o.innerHTML = "", this.transitionCleanup && this.transitionCleanup(), r.forEach((y) => {
|
|
674
666
|
const w = y.querySelector("img.vvw-img-hi");
|
|
675
|
-
y.dataset.vvwPos === "0" && !d.aborted && f && I && S && (v && (w.classList.add("vvw--loaded"), w.dataset.vvwWidth = u.dataset.vvwWidth || "", w.dataset.vvwHeight = u.dataset.vvwHeight || ""), E && (w.classList.add("vvw--ready"), w.width = I, w.height = S), w.setAttribute("style", f)), o.appendChild(y), y.dataset.vvwPos === "0" && !d.aborted && E ? (this.imageState.setCurrentImage(w), this.imageState.setInitialCenter()) :
|
|
676
|
-
|
|
677
|
-
() => {
|
|
667
|
+
y.dataset.vvwPos === "0" && !d.aborted && f && I && S && (v && (w.classList.add("vvw--loaded"), w.dataset.vvwWidth = u.dataset.vvwWidth || "", w.dataset.vvwHeight = u.dataset.vvwHeight || ""), E && (w.classList.add("vvw--ready"), w.width = I, w.height = S), w.setAttribute("style", f)), o.appendChild(y), y.dataset.vvwPos === "0" && !d.aborted && E ? (this.imageState.setCurrentImage(w), this.imageState.setInitialCenter()) : (
|
|
668
|
+
// for non-ready elements, restore animation state
|
|
669
|
+
y.dataset.vvwPos === "0" && !d.aborted && f && I && S && v && b && (this.imageTransitions.set(w, b), this.transitionImage(w, () => {
|
|
678
670
|
this.imageState.setCurrentImage(w), this.imageState.setInitialCenter(), w.classList.add("vvw--ready");
|
|
679
|
-
}
|
|
680
|
-
|
|
681
|
-
));
|
|
671
|
+
}))
|
|
672
|
+
);
|
|
682
673
|
}), this.isRapidSwap = !1, this.waitForImagesToLoad(), this.options.onImageView && this.options.onImageView(c);
|
|
683
674
|
}
|
|
684
|
-
getChildElements(t, e) {
|
|
685
|
-
const i = [], n = [];
|
|
686
|
-
for (let r = -t; r <= t; r++) {
|
|
687
|
-
const a = (e + r + this.elements.length) % this.elements.length, o = this.elements[a], l = o instanceof HTMLImageElement ? o : o instanceof HTMLAnchorElement && o.querySelector("img") || void 0, c = o instanceof HTMLElement ? {
|
|
688
|
-
index: a,
|
|
689
|
-
imageElm: l instanceof HTMLImageElement ? l : void 0,
|
|
690
|
-
anchorElm: o instanceof HTMLAnchorElement ? o : void 0,
|
|
691
|
-
src: o.dataset.vistaviewSrc || o.getAttribute("href") || o.getAttribute("src") || "",
|
|
692
|
-
thumb: o.dataset.vistaviewThumb || (l instanceof HTMLImageElement ? l.getAttribute("src") : void 0) || o.getAttribute("href") || void 0,
|
|
693
|
-
alt: l instanceof HTMLImageElement && l.getAttribute("alt") || void 0
|
|
694
|
-
} : {
|
|
695
|
-
index: a,
|
|
696
|
-
...o
|
|
697
|
-
};
|
|
698
|
-
n.push(c), i.push(U(c, r));
|
|
699
|
-
}
|
|
700
|
-
return {
|
|
701
|
-
htmls: i,
|
|
702
|
-
images: n
|
|
703
|
-
};
|
|
704
|
-
}
|
|
705
675
|
zoomIn() {
|
|
706
676
|
this.throttle.fio(
|
|
707
677
|
() => {
|
|
@@ -720,6 +690,9 @@ class st {
|
|
|
720
690
|
222
|
|
721
691
|
);
|
|
722
692
|
}
|
|
693
|
+
// ============================================================================
|
|
694
|
+
// UI UPDATES
|
|
695
|
+
// ============================================================================
|
|
723
696
|
displayActiveIndex() {
|
|
724
697
|
var a;
|
|
725
698
|
const t = this.currentIndex;
|
|
@@ -734,29 +707,35 @@ class st {
|
|
|
734
707
|
l ? (r.textContent = l, r.setAttribute("aria-label", `Image ${i} of ${n}: ${l}`)) : (r.textContent = "", r.setAttribute("aria-label", `Image ${i} of ${n}`));
|
|
735
708
|
}
|
|
736
709
|
}
|
|
710
|
+
// ============================================================================
|
|
711
|
+
// IMAGE LOADING & TRANSITIONS
|
|
712
|
+
// ============================================================================
|
|
713
|
+
// to make image (.vvw-img-hi) transitions smoothly to target size
|
|
737
714
|
transitionImage(t, e) {
|
|
738
|
-
if (t.classList.contains("vvw--load-cancelled"))
|
|
739
|
-
|
|
715
|
+
if (!t.classList.contains("vvw--load-cancelled")) {
|
|
716
|
+
if (this.isRapidSwap) {
|
|
717
|
+
requestAnimationFrame(() => {
|
|
718
|
+
this.transitionImage(t, e);
|
|
719
|
+
});
|
|
720
|
+
return;
|
|
721
|
+
}
|
|
740
722
|
requestAnimationFrame(() => {
|
|
741
|
-
this.
|
|
723
|
+
const i = this.imageTransitions.get(t);
|
|
724
|
+
if (!i || t.classList.contains("vvw--load-cancelled")) return;
|
|
725
|
+
const { current: n, target: r } = i, a = {
|
|
726
|
+
width: n.width + (r.width - n.width) * 0.2,
|
|
727
|
+
height: n.height + (r.height - n.height) * 0.2,
|
|
728
|
+
radius: n.radius + (r.radius - n.radius) * 0.2
|
|
729
|
+
};
|
|
730
|
+
Math.abs(a.width - r.width) < 1 && Math.abs(a.height - r.height) < 1 && Math.abs(a.radius - r.radius) < 1 ? (t.style.setProperty("--vvw-current-w", `${r.width}px`), t.style.setProperty("--vvw-current-h", `${r.height}px`), t.style.setProperty("--vvw-current-radius", `${r.radius}px`), this.imageTransitions.delete(t), e()) : (t.style.setProperty("--vvw-current-w", `${a.width}px`), t.style.setProperty("--vvw-current-h", `${a.height}px`), t.style.setProperty("--vvw-current-radius", `${a.radius}px`), this.imageTransitions.set(t, { current: a, target: r }), this.transitionImage(
|
|
731
|
+
t,
|
|
732
|
+
e
|
|
733
|
+
/* false */
|
|
734
|
+
));
|
|
742
735
|
});
|
|
743
|
-
return;
|
|
744
736
|
}
|
|
745
|
-
const i = this.imageTransitions.get(t);
|
|
746
|
-
i && requestAnimationFrame(() => {
|
|
747
|
-
if (t.classList.contains("vvw--load-cancelled")) return;
|
|
748
|
-
const { current: n, target: r } = i, a = {
|
|
749
|
-
width: n.width + (r.width - n.width) * 0.2,
|
|
750
|
-
height: n.height + (r.height - n.height) * 0.2,
|
|
751
|
-
radius: n.radius + (r.radius - n.radius) * 0.2
|
|
752
|
-
};
|
|
753
|
-
Math.abs(a.width - r.width) < 1 && Math.abs(a.height - r.height) < 1 && Math.abs(a.radius - r.radius) < 1 ? (t.style.setProperty("--vvw-current-w", `${r.width}px`), t.style.setProperty("--vvw-current-h", `${r.height}px`), t.style.setProperty("--vvw-current-radius", `${r.radius}px`), this.imageTransitions.delete(t), e()) : (t.style.setProperty("--vvw-current-w", `${a.width}px`), t.style.setProperty("--vvw-current-h", `${a.height}px`), t.style.setProperty("--vvw-current-radius", `${a.radius}px`), this.imageTransitions.set(t, { current: a, target: r }), this.transitionImage(
|
|
754
|
-
t,
|
|
755
|
-
e
|
|
756
|
-
/* false */
|
|
757
|
-
));
|
|
758
|
-
});
|
|
759
737
|
}
|
|
738
|
+
// wait, and add classes to high-res images when they load
|
|
760
739
|
waitForImagesToLoad() {
|
|
761
740
|
this.imageContainer.querySelectorAll("img.vvw-img-hi:not(.vvw--loaded)").forEach((i) => {
|
|
762
741
|
const n = i;
|
|
@@ -794,13 +773,64 @@ class st {
|
|
|
794
773
|
});
|
|
795
774
|
});
|
|
796
775
|
}
|
|
776
|
+
// ============================================================================
|
|
777
|
+
// POINTER EVENT MANAGEMENT
|
|
778
|
+
// ============================================================================
|
|
779
|
+
// register external pointer listener
|
|
797
780
|
registerPointerListener(t) {
|
|
798
781
|
this.pointerListeners.push(t);
|
|
799
782
|
}
|
|
800
783
|
unregisterPointerListeners() {
|
|
801
784
|
this.pointerListeners = [];
|
|
802
785
|
}
|
|
803
|
-
|
|
786
|
+
// internal pointer listener
|
|
787
|
+
// this is a function, called at open
|
|
788
|
+
// the closure makes it easier to have local variables without polluting class scope
|
|
789
|
+
getInternalPointerListener() {
|
|
790
|
+
const t = this.imageState;
|
|
791
|
+
let e = 0, i = !1, n = 0;
|
|
792
|
+
const r = 33;
|
|
793
|
+
let a = () => {
|
|
794
|
+
};
|
|
795
|
+
function o() {
|
|
796
|
+
return i || performance.now() - n < r;
|
|
797
|
+
}
|
|
798
|
+
return (l) => {
|
|
799
|
+
if (l.event === "down") {
|
|
800
|
+
if (a(), this.isZoomedIn && l.pointers.length === 1 && !o()) {
|
|
801
|
+
const c = this.pointers.getCentroid();
|
|
802
|
+
t.setInitialCenter(c);
|
|
803
|
+
}
|
|
804
|
+
if (l.pointers.length >= 2) {
|
|
805
|
+
i = !0;
|
|
806
|
+
const c = this.pointers.getCentroid();
|
|
807
|
+
e = this.pointers.getPointerDistance(l.pointers[0], l.pointers[1]), t.setInitialCenter(c);
|
|
808
|
+
}
|
|
809
|
+
} else if (l.event === "move") {
|
|
810
|
+
if (this.isZoomedIn && l.pointers.length === 1 && l.lastPointerLen === 0 && !o()) {
|
|
811
|
+
const c = this.pointers.getCentroid();
|
|
812
|
+
t.move(c);
|
|
813
|
+
}
|
|
814
|
+
if (l.pointers.length >= 2 && i) {
|
|
815
|
+
const c = this.pointers.getCentroid(), d = this.pointers.getPointerDistance(l.pointers[0], l.pointers[1]);
|
|
816
|
+
t.scaleMove(d / e, c);
|
|
817
|
+
}
|
|
818
|
+
} else (l.event === "up" || l.event === "cancel") && (i || this.isZoomedIn) && (i ? (n = performance.now(), i = !1, t.normalize() && requestAnimationFrame(() => {
|
|
819
|
+
this.close();
|
|
820
|
+
})) : this.isZoomedIn && l.pointers.length === 0 && !o() && (a = t.moveAndNormalize(l.pointer)));
|
|
821
|
+
this.pointerListeners.forEach(
|
|
822
|
+
(c) => c({
|
|
823
|
+
...l,
|
|
824
|
+
hasInternalExecution: this.isZoomedIn || o(),
|
|
825
|
+
abortController: this.abortController
|
|
826
|
+
})
|
|
827
|
+
);
|
|
828
|
+
};
|
|
829
|
+
}
|
|
830
|
+
// ============================================================================
|
|
831
|
+
// LIFECYCLE METHODS - open, close, destroy
|
|
832
|
+
// ============================================================================
|
|
833
|
+
// OPEN
|
|
804
834
|
open(t = 0) {
|
|
805
835
|
var c, d, p, x, g;
|
|
806
836
|
if (C.somethingOpened)
|
|
@@ -845,17 +875,19 @@ class st {
|
|
|
845
875
|
u.classList.remove("vvw--loading");
|
|
846
876
|
})) : v.onClick(E, this));
|
|
847
877
|
});
|
|
848
|
-
}), this.initFunction(this),
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
878
|
+
}), this.initFunction(this), requestAnimationFrame(() => {
|
|
879
|
+
requestAnimationFrame(() => {
|
|
880
|
+
var m;
|
|
881
|
+
(m = this.root) == null || m.addEventListener(
|
|
882
|
+
"transitionend",
|
|
883
|
+
() => {
|
|
884
|
+
var u;
|
|
885
|
+
(u = this.root) == null || u.classList.add("vvw--settled"), this.imageState.reset(), this.waitForImagesToLoad();
|
|
886
|
+
},
|
|
887
|
+
{ once: !0 }
|
|
888
|
+
), this.root.classList.add("vvw--active"), this.displayActiveIndex(), this.options.onOpen && this.options.onOpen(this), this.options.onImageView && this.options.onImageView(o);
|
|
889
|
+
});
|
|
890
|
+
});
|
|
859
891
|
}
|
|
860
892
|
/// CLOSE
|
|
861
893
|
async close(t = !0) {
|
|
@@ -870,6 +902,15 @@ class st {
|
|
|
870
902
|
e.style.opacity = "";
|
|
871
903
|
}), this.options.keyboardListeners && window.removeEventListener("keydown", this.onKeyDown), window.removeEventListener("resize", this.onResizeHandler), window.removeEventListener("wheel", this.onScroll), this.unregisterPointerListeners(), this.pointers.removeListeners(), this.root.remove(), this.root = null, this.imageContainer = null, this.currentChildren = null, this.currentIndex = -1, document.body.style.overflow = "", C.somethingOpened = null, this.closeFunction(this), this.options.onClose && this.options.onClose(this));
|
|
872
904
|
}
|
|
905
|
+
// DESTROY
|
|
906
|
+
destroy() {
|
|
907
|
+
this.close(!1), this.elements instanceof NodeList && this.elements.forEach((t) => {
|
|
908
|
+
t.removeAttribute("data-vista-idx"), t.removeEventListener("click", this.defaultOnClickHandler), t.removeEventListener("pointerup", this.onClickElements);
|
|
909
|
+
});
|
|
910
|
+
}
|
|
911
|
+
// ============================================================================
|
|
912
|
+
// NAVIGATION METHODS - next, prev, view
|
|
913
|
+
// ============================================================================
|
|
873
914
|
next() {
|
|
874
915
|
if (C.somethingOpened !== this)
|
|
875
916
|
return;
|
|
@@ -882,14 +923,6 @@ class st {
|
|
|
882
923
|
const t = (this.currentIndex - 1 + this.elements.length) % this.elements.length;
|
|
883
924
|
this.view(t, { next: !1, prev: !0 });
|
|
884
925
|
}
|
|
885
|
-
destroy() {
|
|
886
|
-
this.close(!1), this.elements instanceof NodeList && this.elements.forEach((t) => {
|
|
887
|
-
t.removeAttribute("data-vista-idx"), t.removeEventListener("click", this.defaultOnClickHandler), t.removeEventListener("pointerup", this.onClickElements);
|
|
888
|
-
});
|
|
889
|
-
}
|
|
890
|
-
getCurrentIndex() {
|
|
891
|
-
return C.somethingOpened !== this ? -1 : this.currentIndex;
|
|
892
|
-
}
|
|
893
926
|
view(t, e) {
|
|
894
927
|
if (C.somethingOpened !== this || t < 0 || t >= this.elements.length)
|
|
895
928
|
return;
|
|
@@ -898,6 +931,12 @@ class st {
|
|
|
898
931
|
const n = this.abortController;
|
|
899
932
|
n == null || n.abort(), this.abortController = new AbortController(), this.swap(i, e);
|
|
900
933
|
}
|
|
934
|
+
// ============================================================================
|
|
935
|
+
// GETTERS
|
|
936
|
+
// ============================================================================
|
|
937
|
+
getCurrentIndex() {
|
|
938
|
+
return C.somethingOpened !== this ? -1 : this.currentIndex;
|
|
939
|
+
}
|
|
901
940
|
}
|
|
902
941
|
function ot(s) {
|
|
903
942
|
let t = null;
|
package/dist/vistaview.umd.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
(function(v,w){typeof exports=="object"&&typeof module<"u"?w(exports):typeof define=="function"&&define.amd?define(["exports"],w):(v=typeof globalThis<"u"?globalThis:v||self,w(v.VistaView={}))})(this,(function(v){"use strict";var rt=Object.defineProperty;var at=(v,w,$)=>w in v?rt(v,w,{enumerable:!0,configurable:!0,writable:!0,value:$}):v[w]=$;var h=(v,w,$)=>at(v,typeof w!="symbol"?w+"":w,$);function w(s){return s&&!/^0(px|%|r?em|vw|vh|vmin|vmax|cm|mm|in|pt|pc|ex|ch)?$/i.test(s.trim())&&s}function $(s){const e=window.getComputedStyle(s).objectFit||"",{width:i,height:n}=s.getBoundingClientRect(),r=s.naturalWidth,a=s.naturalHeight;if(!e)return{width:i,height:n};if(!r||!a)return{width:i,height:n};const o=r/a,l=i/n;switch(e){case"fill":return{width:i,height:n};case"none":return{width:r,height:a};case"contain":return o>l?{width:i,height:i/o}:{width:n*o,height:n};case"cover":return o<l?{width:i,height:i/o}:{width:n*o,height:n};case"scale-down":{const c={width:r,height:a},d=o>l?{width:i,height:i/o}:{width:n*o,height:n};return d.width<=c.width&&d.height<=c.height?d:c}}return{width:i,height:n}}function W(s){const t=getComputedStyle(s),e=s.getBoundingClientRect();return{objectFit:t.objectFit,borderRadius:t.borderRadius,objectPosition:t.objectPosition,overflow:t.overflow,top:e.top,left:e.left,width:e.width,height:e.height,naturalWidth:s.naturalWidth,naturalHeight:s.naturalHeight}}function Z(s){const t=s.imageElm?W(s.imageElm):null,e=s.anchorElm?W(s.anchorElm):null,i=w(t==null?void 0:t.borderRadius),n=e&&w(e==null?void 0:e.borderRadius),r=(n?e==null?void 0:e.borderRadius:i?t==null?void 0:t.borderRadius:"")||"";return{fit:(t==null?void 0:t.objectFit)||(e==null?void 0:e.objectFit)||"",pos:(t==null?void 0:t.objectPosition)||"",br:r,overflow:n?e.overflow:i?t.overflow:"",nw:(t==null?void 0:t.naturalWidth)||0,nh:(t==null?void 0:t.naturalHeight)||0,w:(e==null?void 0:e.width)||(t==null?void 0:t.width)||0,h:(e==null?void 0:e.height)||(t==null?void 0:t.height)||0,top:(e==null?void 0:e.top)||(t==null?void 0:t.top)||0,left:(e==null?void 0:e.left)||(t==null?void 0:t.left)||0}}function P(s,t,e,i=!1){const{fit:n,w:r,h:a,nw:o,nh:l,br:c,top:d,left:f}=Z(s),L=Math.min(Math.max(f,-r),window.innerWidth+r)-window.innerWidth/2+r/2,y=Math.min(Math.max(d,-a),window.innerHeight+a)-window.innerHeight/2+a/2,m=e.style;m.width=`${r}px`,m.height=`${a}px`,m.objectFit=n,e.width=o,e.height=l,m.setProperty("--vvw-init-radius",`${c}`),m.setProperty("--vvw-pulse-radius",`calc(1.3 * ${c})`),m.setProperty("--vvw-init-x",`${L}px`),m.setProperty("--vvw-init-y",`${y}px`),i&&(m.setProperty("--vvw-current-x",`${L}px`),m.setProperty("--vvw-current-y",`${y}px`));const u=$(s.imageElm),E=Math.min(r,u.width),x=Math.min(a,u.height),p=t.style;p.setProperty("--vvw-init-radius",`${c}`),p.setProperty("--vvw-init-w",`${E}px`),p.setProperty("--vvw-init-h",`${x}px`),i&&(p.setProperty("--vvw-current-radius",`${c}`),p.setProperty("--vvw-current-w",`${E}px`),p.setProperty("--vvw-current-h",`${x}px`),t.dataset.vvwWidth=E.toString(),t.dataset.vvwHeight=x.toString())}function F(s){const t=window.innerWidth,e=window.innerHeight,i=s.naturalWidth,n=s.naturalHeight;if(!i||!n)throw new Error("Image natural dimensions are zero");if(i<t&&n<e)return{width:i,height:n};const r=i/n,a=t/e;let o,l;return r>a?(o=t,l=t/r):(l=e,o=e*r),{width:o,height:l}}function N(s,t,e){return Math.min(Math.max(s,t),e)}function I(s,t=2){const e=Math.pow(10,t);return Math.round(s*e)/e}const X='<svg viewBox="0 0 24 24"><path d="m15 18-6-6 6-6"/></svg>',Y='<svg viewBox="0 0 24 24"><path d="m9 18 6-6-6-6"/></svg>',B='<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>',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="8" x2="14" y1="11" y2="11"/></svg>',V='<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>',U='<svg viewBox="0 0 24 24"><path d="M12 15V3"/><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><path d="m7 10 5 5 5-5"/></svg>';let D=null;function _(){return D||(window.trustedTypes||(window.trustedTypes={createPolicy:(s,t)=>t}),D=window.trustedTypes.createPolicy("vistaView-policy",{createHTML:s=>s,createScript:()=>{throw new Error("Not implemented")},createScriptURL:()=>{throw new Error("Not implemented")}}),D)}function
|
|
2
|
-
<img class="vvw-img-hi" src="${s.src}" alt="${s.alt||""}" />`));const i=e.querySelector("img.vvw-img-lo"),n=e.querySelector("img.vvw-img-hi");return P(s,n,i,t===0),e}function J({controls:s}){const t=i=>i?i.map(K).join(""):"";return
|
|
1
|
+
(function(v,w){typeof exports=="object"&&typeof module<"u"?w(exports):typeof define=="function"&&define.amd?define(["exports"],w):(v=typeof globalThis<"u"?globalThis:v||self,w(v.VistaView={}))})(this,(function(v){"use strict";var rt=Object.defineProperty;var at=(v,w,$)=>w in v?rt(v,w,{enumerable:!0,configurable:!0,writable:!0,value:$}):v[w]=$;var h=(v,w,$)=>at(v,typeof w!="symbol"?w+"":w,$);function w(s){return s&&!/^0(px|%|r?em|vw|vh|vmin|vmax|cm|mm|in|pt|pc|ex|ch)?$/i.test(s.trim())&&s}function $(s){const e=window.getComputedStyle(s).objectFit||"",{width:i,height:n}=s.getBoundingClientRect(),r=s.naturalWidth,a=s.naturalHeight;if(!e)return{width:i,height:n};if(!r||!a)return{width:i,height:n};const o=r/a,l=i/n;switch(e){case"fill":return{width:i,height:n};case"none":return{width:r,height:a};case"contain":return o>l?{width:i,height:i/o}:{width:n*o,height:n};case"cover":return o<l?{width:i,height:i/o}:{width:n*o,height:n};case"scale-down":{const c={width:r,height:a},d=o>l?{width:i,height:i/o}:{width:n*o,height:n};return d.width<=c.width&&d.height<=c.height?d:c}}return{width:i,height:n}}function W(s){const t=getComputedStyle(s),e=s.getBoundingClientRect();return{objectFit:t.objectFit,borderRadius:t.borderRadius,objectPosition:t.objectPosition,overflow:t.overflow,top:e.top,left:e.left,width:e.width,height:e.height,naturalWidth:s.naturalWidth,naturalHeight:s.naturalHeight}}function Z(s){const t=s.imageElm?W(s.imageElm):null,e=s.anchorElm?W(s.anchorElm):null,i=w(t==null?void 0:t.borderRadius),n=e&&w(e==null?void 0:e.borderRadius),r=(n?e==null?void 0:e.borderRadius:i?t==null?void 0:t.borderRadius:"")||"";return{fit:(t==null?void 0:t.objectFit)||(e==null?void 0:e.objectFit)||"",pos:(t==null?void 0:t.objectPosition)||"",br:r,overflow:n?e.overflow:i?t.overflow:"",nw:(t==null?void 0:t.naturalWidth)||0,nh:(t==null?void 0:t.naturalHeight)||0,w:(e==null?void 0:e.width)||(t==null?void 0:t.width)||0,h:(e==null?void 0:e.height)||(t==null?void 0:t.height)||0,top:(e==null?void 0:e.top)||(t==null?void 0:t.top)||0,left:(e==null?void 0:e.left)||(t==null?void 0:t.left)||0}}function P(s,t,e,i=!1){const{fit:n,w:r,h:a,nw:o,nh:l,br:c,top:d,left:f}=Z(s),L=Math.min(Math.max(f,-r),window.innerWidth+r)-window.innerWidth/2+r/2,y=Math.min(Math.max(d,-a),window.innerHeight+a)-window.innerHeight/2+a/2,m=e.style;m.width=`${r}px`,m.height=`${a}px`,m.objectFit=n,e.width=o,e.height=l,m.setProperty("--vvw-init-radius",`${c}`),m.setProperty("--vvw-pulse-radius",`calc(1.3 * ${c})`),m.setProperty("--vvw-init-x",`${L}px`),m.setProperty("--vvw-init-y",`${y}px`),i&&(m.setProperty("--vvw-current-x",`${L}px`),m.setProperty("--vvw-current-y",`${y}px`));const u=$(s.imageElm),E=Math.min(r,u.width),x=Math.min(a,u.height),p=t.style;p.setProperty("--vvw-init-radius",`${c}`),p.setProperty("--vvw-init-w",`${E}px`),p.setProperty("--vvw-init-h",`${x}px`),i&&(p.setProperty("--vvw-current-radius",`${c}`),p.setProperty("--vvw-current-w",`${E}px`),p.setProperty("--vvw-current-h",`${x}px`),t.dataset.vvwWidth=E.toString(),t.dataset.vvwHeight=x.toString())}function F(s){const t=window.innerWidth,e=window.innerHeight,i=s.naturalWidth,n=s.naturalHeight;if(!i||!n)throw new Error("Image natural dimensions are zero");if(i<t&&n<e)return{width:i,height:n};const r=i/n,a=t/e;let o,l;return r>a?(o=t,l=t/r):(l=e,o=e*r),{width:o,height:l}}function N(s,t,e){return Math.min(Math.max(s,t),e)}function I(s,t=2){const e=Math.pow(10,t);return Math.round(s*e)/e}const X='<svg viewBox="0 0 24 24"><path d="m15 18-6-6 6-6"/></svg>',Y='<svg viewBox="0 0 24 24"><path d="m9 18 6-6-6-6"/></svg>',B='<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>',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="8" x2="14" y1="11" y2="11"/></svg>',V='<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>',U='<svg viewBox="0 0 24 24"><path d="M12 15V3"/><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><path d="m7 10 5 5 5-5"/></svg>';let D=null;function _(){return D||(window.trustedTypes||(window.trustedTypes={createPolicy:(s,t)=>t}),D=window.trustedTypes.createPolicy("vistaView-policy",{createHTML:s=>s,createScript:()=>{throw new Error("Not implemented")},createScriptURL:()=>{throw new Error("Not implemented")}}),D)}function A(s){const e=_().createHTML(s),i=document.createElement("template");i.innerHTML=e;const n=i.content;return i.remove(),n}function R(){return{name:"download",icon:U,onClick:async s=>{var r;const t=await fetch(s.src),e=await t.blob(),i=t.url,n=document.createElement("a");n.href=URL.createObjectURL(e),n.download=((r=i.split("/").pop())==null?void 0:r.split("?")[0].split("#")[0])||"download",document.body.appendChild(n),n.click(),document.body.removeChild(n)}}}function K(s){if(typeof s=="string")switch(s){case"zoomIn":return`<button aria-label="Zoom In" class="vvw-zoom-in vvw-ui">${B}</button>`;case"zoomOut":return`<button aria-label="Zoom Out" disabled class="vvw-zoom-out vvw-ui">${j}</button>`;case"close":return`<button aria-label="Close" class="vvw-close vvw-ui">${V}</button>`;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:return""}return`<button class="vvw-ui" aria-label="${s.description||s.name}" data-vvw-control="${s.name}">${s.icon}</button>`}function G(s,t){const e=document.createElement("div");e.className="vvw-item",e.dataset.vvwPos=`${t!==void 0?t:""}`,e.dataset.vvwIdx=s.index.toString(),e.appendChild(A(`<img class="vvw-img-lo" src="${s.thumb||s.src}" alt="${s.alt||""}" />
|
|
2
|
+
<img class="vvw-img-hi" src="${s.src}" alt="${s.alt||""}" />`));const i=e.querySelector("img.vvw-img-lo"),n=e.querySelector("img.vvw-img-hi");return P(s,n,i,t===0),e}function J({controls:s}){const t=i=>i?i.map(K).join(""):"";return A(`<div class="vvw-root" id="vvw-root">
|
|
3
3
|
<div class="vvw-container">
|
|
4
4
|
<div class="vvw-bg"></div>
|
|
5
5
|
<div class="vvw-image-container"></div>
|
|
@@ -8,4 +8,4 @@
|
|
|
8
8
|
<div class="vvw-prev vvw-ui"><button aria-label="Previous">${X}</button></div>
|
|
9
9
|
<div class="vvw-next vvw-ui"><button aria-label="Next">${Y}</button></div>
|
|
10
10
|
</div>
|
|
11
|
-
</div>`)}const M={animationDurationBase:333,maxZoomLevel:2,preloads:1,keyboardListeners:!0,arrowOnSmallScreens:!1,rapidLimit:222,controls:{topLeft:["indexDisplay"],topRight:["zoomIn","zoomOut",A(),"close"],bottomLeft:["description"]}};function z(s){}function k(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",Q(s)}function Q(s){let t={x:0,y:0},e={x:0,y:0},i=null;s.registerPointerListener(n=>{var r;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},(r=n.abortController)==null||r.abort()),n.event==="move"){e={x:n.pointer.x,y:n.pointer.y};const a=e.x-t.x,o=e.y-t.y;if(!i&&Math.abs(o)>Math.abs(a)||i==="y"){const l=o/window.innerHeight*100;s.imageContainer.style.transition="none",s.imageContainer.style.transform=`translateY(${l}vh)`,i="y"}else if(!i&&Math.abs(a)>Math.abs(o)||i==="x"){const l=a/window.innerWidth*100;s.imageContainer.style.transition="none",s.imageContainer.style.transform=`translateX(${l}vw)`,i="x"}}if(n.event==="up"||n.event==="cancel"){let a=function(o){var l;(l=s.imageContainer)==null||l.addEventListener("transitionend",function c(){var d;(d=s.imageContainer)==null||d.removeEventListener("transitionend",c),s.imageContainer.style.transition="",s.imageContainer.style.transform=""}),s.imageContainer.style.transition="transform 222ms ease",s.imageContainer.style.transform=o};if(i==="y"){const o=e.y-t.y;Math.abs(o)>144?(s.imageContainer.style.transition="transform 222ms ease",s.imageContainer.style.transform="translateY(0vh)",s.close()):a("translateY(0vh)")}if(i==="x"){const o=e.x-t.x,l=n.pointer.movementX,c=1;s.imageContainer.style.transition="",o>0&&Math.abs(l)>c?s.prev():o<0&&Math.abs(l)>c?s.next():a("translateX(0vw)")}i=null,t={x:0,y:0},e={x:0,y:0}}}})}function q(s){}function O({vistaView:{isReducedMotion:s},htmlElements:{to:t},index:{from:e,to:i},vistaView:{elements:n,imageContainer:r,options:a}},o){if(!(!t||o.aborted||s||!(Math.abs(i-e)===1||e===0&&i===n.length-1||e===n.length-1&&i===0)))return{cleanup:()=>{r.style.transition="",r.style.transform=""},transitionEnded:new Promise(c=>{r.addEventListener("transitionend",()=>{c()},{once:!0}),r.addEventListener("transitioncancel",()=>{o.aborted&&c()},{once:!0});const d=Math.round(a.animationDurationBase*100)/100,f=i===e+1||e===n.length-1&&i===0?"translateX(-100vw)":"translateX(100vw)";r.style.transition=`transform ${d}ms ease`,r.style.transform=f})}}class tt{constructor({elm:t,listeners:e}){h(this,"pointers",[]);h(this,"elm");h(this,"listeners",[]);h(this,"lastPointerDownId",null);h(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)}});h(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}))});h(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})))});h(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(r=>r.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(r=>r({event:"up",pointer:i,pointers:this.pointers,lastPointerLen:n}))});h(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(r=>r.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(r=>r({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 et{constructor(t,e){h(this,"maxZoomLevel");h(this,"image",null);h(this,"rect",null);h(this,"initialCenter",{x:0,y:0});h(this,"maxDimension",{width:0});h(this,"minDimension",{initialWidth:0,initialHeight:0,minWidth:0,closingWidth:0});h(this,"accumulatedTranslate",{x:0,y:0});h(this,"scale",1);h(this,"translate",{x:0,y:0});h(this,"onScale",null);h(this,"animationTimestamp",0);this.maxZoomLevel=t,this.onScale=e}clean(){this.image&&(this.image.style.transform="",this.image.style.width="",this.image.style.height="",this.image.style.top="",this.image.style.left="",this.image.style.opacity="")}reset(){this.clean(),this.image=null,this.rect=null,this.initialCenter={x:window.innerWidth/2,y:window.innerHeight/2},this.maxDimension={width:0},this.minDimension={initialWidth:0,initialHeight:0,minWidth:0,closingWidth:0},this.accumulatedTranslate={x:0,y:0},this.scale=1,this.translate={x:0,y:0}}setCurrentImage(t){if(this.rect=null,this.image=t,this.maxDimension={width:t.naturalWidth*this.maxZoomLevel},!t.dataset.vvwWidth||!t.dataset.vvwHeight)throw new Error("VistaImageState: Image dataset vvwWidth or vvwHeight not set.");const e=parseFloat(t.dataset.vvwWidth),i=parseFloat(t.dataset.vvwHeight);this.minDimension={initialWidth:e,initialHeight:i,minWidth:e*.1,closingWidth:e*.5},this.accumulatedTranslate={x:0,y:0}}setInitialCenter(t){this.initialCenter=t||{x:window.innerWidth/2,y:window.innerHeight/2}}move(t){this.image&&(this.rect||(this.rect=this.image.getBoundingClientRect()),this.translate.x=I(t.x-this.initialCenter.x),this.translate.y=I(t.y-this.initialCenter.y),this.image.style.transform=`translate3d(${this.translate.x}px, ${this.translate.y}px, 0px) scale(${this.scale})`)}snapToTargetIfClose(t,e,i=1){return Math.abs(t-e)<=i&&(t=e),t}scaleMove(t,e){if(!this.image)return;this.rect||(this.rect=this.image.getBoundingClientRect()),e||(e=this.initialCenter);const i=this.snapToTargetIfClose(N(this.rect.width*t,this.minDimension.minWidth,this.maxDimension.width),this.minDimension.initialWidth);this.onScale&&this.onScale({scale:i/(this.maxDimension.width/this.maxZoomLevel),isMax:i>=this.maxDimension.width,isMin:i<=this.minDimension.initialWidth}),this.scale=I(i/this.rect.width);const n=this.rect.left+this.rect.width/2,r=this.rect.top+this.rect.height/2,a=this.initialCenter.x-n,o=this.initialCenter.y-r,l=a*(1-this.scale),c=o*(1-this.scale),d=e.x-this.initialCenter.x,f=e.y-this.initialCenter.y;this.translate.x=I(l+d),this.translate.y=I(c+f),this.image.style.transform=`translate3d(${this.translate.x}px, ${this.translate.y}px, 0px) scale(${this.scale})`,i<=this.minDimension.closingWidth?this.image.style.opacity="0.5":this.image.style.opacity=""}moveAndNormalize(t){let e=0,i=!1;const n=({x:r,y:a})=>{if(i)return;if(Math.abs(r)<.001&&Math.abs(a)<.001)return this.normalize();r*=.9,a*=.9;const o=this.image.getBoundingClientRect();this.translate.x=I(this.translate.x+r),this.translate.y=I(this.translate.y+a),o.right<window.innerWidth/2&&(this.translate.x+=(window.innerWidth/2-o.right)*.1,r*=.7),o.left>window.innerWidth/2&&(this.translate.x-=(o.left-window.innerWidth/2)*.1,r*=.7),o.bottom<window.innerHeight/2&&(this.translate.y+=(window.innerHeight/2-o.bottom)*.1,a*=.7),o.top>window.innerHeight/2&&(this.translate.y-=(o.top-window.innerHeight/2)*.1,a*=.7),this.image.style.transform=`translate3d(${this.translate.x}px, ${this.translate.y}px, 0px) scale(${this.scale})`,e=requestAnimationFrame(()=>n({x:r,y:a}))};return n({x:t.movementX,y:t.movementY}),()=>{i=!0,cancelAnimationFrame(e),this.normalize(!1)}}animateZoom(t){if(!this.image)return;this.rect||(this.rect=this.image.getBoundingClientRect());const e=Date.now(),i=this.image;this.rect.width*t<this.minDimension.closingWidth||i.width<Math.floor(this.minDimension.initialWidth)||(i.addEventListener("transitionend",()=>{this.animationTimestamp===e&&i&&(i.style.transition="",this.normalize())},{once:!0}),i.style.transition||(i.style.transition="all 222ms ease"),this.animationTimestamp=e,this.scaleMove(t))}normalize(t=!0){if(!this.image||!this.rect)return;const e=this.rect.width*this.scale,i=e<=this.minDimension.closingWidth,n=i?e:this.snapToTargetIfClose(this.rect.width*this.scale,this.minDimension.initialWidth),r=i?this.rect.height*this.scale:this.snapToTargetIfClose(this.rect.height*this.scale,this.minDimension.initialHeight);if(this.image.style.width=`${n}px`,this.image.style.height=`${r}px`,this.scale=1,this.image.style.opacity="",this.accumulatedTranslate.x+=this.translate.x,this.accumulatedTranslate.y+=this.translate.y,this.image.style.left=`calc(50% + ${this.accumulatedTranslate.x}px)`,this.image.style.top=`calc(50% + ${this.accumulatedTranslate.y}px)`,this.translate={x:0,y:0},this.image.style.transform="",this.rect=this.image.getBoundingClientRect(),i)return!0;if(n<this.minDimension.initialWidth)this.accumulatedTranslate.x=0,this.accumulatedTranslate.y=0,requestAnimationFrame(()=>{const a=this.image;a&&(a.addEventListener("transitionend",()=>{a&&(this.clean(),this.rect=null)},{once:!0}),a.style.transition="all 222ms ease",a.style.width=`${this.minDimension.initialWidth}px`,a.style.height=`${this.minDimension.initialHeight}px`,a.style.left="50%",a.style.top="50%")});else if(t){let a=!1;if(this.rect.right<window.innerWidth/2&&(a=!0,this.accumulatedTranslate.x+=window.innerWidth/2-this.rect.right),this.rect.left>window.innerWidth/2&&(a=!0,this.accumulatedTranslate.x-=this.rect.left-window.innerWidth/2),this.rect.bottom<window.innerHeight/2&&(a=!0,this.accumulatedTranslate.y+=window.innerHeight/2-this.rect.bottom),this.rect.top>window.innerHeight/2&&(a=!0,this.accumulatedTranslate.y-=this.rect.top-window.innerHeight/2),a){const o=this.image;o.addEventListener("transitionend",()=>{o&&(o.style.transition="",this.rect=null)},{once:!0}),o.style.transition="all 222ms ease",o.style.left=`calc(50% + ${this.accumulatedTranslate.x}px)`,o.style.top=`calc(50% + ${this.accumulatedTranslate.y}px)`}else this.rect=null}}}class it{constructor(){h(this,"fiolast",{})}fio(t,e,i=50){const r=Date.now()-(this.fiolast[e]??0),a=()=>{this.fiolast[e]=Date.now(),t()};if(!this.fiolast[e]){a();return}r>=i&&a()}}const C={somethingOpened:null};class nt{constructor(t,e={}){h(this,"options");h(this,"elements");h(this,"isReducedMotion");h(this,"currentIndex",-1);h(this,"currentChildren",null);h(this,"setupFunction",z);h(this,"initFunction",k);h(this,"closeFunction",q);h(this,"transitionFunction",O);h(this,"pointers",null);h(this,"imageState");h(this,"imageTransitions",new Map);h(this,"root",null);h(this,"imageContainer",null);h(this,"onClickElements",t=>{t.preventDefault();const e=t.currentTarget;e.dataset.vistaIdx&&this.open(parseInt(e.dataset.vistaIdx))});h(this,"defaultOnClickHandler",t=>t.preventDefault());h(this,"abortController",null);h(this,"throttle",new it);h(this,"lastSwapTime",0);h(this,"isRapidSwap",!1);h(this,"isRapidSwapRelease",0);h(this,"transitionCleanup",null);h(this,"isZoomedIn",!1);h(this,"onKeyDown",t=>{switch(t.key){case"ArrowLeft":t.preventDefault(),this.prev();break;case"ArrowRight":t.preventDefault(),this.next();break;case"ArrowUp":t.preventDefault(),this.zoomIn();break;case"ArrowDown":t.preventDefault(),this.zoomOut();break;case"Escape":t.preventDefault(),this.close();break}});h(this,"onScroll",t=>{t.preventDefault();const e=t.deltaY;this.imageState.setInitialCenter({x:t.clientX,y:t.clientY}),e<0?this.zoomIn():e>0&&this.zoomOut()});h(this,"onResizeHandler",()=>{this.currentChildren.htmls.forEach((t,e)=>{const i=this.currentChildren.images[e],n=t.querySelector("img.vvw-img-hi"),r=t.querySelector("img.vvw-img-lo");if(P(i,n,r,!1),n.classList.contains("vvw--loaded")){const{width:a,height:o}=F(n);n.style.setProperty("--vvw-current-w",`${a}px`),n.style.setProperty("--vvw-current-h",`${o}px`),n.dataset.vvwWidth=a.toString(),n.dataset.vvwHeight=o.toString()}})});h(this,"pointerListeners",[]);h(this,"getInternalPointerListener",()=>{const t=this.imageState;let e=0,i=!1,n=0;const r=33;let a=()=>{};function o(){return i||performance.now()-n<r}return l=>{if(l.event==="down"){if(a(),this.isZoomedIn&&l.pointers.length===1&&!o()){const c=this.pointers.getCentroid();t.setInitialCenter(c)}if(l.pointers.length>=2){i=!0;const c=this.pointers.getCentroid();e=this.pointers.getPointerDistance(l.pointers[0],l.pointers[1]),t.setInitialCenter(c)}}else if(l.event==="move"){if(this.isZoomedIn&&l.pointers.length===1&&l.lastPointerLen===0&&!o()){const c=this.pointers.getCentroid();t.move(c)}if(l.pointers.length>=2&&i){const c=this.pointers.getCentroid(),d=this.pointers.getPointerDistance(l.pointers[0],l.pointers[1]);t.scaleMove(d/e,c)}}else(l.event==="up"||l.event==="cancel")&&(i||this.isZoomedIn)&&(i?(n=performance.now(),i=!1,t.normalize()&&requestAnimationFrame(()=>{this.close()})):this.isZoomedIn&&l.pointers.length===0&&!o()&&(a=t.moveAndNormalize(l.pointer)));this.pointerListeners.forEach(c=>c({...l,hasInternalExecution:this.isZoomedIn||o(),abortController:this.abortController}))}});this.elements=t,this.options={...M,...e,controls:{...M.controls,...e.controls}},this.imageState=new et(this.options.maxZoomLevel,i=>{var n,r,a,o;i.isMin?(this.isZoomedIn=!1,(n=this.qs(".vvw-zoom-out"))==null||n.setAttribute("disabled","true")):(this.isZoomedIn=!0,(r=this.qs(".vvw-zoom-out"))==null||r.removeAttribute("disabled")),i.isMax?(a=this.qs(".vvw-zoom-in"))==null||a.setAttribute("disabled","true"):(o=this.qs(".vvw-zoom-in"))==null||o.removeAttribute("disabled")}),this.options.setupFunction&&(this.setupFunction=this.options.setupFunction),this.options.closeFunction&&(this.closeFunction=this.options.closeFunction),this.options.initFunction&&(this.initFunction=this.options.initFunction),this.options.transitionFunction&&(this.transitionFunction=this.options.transitionFunction),this.isReducedMotion=window.matchMedia("(prefers-reduced-motion: reduce)").matches,this.elements instanceof NodeList&&this.elements.forEach((i,n)=>{i.dataset.vistaIdx=n.toString(),i.addEventListener("click",this.defaultOnClickHandler),i.addEventListener("pointerup",this.onClickElements)})}qs(t){return this.root?this.root.querySelector(t):null}async swap(t,e){const i=this.options.preloads||0,n=this.currentIndex,{htmls:r,images:a}=this.getChildElements(i,n),o=this.imageContainer,l=this.currentChildren,c={htmlElements:{from:l.htmls,to:r},images:{from:l.images,to:a},index:{from:t,to:this.currentIndex},via:e||{next:!1,prev:!1},vistaView:this};this.setupFunction(c),this.currentChildren={htmls:r,images:a},this.displayActiveIndex();const d=this.abortController.signal,L=performance.now()-this.lastSwapTime<this.options.rapidLimit;if(this.isRapidSwap=L,o.querySelectorAll(".vvw-item img.vvw-img-hi").forEach(b=>b.classList.add("vvw--load-cancelled")),L){this.imageState.reset(),o.innerHTML="",this.transitionCleanup&&this.transitionCleanup(),r.forEach(b=>{o.appendChild(b)}),this.lastSwapTime=performance.now(),this.waitForImagesToLoad(),this.options.onImageView&&this.options.onImageView(c),this.isRapidSwapRelease&&clearTimeout(this.isRapidSwapRelease),this.isRapidSwapRelease=setTimeout(()=>{this.isRapidSwap=!1},333);return}const y=this.transitionFunction(c,d);y&&(this.transitionCleanup=y.cleanup,await y.transitionEnded),this.lastSwapTime=performance.now();const m=r[Math.floor(r.length/2)].dataset.vvwIdx,u=o.querySelector(`.vvw-item[data-vvw-idx="${m}"] img.vvw-img-hi`),E=this.imageTransitions.get(u);this.imageTransitions.delete(u);const x=u.getAttribute("style")||"",p=u.classList.contains("vvw--loaded"),S=u.classList.contains("vvw--ready"),T=u.width,H=u.height;this.imageState.reset(),o.innerHTML="",this.transitionCleanup&&this.transitionCleanup(),r.forEach(b=>{const g=b.querySelector("img.vvw-img-hi");b.dataset.vvwPos==="0"&&!d.aborted&&x&&T&&H&&(p&&(g.classList.add("vvw--loaded"),g.dataset.vvwWidth=u.dataset.vvwWidth||"",g.dataset.vvwHeight=u.dataset.vvwHeight||""),S&&(g.classList.add("vvw--ready"),g.width=T,g.height=H),g.setAttribute("style",x)),o.appendChild(b),b.dataset.vvwPos==="0"&&!d.aborted&&S?(this.imageState.setCurrentImage(g),this.imageState.setInitialCenter()):b.dataset.vvwPos==="0"&&!d.aborted&&x&&T&&H&&p&&E&&(this.imageTransitions.set(g,E),this.transitionImage(g,()=>{this.imageState.setCurrentImage(g),this.imageState.setInitialCenter(),g.classList.add("vvw--ready")}))}),this.isRapidSwap=!1,this.waitForImagesToLoad(),this.options.onImageView&&this.options.onImageView(c)}getChildElements(t,e){const i=[],n=[];for(let r=-t;r<=t;r++){const a=(e+r+this.elements.length)%this.elements.length,o=this.elements[a],l=o instanceof HTMLImageElement?o:o instanceof HTMLAnchorElement&&o.querySelector("img")||void 0,c=o instanceof HTMLElement?{index:a,imageElm:l instanceof HTMLImageElement?l:void 0,anchorElm:o instanceof HTMLAnchorElement?o:void 0,src:o.dataset.vistaviewSrc||o.getAttribute("href")||o.getAttribute("src")||"",thumb:o.dataset.vistaviewThumb||(l instanceof HTMLImageElement?l.getAttribute("src"):void 0)||o.getAttribute("href")||void 0,alt:l instanceof HTMLImageElement&&l.getAttribute("alt")||void 0}:{index:a,...o};n.push(c),i.push(G(c,r))}return{htmls:i,images:n}}zoomIn(){this.throttle.fio(()=>{this.imageState.animateZoom(1.68)},"zoom",222)}zoomOut(){this.throttle.fio(()=>{this.imageState.animateZoom(.68)},"zoom",222)}displayActiveIndex(){var a;const t=this.currentIndex;this.elements instanceof NodeList&&this.elements.forEach((o,l)=>{o.style.opacity="",l===t&&(o.style.opacity="0")});const e=this.qs(".vvw-index"),i=`${t+1}`,n=`${this.elements.length}`;e&&(e.textContent=`${i} / ${n}`);const r=this.qs(".vvw-desc");if(r){const o=(a=this.currentChildren)==null?void 0:a.images.find(c=>c.index===t),l=(o==null?void 0:o.alt)||"";l?(r.textContent=l,r.setAttribute("aria-label",`Image ${i} of ${n}: ${l}`)):(r.textContent="",r.setAttribute("aria-label",`Image ${i} of ${n}`))}}transitionImage(t,e){if(t.classList.contains("vvw--load-cancelled"))return;if(this.isRapidSwap){requestAnimationFrame(()=>{this.transitionImage(t,e)});return}const i=this.imageTransitions.get(t);i&&requestAnimationFrame(()=>{if(t.classList.contains("vvw--load-cancelled"))return;const{current:n,target:r}=i,a={width:n.width+(r.width-n.width)*.2,height:n.height+(r.height-n.height)*.2,radius:n.radius+(r.radius-n.radius)*.2};Math.abs(a.width-r.width)<1&&Math.abs(a.height-r.height)<1&&Math.abs(a.radius-r.radius)<1?(t.style.setProperty("--vvw-current-w",`${r.width}px`),t.style.setProperty("--vvw-current-h",`${r.height}px`),t.style.setProperty("--vvw-current-radius",`${r.radius}px`),this.imageTransitions.delete(t),e()):(t.style.setProperty("--vvw-current-w",`${a.width}px`),t.style.setProperty("--vvw-current-h",`${a.height}px`),t.style.setProperty("--vvw-current-radius",`${a.radius}px`),this.imageTransitions.set(t,{current:a,target:r}),this.transitionImage(t,e))})}waitForImagesToLoad(){this.imageContainer.querySelectorAll("img.vvw-img-hi:not(.vvw--loaded)").forEach(i=>{const n=i;if(n.classList.contains("vvw--load-cancelled"))return;const r=()=>{if(n.classList.contains("vvw--load-cancelled"))return;n.width=n.naturalWidth,n.height=n.naturalHeight;const{width:a,height:o}=F(n);n.dataset.vvwWidth=a.toString(),n.dataset.vvwHeight=o.toString(),n.classList.add("vvw--loaded"),this.imageTransitions.set(n,{current:{width:n.style.getPropertyValue("--vvw-current-w")?parseFloat(n.style.getPropertyValue("--vvw-current-w")):0,height:n.style.getPropertyValue("--vvw-current-h")?parseFloat(n.style.getPropertyValue("--vvw-current-h")):0,radius:n.style.getPropertyValue("--vvw-current-radius")?parseFloat(n.style.getPropertyValue("--vvw-current-radius")):0},target:{width:a,height:o,radius:0}}),this.transitionImage(n,()=>{var c;if(n.classList.contains("vvw--load-cancelled"))return;((c=n.parentElement)==null?void 0:c.matches(`[data-vvw-idx="${this.currentIndex}"][data-vvw-pos="0"]`))&&(this.imageState.setCurrentImage(n),this.imageState.setInitialCenter()),n.classList.add("vvw--ready")})};if(n.complete&&n.naturalWidth!==0){r();return}n.addEventListener("load",()=>{r()}),n.addEventListener("error",()=>{var o;n.classList.add("vvw--loaderror");const a=document.createElement("p");a.className="vvw-img-err",a.setAttribute("role","alert"),a.textContent="Error loading image",(o=n.parentNode)==null||o.appendChild(a)})})}registerPointerListener(t){this.pointerListeners.push(t)}unregisterPointerListeners(){this.pointerListeners=[]}open(t=0){var c,d,f,L,y;if(C.somethingOpened)return;C.somethingOpened=this,this.currentIndex=t,document.body.style.overflow="hidden";const e=J({controls:this.options.controls});if(document.body.prepend(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:r,htmls:a}=this.getChildElements(i,n),o={htmlElements:{from:null,to:a},images:{from:null,to:r},index:{from:null,to:this.currentIndex},via:{next:!1,prev:!1},vistaView:this};this.setupFunction(o),this.currentChildren={htmls:a,images:r},a.forEach(m=>{this.imageContainer.appendChild(m)}),(c=this.qs(".vvw-close"))==null||c.addEventListener("click",()=>this.close()),(d=this.qs(".vvw-zoom-in"))==null||d.addEventListener("click",()=>this.zoomIn()),(f=this.qs(".vvw-zoom-out"))==null||f.addEventListener("click",()=>this.zoomOut()),(L=this.qs(".vvw-prev>button"))==null||L.addEventListener("click",()=>this.prev()),(y=this.qs(".vvw-next>button"))==null||y.addEventListener("click",()=>this.next()),this.options.keyboardListeners&&window.addEventListener("keydown",this.onKeyDown),window.addEventListener("wheel",this.onScroll,{passive:!1}),window.addEventListener("resize",this.onResizeHandler),this.pointers=new tt({elm:this.imageContainer,listeners:[this.getInternalPointerListener()]});const l={};[...this.options.controls.topLeft||[],...this.options.controls.topRight||[],...this.options.controls.topCenter||[],...this.options.controls.bottomCenter||[],...this.options.controls.bottomLeft||[],...this.options.controls.bottomRight||[]].forEach(m=>{typeof m!="string"&&(l[m.name]=m)}),this.root.querySelectorAll("button[data-vvw-control]").forEach(m=>{const u=m;u.addEventListener("click",E=>{const x=E.currentTarget.dataset.vvwControl,p=l[x],S=this.currentChildren.images.find(T=>T.index===this.currentIndex);p&&S&&(p.onClick.constructor.name==="AsyncFunction"?(u.classList.add("vvw--loading"),p.onClick(S,this).finally(()=>{u.classList.remove("vvw--loading")})):p.onClick(S,this))})}),this.initFunction(this),setTimeout(()=>{var m;(m=this.root)==null||m.addEventListener("transitionend",()=>{var u;(u=this.root)==null||u.classList.add("vvw--settled"),this.imageState.reset(),this.waitForImagesToLoad()},{once:!0}),this.root.classList.add("vvw--active"),this.displayActiveIndex(),this.options.onOpen&&this.options.onOpen(this),this.options.onImageView&&this.options.onImageView(o)},0)}async close(t=!0){C.somethingOpened===this&&this.root&&(t?await new Promise(e=>{let n=0;this.root.addEventListener("transitionend",r=>{r.target===this.root&&(n++,n===2&&this.elements instanceof NodeList&&this.elements.forEach(a=>{a.style.opacity=""}),n===3&&e(null))}),this.root.classList.add("vvw--closing")}):this.elements instanceof NodeList&&this.elements.forEach(e=>{e.style.opacity=""}),this.options.keyboardListeners&&window.removeEventListener("keydown",this.onKeyDown),window.removeEventListener("resize",this.onResizeHandler),window.removeEventListener("wheel",this.onScroll),this.unregisterPointerListeners(),this.pointers.removeListeners(),this.root.remove(),this.root=null,this.imageContainer=null,this.currentChildren=null,this.currentIndex=-1,document.body.style.overflow="",C.somethingOpened=null,this.closeFunction(this),this.options.onClose&&this.options.onClose(this))}next(){if(C.somethingOpened!==this)return;const t=(this.currentIndex+1)%this.elements.length;this.view(t,{next:!0,prev:!1})}prev(){if(C.somethingOpened!==this)return;const t=(this.currentIndex-1+this.elements.length)%this.elements.length;this.view(t,{next:!1,prev:!0})}destroy(){this.close(!1),this.elements instanceof NodeList&&this.elements.forEach(t=>{t.removeAttribute("data-vista-idx"),t.removeEventListener("click",this.defaultOnClickHandler),t.removeEventListener("pointerup",this.onClickElements)})}getCurrentIndex(){return C.somethingOpened!==this?-1:this.currentIndex}view(t,e){if(C.somethingOpened!==this||t<0||t>=this.elements.length)return;const i=this.currentIndex;this.currentIndex=t;const n=this.abortController;n==null||n.abort(),this.abortController=new AbortController,this.swap(i,e)}}function st(s){let t=null;if(typeof s=="string"?t=document.querySelectorAll(s):s instanceof NodeList&&(t=s),t)for(let e=0;e<t.length;e++){const i=t[e];if(!(i.dataset.vistaviewSrc||i.getAttribute("href")||i.getAttribute("src")||""))return`Element at index ${e} is missing 'src' / 'data-vistaview-src' / 'href' attribute.`}else{const e=s;for(let i=0;i<e.length;i++)if(!e[i].src)return`Element at index ${i} is missing 'src' attribute.`}return t||s}function ot({elements:s,...t}){if(!s)throw new Error("No elements");let e=st(s);if(typeof e=="string")return null;const i=new nt(e,t);return{open:(n=0)=>i.open(n),close:()=>i.close(),next:()=>i.next(),prev:()=>i.prev(),destroy:()=>i.destroy(),getCurrentIndex:()=>i.getCurrentIndex(),view:n=>{i.view(n)}}}v.DefaultOptions=M,v.close=q,v.init=k,v.setup=z,v.transition=O,v.vistaView=ot,v.vistaViewDownload=A,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})}));
|
|
11
|
+
</div>`)}const M={animationDurationBase:333,maxZoomLevel:2,preloads:1,keyboardListeners:!0,arrowOnSmallScreens:!1,rapidLimit:222,controls:{topLeft:["indexDisplay"],topRight:["zoomIn","zoomOut",R(),"close"],bottomLeft:["description"]}};function z(s){}function q(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",Q(s)}function Q(s){let t={x:0,y:0},e={x:0,y:0},i=null;s.registerPointerListener(n=>{var r;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},(r=n.abortController)==null||r.abort()),n.event==="move"){e={x:n.pointer.x,y:n.pointer.y};const a=e.x-t.x,o=e.y-t.y;if(!i&&Math.abs(o)>Math.abs(a)||i==="y"){const l=o/window.innerHeight*100;s.imageContainer.style.transition="none",s.imageContainer.style.transform=`translateY(${l}vh)`,i="y"}else if(!i&&Math.abs(a)>Math.abs(o)||i==="x"){const l=a/window.innerWidth*100;s.imageContainer.style.transition="none",s.imageContainer.style.transform=`translateX(${l}vw)`,i="x"}}if(n.event==="up"||n.event==="cancel"){let a=function(o){var l;(l=s.imageContainer)==null||l.addEventListener("transitionend",function c(){var d;(d=s.imageContainer)==null||d.removeEventListener("transitionend",c),s.imageContainer.style.transition="",s.imageContainer.style.transform=""}),s.imageContainer.style.transition="transform 222ms ease",s.imageContainer.style.transform=o};if(i==="y"){const o=e.y-t.y;Math.abs(o)>144?(s.imageContainer.style.transition="transform 222ms ease",s.imageContainer.style.transform="translateY(0vh)",s.close()):a("translateY(0vh)")}if(i==="x"){const o=e.x-t.x,l=n.pointer.movementX,c=1;s.imageContainer.style.transition="",o>0&&Math.abs(l)>c?s.prev():o<0&&Math.abs(l)>c?s.next():a("translateX(0vw)")}i=null,t={x:0,y:0},e={x:0,y:0}}}})}function k(s){}function O({vistaView:{isReducedMotion:s},htmlElements:{to:t},index:{from:e,to:i},vistaView:{elements:n,imageContainer:r,options:a}},o){if(!(!t||o.aborted||s||!(Math.abs(i-e)===1||e===0&&i===n.length-1||e===n.length-1&&i===0)))return{cleanup:()=>{r.style.transition="",r.style.transform=""},transitionEnded:new Promise(c=>{r.addEventListener("transitionend",()=>{c()},{once:!0}),r.addEventListener("transitioncancel",()=>{o.aborted&&c()},{once:!0});const d=Math.round(a.animationDurationBase*100)/100,f=i===e+1||e===n.length-1&&i===0?"translateX(-100vw)":"translateX(100vw)";r.style.transition=`transform ${d}ms ease`,r.style.transform=f})}}class tt{constructor({elm:t,listeners:e}){h(this,"pointers",[]);h(this,"elm");h(this,"listeners",[]);h(this,"lastPointerDownId",null);h(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)}});h(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}))});h(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})))});h(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(r=>r.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(r=>r({event:"up",pointer:i,pointers:this.pointers,lastPointerLen:n}))});h(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(r=>r.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(r=>r({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 et{constructor(t,e){h(this,"maxZoomLevel");h(this,"image",null);h(this,"rect",null);h(this,"initialCenter",{x:0,y:0});h(this,"maxDimension",{width:0});h(this,"minDimension",{initialWidth:0,initialHeight:0,minWidth:0,closingWidth:0});h(this,"accumulatedTranslate",{x:0,y:0});h(this,"scale",1);h(this,"translate",{x:0,y:0});h(this,"onScale",null);h(this,"animationTimestamp",0);this.maxZoomLevel=t,this.onScale=e}clean(){this.image&&(this.image.style.transform="",this.image.style.width="",this.image.style.height="",this.image.style.top="",this.image.style.left="",this.image.style.opacity="")}reset(){this.clean(),this.image=null,this.rect=null,this.initialCenter={x:window.innerWidth/2,y:window.innerHeight/2},this.maxDimension={width:0},this.minDimension={initialWidth:0,initialHeight:0,minWidth:0,closingWidth:0},this.accumulatedTranslate={x:0,y:0},this.scale=1,this.translate={x:0,y:0}}setCurrentImage(t){if(this.rect=null,this.image=t,this.maxDimension={width:t.naturalWidth*this.maxZoomLevel},!t.dataset.vvwWidth||!t.dataset.vvwHeight)throw new Error("VistaImageState: Image dataset vvwWidth or vvwHeight not set.");const e=parseFloat(t.dataset.vvwWidth),i=parseFloat(t.dataset.vvwHeight);this.minDimension={initialWidth:e,initialHeight:i,minWidth:e*.1,closingWidth:e*.5},this.accumulatedTranslate={x:0,y:0}}setInitialCenter(t){this.initialCenter=t||{x:window.innerWidth/2,y:window.innerHeight/2}}move(t){this.image&&(this.rect||(this.rect=this.image.getBoundingClientRect()),this.translate.x=I(t.x-this.initialCenter.x),this.translate.y=I(t.y-this.initialCenter.y),this.image.style.transform=`translate3d(${this.translate.x}px, ${this.translate.y}px, 0px) scale(${this.scale})`)}snapToTargetIfClose(t,e,i=1){return Math.abs(t-e)<=i&&(t=e),t}scaleMove(t,e){if(!this.image)return;this.rect||(this.rect=this.image.getBoundingClientRect()),e||(e=this.initialCenter);const i=this.snapToTargetIfClose(N(this.rect.width*t,this.minDimension.minWidth,this.maxDimension.width),this.minDimension.initialWidth);this.onScale&&this.onScale({scale:i/(this.maxDimension.width/this.maxZoomLevel),isMax:i>=this.maxDimension.width,isMin:i<=this.minDimension.initialWidth}),this.scale=I(i/this.rect.width);const n=this.rect.left+this.rect.width/2,r=this.rect.top+this.rect.height/2,a=this.initialCenter.x-n,o=this.initialCenter.y-r,l=a*(1-this.scale),c=o*(1-this.scale),d=e.x-this.initialCenter.x,f=e.y-this.initialCenter.y;this.translate.x=I(l+d),this.translate.y=I(c+f),this.image.style.transform=`translate3d(${this.translate.x}px, ${this.translate.y}px, 0px) scale(${this.scale})`,i<=this.minDimension.closingWidth?this.image.style.opacity="0.5":this.image.style.opacity=""}moveAndNormalize(t){let e=0,i=!1;const n=({x:r,y:a})=>{if(i)return;if(Math.abs(r)<.001&&Math.abs(a)<.001)return this.normalize();r*=.9,a*=.9;const o=this.image.getBoundingClientRect();this.translate.x=I(this.translate.x+r),this.translate.y=I(this.translate.y+a),o.right<window.innerWidth/2&&(this.translate.x+=(window.innerWidth/2-o.right)*.1,r*=.7),o.left>window.innerWidth/2&&(this.translate.x-=(o.left-window.innerWidth/2)*.1,r*=.7),o.bottom<window.innerHeight/2&&(this.translate.y+=(window.innerHeight/2-o.bottom)*.1,a*=.7),o.top>window.innerHeight/2&&(this.translate.y-=(o.top-window.innerHeight/2)*.1,a*=.7),this.image.style.transform=`translate3d(${this.translate.x}px, ${this.translate.y}px, 0px) scale(${this.scale})`,e=requestAnimationFrame(()=>n({x:r,y:a}))};return n({x:t.movementX,y:t.movementY}),()=>{i=!0,cancelAnimationFrame(e),this.normalize(!1)}}animateZoom(t){if(!this.image)return;this.rect||(this.rect=this.image.getBoundingClientRect());const e=Date.now(),i=this.image;this.rect.width*t<this.minDimension.closingWidth||i.width<Math.floor(this.minDimension.initialWidth)||(i.addEventListener("transitionend",()=>{this.animationTimestamp===e&&i&&(i.style.transition="",this.normalize())},{once:!0}),i.style.transition||(i.style.transition="all 222ms ease"),this.animationTimestamp=e,this.scaleMove(t))}normalize(t=!0){if(!this.image||!this.rect)return;const e=this.rect.width*this.scale,i=e<=this.minDimension.closingWidth,n=i?e:this.snapToTargetIfClose(this.rect.width*this.scale,this.minDimension.initialWidth),r=i?this.rect.height*this.scale:this.snapToTargetIfClose(this.rect.height*this.scale,this.minDimension.initialHeight);if(this.image.style.width=`${n}px`,this.image.style.height=`${r}px`,this.scale=1,this.image.style.opacity="",this.accumulatedTranslate.x+=this.translate.x,this.accumulatedTranslate.y+=this.translate.y,this.image.style.left=`calc(50% + ${this.accumulatedTranslate.x}px)`,this.image.style.top=`calc(50% + ${this.accumulatedTranslate.y}px)`,this.translate={x:0,y:0},this.image.style.transform="",this.rect=this.image.getBoundingClientRect(),i)return!0;if(n<this.minDimension.initialWidth)this.accumulatedTranslate.x=0,this.accumulatedTranslate.y=0,requestAnimationFrame(()=>{const a=this.image;a&&(a.addEventListener("transitionend",()=>{a&&(this.clean(),this.rect=null)},{once:!0}),a.style.transition="all 222ms ease",a.style.width=`${this.minDimension.initialWidth}px`,a.style.height=`${this.minDimension.initialHeight}px`,a.style.left="50%",a.style.top="50%")});else if(t){let a=!1;if(this.rect.right<window.innerWidth/2&&(a=!0,this.accumulatedTranslate.x+=window.innerWidth/2-this.rect.right),this.rect.left>window.innerWidth/2&&(a=!0,this.accumulatedTranslate.x-=this.rect.left-window.innerWidth/2),this.rect.bottom<window.innerHeight/2&&(a=!0,this.accumulatedTranslate.y+=window.innerHeight/2-this.rect.bottom),this.rect.top>window.innerHeight/2&&(a=!0,this.accumulatedTranslate.y-=this.rect.top-window.innerHeight/2),a){const o=this.image;o.addEventListener("transitionend",()=>{o&&(o.style.transition="",this.rect=null)},{once:!0}),o.style.transition="all 222ms ease",o.style.left=`calc(50% + ${this.accumulatedTranslate.x}px)`,o.style.top=`calc(50% + ${this.accumulatedTranslate.y}px)`}else this.rect=null}}}class it{constructor(){h(this,"fiolast",{})}fio(t,e,i=50){const r=Date.now()-(this.fiolast[e]??0),a=()=>{this.fiolast[e]=Date.now(),t()};if(!this.fiolast[e]){a();return}r>=i&&a()}}const C={somethingOpened:null};class nt{constructor(t,e={}){h(this,"options");h(this,"elements");h(this,"isReducedMotion");h(this,"currentIndex",-1);h(this,"currentChildren",null);h(this,"setupFunction",z);h(this,"initFunction",q);h(this,"closeFunction",k);h(this,"transitionFunction",O);h(this,"pointers",null);h(this,"imageState");h(this,"imageTransitions",new Map);h(this,"root",null);h(this,"imageContainer",null);h(this,"onClickElements",t=>{t.preventDefault();const e=t.currentTarget;e.dataset.vistaIdx&&this.open(parseInt(e.dataset.vistaIdx))});h(this,"defaultOnClickHandler",t=>t.preventDefault());h(this,"abortController",null);h(this,"throttle",new it);h(this,"lastSwapTime",0);h(this,"isRapidSwap",!1);h(this,"isRapidSwapRelease",0);h(this,"transitionCleanup",null);h(this,"isZoomedIn",!1);h(this,"onKeyDown",t=>{switch(t.key){case"ArrowLeft":t.preventDefault(),this.prev();break;case"ArrowRight":t.preventDefault(),this.next();break;case"ArrowUp":t.preventDefault(),this.zoomIn();break;case"ArrowDown":t.preventDefault(),this.zoomOut();break;case"Escape":t.preventDefault(),this.close();break}});h(this,"onScroll",t=>{t.preventDefault();const e=t.deltaY;this.imageState.setInitialCenter({x:t.clientX,y:t.clientY}),e<0?this.zoomIn():e>0&&this.zoomOut()});h(this,"onResizeHandler",()=>{this.currentChildren.htmls.forEach((t,e)=>{const i=this.currentChildren.images[e],n=t.querySelector("img.vvw-img-hi"),r=t.querySelector("img.vvw-img-lo");if(P(i,n,r,!1),n.classList.contains("vvw--loaded")){const{width:a,height:o}=F(n);n.style.setProperty("--vvw-current-w",`${a}px`),n.style.setProperty("--vvw-current-h",`${o}px`),n.dataset.vvwWidth=a.toString(),n.dataset.vvwHeight=o.toString()}})});h(this,"pointerListeners",[]);this.elements=t,this.options={...M,...e,controls:{...M.controls,...e.controls}},this.imageState=new et(this.options.maxZoomLevel,i=>{var n,r,a,o;i.isMin?(this.isZoomedIn=!1,(n=this.qs(".vvw-zoom-out"))==null||n.setAttribute("disabled","true")):(this.isZoomedIn=!0,(r=this.qs(".vvw-zoom-out"))==null||r.removeAttribute("disabled")),i.isMax?(a=this.qs(".vvw-zoom-in"))==null||a.setAttribute("disabled","true"):(o=this.qs(".vvw-zoom-in"))==null||o.removeAttribute("disabled")}),this.options.setupFunction&&(this.setupFunction=this.options.setupFunction),this.options.closeFunction&&(this.closeFunction=this.options.closeFunction),this.options.initFunction&&(this.initFunction=this.options.initFunction),this.options.transitionFunction&&(this.transitionFunction=this.options.transitionFunction),this.isReducedMotion=window.matchMedia("(prefers-reduced-motion: reduce)").matches,this.elements instanceof NodeList&&this.elements.forEach((i,n)=>{i.dataset.vistaIdx=n.toString(),i.addEventListener("click",this.defaultOnClickHandler),i.addEventListener("pointerup",this.onClickElements)})}qs(t){return this.root?this.root.querySelector(t):null}getChildElements(t,e){const i=[],n=[];for(let r=-t;r<=t;r++){const a=(e+r+this.elements.length)%this.elements.length,o=this.elements[a],l=o instanceof HTMLImageElement?o:o instanceof HTMLAnchorElement&&o.querySelector("img")||void 0,c=o instanceof HTMLElement?{index:a,imageElm:l instanceof HTMLImageElement?l:void 0,anchorElm:o instanceof HTMLAnchorElement?o:void 0,src:o.dataset.vistaviewSrc||o.getAttribute("href")||o.getAttribute("src")||"",thumb:o.dataset.vistaviewThumb||(l instanceof HTMLImageElement?l.getAttribute("src"):void 0)||o.getAttribute("href")||void 0,alt:l instanceof HTMLImageElement&&l.getAttribute("alt")||void 0}:{index:a,...o};n.push(c),i.push(G(c,r))}return{htmls:i,images:n}}async swap(t,e){const i=this.options.preloads||0,n=this.currentIndex,{htmls:r,images:a}=this.getChildElements(i,n),o=this.imageContainer,l=this.currentChildren,c={htmlElements:{from:l.htmls,to:r},images:{from:l.images,to:a},index:{from:t,to:this.currentIndex},via:e||{next:!1,prev:!1},vistaView:this};this.setupFunction(c),this.currentChildren={htmls:r,images:a},this.displayActiveIndex();const d=this.abortController.signal,L=performance.now()-this.lastSwapTime<this.options.rapidLimit;if(this.isRapidSwap=L,o.querySelectorAll(".vvw-item img.vvw-img-hi").forEach(b=>b.classList.add("vvw--load-cancelled")),L){this.imageState.reset(),o.innerHTML="",this.transitionCleanup&&this.transitionCleanup(),r.forEach(b=>{o.appendChild(b)}),this.lastSwapTime=performance.now(),this.waitForImagesToLoad(),this.options.onImageView&&this.options.onImageView(c),this.isRapidSwapRelease&&clearTimeout(this.isRapidSwapRelease),this.isRapidSwapRelease=setTimeout(()=>{this.isRapidSwap=!1},333);return}const y=this.transitionFunction(c,d);y&&(this.transitionCleanup=y.cleanup,await y.transitionEnded),this.lastSwapTime=performance.now();const m=r[Math.floor(r.length/2)].dataset.vvwIdx,u=o.querySelector(`.vvw-item[data-vvw-idx="${m}"] img.vvw-img-hi`),E=this.imageTransitions.get(u);this.imageTransitions.delete(u);const x=u.getAttribute("style")||"",p=u.classList.contains("vvw--loaded"),S=u.classList.contains("vvw--ready"),T=u.width,H=u.height;this.imageState.reset(),o.innerHTML="",this.transitionCleanup&&this.transitionCleanup(),r.forEach(b=>{const g=b.querySelector("img.vvw-img-hi");b.dataset.vvwPos==="0"&&!d.aborted&&x&&T&&H&&(p&&(g.classList.add("vvw--loaded"),g.dataset.vvwWidth=u.dataset.vvwWidth||"",g.dataset.vvwHeight=u.dataset.vvwHeight||""),S&&(g.classList.add("vvw--ready"),g.width=T,g.height=H),g.setAttribute("style",x)),o.appendChild(b),b.dataset.vvwPos==="0"&&!d.aborted&&S?(this.imageState.setCurrentImage(g),this.imageState.setInitialCenter()):b.dataset.vvwPos==="0"&&!d.aborted&&x&&T&&H&&p&&E&&(this.imageTransitions.set(g,E),this.transitionImage(g,()=>{this.imageState.setCurrentImage(g),this.imageState.setInitialCenter(),g.classList.add("vvw--ready")}))}),this.isRapidSwap=!1,this.waitForImagesToLoad(),this.options.onImageView&&this.options.onImageView(c)}zoomIn(){this.throttle.fio(()=>{this.imageState.animateZoom(1.68)},"zoom",222)}zoomOut(){this.throttle.fio(()=>{this.imageState.animateZoom(.68)},"zoom",222)}displayActiveIndex(){var a;const t=this.currentIndex;this.elements instanceof NodeList&&this.elements.forEach((o,l)=>{o.style.opacity="",l===t&&(o.style.opacity="0")});const e=this.qs(".vvw-index"),i=`${t+1}`,n=`${this.elements.length}`;e&&(e.textContent=`${i} / ${n}`);const r=this.qs(".vvw-desc");if(r){const o=(a=this.currentChildren)==null?void 0:a.images.find(c=>c.index===t),l=(o==null?void 0:o.alt)||"";l?(r.textContent=l,r.setAttribute("aria-label",`Image ${i} of ${n}: ${l}`)):(r.textContent="",r.setAttribute("aria-label",`Image ${i} of ${n}`))}}transitionImage(t,e){if(!t.classList.contains("vvw--load-cancelled")){if(this.isRapidSwap){requestAnimationFrame(()=>{this.transitionImage(t,e)});return}requestAnimationFrame(()=>{const i=this.imageTransitions.get(t);if(!i||t.classList.contains("vvw--load-cancelled"))return;const{current:n,target:r}=i,a={width:n.width+(r.width-n.width)*.2,height:n.height+(r.height-n.height)*.2,radius:n.radius+(r.radius-n.radius)*.2};Math.abs(a.width-r.width)<1&&Math.abs(a.height-r.height)<1&&Math.abs(a.radius-r.radius)<1?(t.style.setProperty("--vvw-current-w",`${r.width}px`),t.style.setProperty("--vvw-current-h",`${r.height}px`),t.style.setProperty("--vvw-current-radius",`${r.radius}px`),this.imageTransitions.delete(t),e()):(t.style.setProperty("--vvw-current-w",`${a.width}px`),t.style.setProperty("--vvw-current-h",`${a.height}px`),t.style.setProperty("--vvw-current-radius",`${a.radius}px`),this.imageTransitions.set(t,{current:a,target:r}),this.transitionImage(t,e))})}}waitForImagesToLoad(){this.imageContainer.querySelectorAll("img.vvw-img-hi:not(.vvw--loaded)").forEach(i=>{const n=i;if(n.classList.contains("vvw--load-cancelled"))return;const r=()=>{if(n.classList.contains("vvw--load-cancelled"))return;n.width=n.naturalWidth,n.height=n.naturalHeight;const{width:a,height:o}=F(n);n.dataset.vvwWidth=a.toString(),n.dataset.vvwHeight=o.toString(),n.classList.add("vvw--loaded"),this.imageTransitions.set(n,{current:{width:n.style.getPropertyValue("--vvw-current-w")?parseFloat(n.style.getPropertyValue("--vvw-current-w")):0,height:n.style.getPropertyValue("--vvw-current-h")?parseFloat(n.style.getPropertyValue("--vvw-current-h")):0,radius:n.style.getPropertyValue("--vvw-current-radius")?parseFloat(n.style.getPropertyValue("--vvw-current-radius")):0},target:{width:a,height:o,radius:0}}),this.transitionImage(n,()=>{var c;if(n.classList.contains("vvw--load-cancelled"))return;((c=n.parentElement)==null?void 0:c.matches(`[data-vvw-idx="${this.currentIndex}"][data-vvw-pos="0"]`))&&(this.imageState.setCurrentImage(n),this.imageState.setInitialCenter()),n.classList.add("vvw--ready")})};if(n.complete&&n.naturalWidth!==0){r();return}n.addEventListener("load",()=>{r()}),n.addEventListener("error",()=>{var o;n.classList.add("vvw--loaderror");const a=document.createElement("p");a.className="vvw-img-err",a.setAttribute("role","alert"),a.textContent="Error loading image",(o=n.parentNode)==null||o.appendChild(a)})})}registerPointerListener(t){this.pointerListeners.push(t)}unregisterPointerListeners(){this.pointerListeners=[]}getInternalPointerListener(){const t=this.imageState;let e=0,i=!1,n=0;const r=33;let a=()=>{};function o(){return i||performance.now()-n<r}return l=>{if(l.event==="down"){if(a(),this.isZoomedIn&&l.pointers.length===1&&!o()){const c=this.pointers.getCentroid();t.setInitialCenter(c)}if(l.pointers.length>=2){i=!0;const c=this.pointers.getCentroid();e=this.pointers.getPointerDistance(l.pointers[0],l.pointers[1]),t.setInitialCenter(c)}}else if(l.event==="move"){if(this.isZoomedIn&&l.pointers.length===1&&l.lastPointerLen===0&&!o()){const c=this.pointers.getCentroid();t.move(c)}if(l.pointers.length>=2&&i){const c=this.pointers.getCentroid(),d=this.pointers.getPointerDistance(l.pointers[0],l.pointers[1]);t.scaleMove(d/e,c)}}else(l.event==="up"||l.event==="cancel")&&(i||this.isZoomedIn)&&(i?(n=performance.now(),i=!1,t.normalize()&&requestAnimationFrame(()=>{this.close()})):this.isZoomedIn&&l.pointers.length===0&&!o()&&(a=t.moveAndNormalize(l.pointer)));this.pointerListeners.forEach(c=>c({...l,hasInternalExecution:this.isZoomedIn||o(),abortController:this.abortController}))}}open(t=0){var c,d,f,L,y;if(C.somethingOpened)return;C.somethingOpened=this,this.currentIndex=t,document.body.style.overflow="hidden";const e=J({controls:this.options.controls});if(document.body.prepend(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:r,htmls:a}=this.getChildElements(i,n),o={htmlElements:{from:null,to:a},images:{from:null,to:r},index:{from:null,to:this.currentIndex},via:{next:!1,prev:!1},vistaView:this};this.setupFunction(o),this.currentChildren={htmls:a,images:r},a.forEach(m=>{this.imageContainer.appendChild(m)}),(c=this.qs(".vvw-close"))==null||c.addEventListener("click",()=>this.close()),(d=this.qs(".vvw-zoom-in"))==null||d.addEventListener("click",()=>this.zoomIn()),(f=this.qs(".vvw-zoom-out"))==null||f.addEventListener("click",()=>this.zoomOut()),(L=this.qs(".vvw-prev>button"))==null||L.addEventListener("click",()=>this.prev()),(y=this.qs(".vvw-next>button"))==null||y.addEventListener("click",()=>this.next()),this.options.keyboardListeners&&window.addEventListener("keydown",this.onKeyDown),window.addEventListener("wheel",this.onScroll,{passive:!1}),window.addEventListener("resize",this.onResizeHandler),this.pointers=new tt({elm:this.imageContainer,listeners:[this.getInternalPointerListener()]});const l={};[...this.options.controls.topLeft||[],...this.options.controls.topRight||[],...this.options.controls.topCenter||[],...this.options.controls.bottomCenter||[],...this.options.controls.bottomLeft||[],...this.options.controls.bottomRight||[]].forEach(m=>{typeof m!="string"&&(l[m.name]=m)}),this.root.querySelectorAll("button[data-vvw-control]").forEach(m=>{const u=m;u.addEventListener("click",E=>{const x=E.currentTarget.dataset.vvwControl,p=l[x],S=this.currentChildren.images.find(T=>T.index===this.currentIndex);p&&S&&(p.onClick.constructor.name==="AsyncFunction"?(u.classList.add("vvw--loading"),p.onClick(S,this).finally(()=>{u.classList.remove("vvw--loading")})):p.onClick(S,this))})}),this.initFunction(this),requestAnimationFrame(()=>{requestAnimationFrame(()=>{var m;(m=this.root)==null||m.addEventListener("transitionend",()=>{var u;(u=this.root)==null||u.classList.add("vvw--settled"),this.imageState.reset(),this.waitForImagesToLoad()},{once:!0}),this.root.classList.add("vvw--active"),this.displayActiveIndex(),this.options.onOpen&&this.options.onOpen(this),this.options.onImageView&&this.options.onImageView(o)})})}async close(t=!0){C.somethingOpened===this&&this.root&&(t?await new Promise(e=>{let n=0;this.root.addEventListener("transitionend",r=>{r.target===this.root&&(n++,n===2&&this.elements instanceof NodeList&&this.elements.forEach(a=>{a.style.opacity=""}),n===3&&e(null))}),this.root.classList.add("vvw--closing")}):this.elements instanceof NodeList&&this.elements.forEach(e=>{e.style.opacity=""}),this.options.keyboardListeners&&window.removeEventListener("keydown",this.onKeyDown),window.removeEventListener("resize",this.onResizeHandler),window.removeEventListener("wheel",this.onScroll),this.unregisterPointerListeners(),this.pointers.removeListeners(),this.root.remove(),this.root=null,this.imageContainer=null,this.currentChildren=null,this.currentIndex=-1,document.body.style.overflow="",C.somethingOpened=null,this.closeFunction(this),this.options.onClose&&this.options.onClose(this))}destroy(){this.close(!1),this.elements instanceof NodeList&&this.elements.forEach(t=>{t.removeAttribute("data-vista-idx"),t.removeEventListener("click",this.defaultOnClickHandler),t.removeEventListener("pointerup",this.onClickElements)})}next(){if(C.somethingOpened!==this)return;const t=(this.currentIndex+1)%this.elements.length;this.view(t,{next:!0,prev:!1})}prev(){if(C.somethingOpened!==this)return;const t=(this.currentIndex-1+this.elements.length)%this.elements.length;this.view(t,{next:!1,prev:!0})}view(t,e){if(C.somethingOpened!==this||t<0||t>=this.elements.length)return;const i=this.currentIndex;this.currentIndex=t;const n=this.abortController;n==null||n.abort(),this.abortController=new AbortController,this.swap(i,e)}getCurrentIndex(){return C.somethingOpened!==this?-1:this.currentIndex}}function st(s){let t=null;if(typeof s=="string"?t=document.querySelectorAll(s):s instanceof NodeList&&(t=s),t)for(let e=0;e<t.length;e++){const i=t[e];if(!(i.dataset.vistaviewSrc||i.getAttribute("href")||i.getAttribute("src")||""))return`Element at index ${e} is missing 'src' / 'data-vistaview-src' / 'href' attribute.`}else{const e=s;for(let i=0;i<e.length;i++)if(!e[i].src)return`Element at index ${i} is missing 'src' attribute.`}return t||s}function ot({elements:s,...t}){if(!s)throw new Error("No elements");let e=st(s);if(typeof e=="string")return null;const i=new nt(e,t);return{open:(n=0)=>i.open(n),close:()=>i.close(),next:()=>i.next(),prev:()=>i.prev(),destroy:()=>i.destroy(),getCurrentIndex:()=>i.getCurrentIndex(),view:n=>{i.view(n)}}}v.DefaultOptions=M,v.close=k,v.init=q,v.setup=z,v.transition=O,v.vistaView=ot,v.vistaViewDownload=R,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})}));
|