Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onZoomStart is not called for pinch #790

Closed
tomeronen opened this issue Nov 1, 2023 · 2 comments
Closed

onZoomStart is not called for pinch #790

tomeronen opened this issue Nov 1, 2023 · 2 comments

Comments

@tomeronen
Copy link

if pinch is enabled, then zoom happens without the onZoomStart being called. I think this is a quick fix. Can i open a PR to add the onZoomStart function before the zoom call?

function handlePinch(chart, state, e) {
  if (state.scale) {
    const {center, pointers} = e;
    // Hammer reports the total scaling. We need the incremental amount
    const zoomPercent = 1 / state.scale * e.scale;
    const rect = e.target.getBoundingClientRect();
    const pinch = pinchAxes(pointers[0], pointers[1]);
    const mode = state.options.zoom.mode;
    const amount = {
      x: pinch.x && directionEnabled(mode, 'x', chart) ? zoomPercent : 1,
      y: pinch.y && directionEnabled(mode, 'y', chart) ? zoomPercent : 1,
      focalPoint: {
        x: center.x - rect.left,
        y: center.y - rect.top
      }
    };

    zoom(chart, amount);

    // Keep track of overall scale
    state.scale = e.scale;
  }
}
@kurkle
Copy link
Member

kurkle commented Nov 17, 2024

Fixed by #810

@kurkle kurkle closed this as completed Nov 17, 2024
@romor
Copy link

romor commented Nov 25, 2024

When returning false in the onZoomStart() callback, the zoom operation should be cancelled according documentation.

However, the pinch event is not cancelled for me and the zoom is done although it should be aborted.

Thus, I think this ticket shall not be closed as it is not completely finished.

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

No branches or pull requests

3 participants