ScreenTapGesture

Attributes:

class ScreenTapGesture()

Extends Gesture()

The ScreenTapGesture class represents a tapping gesture by a finger or tool.

A screen tap gesture is recognized when the tip of a finger pokes forward and then springs back to approximately the original postion, as if tapping a vertical screen. The tapping finger must pause briefly before beginning the tap.

ScreenTapImage

ScreenTap gestures are discrete. The ScreenTapGesture object representing a tap always has the state, “stop”. Only one ScreenTapGesture object is ever created for each screen tap gesture recognized.

An uninitialized ScreenTapGesture object is considered invalid. Get valid instances of the ScreenTapGesture class from a Frame object or a gesture event listener.

The following example illustrates how to get gesture objects from a frame of tracking data:

var controller = Leap.loop({enableGestures: true}, function(frame){
  if(frame.valid && frame.gestures.length > 0){
    frame.gestures.forEach(function(gesture){
        switch (gesture.type){
          case "circle":
              console.log("Circle Gesture");
              break;
          case "keyTap":
              console.log("Key Tap Gesture");
              break;
          case "screenTap":
              console.log("Screen Tap Gesture");
              break;
          case "swipe":
              console.log("Swipe Gesture");
              break;
        }
    });
  }
});

You can also add a listener callback to a Controller object. Your callback is called for each gesture object in each device frame:

var controller = Leap.loop({enableGestures: true}, function(frame){
  //... handle frame data
});

controller.on("gesture", function(gesture){
  //... handle gesture object
});
ScreenTapGesture()

Constructs a new ScreenTapGesture object.

An uninitialized ScreenTapGesture object is considered invalid. Get valid instances of the ScreenTapGesture class from a Frame object.

ScreenTapGesture.direction
Type:number[] – a 3-element array representing a unit direction vector

The direction of finger tip motion.

if(gesture.type == "screenTap"){
  var direction = gesture.direction;
}
ScreenTapGesture.duration
Type:number

The elapsed duration of the recognized movement up to the frame containing this Gesture object, in microseconds.

var duration = gesture.duration;

The duration reported for the first Gesture in the sequence (with the start state) will typically be a small positive number since the movement must progress far enough for the Leap to recognize it as an intentional gesture.

ScreenTapGesture.handIds
Type:number[]

The list of hands associated with this Gesture, if any.

var controller = Leap.loop({enableGestures: true}, function(frame){
  if(frame.valid && frame.gestures.length > 0){
    frame.gestures.forEach(function(gesture){
        var handIds = gesture.handIds;
        handIds.forEach(function(handId){
          var hand = frame.hand(handId);
        });
    });
  }
});

If no hands are related to this gesture, the list is empty.

ScreenTapGesture.id
Type:number

The gesture ID.

var gestureIdOfInterest = gesture.id;
ScreenTapGesture.pointableIds
Type:number[]

The list of fingers and tools associated with this Gesture, if any.

var controller = Leap.loop({enableGestures: true}, function(frame){
  if(frame.valid && frame.pointables.length > 0){
    frame.gestures.forEach(function(gesture){
        var pointableIds = gesture.pointableIds;
        pointableIds.forEach(function(pointableId){
          var pointable = frame.pointable(pointableId);
        });
    });
  }
});

If no Pointable objects are related to this gesture, the list is empty.

ScreenTapGesture.position
Type:number[] – a 3-element array representing a position vector.

The position where the screen tap is registered.

if(gesture.type == "screenTap"){
  var position = gesture.position;
}
ScreenTapGesture.state
Type:String

The gesture state. ScreenTapGesture objects always have the state: “stop”.

var state = gesture.state;
ScreenTapGesture.type
Type:String

The gesture type. In this case, always: “screenTap”.

var controller = Leap.loop({enableGestures: true}, function(frame){
  if(frame.valid && frame.gestures.length > 0){
    frame.gestures.forEach(function(gesture){
        switch (gesture.type){
          case "circle":
              console.log("Circle Gesture");
              break;
          case "keyTap":
              console.log("Key Tap Gesture");
              break;
          case "screenTap":
              console.log("Screen Tap Gesture");
              break;
          case "swipe":
              console.log("Swipe Gesture");
              break;
        }
    });
  }
});