Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #44 from magebarf/23149235756df254dde885d4fbccab16…

…79a93ad7

Configurable degrees of tilt for gyro parallaxing
  • Loading branch information...
commit bfa3c42f584be9b04aee22396658cc4abb731060 2 parents bf789ce + 2314923
Cameron McEfee authored
Showing with 9 additions and 5 deletions.
  1. +8 −5 js/plax.js
  2. +1 −0  readme.md
13 js/plax.js
View
@@ -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)
})
1  readme.md
View
@@ -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()
Please sign in to comment.
Something went wrong with that request. Please try again.