Is it possible to turn on webview-level pinch-zoom gesture? #14794
Replies: 2 comments 4 replies
-
|
as far as i know, wkwebview has no easy toggle for this so as i understand it you or we have to use https://developer.apple.com/documentation/appkit/nsmagnificationgesturerecognizer to listen to the pinch event and then call https://docs.rs/tauri/latest/tauri/webview/struct.WebviewWindow.html#method.set_zoom (or its native objc equivalent) to actual zoom in/out :/ The "good" thing is that this should be possible to implement in the app directly, the "bad" thing is that using objective-c, especially in rust, isn't exactly easy. |
Beta Was this translation helpful? Give feedback.
-
|
@hippietrail @FabianLars's suggestion works but there's a simpler path. WKWebView has a built-in tauri/wry doesn't expose it though. looking at wry's source, the quickest workaround is unsafe obj-c from your tauri setup: use objc2::msg_send;
// after webview creation
let webview = window.webview().inner();
unsafe {
let _: () = msg_send![webview, setAllowsMagnification: true];
}if you want something without unsafe code, the CSS viewport approach handles most cases: <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=5, user-scalable=yes">the cleanest long-term fix would be a PR to wry adding |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I can't find this anywhere except for a few people asking a few years ago the opposite, how to turn pinch-zoom off.
But I want to make a Tauri app that allows pinch-zoom just like browsers do, as part of the system. I know I can manually set it up in JavaScript but that's not what I'm looking for.
If it makes a difference I'm on macOS so I guess it's a Safari webview.
Beta Was this translation helpful? Give feedback.
All reactions