Disable Pinch Zoom
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
Thanks for opening this! Sounds annoying. You haven't mentioned what platform you're targeting. Happy to accept a PR.
Wouldn't the user-scalable=no option in a meta viewport tag cover your use case?
Wouldn't the
user-scalable=nooption 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.
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.
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?
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.
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 });
@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
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.
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! 😃
I know that this option was officially added but that's only to windows. Any options for Linux?
If it's in webkit2gtk then it's an option 😅
Hi there! Could you share your full Wails version, operating system, and a small example that reproduces the problem? It would also help to know what you expected to happen and what happened instead. Thanks!
Adding a real-world macOS data point for this request.
App: magpie (https://github.com/yetone/magpie), a Wails v3 desktop app.
Symptom: On macOS, two-finger trackpad scrolling inside the WKWebView does not scroll the page. The user must grab the overlay scrollbar on the right edge to scroll. Pinch-to-zoom on the trackpad works, which suggests the gesture is being interpreted as a magnification event rather than a scrollWheel event.
Environment: macOS 13.4 (22F66), arm64, magpie 0.1.1271.
Binary evidence: Inspecting the shipped magpie binary (/Applications/magpie.app/Contents/MacOS/magpie), the only zoom-related C calls are windowZoomIn, windowZoomOut, windowZoomSet, windowZoomReset, windowZoomGet from Wails' own macOS webview code. There is no scrollWheel override and no DisableZoom field in WebviewWindowOptions (confirmed: the symbol does not exist in the binary). The setPageZoom path only calls -[WKWebView setMagnification:], which leaves allowsMagnification at its default value.
Workaround currently in use: Dragging the native scrollbar works because it goes through NSScrollView directly, bypassing WKWebView's magnify path.
This is blocking basic usability on macOS trackpads for any Wails app that does not override the WKWebView magnification behavior. A DisableZoom: true option (or defaulting allowsMagnification = NO on macOS) would fix it. Related: #6226