Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Cameron423698 committed Aug 17, 2011
1 parent dd703f9 commit 2367628
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions js/plax.js
Expand Up @@ -23,12 +23,12 @@

(function ($) {

var maxfps = 25;
var delay = 1 / maxfps * 1000 // delay in ms
var lastRender = new Date().getTime();
var layers = [],
docWidth = $(window).width(),
docHeight = $(window).height()
var maxfps = 25,
delay = 1 / maxfps * 1000,
lastRender = new Date().getTime(),
layers = [],
docWidth = $(window).width(),
docHeight = $(window).height()

$(window).resize(function() {
docWidth = $(window).width()
Expand Down Expand Up @@ -69,27 +69,26 @@
}

function plaxifier(e) {
if (new Date().getTime() < lastRender + delay) return;
lastRender = new Date().getTime();
if (new Date().getTime() < lastRender + delay) return
lastRender = new Date().getTime()

var x = e.pageX,
y = e.pageY;
y = e.pageY

if(moveable()){
var i = (window.orientation +180) %360 / 90
// portrait(%2==0) or landscape
var accel= e.accelerationIncludingGravity;
var i = (window.orientation +180) %360 / 90, // portrait(%2==0) or landscape
accel= e.accelerationIncludingGravity,
tmp_x = i%2==0 ? -accel.x : accel.y,
tmp_y = i%2==0 ? accel.y : accel.x

var tmp_x = i%2==0 ? -accel.x :accel.y;
var tmp_y = i%2==0 ? accel.y :accel.x;
// facing up(>=2) or down
x = i>=2 ? tmp_x:-tmp_x;
y = i>=2 ? tmp_y:-tmp_y;
x = i>=2 ? tmp_x : -tmp_x
y = i>=2 ? tmp_y : -tmp_y
}

var hRatio = x/(moveable() ? 5 : docWidth),
vRatio = y/(moveable() ? 5 : docHeight),
layer, i;
layer, i

for (i = layers.length; i--;) {
layer = layers[i]
Expand Down Expand Up @@ -118,7 +117,7 @@
},
disable: function(){
$(document).unbind('mousemove.plax')
window.ondevicemotion = undefined;
window.ondevicemotion = undefined
}
}

Expand Down

0 comments on commit 2367628

Please sign in to comment.