jellyflow_runtime/runtime/drag/
activation.rs1use jellyflow_core::core::CanvasPoint;
2
3#[derive(Debug, Clone, Copy, PartialEq)]
8pub struct NodeDragActivationInput {
9 pub screen_delta: CanvasPoint,
10 pub threshold: f32,
11}
12
13impl NodeDragActivationInput {
14 pub fn new(screen_delta: CanvasPoint, threshold: f32) -> Self {
15 Self {
16 screen_delta,
17 threshold,
18 }
19 }
20}
21
22pub fn node_drag_threshold_met(input: NodeDragActivationInput) -> bool {
27 if !input.screen_delta.is_finite() {
28 return false;
29 }
30 if input.threshold == 0.0 {
31 return true;
32 }
33 if !input.threshold.is_finite() {
34 return false;
35 }
36
37 input.screen_delta.x.hypot(input.screen_delta.y) > input.threshold
38}