Skip to content

Commit 3a43bb9

Browse files
committed
fix(pdf-server): wheel pinch-out can exit fullscreen again
The fit-floor pinned previewScale at fit, but the wheel handler multiplied the *clamped* previewScale, so it could never accumulate below fit*0.9 to trigger exit. Drive the wheel accumulator off previewScaleRaw instead, and bound previewScaleRaw to [floor*0.7, ZOOM_MAX] so it can cross the 0.9 exit threshold without drifting unboundedly (which would make direction reversal feel sticky). Touch path was unaffected (absolute ratio).
1 parent 6d0774f commit 3a43bb9

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

examples/pdf-server/src/mcp-app.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3805,14 +3805,17 @@ function beginPinch() {
38053805
}
38063806

38073807
function updatePinch(nextScale: number) {
3808-
previewScaleRaw = nextScale;
38093808
// In fullscreen, never shrink below fit — fit-to-page is "fully visible",
3810-
// so anything smaller just adds dead margin. previewScaleRaw stays
3811-
// unclamped so the exit-to-inline check in commitPinch() still fires.
3809+
// so anything smaller just adds dead margin.
38123810
const floor =
38133811
currentDisplayMode === "fullscreen" && fitScaleAtPinchStart !== null
38143812
? Math.max(ZOOM_MIN, fitScaleAtPinchStart)
38153813
: ZOOM_MIN;
3814+
// previewScaleRaw is the wheel handler's accumulator AND the exit-to-inline
3815+
// signal. It must be allowed past `floor` (so commitPinch sees < fit*0.9)
3816+
// but bounded so reversing direction doesn't have to unwind a huge
3817+
// overshoot before the visible scale moves again.
3818+
previewScaleRaw = Math.min(ZOOM_MAX, Math.max(floor * 0.7, nextScale));
38163819
previewScale = Math.min(ZOOM_MAX, Math.max(floor, nextScale));
38173820
// Transform is RELATIVE to the rendered canvas (which sits at
38183821
// pinchStartScale), so a previewScale equal to pinchStartScale → ratio 1.
@@ -3886,7 +3889,10 @@ canvasContainerEl.addEventListener(
38863889
// physical mouse wheel (deltaY ≈ ±100/notch) doesn't slam to the
38873890
// limit; trackpad pinch deltas are ~±1-10 so the clamp is a no-op.
38883891
const d = Math.max(-25, Math.min(25, e.deltaY));
3889-
updatePinch(previewScale * Math.exp(-d * 0.01));
3892+
// Drive off previewScaleRaw (not previewScale) so we can accumulate
3893+
// past the fit-floor and trigger exit-to-inline. previewScaleRaw is
3894+
// itself bounded in updatePinch() so reversal stays responsive.
3895+
updatePinch(previewScaleRaw * Math.exp(-d * 0.01));
38903896
if (pinchSettleTimer) clearTimeout(pinchSettleTimer);
38913897
// 200ms — slow trackpad pinches can leave >150ms gaps between wheel
38923898
// events, which would commit-then-restart and feel steppy.

0 commit comments

Comments
 (0)