infinite-viewer icon indicating copy to clipboard operation
infinite-viewer copied to clipboard

Question: How do i use ctrl + mouse wheel for zoom in and out?

Open gaterin opened this issue 3 years ago • 12 comments

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?

gaterin avatar Dec 03 '21 10:12 gaterin

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 avatar Dec 28 '21 09:12 Dzxwind

@Dzxwind

Set maxPinchWheel(default: Infinity) to 10.

And demo i s updated. Thank you :)

daybrush avatar Mar 06 '22 14:03 daybrush

@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)

daybrush avatar Mar 06 '22 16:03 daybrush

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 avatar Mar 25 '22 02:03 Samin100

@Samin100

For now, it's ctrlKey, but I'll consider it.

daybrush avatar Apr 04 '22 02:04 daybrush

@Samin100

InfiniteViewer's new version is released.

Use wheelPinchKey to ("ctrl" or "shift" or "meta" or "alt")

daybrush avatar Jul 26 '22 15:07 daybrush

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 avatar Sep 17 '22 18:09 bytasv

@bytasv

Temporarily modified so that it can be used with ctrlKey.

Test with the new version.

daybrush avatar Sep 18 '22 01:09 daybrush

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 avatar Sep 18 '22 07:09 bytasv

@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.

daybrush avatar Sep 18 '22 07:09 daybrush

Ohhh thats interesting, so that's a default browser behaviour? 😮 in that case ignore my last concern 👍 thanks again!

bytasv avatar Sep 18 '22 08:09 bytasv

@daybrush

Yes. This is the default behavior of the browser.

daybrush avatar Sep 18 '22 08:09 daybrush