fix: window zoom

This commit is contained in:
Jonathan Kelley 2022-12-30 02:09:02 -05:00
parent 6dfe84834d
commit 7f418bbfee
3 changed files with 9 additions and 5 deletions

View File

@ -4,9 +4,8 @@
use dioxus::prelude::*;
#[tokio::main]
async fn main() {
dioxus_desktop::launch(app).await;
fn main() {
dioxus_desktop::launch(app);
}
fn app(cx: Scope) -> Element {

View File

@ -7,8 +7,8 @@ fn main() {
fn app(cx: Scope) -> Element {
let window = use_window(cx);
let level = use_state(cx, || 1.0);
cx.render(rsx! {
input {
r#type: "number",
@ -16,7 +16,7 @@ fn app(cx: Scope) -> Element {
oninput: |e| {
let num = e.value.parse::<f64>().unwrap_or(1.0);
level.set(num);
window.set_zoom_level(num);
window.webview.zoom(num);
}
}
})

View File

@ -118,6 +118,11 @@ impl DesktopContext {
}
}
/// Set the zoom level of the webview
pub fn set_zoom_level(&self, level: f64) {
self.webview.zoom(level);
}
/// opens DevTool window
pub fn devtool(&self) {
#[cfg(debug_assertions)]