nodebb-plugin-pdf-secure2 1.4.4 → 1.4.5
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/package.json +1 -1
- package/static/viewer-app.js +19 -7
package/package.json
CHANGED
package/static/viewer-app.js
CHANGED
|
@@ -2731,16 +2731,28 @@
|
|
|
2731
2731
|
document.getElementById('fullscreenBtn').onclick = () => toggleFullscreen();
|
|
2732
2732
|
|
|
2733
2733
|
|
|
2734
|
-
// Mouse wheel zoom with Ctrl (
|
|
2735
|
-
let
|
|
2734
|
+
// Mouse wheel / touchpad pinch zoom with Ctrl (clamped 0.5x-5x)
|
|
2735
|
+
let zoomAccumulator = 0;
|
|
2736
|
+
let zoomRafId = null;
|
|
2736
2737
|
container.addEventListener('wheel', (e) => {
|
|
2737
2738
|
if (!e.ctrlKey) return;
|
|
2738
2739
|
e.preventDefault();
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2740
|
+
|
|
2741
|
+
// Touchpad pinch sends small deltaY values; mouse wheel sends large ones (100+)
|
|
2742
|
+
// Normalize: clamp large mouse wheel jumps, keep touchpad's fine granularity
|
|
2743
|
+
const raw = e.deltaY;
|
|
2744
|
+
const clamped = Math.max(-10, Math.min(10, raw));
|
|
2745
|
+
const sensitivity = 0.008;
|
|
2746
|
+
zoomAccumulator -= clamped * sensitivity;
|
|
2747
|
+
|
|
2748
|
+
if (!zoomRafId) {
|
|
2749
|
+
zoomRafId = requestAnimationFrame(() => {
|
|
2750
|
+
const newScale = pdfViewer.currentScale * (1 + zoomAccumulator);
|
|
2751
|
+
pdfViewer.currentScale = Math.max(0.5, Math.min(5, newScale));
|
|
2752
|
+
zoomAccumulator = 0;
|
|
2753
|
+
zoomRafId = null;
|
|
2754
|
+
});
|
|
2755
|
+
}
|
|
2744
2756
|
}, { passive: false });
|
|
2745
2757
|
|
|
2746
2758
|
console.log('PDF Viewer Ready');
|