wailsapp / wails

Create beautiful applications using Go
https://wails.io
MIT License
25.63k stars 1.24k forks source link

Disable Pinch Zoom #2021

Open allcapsc opened 2 years ago

allcapsc commented 2 years ago

Is your feature request related to a problem? Please describe.

I've been using Wails as an alternative for Electron but have noticed Wails doesn't support disabling Window Pinch or Mouse Scroll Zoom which can sometimes seem unprofessional when pushing an app to production. I would think this is a necessary feature for some people when wanting to limit control on an app window.

Describe the solution you'd like

I think it would be best for an option in the App Structure to Enable/Disable PinchZoom which would default to true and be edited to false to stop zooming entirely on an app window.

Describe alternatives you've considered

An alternative I tried was using CSS in the frontend but that doesn't do anything for limiting zoom pinch control on laptop touch-pads.

Additional context

No response

leaanthony commented 2 years ago

Thanks for opening this! Sounds annoying. You haven't mentioned what platform you're targeting. Happy to accept a PR.

brody192 commented 2 years ago

Wouldn't the user-scalable=no option in a meta viewport tag cover your use case?

allcapsc commented 2 years ago

Wouldn't the user-scalable=no option in a meta viewport tag cover your use case?

Unfortunately no, I also tried that but it does not stop pinch zoom on desktop rather mobile only.

allcapsc commented 2 years ago

Thanks for opening this! Sounds annoying. You haven't mentioned what platform you're targeting. Happy to accept a PR.

Currently targeting Windows, If I can find some info I'll try adding it onto here.

brody192 commented 2 years ago

Unfortunately no, I also tried that but it does not stop pinch zoom on desktop rather mobile only.

Have you tried prevent default on various gesture events?

stffabi commented 2 years ago

Should be pretty straight forward to be implemented for Windows: ICoreWebView2Settings5.IsPinchZoomEnabled

https://github.com/wailsapp/wails/blob/638caf72f0a85c9b29dc4d4e993d2f80e01491b7/v2/internal/frontend/desktop/windows/go-webview2/pkg/edge/ICoreWebViewSettings.go#L358

Couldn't yet find more information for macOS and Linux.

KiddoV commented 1 year ago

Any update on this? It is weird that one of my application has disabled zoom, but some are not. Not sure what I did in that app.

Updated: I used the vanilla template (back on Wails version 2.2.0) which disable the pinch zoom.

In the meantime, this method works for me in the front-end:

//Manually disable pinch zoom!
document.addEventListener("wheel", event => {
    const { ctrlKey } = event;
    if (ctrlKey) {
       event.preventDefault();
       return
    }
}, { passive: false });
leaanthony commented 1 year ago

@KiddoV can you please provide more information about the difference between v2.2 and current regarding this? As far as I'm aware, we haven't ever supported this feature but there was a PR to manually set the scale of the viewport

KiddoV commented 1 year ago

TBH, that version is too old and I don't know what is the differences between those, but looking at my old application which using v2.2.0 and the vanilla template, hitting CTRL+Mouse Wheel doesn't zoom in/out (I don't think I did something in the front-end back then) like other app which currently at the latest version/ svelte templates.

FoliageOwO commented 1 year ago

Any update on this? It is weird that one of my application has disabled zoom, but some are not. Not sure what I did in that app.

Updated: I used the vanilla template (back on Wails version 2.2.0) which disable the pinch zoom.

In the meantime, this method works for me in the front-end:

//Manually disable pinch zoom!
document.addEventListener("wheel", event => {
    const { ctrlKey } = event;
    if (ctrlKey) {
       event.preventDefault();
       return
    }
}, { passive: false });

TYSM, this method works fine on me! 😃