Skip to content

Commit

Permalink
fix: fixed increasing scale on web
Browse files Browse the repository at this point in the history
  • Loading branch information
lukexor committed Jun 27, 2024
1 parent 3866efa commit 8c4265e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions tetanes/src/sys/platform/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,10 @@ pub mod renderer {
let window_width = canvas.get_bounding_client_rect().width() as f32;

if window_width < desired_window_width {
tracing::debug!(
"window width ({window_width}) is less than desired ({desired_window_width})"
);

let scale = if let Some(viewport_width) = web_sys::window()
.and_then(|win| win.inner_width().ok())
.and_then(|width| width.as_f64())
Expand All @@ -252,9 +256,9 @@ pub mod renderer {
1.0
};

tracing::debug!("max scale for viewport: {scale}");
let new_window_size = renderer.window_size_for_scale(cfg, scale);
if scale != cfg.renderer.scale && (window_width - new_window_size.x).abs() > 1.0
{
if (window_width - new_window_size.x).abs() > 1.0 {
tracing::debug!("constraining window to viewport: {new_window_size:?}");

let _ = window.request_inner_size(LogicalSize::new(
Expand Down

0 comments on commit 8c4265e

Please sign in to comment.