diff options
author | Rory Hardy <rory.cronin-hardy@cerner.com> | 2013-08-04 20:22:34 -0500 |
---|---|---|
committer | Rory Hardy <rory.cronin-hardy@cerner.com> | 2013-08-04 20:22:34 -0500 |
commit | 70cade3732200f769f0d6c930c7dd14a94da7be2 (patch) | |
tree | 3ae01b837191ffb436801813a20a457956b220b1 /plugin/leap | |
parent | af5acd1aa2735833ec9f0104f1c16f97641f894c (diff) | |
download | fosdem-2018-presentation-70cade3732200f769f0d6c930c7dd14a94da7be2.tar fosdem-2018-presentation-70cade3732200f769f0d6c930c7dd14a94da7be2.tar.gz |
Updates to leap.js and index.html
Added timing code to limit gesture calls.
Added gesture to access the overview.
index.html includes the leap plugin
Diffstat (limited to 'plugin/leap')
-rw-r--r-- | plugin/leap/leap.js | 58 |
1 files changed, 40 insertions, 18 deletions
diff --git a/plugin/leap/leap.js b/plugin/leap/leap.js index 3af73ce..27dc517 100644 --- a/plugin/leap/leap.js +++ b/plugin/leap/leap.js @@ -21,34 +21,56 @@ var b=right.criteria;if(a!==b){if(a>b||a===void 0)return 1;if(a<b||b===void 0)re */ (function () { - var controller = new Leap.Controller({enableGestures: true}), - config = Reveal.getConfig().leap || + var controller = new Leap.Controller({enableGestures: true}), + lastGesture = 0, + config = Reveal.getConfig().leap || { invert: false - }; + }, + now; controller.on('frame', function (frame) { - if (frame.gestures.length > 0) { - var gesture = frame.gestures[0]; - //console.log(gesture); - var x = gesture.direction[0]; - var y = gesture.direction[1]; - if (gesture.state === 'start' && gesture.type === 'swipe') { - if (Math.abs(x) > Math.abs(y)) { - if (x > 0) { - config.invert ? Reveal.left() : Reveal.right(); + now = new Date().getTime(); + + if( lastGesture === 0 ) { + lastGesture = now; + } + + if ( (now - lastGesture) > 500 && frame.gestures.length > 0 ) { + var gesture = frame.gestures[0], + x = gesture.direction[0], + y = gesture.direction[1]; + + + if ( gesture.speed > 1000 && gesture.state === 'start' && gesture.type === 'swipe' ) { + if( frame.fingers.length > 1 ) { + if ( Math.abs(x) > Math.abs(y) ) { + if ( x > 0 ) { + config.invert ? Reveal.left() : Reveal.right(); + } else { + config.invert ? Reveal.right() : Reveal.left(); + } + + lastGesture = now; } else { - config.invert ? Reveal.right() : Reveal.left(); + if ( y > 0 ) { + config.invert ? Reveal.down() : Reveal.up(); + } else { + config.invert ? Reveal.up() : Reveal.down(); + } } - } else { - if (y > 0) { - config.invert ? Reveal.down() : Reveal.up(); - } else { - config.invert ? Reveal.up() : Reveal.down(); + + lastGesture = now; + } else if( frame.hands.length == 2 ) { + if ( y > 0 ) { + Reveal.toggleOverview(); } + + lastGesture = now; } } } }); + controller.connect(); })(); |