Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panning jitter problem when dragging nodes #222

Open
crane-may opened this issue Nov 11, 2024 · 2 comments
Open

Panning jitter problem when dragging nodes #222

crane-may opened this issue Nov 11, 2024 · 2 comments
Assignees
Labels
enhancement New feature or request v1.0.0

Comments

@crane-may
Copy link

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:

20241111-110227.mp4

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);
        }
    }
@blitzarx1 blitzarx1 self-assigned this Nov 15, 2024
@blitzarx1
Copy link
Owner

blitzarx1 commented Nov 15, 2024

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.

@blitzarx1 blitzarx1 added the enhancement New feature or request label Nov 15, 2024
@blitzarx1
Copy link
Owner

Added new feat to respect node dragging. Maybe it helps with this issue.
#223

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request v1.0.0
Projects
None yet
Development

No branches or pull requests

2 participants