Skip to content

Map: pinch to zoom the map instead of the page - #99

Merged
davd-gzl merged 2 commits into
mainfrom
claude/map-pinch-zoom-561hwn
Oct 12, 2026
Merged

davd-gzl merged 2 commits into
mainfrom
claude/map-pinch-zoom-561hwn

Conversation

@davd-gzl

@davd-gzl davd-gzl commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator

Before: pinching on a trackpad over the map, or ctrl+scrolling with a mouse, zoomed the whole page and the map stayed where it was.

After: a pinch over the map zooms the map around the pointer, and the page stays still. This works in Chrome, Edge, Firefox and desktop Safari. A plain scroll over the map still scrolls the page, and pinching on a phone works as before.

Screenshots

These show the map after the same trackpad pinch on Paris → Marseille. Tiles don't load in the test browser, so only the route is drawn.

Before After
The route is unchanged after the pinch The map is zoomed in two levels on the route

How

zoomOnPinch in src/ui/map.ts cancels pinches over the map, both wheel events with ctrlKey and Safari's gesture* events, and applies them as map zoom steps instead. Plain wheels are left alone, and so are touch pinches, which Leaflet's touchZoom already handles.

Checks

tsc, npm test (216 passed), npm run build and npm run test:e2e (24/24) pass. The test run includes a new end-to-end scenario for both kinds of pinch and for a plain scroll.

A trackpad pinch (ctrl+wheel in Chromium and Firefox, gesture events in
Safari) over the map zoomed the whole page, because the map only listens to
touch pinches. Catch those on the map, zoom the map around the pointer and
keep the page still. A plain wheel still scrolls the page past the map.

Adds an end-to-end scenario for both pinch kinds.
@davd-gzl davd-gzl self-assigned this Oct 12, 2026
@davd-gzl
davd-gzl marked this pull request as ready for review October 12, 2026 09:23
@davd-gzl
davd-gzl merged commit ff0393d into main Oct 12, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants