Skip to content

Proper touch pinch support for Zoom & Pan#21655

Open
NightRa wants to merge 4 commits into
apache:masterfrom
NightRa:master
Open

Proper touch pinch support for Zoom & Pan#21655
NightRa wants to merge 4 commits into
apache:masterfrom
NightRa:master

Conversation

@NightRa

@NightRa NightRa commented Jun 19, 2026

Copy link
Copy Markdown

Brief Information

This pull request is in the type of:

  • bug fixing
  • new feature
  • others

What does this PR do?

Improve RoamController pinch handling by using the real touch pinch scale, supporting two-finger pan, and capturing pinch gestures consistently.

Fixed issues

Fixes #18949
Fixes #18113
Related #21417
Related #20939

Details

Before: What was the problem?

Touch pinch zoom used a fixed zoom step:

e.pinchScale > 1 ? 1.1 : 1 / 1.1

This made small frame-to-frame pinch changes to zoom exponentially instead of according to the pinch distance.

Pinch also emitted only zoom events. When the pinch center moved, roamable views did not pan with the fingers. Additionally, pinch hit-testing was repeated on every frame, so an active pinch could stop when moving outside the roam area, or be picked up mid-gesture by another overlapping RoamController.

After: How does it behave after the fixing?

RoamController now uses the actual e.pinchScale reported by ZRender.

Pinch is treated as a two-finger roam gesture:

  • roam: true: pinch can pan and zoom.
  • roam: 'move' / 'pan': pinch can pan without zooming.
  • roam: 'scale' / 'zoom': pinch can zoom without panning.

A pinch is captured only when it starts from a native touchstart inside the valid roam area. Once captured, it continues outside the area like mouse drag, and another RoamController cannot pick up the already-moving pinch.

Document Info

  • This PR doesn't relate to document changes
  • The document should be updated later
  • The document changes have been made in apache/echarts-doc#xxx

Misc

Security Checking

  • This PR uses security-sensitive Web APIs.

ZRender Changes

  • This PR depends on ZRender changes (ecomfe/zrender#xxx).

Related test cases or examples to use the new APIs

Manual examples:

  • test/dataZoom-timeAxis.html
  • dataZoom-rainfall-inside.html
  • test/geo-map-roam.html
  • test/graph-layout-roam.html
  • test/tree-roam.html
  • test/sankey-roam.html
  • test/treemap-simple.html
  • test/treemap-scaleLimit.html
  • test/graph-thumbnail.html

I've tested the changes in all the mentioned test examples on an Android phone in Chrome.

Merging options

  • Please squash the commits into a single one when merging.

Before & After videos

dataZoom-Before.mp4
dataZoom-After.mp4
Geo-Before.mp4
Geo-After.mp4

@echarts-bot

echarts-bot Bot commented Jun 19, 2026

Copy link
Copy Markdown

Thanks for your contribution!
The community will review it ASAP. In the meanwhile, please checkout the coding standard and Wiki about How to make a pull request.

Please DO NOT commit the files in dist, i18n, and ssr/client/dist folders in a non-release pull request. These folders are for release use only.

@NightRa NightRa changed the title Fix exponential zoom for pinch zoom in RoamController Proper touch pinch support for Zoom & Pan Jun 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] pinch-to-zoom is too responsive on mobile [Bug] Pinch on maps has too high scale factor, thus feeling unnatural

1 participant