Merge pull request #44 from magebarf/23149235756df254dde885d4fbccab1679a93ad7

Configurable degrees of tilt for gyro parallaxing
This commit is contained in:
Cameron McEfee 2013-05-09 09:05:02 -07:00
Родитель bf789ceb03 2314923575
Коммит bfa3c42f58
2 изменённых файлов: 9 добавлений и 5 удалений

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

@ -30,6 +30,7 @@
lastRender = new Date().getTime(),
layers = [],
plaxActivityTarget = $(window),
motionDegrees = 30,
motionMax = 1,
motionMin = -1,
motionStartX = null,
@ -167,8 +168,8 @@
values = valuesFromMotion(e)
// Admittedly fuzzy measurements
x = values.x / 30
y = values.y / 30
x = values.x / motionDegrees
y = values.y / motionDegrees
// 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)
@ -210,10 +211,12 @@
//
// returns nothing
enable: function(opts){
if (opts) {
if (opts.activityTarget) plaxActivityTarget = opts.activityTarget || $(window)
if (typeof opts.gyroRange === 'number' && opts.gyroRange > 0) motionDegrees = opts.gyroRange
}
$(document).bind('mousemove.plax', function (e) {
if(opts){
plaxActivityTarget = opts.activityTarget || $(window)
}
plaxifier(e)
})

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

@ -87,6 +87,7 @@ __Parameters__
`activityTarget` &mdash; Object: (optional) sets a specific DOM element over which Plax will track the mouse.
`gyroRange` &mdash; Integer / Float: (optional) sets the degrees of tilt needed to reach full movement in one direction, from the center position. For the full range, two times the degrees tilt is needed. Default value: 30.
### disable()