зеркало из https://github.com/github/plax.git
Merge pull request #44 from magebarf/23149235756df254dde885d4fbccab1679a93ad7
Configurable degrees of tilt for gyro parallaxing
This commit is contained in:
Коммит
bfa3c42f58
13
js/plax.js
13
js/plax.js
|
@ -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` — Object: (optional) sets a specific DOM element over which Plax will track the mouse.
|
||||
|
||||
`gyroRange` — 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()
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче