class Leap.SwipeGesture

Extends Gesture.

The SwipeGesture class represents a swiping motion of a finger or tool.


SwipeGesture objects are generated for each swiping finger or tool.

Important: To use swipe gestures in your application, you must enable recognition of the swipe gesture. You can enable recognition with:


Swipe gestures are continuous.

You can set the minimum length and velocity required for a movement to be recognized as a swipe using the config attribute of a connected Controller object. Use the following keys to configure swipe recognition:

Key string Value type Default value Units
Gesture.Swipe.MinLength float 150 mm
Gesture.Swipe.MinVelocity float 1000 mm/s

The following example demonstrates how to set the swipe configuration parameters:

controller.config.set("Gesture.Swipe.MinLength", 100.0)
controller.config.set("Gesture.Swipe.MinVelocity", 750)

New in version 1.0.

classmethod SwipeGesture([gesture])

Constructs a SwipeGesture object from an instance of the Gesture class.

for gesture in frame.gestures():
    if gesture.type is Leap.Gesture.TYPE_SWIPE:
        swipe = Leap.SwipeGesture(gesture)
Parameters:gesture (Gesture) – The Gesture instance to specialize. This Gesture instance must be a SwipeGesture object. If no argument is supplied, an invalid SwipeGesture object is created.

New in version 1.0.


The position where the swipe began.

start = swipe.start_position

New in version 1.0.


The current position of the swipe.

current = swipe.position

New in version 1.0.


The unit direction vector parallel to the swipe motion.

direction = swipe.direction

You can compare the components of the vector to classify the swipe as appropriate for your application. For example, if you are using swipes for two dimensional scrolling, you can compare the x and y values to determine if the swipe is primarily horizontal or vertical.

New in version 1.0.


The swipe speed in mm/second.

velocity = swipe.speed

New in version 1.0.


The finger performing the swipe gesture.

swipper = swipe.pointable

New in version 1.0.

classmethod class_type()

The swipe gesture type designator: Gesture.TYPE_SWIPE

New in version 1.0.