Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Restrict the input from the gyro to the same range as desktop version.

Also ensures that starting position when using gyro is "in the middle", and not the position corresponding to the top left corner when using mouse.
  • Loading branch information...
commit 253f0336806772cae09bc6493d94a2fc2d85409d 1 parent 98acc32
@magebarf magebarf authored
Showing with 7 additions and 0 deletions.
  1. +7 −0 js/plax.js
View
7 js/plax.js
@@ -31,6 +31,7 @@
layers = [],
plaxActivityTarget = $(window),
motionMax = 1,
+ motionMin = -1,
motionStartX = null,
motionStartY = null,
ignoreMoveable = false
@@ -168,6 +169,12 @@
// Admittedly fuzzy measurements
x = values.x / 30
y = values.y / 30
+ // Ensure not outside of expected range, -1 to 1
+ x = x < motionMin ? motionMin : (x > motionMax ? motionMax : x)
+ y = y < motionMin ? motionMin : (y > motionMax ? motionMax : y)
+ // Normalize from -1 to 1 => 0 to 1
+ x = (x + 1) / 2
+ y = (y + 1) / 2
}
var hRatio = x/((moveable() == true) ? motionMax : plaxActivityTarget.width()),
Please sign in to comment.
Something went wrong with that request. Please try again.