nodebb-plugin-pdf-secure2 1.4.7 → 1.4.8

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.7",
3
+ "version": "1.4.8",
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": {
@@ -2787,18 +2787,23 @@
2787
2787
 
2788
2788
 
2789
2789
  // Mouse wheel / touchpad pinch zoom with Ctrl (clamped 0.5x-5x)
2790
+ // Touchpad pinch fires 60+ small events/sec → must heavily dampen.
2791
+ // Mouse wheel fires fewer large events → needs separate handling.
2790
2792
  let zoomAccumulator = 0;
2791
2793
  let zoomRafId = null;
2792
2794
  container.addEventListener('wheel', (e) => {
2793
2795
  if (!e.ctrlKey) return;
2794
2796
  e.preventDefault();
2795
2797
 
2796
- // Touchpad pinch sends small deltaY values; mouse wheel sends large ones (100+)
2797
- // Normalize: clamp large mouse wheel jumps, keep touchpad's fine granularity
2798
2798
  const raw = e.deltaY;
2799
- const clamped = Math.max(-10, Math.min(10, raw));
2800
- const sensitivity = 0.008;
2801
- zoomAccumulator -= clamped * sensitivity;
2799
+ const isMouseWheel = Math.abs(raw) >= 50;
2800
+ if (isMouseWheel) {
2801
+ zoomAccumulator += (raw < 0 ? 0.08 : -0.08);
2802
+ } else {
2803
+ const clamped = Math.max(-5, Math.min(5, raw));
2804
+ zoomAccumulator -= clamped * 0.002;
2805
+ }
2806
+ zoomAccumulator = Math.max(-0.04, Math.min(0.04, zoomAccumulator));
2802
2807
 
2803
2808
  if (!zoomRafId) {
2804
2809
  zoomRafId = requestAnimationFrame(() => {
@@ -7581,8 +7581,8 @@
7581
7581
 
7582
7582
 
7583
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.
7584
+ // Touchpad pinch fires 60+ small events/sec must heavily dampen.
7585
+ // Mouse wheel fires fewer large events needs separate handling.
7586
7586
  let zoomAccumulator = 0;
7587
7587
  let zoomRafId = null;
7588
7588
  container.addEventListener('wheel', (e) => {
@@ -7590,9 +7590,18 @@
7590
7590
  e.preventDefault();
7591
7591
 
7592
7592
  const raw = e.deltaY;
7593
- const clamped = Math.max(-10, Math.min(10, raw));
7594
- const sensitivity = 0.008;
7595
- zoomAccumulator -= clamped * sensitivity;
7593
+ // Detect input type: mouse wheel sends |deltaY| >= 50, touchpad sends < 50
7594
+ const isMouseWheel = Math.abs(raw) >= 50;
7595
+ if (isMouseWheel) {
7596
+ // Mouse wheel: fixed step per click (ignore magnitude)
7597
+ zoomAccumulator += (raw < 0 ? 0.08 : -0.08);
7598
+ } else {
7599
+ // Touchpad: very low sensitivity, clamp individual delta
7600
+ const clamped = Math.max(-5, Math.min(5, raw));
7601
+ zoomAccumulator -= clamped * 0.002;
7602
+ }
7603
+ // Cap total accumulator per frame (max ~4% zoom per frame)
7604
+ zoomAccumulator = Math.max(-0.04, Math.min(0.04, zoomAccumulator));
7596
7605
 
7597
7606
  if (!zoomRafId) {
7598
7607
  zoomRafId = requestAnimationFrame(() => {