leapConfig = Reveal.getConfig().leap,
leapDOM = document.createElement('div'),
body = document.body,
+ lastGesture = 0,
config = {
naturalSwipe : true,
pointerDefault : 15,
pointerColor : '#00aaff',
pointerOpacity : 0.75
- };
+ },
+ now;
// Merge user defined settings with defaults
if ( leapConfig ) {
body.appendChild(leapDOM);
controller.on('frame', function (frame) {
+ // Timing code to rate limit gesture execution
+ now = new Date().getTime();
+
+ if( lastGesture === 0 ) {
+ lastGesture = now;
+ }
// Pointer code
if ( frame.hands.length === 1 && frame.fingers.length === 1 ) {
}
// Gestures
- if ( frame.gestures.length > 0 ) {
+ if ( (now - lastGesture) > 500 && frame.gestures.length > 0 ) {
var gesture = frame.gestures[0];
// One hand gestures
if( frame.hands.length === 1 ) {
// Swipe gestures. 2+ fingers.
- if ( frame.fingers.length > 1 && gesture.speed > 1000 && gesture.state === 'start' && gesture.type === 'swipe' ) {
+ if ( frame.fingers.length > 1 && gesture.speed > 1000 && gesture.type === 'swipe' ) {
var x = gesture.direction[0],
y = gesture.direction[1];
} else {
config.naturalSwipe ? Reveal.right() : Reveal.left();
}
+
+ lastGesture = now;
// Up/down swipe gestures
} else {
if ( y > 0 ) {
} else {
config.naturalSwipe ? Reveal.up() : Reveal.down();
}
+
+ lastGesture = now;
}
}
// Two hand gestures
if ( gesture.direction[1] > 0 ) {
Reveal.toggleOverview();
}
+
+ lastGesture = now;
}
}
});