Skip to content

Commit

Permalink
Adapt to web-related API changes
Browse files Browse the repository at this point in the history
  • Loading branch information
niklaskorz committed May 7, 2024
1 parent 21d0215 commit d47f048
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,21 +185,22 @@ fn main() -> Result<()> {
std::panic::set_hook(Box::new(console_error_panic_hook::hook));
// On wasm, append the canvas to the document body
let window = window.clone();
let canvas = window.canvas().expect("couldn't retrieve canvas");
let web_window = web_sys::window().expect("couldn't retrieve website window");
let body = web_window
.document()
.and_then(|doc| doc.body())
.expect("couldn't retrieve document body");
body.append_child(&web_sys::Element::from(window.canvas()))
body.append_child(&web_sys::Element::from(canvas))
.ok()
.expect("couldn't append canvas to body");
window.set_inner_size(winit::dpi::LogicalSize::new(
let _ = window.request_inner_size(winit::dpi::LogicalSize::new(
body.client_width(),
body.client_height(),
));
let resize_closure =
wasm_bindgen::closure::Closure::wrap(Box::new(move |_e: web_sys::Event| {
window.set_inner_size(winit::dpi::LogicalSize::new(
let _ = window.request_inner_size(winit::dpi::LogicalSize::new(
body.client_width(),
body.client_height(),
));
Expand Down

0 comments on commit d47f048

Please sign in to comment.