Created
June 3, 2013 17:28
-
-
Save joyrexus/5699761 to your computer and use it in GitHub Desktop.
Simple demo of leap.js: move and scale a div.
This file contains 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
<!DOCTYPE HTML> | |
<meta charset="utf8"> | |
<script src="leap.min.js"></script> | |
<style> | |
#box { | |
width: 200px; | |
height: 200px; | |
background-color: steelblue; | |
} | |
</style> | |
<body> | |
<div id="box"></div> | |
<script> | |
var first = null | |
var box = document.getElementById("box"); | |
var render = function(frame) { | |
if (!first) first = frame; | |
var delta = frame.translation(first); | |
box.style.marginLeft = delta.x + "px"; | |
box.style.marginTop = -delta.y + "px"; | |
box.style.width = 200 + delta.z + "px"; | |
box.style.height = 200 + delta.z + "px"; | |
}; | |
Leap.loop(render); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment