Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion editor/src/messages/viewport/viewport_message_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ impl MessageHandler<ViewportMessage, ()> for ViewportMessageHandler {
fn process_message(&mut self, message: ViewportMessage, responses: &mut VecDeque<Message>, _: ()) {
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 {
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/utility-functions/viewports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});

Expand Down
Loading