UNPKG

images-viewer-vue3

Version:
143 lines (142 loc) 3.11 kB
import { ref as i, readonly as o, watch as w, computed as p, getCurrentInstance as T, onMounted as I, onBeforeUnmount as h, onBeforeMount as R } from "vue"; import { o as v, a as m } from "./npm-evtd-Bc7Iy9dF.js"; function H(e) { const n = i(!!e.value); if (n.value) return o(n); const t = w(e, (u) => { u && (n.value = !0, t()); }); return o(n); } function U(e) { const n = p(e), t = i(n.value); return w(n, (u) => { t.value = u; }), typeof e == "function" ? t : { __v_isRef: !0, get value() { return t.value; }, set value(u) { e.set(u); } }; } function P() { return T() !== null; } const k = typeof window < "u"; let l, a; const b = () => { var e, n; l = k ? (n = (e = document) === null || e === void 0 ? void 0 : e.fonts) === null || n === void 0 ? void 0 : n.ready : void 0, a = !1, l !== void 0 ? l.then(() => { a = !0; }) : a = !0; }; b(); function X(e) { if (a) return; let n = !1; I(() => { a || l == null || l.then(() => { n || e(); }); }), h(() => { n = !0; }); } const r = i(null); function y(e) { if (e.clientX > 0 || e.clientY > 0) r.value = { x: e.clientX, y: e.clientY }; else { const { target: n } = e; if (n instanceof Element) { const { left: t, top: u, width: s, height: f } = n.getBoundingClientRect(); t > 0 || u > 0 ? r.value = { x: t + s / 2, y: u + f / 2 } : r.value = { x: 0, y: 0 }; } else r.value = null; } } let c = 0, g = !0; function Y() { if (!k) return o(i(null)); c === 0 && v("click", document, y, !0); const e = () => { c += 1; }; return g && (g = P()) ? (R(e), h(() => { c -= 1, c === 0 && m("click", document, y, !0); })) : e(), o(r); } const x = i(void 0); let d = 0; function C() { x.value = Date.now(); } let M = !0; function $(e) { if (!k) return o(i(!1)); const n = i(!1); let t = null; function u() { t !== null && window.clearTimeout(t); } function s() { u(), n.value = !0, t = window.setTimeout(() => { n.value = !1; }, e); } d === 0 && v("click", window, C, !0); const f = () => { d += 1, v("click", window, s, !0); }; return M && (M = P()) ? (R(f), h(() => { d -= 1, d === 0 && m("click", window, C, !0), m("click", window, s, !0), u(); })) : f(), o(n); } function D(e, n) { return w(e, (t) => { t !== void 0 && (n.value = t); }), p(() => e.value === void 0 ? n.value : e.value); } function E() { const e = i(!1); return I(() => { e.value = !0; }), o(e); } function V(e, n) { return p(() => { for (const t of n) if (e[t] !== void 0) return e[t]; return e[n[n.length - 1]]; }); } const _ = (typeof window > "u" ? !1 : /iPad|iPhone|iPod/.test(navigator.platform) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1) && // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions !window.MSStream; function j() { return _; } export { j as a, D as b, V as c, $ as d, Y as e, H as f, E as i, X as o, U as u };