nodebb-plugin-pdf-secure2 1.4.6 → 1.4.7

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/static/viewer.html +21 -9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-pdf-secure2",
3
- "version": "1.4.6",
3
+ "version": "1.4.7",
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": {
@@ -7580,16 +7580,28 @@
7580
7580
 
7581
7581
 
7582
7582
 
7583
- // Mouse wheel zoom with Ctrl
7583
+ // Mouse wheel / touchpad pinch zoom with Ctrl (clamped 0.5x–5x)
7584
+ // Touchpad pinch sends many small deltaY events; mouse wheel sends large ones (100+).
7585
+ // We accumulate deltas and apply once per frame to keep zoom smooth on both.
7586
+ let zoomAccumulator = 0;
7587
+ let zoomRafId = null;
7584
7588
  container.addEventListener('wheel', (e) => {
7585
- if (e.ctrlKey) {
7586
- e.preventDefault();
7587
- if (e.deltaY < 0) {
7588
- pdfViewer.currentScale += 0.1;
7589
- } else {
7590
- pdfViewer.currentScale -= 0.1;
7591
- }
7592
- updateAllWatermarkScales();
7589
+ if (!e.ctrlKey) return;
7590
+ e.preventDefault();
7591
+
7592
+ const raw = e.deltaY;
7593
+ const clamped = Math.max(-10, Math.min(10, raw));
7594
+ const sensitivity = 0.008;
7595
+ zoomAccumulator -= clamped * sensitivity;
7596
+
7597
+ if (!zoomRafId) {
7598
+ zoomRafId = requestAnimationFrame(() => {
7599
+ const newScale = pdfViewer.currentScale * (1 + zoomAccumulator);
7600
+ pdfViewer.currentScale = Math.max(0.5, Math.min(5, newScale));
7601
+ zoomAccumulator = 0;
7602
+ zoomRafId = null;
7603
+ updateAllWatermarkScales();
7604
+ });
7593
7605
  }
7594
7606
  }, { passive: false });
7595
7607