@peeekpage/viewer 0.4.3 → 0.4.4
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/index.js +26 -26
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -506,17 +506,17 @@ function Tt(t) {
|
|
|
506
506
|
isFullscreen: k,
|
|
507
507
|
onToggleFullscreen: f,
|
|
508
508
|
onAbout: u
|
|
509
|
-
} = t, l = e.length, O = Ce() || !_, [F, R] = v(0), [x, A] = v(1), [Z, j] = v(!1), [M, $] = v({ x: 0, y: 0 }), [B, P] = v(!1), [X, m] = v(0), p = E(null),
|
|
509
|
+
} = t, l = e.length, O = Ce() || !_, [F, R] = v(0), [x, A] = v(1), [Z, j] = v(!1), [M, $] = v({ x: 0, y: 0 }), [B, P] = v(!1), [X, m] = v(0), p = E(null), S = E(null), { layout: b, toggle: K } = kt(S, a), re = me(l, b), [T, le] = v(null), [xe, pe] = v(!1), ie = E(null), [be, Se] = v(0.707);
|
|
510
510
|
C(() => {
|
|
511
511
|
if (!e[0]) return;
|
|
512
512
|
const r = new globalThis.Image();
|
|
513
513
|
r.onload = () => {
|
|
514
|
-
r.naturalWidth && r.naturalHeight &&
|
|
514
|
+
r.naturalWidth && r.naturalHeight && Se(r.naturalWidth / r.naturalHeight);
|
|
515
515
|
}, r.src = e[0];
|
|
516
516
|
}, [e]);
|
|
517
|
-
const
|
|
517
|
+
const z = ne(F, l, b), ze = z <= 0, se = z >= re - 1, he = E(/* @__PURE__ */ new Set());
|
|
518
518
|
C(() => {
|
|
519
|
-
const r = [
|
|
519
|
+
const r = [z - 1, z + 1, z + 2].map((s) => ne(s, l, b)).flatMap((s) => ge(s, l, b)).filter((s) => s >= 0);
|
|
520
520
|
for (const s of r) {
|
|
521
521
|
const N = e[s];
|
|
522
522
|
if (!N || he.current.has(N)) continue;
|
|
@@ -524,7 +524,7 @@ function Tt(t) {
|
|
|
524
524
|
const q = new globalThis.Image();
|
|
525
525
|
q.src = N;
|
|
526
526
|
}
|
|
527
|
-
}, [
|
|
527
|
+
}, [z, l, b, e]);
|
|
528
528
|
const W = L(
|
|
529
529
|
(r) => {
|
|
530
530
|
T || R((s) => {
|
|
@@ -565,16 +565,16 @@ function Tt(t) {
|
|
|
565
565
|
if (!h || se) return;
|
|
566
566
|
const r = setTimeout(() => W(1), g);
|
|
567
567
|
return () => clearTimeout(r);
|
|
568
|
-
}, [h, g, se,
|
|
568
|
+
}, [h, g, se, z, W]);
|
|
569
569
|
const Fe = () => A((r) => Math.min(ae, r + Te)), Me = () => A((r) => Math.max(ee, r - Te)), Ee = () => {
|
|
570
570
|
T || A((r) => r > ee ? ee : ae);
|
|
571
571
|
}, Le = () => m((r) => (r + 90) % 360), De = X === 90 || X === 270 ? be : 1, ue = L((r, s, N) => {
|
|
572
|
-
const q =
|
|
572
|
+
const q = S.current;
|
|
573
573
|
if (!q || N <= 1) return { x: 0, y: 0 };
|
|
574
574
|
const ye = (N - 1) * q.clientWidth / 2, ve = (N - 1) * q.clientHeight / 2;
|
|
575
575
|
return { x: Math.max(-ye, Math.min(ye, r)), y: Math.max(-ve, Math.min(ve, s)) };
|
|
576
576
|
}, []);
|
|
577
|
-
C(() => $((r) => ue(r.x, r.y, x)), [x, ue]), C(() => $({ x: 0, y: 0 }), [
|
|
577
|
+
C(() => $((r) => ue(r.x, r.y, x)), [x, ue]), C(() => $({ x: 0, y: 0 }), [z]);
|
|
578
578
|
const Oe = (r) => {
|
|
579
579
|
var s, N;
|
|
580
580
|
x <= 1 || (p.current = { x: r.clientX, y: r.clientY, px: M.x, py: M.y }, P(!0), (N = (s = r.currentTarget).setPointerCapture) == null || N.call(s, r.pointerId));
|
|
@@ -589,7 +589,7 @@ function Tt(t) {
|
|
|
589
589
|
} catch {
|
|
590
590
|
}
|
|
591
591
|
}
|
|
592
|
-
}, Y = ge(
|
|
592
|
+
}, Y = ge(z, l, b), te = Y[0] ?? 0, Be = b === "double" && Y.length === 2 ? `${Y[0] + 1} - ${Y[1] + 1} / ${l}` : `${te + 1} / ${l}`, Ue = re <= 1 ? 100 : z / (re - 1) * 100, Ze = n.prev, He = n.next, Ge = T ? T.to : z, H = oe(Ge, l, b), je = H.left < 0 && H.right >= 0, Ve = H.left >= 0 && H.right < 0, Xe = H.left >= 0 && H.right >= 0, Ke = je ? "-25%" : Ve ? "25%" : "0%", U = oe(z, l, b), V = T ? oe(T.to, l, b) : U, We = T ? T.dir === 1 ? U.right >= 0 ? U.right : U.left : U.left >= 0 ? U.left : U.right : te, Ye = T ? T.dir === 1 ? V.left >= 0 ? V.left : V.right : V.right >= 0 ? V.right : V.left : te, qe = T ? T.dir === 1 ? "left" : "right" : null, ke = (r) => r === qe && !xe ? U[r] : H[r], Je = [
|
|
593
593
|
["left", ke("left")],
|
|
594
594
|
["right", ke("right")]
|
|
595
595
|
];
|
|
@@ -597,7 +597,7 @@ function Tt(t) {
|
|
|
597
597
|
/* @__PURE__ */ y(
|
|
598
598
|
"div",
|
|
599
599
|
{
|
|
600
|
-
ref:
|
|
600
|
+
ref: S,
|
|
601
601
|
className: "peeek__stage",
|
|
602
602
|
"data-layout": b,
|
|
603
603
|
tabIndex: 0,
|
|
@@ -610,7 +610,7 @@ function Tt(t) {
|
|
|
610
610
|
type: "button",
|
|
611
611
|
className: "peeek__arrow peeek__arrow--prev",
|
|
612
612
|
"aria-label": Ze,
|
|
613
|
-
disabled:
|
|
613
|
+
disabled: ze,
|
|
614
614
|
onClick: () => W(-1),
|
|
615
615
|
children: "‹"
|
|
616
616
|
}
|
|
@@ -647,9 +647,9 @@ function Tt(t) {
|
|
|
647
647
|
className: "peeek__page-btn",
|
|
648
648
|
"aria-label": n.openFullscreen,
|
|
649
649
|
onClick: f,
|
|
650
|
-
children: /* @__PURE__ */ o("img", { src: e[s], alt: `Page ${s + 1}`,
|
|
650
|
+
children: /* @__PURE__ */ o("img", { src: e[s], alt: `Page ${s + 1}`, referrerPolicy: "no-referrer" })
|
|
651
651
|
}
|
|
652
|
-
) : /* @__PURE__ */ o("img", { src: e[s], alt: `Page ${s + 1}`,
|
|
652
|
+
) : /* @__PURE__ */ o("img", { src: e[s], alt: `Page ${s + 1}`, referrerPolicy: "no-referrer" }))
|
|
653
653
|
},
|
|
654
654
|
r
|
|
655
655
|
);
|
|
@@ -766,8 +766,8 @@ function Pt(t) {
|
|
|
766
766
|
const p = m >= 0 && m < u ? e[m] : void 0;
|
|
767
767
|
if (!p || Z.current.has(p)) continue;
|
|
768
768
|
Z.current.add(p);
|
|
769
|
-
const
|
|
770
|
-
|
|
769
|
+
const S = new globalThis.Image();
|
|
770
|
+
S.src = p;
|
|
771
771
|
}
|
|
772
772
|
}, [l, u, e]);
|
|
773
773
|
const j = E([]);
|
|
@@ -873,19 +873,19 @@ function Pt(t) {
|
|
|
873
873
|
}
|
|
874
874
|
),
|
|
875
875
|
e.map((m, p) => {
|
|
876
|
-
const
|
|
877
|
-
if (Math.abs(
|
|
878
|
-
const b =
|
|
876
|
+
const S = p - l;
|
|
877
|
+
if (Math.abs(S) > 1) return null;
|
|
878
|
+
const b = S === 0, K = b && f.fullscreen;
|
|
879
879
|
return /* @__PURE__ */ o(
|
|
880
880
|
"button",
|
|
881
881
|
{
|
|
882
882
|
type: "button",
|
|
883
883
|
className: `peeek__cf-card${b ? " peeek__cf-card--center" : ""}${K ? " peeek__cf-card--zoom" : ""}`,
|
|
884
|
-
style: Ct(
|
|
884
|
+
style: Ct(S, d),
|
|
885
885
|
tabIndex: b ? 0 : -1,
|
|
886
886
|
"aria-label": K ? n.openFullscreen : `Go to page ${p + 1}`,
|
|
887
887
|
onClick: () => K ? w() : D(p),
|
|
888
|
-
children: /* @__PURE__ */ o("img", { src: m, alt: b ? `Page ${p + 1}` : "",
|
|
888
|
+
children: /* @__PURE__ */ o("img", { src: m, alt: b ? `Page ${p + 1}` : "", referrerPolicy: "no-referrer" })
|
|
889
889
|
},
|
|
890
890
|
p
|
|
891
891
|
);
|
|
@@ -905,7 +905,7 @@ function Pt(t) {
|
|
|
905
905
|
}
|
|
906
906
|
),
|
|
907
907
|
f.thumbnails && /* @__PURE__ */ o("div", { className: "peeek__cf-thumbs", role: "group", "aria-label": "Pages", children: e.map((m, p) => {
|
|
908
|
-
const
|
|
908
|
+
const S = p === l;
|
|
909
909
|
return /* @__PURE__ */ y(
|
|
910
910
|
"button",
|
|
911
911
|
{
|
|
@@ -913,9 +913,9 @@ function Pt(t) {
|
|
|
913
913
|
j.current[p] = b;
|
|
914
914
|
},
|
|
915
915
|
type: "button",
|
|
916
|
-
className: `peeek__cf-thumb${
|
|
916
|
+
className: `peeek__cf-thumb${S ? " peeek__cf-thumb--active" : ""}`,
|
|
917
917
|
"aria-label": `Go to page ${p + 1}`,
|
|
918
|
-
"aria-current":
|
|
918
|
+
"aria-current": S ? "page" : void 0,
|
|
919
919
|
onClick: () => D(p),
|
|
920
920
|
children: [
|
|
921
921
|
/* @__PURE__ */ o("img", { src: m, alt: "", loading: "lazy", referrerPolicy: "no-referrer" }),
|
|
@@ -946,7 +946,7 @@ const xt = [
|
|
|
946
946
|
{ top: "16%", left: "50%", size: 2, v: "B", dur: 14, delay: 3 },
|
|
947
947
|
{ top: "62%", left: "34%", size: 2, v: "C", dur: 12, delay: 2 }
|
|
948
948
|
];
|
|
949
|
-
function
|
|
949
|
+
function St({ strings: t, onClose: e }) {
|
|
950
950
|
const n = E(null);
|
|
951
951
|
return C(() => {
|
|
952
952
|
var a;
|
|
@@ -1027,7 +1027,7 @@ function zt({ strings: t, onClose: e }) {
|
|
|
1027
1027
|
/* @__PURE__ */ o("div", { className: "peeek__about-tagline", children: t.aboutTagline }),
|
|
1028
1028
|
/* @__PURE__ */ y("div", { className: "peeek__about-version", children: [
|
|
1029
1029
|
"v",
|
|
1030
|
-
"0.4.
|
|
1030
|
+
"0.4.4"
|
|
1031
1031
|
] }),
|
|
1032
1032
|
/* @__PURE__ */ o("p", { className: "peeek__about-desc", children: t.aboutDescription })
|
|
1033
1033
|
] })
|
|
@@ -1106,7 +1106,7 @@ function Ft(t) {
|
|
|
1106
1106
|
onAbout: () => h(!0)
|
|
1107
1107
|
}
|
|
1108
1108
|
),
|
|
1109
|
-
_ && /* @__PURE__ */ o(
|
|
1109
|
+
_ && /* @__PURE__ */ o(St, { strings: n, onClose: () => h(!1) })
|
|
1110
1110
|
]
|
|
1111
1111
|
}
|
|
1112
1112
|
);
|