From 70cade3732200f769f0d6c930c7dd14a94da7be2 Mon Sep 17 00:00:00 2001 From: Rory Hardy Date: Sun, 4 Aug 2013 20:22:34 -0500 Subject: 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 --- index.html | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'index.html') diff --git a/index.html b/index.html index fab2780..decc294 100644 --- a/index.html +++ b/index.html @@ -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; } } ] -- cgit v1.2.3 From 0e7bc4091ec7a870805f040e342732388db99560 Mon Sep 17 00:00:00 2001 From: Rory Hardy Date: Sun, 4 Aug 2013 20:27:47 -0500 Subject: Minor updates Changed invert to naturalSwipe Removed invert rule from index.html Ensured that left/right swipes only work with 1 hand present modified: index.html modified: plugin/leap/leap.js --- index.html | 3 --- plugin/leap/leap.js | 12 ++++++------ 2 files changed, 6 insertions(+), 9 deletions(-) (limited to 'index.html') diff --git a/index.html b/index.html index decc294..9ee0941 100644 --- a/index.html +++ b/index.html @@ -359,9 +359,6 @@ 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 diff --git a/plugin/leap/leap.js b/plugin/leap/leap.js index 27dc517..ad2e3db 100644 --- a/plugin/leap/leap.js +++ b/plugin/leap/leap.js @@ -25,7 +25,7 @@ var b=right.criteria;if(a!==b){if(a>b||a===void 0)return 1;if(ab||a===void 0)return 1;if(a 1000 && gesture.state === 'start' && gesture.type === 'swipe' ) { - if( frame.fingers.length > 1 ) { + if( frame.hands.length === 1 && frame.fingers.length > 1 ) { if ( Math.abs(x) > Math.abs(y) ) { if ( x > 0 ) { - config.invert ? Reveal.left() : Reveal.right(); + config.naturalSwipe ? Reveal.left() : Reveal.right(); } else { - config.invert ? Reveal.right() : Reveal.left(); + config.naturalSwipe ? Reveal.right() : Reveal.left(); } lastGesture = now; } else { if ( y > 0 ) { - config.invert ? Reveal.down() : Reveal.up(); + config.naturalSwipe ? Reveal.down() : Reveal.up(); } else { - config.invert ? Reveal.up() : Reveal.down(); + config.naturalSwipe ? Reveal.up() : Reveal.down(); } } -- cgit v1.2.3 From 1d895bad612c218f125c43b8195ab475be625bf0 Mon Sep 17 00:00:00 2001 From: Rory Hardy Date: Tue, 6 Aug 2013 00:11:58 -0500 Subject: Docs and updates Updated README.md to mention the leap plugin. Removed leap settings from index.html. Better variable naming in leap.js modified: README.md modified: index.html modified: plugin/leap/leap.js --- README.md | 42 ++++++++++++++++++++++++++++++++++++++++++ index.html | 3 +-- plugin/leap/leap.js | 6 +++--- 3 files changed, 46 insertions(+), 5 deletions(-) (limited to 'index.html') diff --git a/README.md b/README.md index 04313df..15cabcf 100644 --- a/README.md +++ b/README.md @@ -625,6 +625,48 @@ Reveal.initialize({ }); ``` +## Leap Motion +The Leap Motion plugin lets you utilize your [Leap Motion](https://www.leapmotion.com/) device to control basic navigation of your presentation. The gestures currently supported are: + +##### 1 hand + 1 finger +* Pointer — Point to anything on screen. Move your finger past the device to expand the pointer. + +##### 1 hand + 2 or more fingers + +* Left +* Right +* Up +* down + +Navigate through your slides. See config options to invert movements. + +##### 2 hands +* Up + +Toggle the overview mode. Do it a second time to exit the overview. + +#### Config Options +You can edit the following options: +* naturalSwipe: Defaults to true. Swipe as though you were touching a touch screen. Set to false to invert. +* pointerSize: Defaults to 15. The minimum height and width of the pointer. +* pointerColor: Defaults to #00aaff. The color of the pointer. +* pointerOpacity: Defaults to 0.75. The opacity of the pointer. +* gestureDelay: Defaults to 500. How long to delay between gestures in milliseconds. + +Example configuration: +```js +Reveal.initialize({ + // other options + leap: { + naturalSwipe : false, // Invert swipe gestures + pointerOpacity : 0.5, // Set pointer opacity to 0.5 + pointerColor : '#d80000' // Red pointer + } + + // Optional libraries used to extend on reveal.js + { src: 'plugin/leap/leap.js', async: true } +``` + ## Installation The **basic setup** is for authoring presentations only. The **full setup** gives you access to all reveal.js features as well as the development tasks needed to make changes to the source. diff --git a/index.html b/index.html index 9ee0941..fab2780 100644 --- a/index.html +++ b/index.html @@ -370,8 +370,7 @@ 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/leap/leap.js', async: true, } + { src: 'plugin/notes/notes.js', async: true, condition: function() { return !!document.body.classList; } } // { 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; } } ] diff --git a/plugin/leap/leap.js b/plugin/leap/leap.js index 072f73d..a605153 100644 --- a/plugin/leap/leap.js +++ b/plugin/leap/leap.js @@ -30,7 +30,7 @@ var b=right.criteria;if(a!==b){if(a>b||a===void 0)return 1;if(ab||a===void 0)return 1;if(ab||a===void 0)return 1;if(a 0 && frame.fingers.length < 3 ) { + // Invert direction and multiply by 3 for greater effect. + var size = -3 * frame.fingers[0].tipPosition[2]; - if ( size < config.pointerSize ) { - size = config.pointerSize + if( size < config.pointerSize ) { + size = config.pointerSize; } - pointer.style.bottom = - frame.hands[0].palmPosition[1] * (body.offsetHeight / 100) - body.offsetHeight + 'px'; - - pointer.style.left = - frame.hands[0].palmPosition[0] * (body.offsetWidth / 100) + (body.offsetWidth / 2) + 'px'; - - pointer.style.visibility = 'visible'; pointer.style.width = size + 'px'; pointer.style.height = size + 'px'; pointer.style.borderRadius = size - 5 + 'px'; - } + pointer.style.visibility = 'visible'; + + tipPosition = frame.fingers[0].tipPosition; + + if( config.autoCenter ) { + // Check whether the finger has entered the z range of the Leap Motion. Used for the autoCenter option. + if( !entered ) { + entered = true; + enteredPosition = frame.fingers[0].tipPosition; + } + + pointer.style.top = + (-1 * (( tipPosition[1] - enteredPosition[1] ) * body.offsetHeight / config.pointerTolerance )) + + ( body.offsetHeight / 2 ) + 'px'; + + pointer.style.left = + (( tipPosition[0] - enteredPosition[0] ) * body.offsetWidth / config.pointerTolerance ) + + ( body.offsetWidth / 2 ) + 'px'; + } + else { + pointer.style.top = ( 1 - (( tipPosition[1] - 50) / config.pointerTolerance )) * + body.offsetHeight + 'px'; + + pointer.style.left = ( tipPosition[0] * body.offsetWidth / config.pointerTolerance ) + + ( body.offsetWidth / 2 ) + 'px'; + } + } else { // Hide pointer on exit + entered = false; pointer.style.visibility = 'hidden'; } - + // Gestures - if ( frame.gestures.length > 0 && (now - lastGesture) > config.gestureDelay ) { + if( frame.gestures.length > 0 && (now - lastGesture) > config.gestureDelay ) { var gesture = frame.gestures[0]; // One hand gestures if( frame.hands.length === 1 ) { - // Swipe gestures. 2+ fingers. - if ( frame.fingers.length > 1 && gesture.type === 'swipe' ) { + // Swipe gestures. 3+ fingers. + if( frame.fingers.length > 2 && gesture.type === 'swipe' ) { // Define here since some gestures will throw undefined for these. var x = gesture.direction[0], y = gesture.direction[1]; // Left/right swipe gestures - if ( Math.abs(x) > Math.abs(y) ) { - if ( x > 0 ) { + if( Math.abs( x ) > Math.abs( y )) { + if( x > 0 ) { config.naturalSwipe ? Reveal.left() : Reveal.right(); } else { @@ -105,7 +130,7 @@ var b=right.criteria;if(a!==b){if(a>b||a===void 0)return 1;if(a 0 ) { + if( y > 0 ) { config.naturalSwipe ? Reveal.down() : Reveal.up(); } else { @@ -115,11 +140,11 @@ var b=right.criteria;if(a!==b){if(a>b||a===void 0)return 1;if(a 0 ) { + // Two hand gestures + else if( frame.hands.length === 2 ) { + // Upward two hand swipe gesture + if( gesture.direction[1] > 0 && gesture.type === 'swipe' ) { Reveal.toggleOverview(); } -- cgit v1.2.3 From 0a78486b22ff904c6bf5c54efcb726da38974cdd Mon Sep 17 00:00:00 2001 From: Rory Hardy Date: Wed, 7 Aug 2013 22:06:41 -0500 Subject: Update index.html Commented out leap plugin inclusion.--- index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'index.html') diff --git a/index.html b/index.html index 5aa8dfe..8df38ed 100644 --- a/index.html +++ b/index.html @@ -370,8 +370,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/leap/leap.js', async: true } + { 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; } } ] -- cgit v1.2.3