infinite-viewer
infinite-viewer copied to clipboard
Question: How do i use ctrl + mouse wheel for zoom in and out?
I tried to remove the e.preventDefault from your code but it does not seem to work.
at InfiniteViewerManager:
- onWheel
- onGestureStart
- onGestureChange
I need to have this option to be enabled on and off. how do i do this?
It seems to have a bug here!
If I hold ctrl
and wheelDown
, the wrapper will zoom out to a very small state.
You can look this bug in infinite-viewer demo page
https://daybrush.com/infinite-viewer/
@daybrush
@Dzxwind
Set maxPinchWheel
(default: Infinity) to 10
.
And demo i s updated. Thank you :)
@gaterin
infinite-viewer's new version is released. on or off options are added. see below:
useWheelPinch - Whether to use wheel pinch. you can pinch using the ctrl key. (default: true)
useWheelScroll - Whether to use wheel scroll. You can scroll smoothly by using the wheel. (default: IS_SAFARI)
useGesture - Whether to use gestures using trackpad or magic mouse. (default: true)
Is there a way to enable zoom with wheel scroll + the (CMD or Option) key? This would be helpful as on Mac, it's common to use the CMD key as a modifier key for zooming when using a regular mouse wheel.
@Samin100
For now, it's ctrlKey, but I'll consider it.
@Samin100
InfiniteViewer's new version is released.
Use wheelPinchKey
to ("ctrl" or "shift" or "meta" or "alt")
hey @daybrush I was wondering if you would know how to solve the following issue - if I don't pass wheelPinchKey
I can zoom in using pinch on the trackpad as well as pressing ctrl
You can see it working like that in one of your examples: https://codesandbox.io/s/youthful-diffie-kgnfrl?file=/src/App.js
However, once I add wheelPinchKey='meta'
pinch zoom stops working, zooming with scroll + meta key works: https://codesandbox.io/s/optimistic-wozniak-xsoteo
I tried looking into the code of infinite viewer but I can't figure out what's causing this weird behavior 🤔 I'd really like to keep using pinch zoom together with meta modifier for scroll zoom, I'm happy to do a PR, but I need some guidance to understand where it's coming from. thanks!
edit:
so for I've found a weird thing - seems that when I pinch event.ctrlKey
is set to true, even though I don't have it pressed down. Because it's true this line https://github.com/daybrush/infinite-viewer/blob/master/src/InfiniteViewerManager.tsx#L639 evaluates to true and makes zoom work.
As soon as I use meta
key as a wheelPinchKey
this stops working, because nothing seems to set meta
to true
🤔
@bytasv
Temporarily modified so that it can be used with ctrlKey.
Test with the new version.
OMG, such a fast reply and fix! Thanks a lot for an amazing job! 🙇 Everything works now as expected.
Just out of curiosity - is it gesto lib which sets ctrl when pinching? IMO this might be something to keep an eye for if it won't bring some unexpected behaviours in the future 🤔
@bytasv
The pinch of the trackpad is specified with the ctrlKey in the browser. I know that trackpad(gesture) can only be checked in safari.
Ohhh thats interesting, so that's a default browser behaviour? 😮 in that case ignore my last concern 👍 thanks again!
@daybrush
Yes. This is the default behavior of the browser.