Skip to content

Instantly share code, notes, and snippets.

@joyrexus
Created June 3, 2013 17:28
Show Gist options
  • Save joyrexus/5699761 to your computer and use it in GitHub Desktop.
Save joyrexus/5699761 to your computer and use it in GitHub Desktop.
Simple demo of leap.js: move and scale a div.
<!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