Add 'reverse' option to wheel gesture#660
Conversation
|
|
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:
|
|
@dbismut could you please take a look? |
|
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 |
|
Hi @dbismut, I'm sorry for the late reply to your swift response. I got distracted. I've created a simple reproduction of what I'm trying to achieve. Unfortunately, I could not get it working using the https://codesandbox.io/p/sandbox/use-gesture-zoom-reverse-23npzv?file=%2Fsrc%2FApp.js |
|
Hi @dbismut, I just noticed that I'd left the codesandbox on private. It should be public now. Do you think this behaviour should be accomplishable by using the https://codesandbox.io/p/sandbox/use-gesture-zoom-reverse-23npzv |
This PR adds a
reverseoption 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
fromandboundsproperties to limit the canvas movement. This led to some complications when I tried to invert the direction of the wheel scroll. Without having thereverseoption, it would require a complex bounds calculation which would be the inverse of the bounds which I'm already calculating for thedraggesture. This was my first approach, however I ran into some weird behaviour which is was not able to easily fix.The
reverseoption that is introduced by this PR allows developers in the invert the wheel gesture, while allowing to use the sameboundscalculation that is used by thedraggesture. This will make it easier for developers that wish to implement drag and wheel gesture behaviour similar to something like excalidraw.com.