Updates to leap.js and index.html
authorRory Hardy <rory.cronin-hardy@cerner.com>
Mon, 5 Aug 2013 01:22:34 +0000 (20:22 -0500)
committerRory Hardy <rory.cronin-hardy@cerner.com>
Mon, 5 Aug 2013 01:22:34 +0000 (20:22 -0500)
Added timing code to limit gesture calls.
Added gesture to access the overview.
index.html includes the leap plugin

index.html
plugin/leap/leap.js

index fab2780dc45341285315307cfc1af558ca25a9b1..decc2944389cc199617daf412cd3fda122210b18 100644 (file)
@@ -359,6 +359,9 @@ function linkify( selector ) {
                                progress: true,
                                history: true,
                                center: true,
+                               leap: {
+                           invert : true
+                         },
 
                                theme: Reveal.getQueryHash().theme, // available themes are in /css/theme
                                transition: Reveal.getQueryHash().transition || 'default', // default/cube/page/concave/zoom/linear/fade/none
@@ -370,7 +373,8 @@ function linkify( selector ) {
                                        { src: 'plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
                                        { src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
                                        { src: 'plugin/zoom-js/zoom.js', async: true, condition: function() { return !!document.body.classList; } },
-                                       { src: 'plugin/notes/notes.js', async: true, condition: function() { return !!document.body.classList; } }
+                                       { src: 'plugin/notes/notes.js', async: true, condition: function() { return !!document.body.classList; } },
+                                       { src: 'plugin/leap/leap.js', async: true, }
                                        // { src: 'plugin/search/search.js', async: true, condition: function() { return !!document.body.classList; } }
                                        // { src: 'plugin/remotes/remotes.js', async: true, condition: function() { return !!document.body.classList; } }
                                ]
index 3af73ce5d1a27c76946fd3e20c2e2d951a532a27..27dc517a2a7c8d53010b0af5c6c3c566ac9200f5 100644 (file)
@@ -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();
 })();