Created
February 28, 2014 17:54
-
-
Save codejoust/9276090 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="//js.leapmotion.com/0.2.2/leap.min.js"></script> | |
<script> | |
window.addEventListener('load', function(){ | |
var ctl = new Leap.Controller({enableGestures: true}); | |
var swiper = ctl.gesture('swipe'); | |
var totalDistance = 0; | |
var tolerance = 50; | |
var cooloff = 300; | |
var x = 2, y = 2; | |
var slider = _.debounce(function(xDir, yDir) { | |
console.log(xDir,yDir); | |
if (yDir == 1 && xDir == 0){ | |
alert('playing video!'); | |
return; | |
} else { | |
if (xDir == -1){ | |
gShowController.goBackToPreviousSlide('tapPreviousButton'); | |
return; | |
} | |
if (xDir == 1){ | |
gShowController.advanceToNextBuild('tapNextButton'); | |
return; | |
} | |
} | |
/* | |
x += xDir; | |
x = (x + 5) % 5; | |
y += yDir; | |
y = (y + 5) % 5; | |
*/ | |
//updateHighlight(); | |
}, cooloff); | |
swiper.update(function(g) { | |
if (Math.abs(g.translation()[0]) > tolerance || Math.abs(g.translation()[1]) > tolerance) { | |
var xDir = Math.abs(g.translation()[0]) > tolerance ? (g.translation()[0] > 0 ? -1 : 1) : 0; | |
var yDir = Math.abs(g.translation()[1]) > tolerance ? (g.translation()[1] < 0 ? -1 : 1) : 0; | |
console.log([slider,xDir,yDir]); | |
slider(xDir, yDir); | |
} | |
}); | |
ctl.connect(); | |
//updateHighlight(); | |
}) | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment