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

Add Left, Right, and Middle click pan options #420

Merged
merged 1 commit into from
Oct 19, 2023

Conversation

EEwing
Copy link
Contributor

@EEwing EEwing commented Sep 17, 2023

This PR allows users to disable panning with certain mouse buttons. At the moment, any mouse button that triggers a MouseEvent will initiate panning, but in many situations a user might want to limit that functionality to a single button, or any of a set of buttons. For instance, a common use case is that right click should not pan, or that only middle click should pan to emulate other similar desktop applications with zoom/pan/pinch interfaces.

With this PR, all three buttons (left click, right click, middle click) are enabled by default to avoid changing existing functionality. To disable specific button presses, you can add any of the following props to the TransformWrapper:

allowLeftClickPan: Allows left click to initiate panning. Defaults to true
allowMiddleClickPan: Allows middle click to initiate panning. Defaults to true
allowRightClickPan: Allows right click to initiate panning. Defaults to true

Here is an example bit of code to disable left and right click panning, and only allow middle click to initiate panning:

function MyComponent() {
    return (
        <TransformWrapper
            panning={{
                allowLeftClickPan: false,
                allowMiddleClickPan: true,
                allowRightClickPan: false
            }}
        >
            <TransformComponent>
                <div>Content</div>
            </TransformComponent>
        </TransformWrapper>
    )
}

@EEwing EEwing requested a review from prc5 as a code owner September 17, 2023 07:57
@Trithir
Copy link

Trithir commented Oct 19, 2023

This would be incredibly helpful! The only way I can use panning right now is by using an activationKey. Being able to enable only MMB for panning would improve the UX greatly.

@prc5 prc5 merged commit 2777107 into BetterTyped:master Oct 19, 2023
@github-actions
Copy link

🎉 This PR is included in version 3.3.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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.

3 participants