use jellyflow_core::core::CanvasPoint;
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct ConnectionDragActivationInput {
pub screen_delta: CanvasPoint,
pub threshold: f32,
}
impl ConnectionDragActivationInput {
pub fn new(screen_delta: CanvasPoint, threshold: f32) -> Self {
Self {
screen_delta,
threshold,
}
}
}
pub fn connection_drag_threshold_met(input: ConnectionDragActivationInput) -> bool {
if !input.screen_delta.is_finite() {
return false;
}
if input.threshold == 0.0 {
return true;
}
if !input.threshold.is_finite() {
return false;
}
let threshold = input.threshold.abs();
let distance_squared =
input.screen_delta.x * input.screen_delta.x + input.screen_delta.y * input.screen_delta.y;
distance_squared > threshold * threshold
}