pdf-flipbook 1.8.0 → 1.9.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/pdf-flipbook.css +3 -1
- package/dist/pdf-flipbook.esm.js +30 -10
- package/dist/pdf-flipbook.esm.js.map +2 -2
- package/dist/pdf-flipbook.esm.min.js +2 -2
- package/dist/pdf-flipbook.esm.min.js.map +3 -3
- package/dist/pdf-flipbook.umd.js +31 -11
- package/dist/pdf-flipbook.umd.js.map +2 -2
- package/package.json +2 -2
package/dist/pdf-flipbook.css
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
flex-direction: column;
|
|
14
14
|
width: 100%;
|
|
15
15
|
background: var(--pfb-bg);
|
|
16
|
-
font-family: '
|
|
16
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
|
|
17
17
|
-webkit-font-smoothing: antialiased;
|
|
18
18
|
box-sizing: border-box;
|
|
19
19
|
user-select: none;
|
|
@@ -44,7 +44,9 @@
|
|
|
44
44
|
display: block;
|
|
45
45
|
width: 100%;
|
|
46
46
|
height: 100%;
|
|
47
|
+
cursor: grab;
|
|
47
48
|
}
|
|
49
|
+
.pfb__canvas:active { cursor: grabbing; }
|
|
48
50
|
|
|
49
51
|
/* Arrow buttons — sit in the side padding */
|
|
50
52
|
.pfb__btn {
|
package/dist/pdf-flipbook.esm.js
CHANGED
|
@@ -21212,7 +21212,7 @@ var DEFAULTS = {
|
|
|
21212
21212
|
flippingTime: 800,
|
|
21213
21213
|
toolbar: true,
|
|
21214
21214
|
theme: "dark",
|
|
21215
|
-
maxDpr:
|
|
21215
|
+
maxDpr: 3,
|
|
21216
21216
|
onFlip: null,
|
|
21217
21217
|
onReady: null,
|
|
21218
21218
|
onError: null
|
|
@@ -21310,7 +21310,7 @@ var PdfFlipbook = class {
|
|
|
21310
21310
|
if (this._loaderT) this._loaderT.textContent = `Loading ${i} / ${this._total}\u2026`;
|
|
21311
21311
|
const page = await pdf.getPage(i);
|
|
21312
21312
|
const dpr = clamp(window.devicePixelRatio || 1, 1, this._opts.maxDpr);
|
|
21313
|
-
const W =
|
|
21313
|
+
const W = 2400 * dpr;
|
|
21314
21314
|
const vp = page.getViewport({ scale: W / vp0.width });
|
|
21315
21315
|
const cvs = document.createElement("canvas");
|
|
21316
21316
|
cvs.width = vp.width;
|
|
@@ -21575,19 +21575,39 @@ var PdfFlipbook = class {
|
|
|
21575
21575
|
if (["ArrowLeft", "ArrowUp"].includes(e.key)) this.prev();
|
|
21576
21576
|
};
|
|
21577
21577
|
window.addEventListener("keydown", this._onKey);
|
|
21578
|
-
|
|
21579
|
-
|
|
21578
|
+
let dragStart = null;
|
|
21579
|
+
const getCanvasX = (clientX) => {
|
|
21580
21580
|
const rect = this._canvas.getBoundingClientRect();
|
|
21581
|
-
|
|
21582
|
-
|
|
21581
|
+
return (clientX - rect.left) * (this._canvas.width / rect.width);
|
|
21582
|
+
};
|
|
21583
|
+
const onDragStart = (clientX) => {
|
|
21584
|
+
if (this._flip) return;
|
|
21585
|
+
const cx = getCanvasX(clientX);
|
|
21586
|
+
const half = this._canvas.width / 2;
|
|
21587
|
+
dragStart = { x: clientX, canvasX: cx, side: cx < half ? "left" : "right" };
|
|
21588
|
+
};
|
|
21589
|
+
const onDragEnd = (clientX) => {
|
|
21590
|
+
if (!dragStart) return;
|
|
21591
|
+
const dx = clientX - dragStart.x;
|
|
21592
|
+
const absDx = Math.abs(dx);
|
|
21593
|
+
if (absDx > 30) {
|
|
21594
|
+
if (dragStart.side === "right" && dx < 0) this.next();
|
|
21595
|
+
else if (dragStart.side === "left" && dx > 0) this.prev();
|
|
21596
|
+
else if (dx < 0) this.next();
|
|
21597
|
+
else this.prev();
|
|
21598
|
+
}
|
|
21599
|
+
dragStart = null;
|
|
21600
|
+
};
|
|
21601
|
+
this._canvas.addEventListener("mousedown", (e) => onDragStart(e.clientX));
|
|
21602
|
+
this._canvas.addEventListener("mouseup", (e) => onDragEnd(e.clientX));
|
|
21603
|
+
this._canvas.addEventListener("mouseleave", () => {
|
|
21604
|
+
dragStart = null;
|
|
21583
21605
|
});
|
|
21584
|
-
let tx = 0;
|
|
21585
21606
|
this._canvas.addEventListener("touchstart", (e) => {
|
|
21586
|
-
|
|
21607
|
+
onDragStart(e.touches[0].clientX);
|
|
21587
21608
|
}, { passive: true });
|
|
21588
21609
|
this._canvas.addEventListener("touchend", (e) => {
|
|
21589
|
-
|
|
21590
|
-
if (Math.abs(dx) > 40) dx < 0 ? this.next() : this.prev();
|
|
21610
|
+
onDragEnd(e.changedTouches[0].clientX);
|
|
21591
21611
|
}, { passive: true });
|
|
21592
21612
|
this._onResize = () => this._resizeCanvas();
|
|
21593
21613
|
window.addEventListener("resize", this._onResize);
|