Skip to content

Commit

Permalink
fix example
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Oct 28, 2012
1 parent f7a0861 commit 067b864
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
12 changes: 8 additions & 4 deletions Readme.md
Expand Up @@ -70,8 +70,6 @@ var requestAnimationFrame = require('raf');
var canvas = document.querySelector('canvas');
var ctx = canvas.getContext('2d');

animate();

var stop = false;
function animate() {
if (stop) return;
Expand All @@ -81,20 +79,26 @@ function animate() {

var startx = 20;
var x = startx;
var destx = 700;
var destx = 300;
var y = 400 / 2;
var duration = 1000;
var start = Date.now();
var end = start + duration;

function draw() {
var now = Date.now();
if (now - start >= duration) stop = true;
x = ease.inOutCirc(now - start, startx, destx - x, duration) | 0;
var p = (now - start) / duration;
val = ease.inOutBounce(p);
x = startx + (destx - startx) * val;
canvas.width = canvas.width;
ctx.fillStyle = 'red';
ctx.arc(x, y, 10, 0, Math.PI * 2, false);
ctx.fill();
}

animate();

```

# License
Expand Down
1 change: 0 additions & 1 deletion example.html
Expand Up @@ -43,5 +43,4 @@
}

animate();

</script>

0 comments on commit 067b864

Please sign in to comment.