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

Stop catching scroll events when there is no zoom that #787

Open
tomeronen opened this issue Oct 25, 2023 · 0 comments
Open

Stop catching scroll events when there is no zoom that #787

tomeronen opened this issue Oct 25, 2023 · 0 comments

Comments

@tomeronen
Copy link

What do you think about not catching scroll events if there is no zoom that can be done. My use case is that i have 3 charts in a single page.

When i scroll down, i want the charts to zoom in until no zoom can be done and then scroll the content.
When i scroll up, i want the charts to zoom out until no zoom can be done and then scroll the content.

I thought about maybe adding a check if the current y axis value is equal to the limit and the delta is positive/negative.

handlers.js


function wheelPreconditions(chart, event, zoomOptions) {
  // Before preventDefault, check if the modifier key required and pressed
  if (keyNotPressed(getModifierKey(zoomOptions.wheel), event)) {
    call(zoomOptions.onZoomRejected, [{chart, event}]);
    return;
  }

  if (zoomStart(chart, event, zoomOptions) === false) {
    return;
  }

  // Prevent the event from triggering the default behavior (e.g. content scrolling).
 -  if (event.cancelable) {
 -   event.preventDefault();
 - } 

 +  if (event.cancelable && chartCanScroll(chart, event, zoomOptions)) {
 +   event.preventDefault();
 + } 

  // Firefox always fires the wheel event twice:
  // First without the delta and right after that once with the delta properties.
  if (event.deltaY === undefined) {
    return;
  }
  return true;
}

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

1 participant