зеркало из https://github.com/github/plax.git
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:
Коммит
d4f9b33b8a
|
@ -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()),
|
||||
|
|
Загрузка…
Ссылка в новой задаче