Permalink
Browse files

fixed animating - without the px it would not actually move

  • Loading branch information...
1 parent 6997fdf commit f07a64c928f9385dc6d0530f023719cbb23adf4e @remy committed Jan 7, 2013
Showing with 6 additions and 6 deletions.
  1. +6 −6 js/worker-main.js
View
@@ -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 ||
@@ -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:

0 comments on commit f07a64c

Please sign in to comment.