Merge pull request #41 from magebarf/gyrorange

Restrict the input from the gyro to the same range as desktop version.
This commit is contained in:
Cameron McEfee 2013-04-30 11:19:09 -07:00
Родитель 98acc32964 253f033680
Коммит d4f9b33b8a
1 изменённых файлов: 7 добавлений и 0 удалений

Просмотреть файл

@ -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()),