Permalink
Browse files

Account for the fact that firefox still fires DeviceOrientationEvent

  • Loading branch information...
Cameron McEfee
Cameron McEfee committed Dec 8, 2012
1 parent 67997a7 commit cf06a692feb987874a4a249b6cbf03b59cbf905f
Showing with 6 additions and 4 deletions.
  1. +6 −4 js/plax.js
View
@@ -32,7 +32,8 @@
plaxActivityTarget = $(window),
motionMax = 1,
motionStartX = null,
- motionStartY = null
+ motionStartY = null,
+ ignoreMoveable = false
// Public Methods
$.fn.plaxify = function (params){
@@ -104,7 +105,7 @@
//
// returns true if the browser has window.DeviceMotionEvent (mobile)
function moveable(){
- return window.DeviceMotionEvent != undefined
+ return (ignoreMoveable==true) ? false : window.DeviceOrientationEvent != undefined
}
// The values pulled from the gyroscope of a motion device.
@@ -144,13 +145,14 @@
) return
if(moveable()){
+ if(e.gamma == undefined){
+ ignoreMoveable = true
+ }
values = valuesFromMotion(e)
// Admittedly fuzzy measurements
x = values.x / 30
y = values.y / 30
-
- console.log(x)
}
var hRatio = x/((moveable() == true) ? motionMax : plaxActivityTarget.width()),

0 comments on commit cf06a69

Please sign in to comment.