egui_graphs
egui_graphs copied to clipboard
Panning jitter problem when dragging nodes
I really like this library. I am making a node editor with this library. I've noticed a small problem when node dragging, the whole canvas pans a small distance. Like this:
https://github.com/user-attachments/assets/a399b172-174a-41d3-8d72-92d13e1ba397
I've made a simple change to a line of code myself that avoids this problem, but I realize this may not be the best way to do it. I hope this helps anyone who needs it!
// src/graph_view.rs line 467:
fn handle_pan(&self, resp: &Response, meta: &mut Metadata) {
if !self.settings_navigation.zoom_and_pan_enabled {
return;
}
if (resp.dragged_by(PointerButton::Middle) || resp.dragged_by(PointerButton::Primary))
&& self.g.dragged_node().is_none()
&& (resp.drag_delta().x.abs() > 0. || resp.drag_delta().y.abs() > 0.)
&& !(self.settings_interaction.dragging_enabled // ADD
&& resp.drag_started() // ADD
&& self.g.node_by_screen_pos(meta, resp.hover_pos().unwrap()).is_some()) // ADD
{
let new_pan = meta.pan + resp.drag_delta();
self.set_pan(new_pan, meta);
}
}
Hi, sorry for the long response.
Thanks for the interest and work that you've done. I will consider it in the upcoming stabilization PR's. I will leave this issue open and close, when this is done.
Feel free to open PR, I will check it later.
Added new feat to respect node dragging. Maybe it helps with this issue. #223
fixed in #264