diff --git a/editor/src/messages/viewport/viewport_message_handler.rs b/editor/src/messages/viewport/viewport_message_handler.rs index a060a14efa..ef459e4069 100644 --- a/editor/src/messages/viewport/viewport_message_handler.rs +++ b/editor/src/messages/viewport/viewport_message_handler.rs @@ -26,7 +26,9 @@ impl MessageHandler for ViewportMessageHandler { fn process_message(&mut self, message: ViewportMessage, responses: &mut VecDeque, _: ()) { match message { ViewportMessage::Update { x, y, width, height, scale } => { - assert!(scale > 0., "Viewport scale must be greater than zero"); + if scale == 0. { + return; + } self.scale = scale; self.bounds = Bounds { diff --git a/frontend/src/utility-functions/viewports.ts b/frontend/src/utility-functions/viewports.ts index 370d5567f8..1c4e765ccb 100644 --- a/frontend/src/utility-functions/viewports.ts +++ b/frontend/src/utility-functions/viewports.ts @@ -40,13 +40,13 @@ export function setupViewportResizeObserver(editor: Editor) { const bounds = entry.target.getBoundingClientRect(); // TODO: Consider passing physical sizes as well to eliminate pixel inaccuracies since width and height could be rounded differently - const scale = physicalWidth / logicalWidth; + const scale = logicalWidth > 0 ? physicalWidth / logicalWidth : 1; if (!scale || scale <= 0) { - continue; + editor.handle.updateViewport(bounds.x, bounds.y, logicalWidth, logicalHeight, 1e-6); + } else { + editor.handle.updateViewport(bounds.x, bounds.y, logicalWidth, logicalHeight, scale); } - - editor.handle.updateViewport(bounds.x, bounds.y, logicalWidth, logicalHeight, scale); } });