Skip to content
This repository has been archived by the owner on Oct 9, 2019. It is now read-only.

Commit

Permalink
fixed animating - without the px it would not actually move
Browse files Browse the repository at this point in the history
  • Loading branch information
remy committed Jan 7, 2013
1 parent 6997fdf commit f07a64c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions js/worker-main.js
Expand Up @@ -4,7 +4,7 @@
(function () {
"use strict";

var SQUARE_SIZE = 75;
var SQUARE_SIZE = 50;
var MOVEMENT_STEP = 3;

var requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame ||
Expand Down Expand Up @@ -52,26 +52,26 @@
var top = parseInt(square.style.top, 10);
var right = left + SQUARE_SIZE;
var bottom = top + SQUARE_SIZE;

switch (direction) {
case 37: // left
if (left > 0) {
square.style.left = left - MOVEMENT_STEP;
square.style.left = left - MOVEMENT_STEP + 'px';
}
break;
case 38: // up
if (top > 0) {
square.style.top = top - MOVEMENT_STEP;
square.style.top = top - MOVEMENT_STEP + 'px';
}
break;
case 39: //right
if (right < document.documentElement.clientWidth) {
square.style.left = left + MOVEMENT_STEP;
square.style.left = left + MOVEMENT_STEP + 'px';
}
break;
case 40: // down
if (bottom < document.documentElement.clientHeight) {
square.style.top = top + MOVEMENT_STEP;
square.style.top = top + MOVEMENT_STEP + 'px';
}
break;
default:
Expand Down

0 comments on commit f07a64c

Please sign in to comment.