Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixed animating - without the px it would not actually move

  • Loading branch information...
commit f07a64c928f9385dc6d0530f023719cbb23adf4e 1 parent 6997fdf
Remy Sharp authored
Showing with 6 additions and 6 deletions.
  1. +6 −6 js/worker-main.js
12 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:
Please sign in to comment.
Something went wrong with that request. Please try again.