Skip to content

Commit c2a36ce

Browse files
c-mateoKeavon
andauthored
Restore auto-panning that #2443 had broken (#2562)
* Fix auto panning * Clean up comments --------- Co-authored-by: Keavon Chambers <[email protected]>
1 parent b3d6be9 commit c2a36ce

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

editor/src/messages/broadcast/broadcast_event.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use crate::messages::prelude::*;
33
#[derive(PartialEq, Eq, Clone, Debug, serde::Serialize, serde::Deserialize, Hash)]
44
#[impl_message(Message, BroadcastMessage, TriggerEvent)]
55
pub enum BroadcastEvent {
6+
/// Triggered by requestAnimationFrame in JS
67
AnimationFrame,
78
CanvasTransformed,
89
ToolAbort,

editor/src/messages/input_preprocessor/input_preprocessor_message_handler.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use crate::messages::input_mapper::utility_types::misc::FrameTimeInfo;
44
use crate::messages::portfolio::utility_types::KeyboardPlatformLayout;
55
use crate::messages::prelude::*;
66
use glam::DVec2;
7+
use std::time::Duration;
78

89
pub struct InputPreprocessorMessageData {
910
pub keyboard_platform: KeyboardPlatformLayout,
@@ -97,6 +98,7 @@ impl MessageHandler<InputPreprocessorMessage, InputPreprocessorMessageData> for
9798
InputPreprocessorMessage::CurrentTime { timestamp } => {
9899
responses.add(AnimationMessage::SetTime(timestamp as f64));
99100
self.time = timestamp;
101+
self.frame_time.advance_timestamp(Duration::from_millis(timestamp));
100102
}
101103
InputPreprocessorMessage::WheelScroll { editor_mouse_state, modifier_keys } => {
102104
self.update_states_of_modifier_keys(modifier_keys, keyboard_platform, responses);

frontend/wasm/src/editor_api.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,12 @@ impl EditorHandle {
152152
for message in editor.handle_message(AnimationMessage::IncrementFrameCounter) {
153153
handle.send_frontend_message_to_js(message);
154154
}
155+
156+
// Used by auto-panning, but this could possibly be refactored in the future, see:
157+
// <https://github.com/GraphiteEditor/Graphite/pull/2562#discussion_r2041102786>
158+
for message in editor.handle_message(BroadcastMessage::TriggerEvent(BroadcastEvent::AnimationFrame)) {
159+
handle.send_frontend_message_to_js(message);
160+
}
155161
});
156162
}
157163

0 commit comments

Comments
 (0)