jellyflow_runtime/runtime/connection/
activation.rs1use jellyflow_core::core::CanvasPoint;
2
3#[derive(Debug, Clone, Copy, PartialEq)]
8pub struct ConnectionDragActivationInput {
9 pub screen_delta: CanvasPoint,
10 pub threshold: f32,
11}
12
13impl ConnectionDragActivationInput {
14 pub fn new(screen_delta: CanvasPoint, threshold: f32) -> Self {
15 Self {
16 screen_delta,
17 threshold,
18 }
19 }
20}
21
22pub fn connection_drag_threshold_met(input: ConnectionDragActivationInput) -> 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 let threshold = input.threshold.abs();
38 let distance_squared =
39 input.screen_delta.x * input.screen_delta.x + input.screen_delta.y * input.screen_delta.y;
40 distance_squared > threshold * threshold
41}