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 'reverse' option to wheel gesture #660

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jeroenkroese
Copy link

This PR adds a reverse option to the wheel gesture, which inverts the direction of wheel scrolling. A few years ago, a similar PR #171 has been closed with the reason that the inversion could easily be done in userland.

In my scenario, I'm using multiple gestures (drag, pinch-to-zoom, and wheel) to navigate around a canvas element, and I'm using the from and bounds properties to limit the canvas movement. This led to some complications when I tried to invert the direction of the wheel scroll. Without having the reverse option, it would require a complex bounds calculation which would be the inverse of the bounds which I'm already calculating for the drag gesture. This was my first approach, however I ran into some weird behaviour which is was not able to easily fix.

The reverse option that is introduced by this PR allows developers in the invert the wheel gesture, while allowing to use the same bounds calculation that is used by the drag gesture. This will make it easier for developers that wish to implement drag and wheel gesture behaviour similar to something like excalidraw.com.

Copy link

changeset-bot bot commented Apr 2, 2024

⚠️ No Changeset found

Latest commit: 7f07adb

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

codesandbox-ci bot commented Apr 2, 2024

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 7f07adb:

Sandbox Source
gesture-drag Configuration
gesture-drag-target Configuration
gesture-nested Configuration
gesture-drag-vanilla Configuration
gesture-move Configuration
gesture-pinch Configuration
gesture-multiple-pinch Configuration
gesture-three Configuration
gesture-card-zoom Configuration
gesture-viewpager Configuration

@jeroenkroese
Copy link
Author

@dbismut could you please take a look?

@dbismut
Copy link
Collaborator

dbismut commented May 4, 2024

Hi @jeroenkroese thanks for the PR. Unfortunately I don't have a lot of time to dedicate to OSS atm. What's the benefit of this vs using the transform option beyond simplicity?

https://use-gesture.netlify.app/docs/options/#transform

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

Successfully merging this pull request may close these issues.

None yet

2 participants