Skip to main content

detect_swipe

Function detect_swipe 

Source
pub fn detect_swipe(dx: i32, dy: i32) -> Option<GestureDirection>
Expand description

Classify the running raw-XY travel of a held gesture button into a directional swipe, the instant it commits — or None while it’s still too short or too diagonal.

The dominant axis must pass GESTURE_SWIPE_THRESHOLD while the cross axis stays within max(GESTURE_SWIPE_DEADZONE, 35% of dominant). Callers fire the bound action the moment this returns Some — mid-swipe, like Options+ — rather than waiting for the button release; a press that never commits a direction is treated as GestureDirection::Click on release.

Coordinates follow the device’s raw-XY convention (+x = right, +y = down), so an upward swipe (negative dy) maps to GestureDirection::Up.