Prevent nodes from being dragged out of the graph view

This commit is contained in:
Tom A. Wagner
2021-02-10 10:58:01 +01:00
parent ec8de4a4a7
commit 5ac535ab37

View File

@@ -257,7 +257,8 @@ impl GraphView {
.expect("Failed to cast to FixedLayout");
let transform = gsk::Transform::new()
.translate(&graphene::Point::new(x, y))
// Nodes should not be able to be dragged out of the view, so we use `max(coordinate, 0.0)` to prevent that.
.translate(&graphene::Point::new(f32::max(x, 0.0), f32::max(y, 0.0)))
.unwrap();
layout_manager