Skip to content
Browse files

Swap and invert x and y based on orientation

  • Loading branch information...
1 parent 8a9c3b9 commit 33300376c6812a70bf549e4d07a575497a07fed1 @yury yury committed Jan 11, 2013
Showing with 14 additions and 1 deletion.
  1. +14 −1 js/plax.js
View
15 js/plax.js
@@ -115,6 +115,19 @@
x = e.gamma
y = e.beta
+ // Swap x and y in Landscape orientation
+ if (Math.abs(window.orientation) === 90) {
+ var a = x;
+ x = y;
+ y = a;
+ }
+
+ // Invert x and y in upsidedown orientations
+ if (window.orientation < 0) {
+ x = -x;
+ y = -y;
+ }
+
motionStartX = (motionStartX == null) ? x : motionStartX
motionStartY = (motionStartY == null) ? y : motionStartY
@@ -227,4 +240,4 @@
})(function () {
return typeof jQuery !== 'undefined' ? jQuery : ender
-}())
+}())

0 comments on commit 3330037

Please sign in to comment.
Something went wrong with that request. Please try again.