Skip to content
Merged
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
16 changes: 12 additions & 4 deletions frontend/app/src/simulation_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub enum Msg {
WheelEvent(web_sys::WheelEvent),
PointerEvent(web_sys::PointerEvent),
BlurEvent(web_sys::FocusEvent),
TimelineEvent(usize),
TimelineEvent(usize, bool),
RequestSnapshot,
ReceivedSimAgentResponse(oort_simulation_worker::Response),
}
Expand Down Expand Up @@ -169,11 +169,19 @@ impl Component for SimulationWindow {
}
false
}
Msg::TimelineEvent(index) => {
Msg::TimelineEvent(index, is_change_event) => {
// Timeline was set to a new index
// Display the relevant snapshot
if let Some(ui) = self.ui.as_mut() {
ui.seek_from_timeline(index);

// Change event fires after the user lets go
// of the slider. In Firefox focusing the canvas
// makes the slider ignore further motion, hence
// breaking the experience.
if is_change_event {
ui.focus_canvas();
}
}
false
}
Expand Down Expand Up @@ -209,7 +217,7 @@ impl Component for SimulationWindow {
.value_as_number()
.round() as usize;

Msg::TimelineEvent(slider_value)
Msg::TimelineEvent(slider_value, false)
});

// We need a separate callback for the onchange event because the input event is not fired on release
Expand All @@ -224,7 +232,7 @@ impl Component for SimulationWindow {
.value_as_number()
.round() as usize;

Msg::TimelineEvent(slider_value)
Msg::TimelineEvent(slider_value, true)
});

create_portal(
Expand Down
3 changes: 3 additions & 0 deletions frontend/app/src/ui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,9 @@ impl UI {
self.paused = true;
self.needs_render = true;
self.is_buffering = false;
}

pub fn focus_canvas(&mut self) {
let _ = self.canvas.focus();
}

Expand Down