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

ZoomPlugin()'s onMouseWheel event needs to block the default action. Because if you do not block the default action, scrolling is triggered when zooming is made #50

Open
Z-J-wang opened this issue Jun 15, 2022 · 0 comments

Comments

@Z-J-wang
Copy link

Z-J-wang commented Jun 15, 2022

ZoomPlugin()'s onMouseWheel event needs to block the default action. Because if you do not block the default action, scrolling is triggered when zooming is made.

ZoomPlugin.prototype.onMouseWheel = function (event) {
        event.preventDefault();  //  add
        var scale = this.workflow.scale;
        var scaleUpdate = scale - event.deltaY / 500;
        var zoominOut = scaleUpdate < scale;
        var zoomingIn = scaleUpdate > scale;
        if (zoomingIn && this.workflow.maxScale < scaleUpdate) {
            return;
        }
        if (zoominOut && this.workflow.minScale > scaleUpdate) {
            return;
        }
        this.workflow.scaleAtPoint(scaleUpdate, event.clientX, event.clientY);
        event.stopPropagation();
    };
@Z-J-wang Z-J-wang changed the title ZoomPlugin()'s onMouseWheel event needs to block the default event, because if the default event is not blocked, scrolling is triggered when zooming is made ZoomPlugin()'s onMouseWheel event needs to block the default action. Because if you do not block the default action, scrolling is triggered when zooming is made Jun 15, 2022
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