Skip to content

Commit 4ea893e

Browse files
committed
feat(pdf-server): horizontal swipe changes pages whenever page fits width
Previously gated on scale <= 1.0, which blocked page-nav in fullscreen where fit-scale is often >100%. Now gate on actual horizontal overflow (scrollWidth > clientWidth) so swipe works at any fit-to-width scale and still defers to native panning once you zoom past it.
1 parent 0ae6de3 commit 4ea893e

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3878,10 +3878,15 @@ canvasContainerEl.addEventListener(
38783878
// Only intercept horizontal scroll, let vertical scroll through
38793879
if (Math.abs(e.deltaX) <= Math.abs(e.deltaY)) return;
38803880

3881-
// When zoomed, let natural panning happen (no page changes)
3882-
if (scale > 1.0) return;
3881+
// If the page overflows horizontally, let native panning handle it
3882+
// (no page changes). Checking actual overflow rather than `scale > 1.0`
3883+
// because fullscreen fit-scale is often >100% with the page still fully
3884+
// visible — we want swipe-to-page there. +1 absorbs sub-pixel rounding.
3885+
if (canvasContainerEl.scrollWidth > canvasContainerEl.clientWidth + 1) {
3886+
return;
3887+
}
38833888

3884-
// At 100% zoom, handle page navigation
3889+
// No horizontal overflow → swipe changes pages.
38853890
e.preventDefault();
38863891
horizontalScrollAccumulator += e.deltaX;
38873892
if (horizontalScrollAccumulator > SCROLL_THRESHOLD) {

0 commit comments

Comments
 (0)