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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-pdf-secure2",
3
- "version": "1.4.4",
3
+ "version": "1.4.5",
4
4
  "description": "Secure PDF viewer plugin for NodeBB - prevents downloading, enables canvas-only rendering with Premium group support",
5
5
  "main": "library.js",
6
6
  "repository": {
@@ -2731,16 +2731,28 @@
2731
2731
  document.getElementById('fullscreenBtn').onclick = () => toggleFullscreen();
2732
2732
 
2733
2733
 
2734
- // Mouse wheel zoom with Ctrl (debounced, clamped 0.5x-5x)
2735
- let zoomTimeout;
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
- clearTimeout(zoomTimeout);
2740
- const delta = e.deltaY < 0 ? 0.1 : -0.1;
2741
- zoomTimeout = setTimeout(() => {
2742
- pdfViewer.currentScale = Math.max(0.5, Math.min(5, pdfViewer.currentScale + delta));
2743
- }, 30);
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');