From f38904336b113e77a5d6552706e64febd3141534 Mon Sep 17 00:00:00 2001 From: Samit Basu Date: Wed, 29 Mar 2023 06:04:04 -0700 Subject: [PATCH] Prefer the client width/height for the canvas parent (#2804) --- crates/eframe/src/web/mod.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/eframe/src/web/mod.rs b/crates/eframe/src/web/mod.rs index dcf58b05..eca53743 100644 --- a/crates/eframe/src/web/mod.rs +++ b/crates/eframe/src/web/mod.rs @@ -113,8 +113,10 @@ pub fn resize_canvas_to_screen_size(canvas_id: &str, max_size_points: egui::Vec2 let canvas = canvas_element(canvas_id)?; let parent = canvas.parent_element()?; - let width = parent.scroll_width(); - let height = parent.scroll_height(); + // Prefer the client width and height so that if the parent + // element is resized that the egui canvas resizes appropriately. + let width = parent.client_width(); + let height = parent.client_height(); let canvas_real_size = Vec2 { x: width as f32,