[
  {
    "path": ".gitignore",
    "content": "*.DS_Store\nnode_modules\ndist\n**/*.css\nnpm-debug.log\n"
  },
  {
    "path": ".npmignore",
    "content": "examples\nlogo.png\n"
  },
  {
    "path": ".nvmrc",
    "content": "8\n"
  },
  {
    "path": "LICENSE",
    "content": "//============================================================\n//\n// The MIT License\n//\n// Copyright (C) 2014 Matthew Wagerfield - @wagerfield\n//\n// Permission is hereby granted, free of charge, to any\n// person obtaining a copy of this software and associated\n// documentation files (the \"Software\"), to deal in the\n// Software without restriction, including without limitation\n// the rights to use, copy, modify, merge, publish, distribute,\n// sublicense, and/or sell copies of the Software, and to\n// permit persons to whom the Software is furnished to do\n// so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice\n// shall be included in all copies or substantial portions\n// of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY\n// OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT\n// LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\n// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO\n// EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE\n// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN\n// AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE\n// OR OTHER DEALINGS IN THE SOFTWARE.\n//\n//============================================================\n"
  },
  {
    "path": "README.md",
    "content": "![Parallax.js](logo.png)\n\n[![CDNJS](https://img.shields.io/cdnjs/v/parallax.svg)](https://cdnjs.com/libraries/parallax)\n\nParallax Engine that reacts to the orientation of a smart device. Where no gyroscope or motion detection hardware is available, the position of the cursor is used instead.\n\nCheck out the **[demo](https://matthew.wagerfield.com/parallax/)** to see it in action!\n\n# Table of Contents\n\n- [1. Getting started](#1-getting-started)\n\t- [1.1 Installation](#11-installation)\n\t- [1.2 Preparations](#12-preparations)\n\t- [1.3 Run Parallax](#13-run-parallax)\n- [2. Configuration](#2-configuration)\n\t- [2.1 Programmatic vs Declarative](#21-programmatic-vs-declarative)\n\t- [2.2 Configuration Options](#22-configuration-options)\n- [3. Methods](#3-methods)\n- [4. Development](#4-development)\n\t- [4.1 Running the Project](#41-running-the-project)\n\t- [4.2 Opening an Issue](#42-opening-an-issue)\n\t- [4.3 Known Issues](#43-known-issues)\n- [5. FAQ](#5-faq)\n- [6. Information](#6-information)\n   - [6.1 License](#61-license)\n   - [6.2 Contributors](#62-authors)\n\n# 1. Getting started\n\n## 1.1 Installation\n\n### 1.1 a) Using the CDN\n\n1. Add `<script src=\"https://cdnjs.cloudflare.com/ajax/libs/parallax/3.1.0/parallax.min.js\"></script>` to your markup\n2. Done!\n\nMany thanks to the fine folks over at [cdnjs](https://cdnjs.com/) for hosting our library.\n\n### 1.1 b) Beginners\n\n1. Head over to the [releases](https://github.com/wagerfield/parallax/releases) Section\n2. Download `compiled.zip` from the latest release\n3. Extract the ZIP archive and locate the `parallax.js` and `parallax.min.js` files\n\t- Use `parallax.js` if you want to snoop around in the code\n\t- Use `parallax.min.js` for deployment, because it has a smaller file size\n4. Copy the file of your choice into your project directory\n5. So far, so good!\n\n### 1.1 c) Professionals\n\n`npm i -s parallax-js`\n\nYou will then find the source code in `node_modules/parallax-js/src/parallax.js` and the browserified, babelified, uglified, production-ready version in `node_modules/parallax-js/dist/parallax.min.js`\n\n## 1.2 Preparations\n\n### Include the Script\n\nIf you use the compiled version, either downloaded from the releases page, or copied from the `dist` folder, include the script like any other Javascript library:  \n`<script src=\"path/to/parallax.js\"></script>`\n\nOf course, when you've installed via npm, and use browserify/babel, you can also simply do:  \n`import Parallax from 'parallax-js'` or  \n`const Parallax = require('parallax-js')`\n\n### Create your HTML elements\n\nEach Parallax.js instance needs a container element, the scene. You're free to identify it by any means you want, but for now, let's use an ID:\n\n```html\n<div id=\"scene\">\n</div>\n```\n\nPer default, all direct child elements of the scene will become moving objects, the layers. You can change this to a custom query selector, but again, we're going with the easiest approach for now:\n\n```html\n<div id=\"scene\">\n  <div>My first Layer!</div>\n  <div>My second Layer!</div>\n</div>\n```\n\nWhile all other options and parameters are optional, with sane defaults, and can be set programatically, each layer needs a `data-depth` attribute. The movement applied to each layer will be multiplied by its depth attribute.\n\n```html\n<div id=\"scene\">\n  <div data-depth=\"0.2\">My first Layer!</div>\n  <div data-depth=\"0.6\">My second Layer!</div>\n</div>\n```\n\n## 1.3 Run Parallax\n\nAs soon as your DOM is ready and loaded, you can create a new Parallax.js instance, providing your scene element as first parameter.\n\n```javascript\nvar scene = document.getElementById('scene');\nvar parallaxInstance = new Parallax(scene);\n```\n\nThat's it, you're running Parallax.js now!\n\n# 2. Configuration\n\n## 2.1 Programmatic vs Declarative\n\nMost configuration settings can be declared either as data-value attribute of the scene element, or property of the configuration object. The programmatic approach will take priority over the data-value attributes set in the HTML.  \nSome options can also be set at run-time via instance methods.\n\nDeclarative:\n\n```html\n<div data-relative-input=\"true\" id=\"scene\">\n  <div data-depth=\"0.2\">My first Layer!</div>\n  <div data-depth=\"0.6\">My second Layer!</div>\n</div>\n```\n\nProgrammatic:\n\n```javascript\nvar scene = document.getElementById('scene');\nvar parallaxInstance = new Parallax(scene, {\n  relativeInput: true\n});\n```\n\nUsing Methods at Runtime:\n\n```javascript\nparallaxInstance.friction(0.2, 0.2);\n```\n\n## 2.2 Configuration Options\n\n### relativeInput\n\nProperty: **relativeInput**  \nAttribute: **data-relative-input**\n\nValue: *boolean*  \nDefault: *false*\n\nMakes mouse input relative to the position of the scene element.  \nNo effect when gyroscope is used.\n\n### clipRelativeInput\n\nProperty: **clipRelativeInput**  \nAttribute: **data-clip-relative-input**\n\nValue: *boolean*  \nDefault: *false*\n\nClips mouse input to the bounds of the scene. This means the movement stops as soon as the edge of the scene element is reached by the cursor.  \nNo effect when gyroscope is used, or `hoverOnly` is active.\n\n### hoverOnly\n\nProperty: **hoverOnly**  \nAttribute: **data-hover-only**\n\nValue: *boolean*  \nDefault: *false*\n\nParallax will only be in effect while the cursor is over the scene element, otherwise all layers move back to their initial position. Works best in combination with `relativeInput`.  \nNo effect when gyroscope is used.\n\n### inputElement\n\nProperty: **inputElement**  \nAttribute: **data-input-element**  \nMethod: **setInputElement(HTMLElement)**\n\nValue: *null* or *HTMLElement* / *String*  \nDefault: *null*\n\nAllows usage of a different element for cursor input.  \nThe configuration property expects an HTMLElement, the data value attribute a query selector string.  \nWill only work in combination with `relativeInput`, setting `hoverOnly` might make sense too.  \nNo effect when gyroscope is used.\n\n### calibrateX & calibrateY\n\nProperty: **calibrateX** & **calibrateY**  \nAttribute: **data-calibrate-x** & **data-calibrate-y**  \nMethod: **calibrate(x, y)**\n\nValue: *boolean*  \nDefault: *false* for X, *true* for Y\n\nCaches the initial X/Y axis value on initialization and calculates motion relative to this.  \nNo effect when cursor is used.\n\n### invertX & invertY\n\nProperty: **invertX** & **invertY**  \nAttribute: **data-invert-x** & **data-invert-y**  \nMethod: **invert(x, y)**\n\nValue: *boolean*  \nDefault: *true*\n\nInverts the movement of the layers relative to the input. Setting both of these values to *false* will cause the layers to move with the device motion or cursor.\n\n### limitX & limitY\n\nProperty: **limitX** & **limitY**  \nAttribute: **data-limit-x** & **data-limit-y**  \nMethod: **limit(x, y)**\n\nValue: *false* or *integer*  \nDefault: *false*\n\nLimits the movement of layers on the respective axis. Leaving this value at false gives complete freedom to the movement.\n\n### scalarX & scalarY\n\nProperty: **scalarX** & **scalarY**  \nAttribute: **data-scalar-x** & **data-scalar-y**  \nMethod: **scalar(x, y)**\n\nValue: *float*  \nDefault: *10.0*\n\nMultiplies the input motion by this value, increasing or decreasing the movement speed and range.\n\n### frictionX & frictionY\n\nProperty: **frictionX** & **frictionY**  \nAttribute: **data-friction-x** & **data-friction-y**  \nMethod: **friction(x, y)**\n\nValue: *float* between *0* and *1*  \nDefault: *0.1*\n\nAmount of friction applied to the layers. At *1* the layers will instantly go to their new positions, everything below 1 adds some easing.  \nThe default value of *0.1* adds some sensible easing. Try *0.15* or *0.075* for some difference.\n\n### originX & originY\n\nProperty: **originX** & **originY**  \nAttribute: **data-origin-x** & **data-origin-y**  \nMethod: **origin(x, y)**\n\nValue: *float* between *0* and *1*  \nDefault: *0.5*\n\nX and Y origin of the mouse input. The default of *0.5* refers to the center of the screen or element, *0* is the left (X axis) or top (Y axis) border, 1 the right or bottom.  \nNo effect when gyroscope is used.\n\n### precision\n\nProperty: **precision**  \nAttribute: **data-precision**\n\nValue: *integer*  \nDefault: *1*\n\nDecimals the element positions will be rounded to. *1* is a sensible default which you should not need to change in the next few years, unless you have a very interesting and unique setup.\n\n### selector\n\nProperty: **selector**  \nAttribute: **data-selector**\n\nValue: *null* or *string*  \nDefault: *null*\n\nString that will be fed to querySelectorAll on the scene element to select the layer elements. When *null*, will simply select all direct child elements.  \nUse `.layer` for legacy behaviour, selecting only child elements having the class name *layer*.\n\n### pointerEvents\n\nProperty: **pointerEvents**  \nAttribute: **data-pointer-events**\n\nValue: *boolean*  \nDefault: *false*\n\nSet to *true* to enable interactions with the scene and layer elements. When set to the default of *false*, the CSS attribute `pointer-events: none` will be applied for performance reasons.  \nSetting this to *true* alone will not be enough to fully interact with all layers, since they will be overlapping. You have to either set `position: absolute` on all layer child elements, or keep **pointerEvents** at *false* and set `pointer-events: all` for the interactable elements only.\n\n### onReady\n\nProperty: **onReady**\n\nValue: *null* or *function*  \nDefault: *null*\n\nCallback function that will be called as soon as the Parallax instance has finished its setup. This might currently take up to 1000ms (`calibrationDelay * 2`).\n\n# 3. Methods\n\nIn addition to the configuration methods outlined in the section above, there are a few more publicly accessible methods:\n\n### enable()\n\nEnables a disabled Parallax instance.\n\n### disable()\n\nDisables a running Parallax instance.\n\n### destroy()\n\nCompletely destroys a Parallax instance, allowing it to be garbage collected.\n\n### version()\n\nReturns the version number of the Parallax library.\n\n# 4. Development\n\n## 4.1 Running the Project\n\n1. Clone the Repository `git clone git@github.com:wagerfield/parallax.git`\n2. Open the working directory `cd parallax`\n3. Install dependencies `npm install`\n4. Run development server `gulp watch`\n5. Open [http://localhost:9000/](http://localhost:9000/) in browser\n\n## 4.2 Opening an Issue\n\nIf you need help relating the direct usage of this library in a project of yours, provide us with a working, running example of your work. This can be a GitHub repository, a ZIP file containing your work, a project on CodePen or JSFiddle, you name it.  \n*Do not complain about something not working without giving us some way to help you.* Thank you!\n\n## 4.3 Known Issues\n\n### SVG-Bug in MS Edge\n\nIt seems MS Edge does not support the `children` or `querySelectorAll` methods for SVG elements.\n\n### Animation running really slow\n\nDepending on your site, the GPU might have a bit too much to do. You can try adding the CSS definition `will-change: transform` to the layer elements to speed things up. Use sparingly!\n\n### Gyroscope not working on Android\n\nAndroid will only allow access to the gyroscope o secure origins (that is, with `https` protocol).\n\n### Gyroscope not working on iOS\n\nBecause gyroscope data had been abused to track users, it's disabled on iDevices by default and needs to be enabled by the users. You can try asking for permission via [DeviceOrientationEvent.requestPermission](https://www.w3.org/TR/orientation-event/#dom-deviceorientationevent-requestpermission).\n\nDo something like:\n\n```js\nDeviceOrientationEvent\n  .requestPermission()\n  .then(() => {\n    new Parallax(scene)\n  })\n```\n\n### Unable to manually set position of layers\n\nSince this often lead to issues, this library forces the positioning of the layers to be absolute. If you need to override this, add `!important` to your CSS positioning.\n\n# 5. FAQ\n\n### How can I use this Library with jQuery?\n\njQuery will not prevent you from using this library in any way. If you want to use jQuery for selecting your Parallax scene element, you can do so too.\n\n```javascript\nvar scene = $('#scene').get(0);\nvar parallaxInstance = new Parallax(scene);\n```\n\n### How can I interact with my layers?\n\nCheck out the section on the configuration option `pointerEvents` above.\n\n### How do I get the demo files to work?\n\nEither download compiled_with_examples.zip from the [GitHub Releases](https://github.com/wagerfield/parallax/releases) section, or follow section 4.1\n\n\n# 6. Information\n\n## 6.1 License\n\nThis project is licensed under the terms of the  [MIT](http://www.opensource.org/licenses/mit-license.php) License. Enjoy!\n\n## 6.2 Authors\n\nMatthew Wagerfield: [@wagerfield](http://twitter.com/wagerfield)  \nRené Roth: [Website](http://reneroth.xyz/)\n"
  },
  {
    "path": "examples/assets/styles.scss",
    "content": "$color-green: #00ffaa;\n$color-background: #111;\n$color-text: #555;\n\n\nbody {\n  background: $color-background;\n  color: $color-text;\n  font-family: monospace;\n  font-size: 18px;\n  margin: 0;\n}\n\nimg {\n  display: block;\n  width: 100%;\n}\n\ninput[type=checkbox] {\n  display: none;\n}\n\nlabel {\n  cursor: pointer;\n  display: inline-block;\n  margin-right: 1em;\n  padding: 0.4em 0;\n}\n\ninput[type=checkbox] + label:before {\n  background: $color-text;\n  content: '';\n  display: inline-block;\n  height: 16px;\n  margin-right: 8px;\n  position: relative;\n  top: 1px;\n  width: 16px;\n}\n\ninput[type=checkbox]:checked + label:before {\n  background: $color-green;\n}\n\n.container {\n  margin: 0 auto;\n  max-width: 600px;\n  padding: 10px;\n  position: relative;\n}\n\n.container--offset {\n  margin-left: 0;\n}\n\nbutton {\n  background: $color-text;\n  border: 10px solid $color-green;\n  cursor: pointer;\n  display: block;\n  font-family: monospace;\n  font-size: 24px;\n  height: 80px;\n  line-height: 60px;\n  margin: 0;\n  outline: none;\n  padding: 0 1.2em;\n  text-align: right;\n\n  &:hover {\n    background: $color-green;\n  }\n\n  &#deleteme {\n    margin: 2rem;\n  }\n}\n\n.scene {\n  margin: 0;\n  padding: 0;\n\n  button {\n    left: 10%;\n    top: 260px;\n    width: 80%;\n    position: absolute;\n  }\n}\n\n.fill {\n  bottom: 5%;\n  left: 5%;\n  position: absolute;\n  right: 5%;\n  top: 5%;\n}\n\n.expand-width {\n  width: 100%;\n}\n\n.border {\n  border: 2px dashed $color-green;\n}\n\n.aspect {\n  opacity: 0.2;\n}\n\n@for $i from 1 through 6 {\n  .scene > *:nth-child(#{$i}) {\n    opacity: #{0.15 * $i};\n\n    button {\n      transform: rotate(#{180 - 30 * $i}deg)\n    }\n  }\n}\n"
  },
  {
    "path": "examples/pages/callback.html",
    "content": "<!DOCTYPE html>\n<html>\n<head>\n\n\t<meta charset=\"utf-8\">\n\n\t<title>Parallax.js | Callback Example</title>\n\n\t<!-- Behavioral Meta Data -->\n\t<meta name=\"apple-mobile-web-app-capable\" content=\"yes\">\n\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no\">\n\n\t<!-- Styles -->\n\t<link rel=\"stylesheet\" type=\"text/css\" href=\"styles.css\"/>\n\n</head>\n<body>\n\n\t<div id=\"container\" class=\"container\">\n\t\t<div id=\"scene\" class=\"scene\">\n\t\t\t<div data-depth=\"1.00\"><img src=\"images/layer1.png\"></div>\n\t\t\t<div data-depth=\"0.80\"><img src=\"images/layer2.png\"></div>\n\t\t\t<div data-depth=\"0.60\"><img src=\"images/layer3.png\"></div>\n\t\t\t<div data-depth=\"0.40\"><img src=\"images/layer4.png\"></div>\n\t\t\t<div data-depth=\"0.20\"><img src=\"images/layer5.png\"></div>\n\t\t\t<div data-depth=\"0.00\"><img src=\"images/layer6.png\"></div>\n\t\t</div>\n\t</div>\n\n\t<!-- Scripts -->\n\t<script src=\"./parallax.js\"></script>\n\t<script>\n\n\tfunction myAwesomeCallback() {\n\t\talert('Parallax is ready to go now!');\n\t}\n\n\t// the onReady function is called as soon as Parallax knows what input method to use. This might take up to 1000ms (supportDelay * 2) after initialisation\n\tvar scene = document.getElementById('scene');\n\tvar parallax = new Parallax(scene, {\n\t\tonReady: myAwesomeCallback\n\t});\n\n\t</script>\n\n</body>\n</html>\n"
  },
  {
    "path": "examples/pages/destroy.html",
    "content": "<!DOCTYPE html>\n<html>\n<head>\n\n\t<meta charset=\"utf-8\">\n\n\t<title>Parallax.js | Instance Destruction Example</title>\n\n\t<!-- Behavioral Meta Data -->\n\t<meta name=\"apple-mobile-web-app-capable\" content=\"yes\">\n\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no\">\n\n\t<!-- Styles -->\n\t<link rel=\"stylesheet\" type=\"text/css\" href=\"styles.css\"/>\n\n</head>\n<body>\n\n\t<button id=\"deleteme\">Delete me!</button>\n\n\t<div id=\"container\" class=\"container\">\n\t\t<div id=\"scene\" class=\"scene\">\n\t\t\t<div data-depth=\"1.00\"><img src=\"images/layer1.png\"></div>\n\t\t\t<div data-depth=\"0.80\"><img src=\"images/layer2.png\"></div>\n\t\t\t<div data-depth=\"0.60\"><img src=\"images/layer3.png\"></div>\n\t\t\t<div data-depth=\"0.40\"><img src=\"images/layer4.png\"></div>\n\t\t\t<div data-depth=\"0.20\"><img src=\"images/layer5.png\"></div>\n\t\t\t<div data-depth=\"0.00\"><img src=\"images/layer6.png\"></div>\n\t\t</div>\n\t</div>\n\n\t<!-- Scripts -->\n\t<script src=\"./parallax.js\"></script>\n\t<script>\n\n\tvar scene = document.getElementById('scene');\n\tvar parallax = new Parallax(scene);\n\n\tdocument.getElementById('deleteme').onclick = function() {\n\t\tparallax.destroy();\n\t\tparallax = null;\n\n\t\tthis.onclick = null;\n\t\tthis.style.display = 'none';\n\t};\n\n\t</script>\n\n</body>\n</html>\n"
  },
  {
    "path": "examples/pages/hoveronly.html",
    "content": "<!DOCTYPE html>\n<html>\n<head>\n\n\t<meta charset=\"utf-8\">\n\n\t<title>Parallax.js | Hover Only Example</title>\n\n\t<!-- Behavioral Meta Data -->\n\t<meta name=\"apple-mobile-web-app-capable\" content=\"yes\">\n\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no\">\n\n\t<!-- Styles -->\n\t<link rel=\"stylesheet\" type=\"text/css\" href=\"styles.css\"/>\n\n</head>\n<body>\n\n\t<div id=\"container\" class=\"container\">\n\t\t<div id=\"scene\" data-hover-only=\"true\" data-relative-input=\"true\" class=\"scene border\">\n\t\t\t<div data-depth=\"1.00\"><img src=\"images/layer1.png\"></div>\n\t\t\t<div data-depth=\"0.80\"><img src=\"images/layer2.png\"></div>\n\t\t\t<div data-depth=\"0.60\"><img src=\"images/layer3.png\"></div>\n\t\t\t<div data-depth=\"0.40\"><img src=\"images/layer4.png\"></div>\n\t\t\t<div data-depth=\"0.20\"><img src=\"images/layer5.png\"></div>\n\t\t\t<div data-depth=\"0.00\"><img src=\"images/layer6.png\"></div>\n\t\t</div>\n\t</div>\n\n\t<!-- Scripts -->\n\t<script src=\"./parallax.js\"></script>\n\t<script>\n\n\tvar scene = document.getElementById('scene');\n\tvar parallax = new Parallax(scene);\n\n\t</script>\n\n</body>\n</html>\n"
  },
  {
    "path": "examples/pages/input_element.html",
    "content": "<!DOCTYPE html>\n<html>\n<head>\n\n  <meta charset=\"utf-8\">\n\n  <title>Parallax.js | Input Element Example</title>\n\n  <!-- Behavioral Meta Data -->\n  <meta name=\"apple-mobile-web-app-capable\" content=\"yes\">\n  <meta name=\"viewport\" content=\"width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no\">\n\n  <!-- Styles -->\n  <link rel=\"stylesheet\" type=\"text/css\" href=\"styles.css\"/>\n\n</head>\n<body>\n\n  <div class=\"container\" style=\"float:left\">\n    <div id=\"scene\" class=\"scene border\" data-input-element=\"#scene-input\">\n      <div data-depth=\"1.00\"><img src=\"images/layer1.png\"></div>\n      <div data-depth=\"0.80\"><img src=\"images/layer2.png\"></div>\n      <div data-depth=\"0.60\"><img src=\"images/layer3.png\"></div>\n      <div data-depth=\"0.40\"><img src=\"images/layer4.png\"></div>\n      <div data-depth=\"0.20\"><img src=\"images/layer5.png\"></div>\n      <div data-depth=\"0.00\"><img src=\"images/layer6.png\"></div>\n    </div>\n  </div>\n\n  <div class=\"container\" style=\"float:right\">\n    <div id=\"scene-input\" class=\"scene border\">\n      <div><img src=\"images/layer6.png\"></div>\n    </div>\n  </div>\n\n  <!-- Scripts -->\n  <script src=\"./parallax.js\"></script>\n  <script>\n\n  // Elements\n  var scene = document.getElementById('scene');\n  var input = document.getElementById('scene-input');\n\n  // Pretty simple huh?\n  var parallax = new Parallax(scene, {\n    hoverOnly: true,\n    relativeInput: true,\n    inputElement: input\n  });\n\n\n  </script>\n\n</body>\n</html>\n"
  },
  {
    "path": "examples/pages/interactive.html",
    "content": "<!DOCTYPE html>\n<html>\n<head>\n\n  <meta charset=\"utf-8\">\n\n  <title>Parallax.js | Interactive Example</title>\n\n  <!-- Behavioral Meta Data -->\n  <meta name=\"apple-mobile-web-app-capable\" content=\"yes\">\n  <meta name=\"viewport\" content=\"width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no\">\n\n  <!-- Styles -->\n  <link rel=\"stylesheet\" type=\"text/css\" href=\"styles.css\"/>\n\n</head>\n<body>\n\n  <div id=\"container\" class=\"container\">\n    <img class=\"aspect\" src=\"images/layer2.png\">\n    <div id=\"scene\" class=\"scene border fill\" data-pointer-events=\"true\">\n      <div class=\"expand-width\" data-depth=\"1.00\"><button>layer[6]</button></div>\n      <div class=\"expand-width\" data-depth=\"0.80\"><button>layer[5]</button></div>\n      <div class=\"expand-width\" data-depth=\"0.60\"><button>layer[4]</button></div>\n      <div class=\"expand-width\" data-depth=\"0.40\"><button>layer[3]</button></div>\n      <div class=\"expand-width\" data-depth=\"0.20\"><button>layer[2]</button></div>\n      <div class=\"expand-width\" data-depth=\"0.00\"><button>layer[1]</button></div>\n    </div>\n  </div>\n\n  <!-- Scripts -->\n  <script src=\"./parallax.js\"></script>\n  <script>\n\n  // Nothing new here...it's all in the CSS!\n  // And don't forget to activate the pointerEvents option\n  var scene = document.getElementById('scene');\n  var parallax = new Parallax(scene);\n\n  </script>\n\n</body>\n</html>\n"
  },
  {
    "path": "examples/pages/relative.html",
    "content": "<!DOCTYPE html>\n<html>\n<head>\n\n  <meta charset=\"utf-8\">\n\n  <title>Parallax.js | Relative Example</title>\n\n  <!-- Behavioral Meta Data -->\n  <meta name=\"apple-mobile-web-app-capable\" content=\"yes\">\n  <meta name=\"viewport\" content=\"width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no\">\n\n  <!-- Styles -->\n  <link rel=\"stylesheet\" type=\"text/css\" href=\"styles.css\"/>\n\n</head>\n<body>\n\n  <div id=\"container\" class=\"container container--offset\">\n    <div id=\"scene\" class=\"scene border\">\n      <div data-depth=\"1.00\"><img src=\"images/layer1.png\"></div>\n      <div data-depth=\"0.80\"><img src=\"images/layer2.png\"></div>\n      <div data-depth=\"0.60\"><img src=\"images/layer3.png\"></div>\n      <div data-depth=\"0.40\"><img src=\"images/layer4.png\"></div>\n      <div data-depth=\"0.20\"><img src=\"images/layer5.png\"></div>\n      <div data-depth=\"0.00\"><img src=\"images/layer6.png\"></div>\n    </div>\n    <br>\n    <input type=\"checkbox\" id=\"relative\" checked>\n    <label for=\"relative\">relativeInput</label>\n    <input type=\"checkbox\" id=\"clip\">\n    <label for=\"clip\">clipRelativeInput</label>\n  </div>\n\n  <!-- Scripts -->\n  <script src=\"./parallax.js\"></script>\n  <script>\n\n  // Elements\n  var scene = document.getElementById('scene');\n  var clipCheckbox = document.getElementById('clip');\n  var relativeCheckbox = document.getElementById('relative');\n\n  // Pretty simple huh?\n  var parallax = new Parallax(scene, {\n    relativeInput: relativeCheckbox.checked,\n    clipRelativeInput: clipCheckbox.checked\n  });\n\n  relativeCheckbox.addEventListener('change', function(event) {\n    parallax.relativeInput = relativeCheckbox.checked;\n  });\n\n  clipCheckbox.addEventListener('change', function(event) {\n    parallax.clipRelativeInput = clipCheckbox.checked;\n  });\n\n  </script>\n\n</body>\n</html>\n"
  },
  {
    "path": "examples/pages/selector.html",
    "content": "<!DOCTYPE html>\n<html>\n<head>\n\n\t<meta charset=\"utf-8\">\n\n\t<title>Parallax.js | Selector Example</title>\n\n\t<!-- Behavioral Meta Data -->\n\t<meta name=\"apple-mobile-web-app-capable\" content=\"yes\">\n\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no\">\n\n\t<!-- Styles -->\n\t<link rel=\"stylesheet\" type=\"text/css\" href=\"styles.css\"/>\n\n</head>\n<body>\n\n\t<div id=\"container\" class=\"container\">\n\t\t<div id=\"scene\" class=\"scene\">\n\t\t\t<div class=\"layer\" data-depth=\"1.00\"><img src=\"images/layer1.png\"></div>\n\t\t\t<div class=\"layer\" data-depth=\"0.80\"><img src=\"images/layer4.png\"></div>\n\t\t\t<div class=\"layer\" data-depth=\"0.60\"><img src=\"images/layer6.png\"></div>\n\t\t\t<div data-depth=\"0.40\">I am not a Parallax Layer</div>\n\t\t\t<div data-depth=\"0.20\">I am not a Parallax Layer</div>\n\t\t\t<div data-depth=\"0.00\">I am not a Parallax Layer</div>\n\t\t</div>\n\t</div>\n\n\t<!-- Scripts -->\n\t<script src=\"./parallax.js\"></script>\n\t<script>\n\n\tvar scene = document.getElementById('scene');\n\tvar parallax = new Parallax(scene, {\n    selector: '.layer'\n  });\n\n\t</script>\n\n</body>\n</html>\n"
  },
  {
    "path": "examples/pages/separate_axis_data.html",
    "content": "<!DOCTYPE html>\n<html>\n<head>\n\n\t<meta charset=\"utf-8\">\n\n\t<title>Parallax.js | Separate Axis Example</title>\n\n\t<!-- Behavioral Meta Data -->\n\t<meta name=\"apple-mobile-web-app-capable\" content=\"yes\">\n\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no\">\n\n\t<!-- Styles -->\n\t<link rel=\"stylesheet\" type=\"text/css\" href=\"styles.css\"/>\n\n</head>\n<body>\n\n\t<div id=\"container\" class=\"container\">\n\t\t<div id=\"scene\" class=\"scene\">\n\t\t\t<div data-depth=\"1.00\">\n\t\t\t\t<img src=\"images/layer1.png\">\n\t\t\t</div>\n\t\t\t<div data-depth-x=\"0.80\" data-depth-y=\"-0.80\">\n\t\t\t\t<img src=\"images/layer2.png\">\n\t\t\t</div>\n\t\t\t<div data-depth-x=\"-0.60\" data-depth-y=\"-0.20\">\n\t\t\t\t<img src=\"images/layer3.png\">\n\t\t\t</div>\n\t\t\t<div data-depth=\"0.40\" data-depth-y=\"-0.30\">\n\t\t\t\t<img src=\"images/layer4.png\">\n\t\t\t</div>\n\t\t\t<div data-depth=\"0.20\">\n\t\t\t\t<img src=\"images/layer5.png\">\n\t\t\t</div>\n\t\t\t<div data-depth=\"0.00\">\n\t\t\t\t<img src=\"images/layer6.png\">\n\t\t\t</div>\n\t\t</div>\n\t</div>\n\n\t<!-- Scripts -->\n\t<script src=\"./parallax.js\"></script>\n\t<script>\n\n\t// Pretty simple huh?\n\tvar scene = document.getElementById('scene');\n\tvar parallax = new Parallax(scene);\n\n\t</script>\n\n</body>\n</html>\n"
  },
  {
    "path": "examples/pages/simple.html",
    "content": "<!DOCTYPE html>\n<html>\n<head>\n\n\t<meta charset=\"utf-8\">\n\n\t<title>Parallax.js | Simple Example</title>\n\n\t<!-- Behavioral Meta Data -->\n\t<meta name=\"apple-mobile-web-app-capable\" content=\"yes\">\n\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no\">\n\n\t<!-- Styles -->\n\t<link rel=\"stylesheet\" type=\"text/css\" href=\"styles.css\"/>\n\n</head>\n<body>\n\n\t<div id=\"container\" class=\"container\">\n\t\t<div id=\"scene\" class=\"scene\">\n\t\t\t<div data-depth=\"1.00\"><img src=\"images/layer1.png\"></div>\n\t\t\t<div data-depth=\"0.80\"><img src=\"images/layer2.png\"></div>\n\t\t\t<div data-depth=\"0.60\"><img src=\"images/layer3.png\"></div>\n\t\t\t<div data-depth=\"0.40\"><img src=\"images/layer4.png\"></div>\n\t\t\t<div data-depth=\"0.20\"><img src=\"images/layer5.png\"></div>\n\t\t\t<div data-depth=\"0.00\"><img src=\"images/layer6.png\"></div>\n\t\t</div>\n\t</div>\n\n\t<!-- Scripts -->\n\t<script src=\"./parallax.js\"></script>\n\t<script>\n\n\t// Pretty simple huh?\n\tvar scene = document.getElementById('scene');\n\tvar parallax = new Parallax(scene);\n\n\t</script>\n\n</body>\n</html>\n"
  },
  {
    "path": "gulpfile.js",
    "content": "const gulp = require('gulp')\nconst path = require('path')\n\nconst autoprefixer = require('autoprefixer')\nconst babelify = require('babelify')\nconst browserify = require('browserify')\nconst browsersync = require('browser-sync').create()\nconst buffer = require('vinyl-buffer')\nconst notifier = require('node-notifier')\nconst postcss = require('gulp-postcss')\nconst rename = require('gulp-rename');\nconst rimraf = require('rimraf')\nconst sass = require('gulp-sass')\nconst source = require('vinyl-source-stream')\nconst sourcemaps = require('gulp-sourcemaps')\nconst uglify = require('gulp-uglify')\nconst util = require('gulp-util')\n\ngulp.task('clean', (cb) => {\n  rimraf('./dist', cb)\n})\n\ngulp.task('build', ['clean'], () => {\n  gulp.start('build:js', 'build:scss')\n})\n\nfunction showError(arg) {\n  notifier.notify({\n    title: 'Error',\n    message: '' + arg,\n    sound: 'Basso'\n  })\n  console.log(arg)\n  this.emit('end')\n}\n\ngulp.task('build:scss', () => {\n  return gulp.src(path.join('examples', 'assets', 'styles.scss'))\n    .pipe(sass({\n      outputStyle: 'nested',\n      precision: 10,\n      includePaths: ['.', 'node_modules'],\n      onError: showError\n    }).on('error', function(error) {\n      showError(error)\n      this.emit('end')\n    }))\n    .pipe(postcss([\n      autoprefixer({\n        browsers: ['last 2 versions', 'Firefox ESR', 'Explorer >= 9', 'Android >= 4.0', '> 2%']\n      })\n    ]))\n    .pipe(gulp.dest(path.join('examples', 'assets')))\n    .pipe(browsersync.stream({match: '**/*.css'}))\n})\n\ngulp.task('build:js', () => {\n  return browserify({entries: path.join('src', 'parallax.js'), debug: false, standalone: 'Parallax'})\n        .transform(\"babelify\", {presets: [\"es2015\"]})\n        .bundle()\n          .on('error', showError)\n        .pipe(source('parallax.js'))\n        .pipe(buffer())\n        .pipe(gulp.dest('dist'))\n        .pipe(rename('parallax.min.js'))\n        .pipe(sourcemaps.init({loadMaps: true}))\n        .pipe(uglify())\n          .on('error', showError)\n        .pipe(sourcemaps.write('./'))\n        .pipe(gulp.dest('dist'))\n        .pipe(browsersync.stream({match: path.join('**','*.js')}))\n})\n\ngulp.task('watch', ['build'], () => {\n  browsersync.init({\n    notify: false,\n    port: 9000,\n    server: {\n      baseDir: [path.join('examples', 'pages'), path.join('examples', 'assets'), 'dist'],\n      directory: true\n    }\n  })\n   gulp.watch(path.join('src', '*.js'), ['build:js'])\n   gulp.watch(path.join('examples', 'assets', '*.scss'), ['build:scss'])\n   gulp.watch(path.join('examples', 'pages', '*.html'), browsersync.reload)\n})\n\ngulp.task('default', ['watch'])\n"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"parallax-js\",\n  \"description\": \"Parallax Engine that reacts to the orientation of a smart device.\",\n  \"version\": \"3.1.0\",\n  \"license\": \"MIT\",\n  \"main\": \"dist/parallax.js\",\n  \"homepage\": \"http://wagerfield.github.io/parallax/\",\n  \"author\": \"Matthew Wagerfield <matthew@wagerfield.com>, René Roth <mail@reneroth.org>\",\n  \"directories\": {\n    \"example\": \"examples\"\n  },\n  \"scripts\": {},\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"git://github.com/wagerfield/parallax.git\"\n  },\n  \"keywords\": [\n    \"parallax\",\n    \"gyroscope\",\n    \"jquery\",\n    \"javascript\",\n    \"library\"\n  ],\n  \"bugs\": {\n    \"url\": \"https://github.com/wagerfield/parallax/issues\"\n  },\n  \"devDependencies\": {\n    \"autoprefixer\": \"^7.1.4\",\n    \"babel-preset-es2015\": \"^6.24.1\",\n    \"babelify\": \"^7.3.0\",\n    \"browser-sync\": \"^2.18.13\",\n    \"browserify\": \"^14.0.0\",\n    \"gulp\": \"^3.9.1\",\n    \"gulp-postcss\": \"^7.0.0\",\n    \"gulp-rename\": \"^1.2.2\",\n    \"gulp-sass\": \"^3.1.0\",\n    \"gulp-sourcemaps\": \"^2.6.1\",\n    \"gulp-uglify\": \"^3.0.0\",\n    \"gulp-util\": \"^3.0.8\",\n    \"node-notifier\": \"^5.0.2\",\n    \"rimraf\": \"^2.5.4\",\n    \"vinyl-buffer\": \"^1.0.0\",\n    \"vinyl-source-stream\": \"^1.1.0\"\n  },\n  \"dependencies\": {\n    \"object-assign\": \"^4.1.1\",\n    \"raf\": \"^3.3.0\"\n  }\n}\n"
  },
  {
    "path": "src/parallax.js",
    "content": "/**\n* Parallax.js\n* @author Matthew Wagerfield - @wagerfield, René Roth - mail@reneroth.org\n* @description Creates a parallax effect between an array of layers,\n*              driving the motion from the gyroscope output of a smartdevice.\n*              If no gyroscope is available, the cursor position is used.\n*/\n\nconst rqAnFr = require('raf')\nconst objectAssign = require('object-assign')\n\nconst helpers = {\n  propertyCache: {},\n  vendors: [null, ['-webkit-','webkit'], ['-moz-','Moz'], ['-o-','O'], ['-ms-','ms']],\n\n  clamp(value, min, max) {\n    return min < max\n      ? (value < min ? min : value > max ? max : value)\n      : (value < max ? max : value > min ? min : value)\n  },\n\n  data(element, name) {\n    return helpers.deserialize(element.getAttribute('data-'+name))\n  },\n\n  deserialize(value) {\n    if (value === 'true') {\n      return true\n    } else if (value === 'false') {\n      return false\n    } else if (value === 'null') {\n      return null\n    } else if (!isNaN(parseFloat(value)) && isFinite(value)) {\n      return parseFloat(value)\n    } else {\n      return value\n    }\n  },\n\n  camelCase(value) {\n    return value.replace(/-+(.)?/g, (match, character) => {\n      return character ? character.toUpperCase() : ''\n    })\n  },\n\n  accelerate(element) {\n    helpers.css(element, 'transform', 'translate3d(0,0,0) rotate(0.0001deg)')\n    helpers.css(element, 'transform-style', 'preserve-3d')\n    helpers.css(element, 'backface-visibility', 'hidden')\n  },\n\n  transformSupport(value) {\n    let element = document.createElement('div'),\n        propertySupport = false,\n        propertyValue = null,\n        featureSupport = false,\n        cssProperty = null,\n        jsProperty = null\n    for (let i = 0, l = helpers.vendors.length; i < l; i++) {\n      if (helpers.vendors[i] !== null) {\n        cssProperty = helpers.vendors[i][0] + 'transform'\n        jsProperty = helpers.vendors[i][1] + 'Transform'\n      } else {\n        cssProperty = 'transform'\n        jsProperty = 'transform'\n      }\n      if (element.style[jsProperty] !== undefined) {\n        propertySupport = true\n        break\n      }\n    }\n    switch(value) {\n      case '2D':\n        featureSupport = propertySupport\n        break\n      case '3D':\n        if (propertySupport) {\n          let body = document.body || document.createElement('body'),\n              documentElement = document.documentElement,\n              documentOverflow = documentElement.style.overflow,\n              isCreatedBody = false\n\n          if (!document.body) {\n            isCreatedBody = true\n            documentElement.style.overflow = 'hidden'\n            documentElement.appendChild(body)\n            body.style.overflow = 'hidden'\n            body.style.background = ''\n          }\n\n          body.appendChild(element)\n          element.style[jsProperty] = 'translate3d(1px,1px,1px)'\n          propertyValue = window.getComputedStyle(element).getPropertyValue(cssProperty)\n          featureSupport = propertyValue !== undefined && propertyValue.length > 0 && propertyValue !== 'none'\n          documentElement.style.overflow = documentOverflow\n          body.removeChild(element)\n\n          if ( isCreatedBody ) {\n            body.removeAttribute('style')\n            body.parentNode.removeChild(body)\n          }\n        }\n        break\n    }\n    return featureSupport\n  },\n\n  css(element, property, value) {\n    let jsProperty = helpers.propertyCache[property]\n    if (!jsProperty) {\n      for (let i = 0, l = helpers.vendors.length; i < l; i++) {\n        if (helpers.vendors[i] !== null) {\n          jsProperty = helpers.camelCase(helpers.vendors[i][1] + '-' + property)\n        } else {\n          jsProperty = property\n        }\n        if (element.style[jsProperty] !== undefined) {\n          helpers.propertyCache[property] = jsProperty\n          break\n        }\n      }\n    }\n    element.style[jsProperty] = value\n  }\n\n}\n\nconst MAGIC_NUMBER = 30,\n      DEFAULTS = {\n        relativeInput: false,\n        clipRelativeInput: false,\n        inputElement: null,\n        hoverOnly: false,\n        calibrationThreshold: 100,\n        calibrationDelay: 500,\n        supportDelay: 500,\n        calibrateX: false,\n        calibrateY: true,\n        invertX: true,\n        invertY: true,\n        limitX: false,\n        limitY: false,\n        scalarX: 10.0,\n        scalarY: 10.0,\n        frictionX: 0.1,\n        frictionY: 0.1,\n        originX: 0.5,\n        originY: 0.5,\n        pointerEvents: false,\n        precision: 1,\n        onReady: null,\n        selector: null\n      }\n\nclass Parallax {\n  constructor(element, options) {\n\n    this.element = element\n\n    const data = {\n      calibrateX: helpers.data(this.element, 'calibrate-x'),\n      calibrateY: helpers.data(this.element, 'calibrate-y'),\n      invertX: helpers.data(this.element, 'invert-x'),\n      invertY: helpers.data(this.element, 'invert-y'),\n      limitX: helpers.data(this.element, 'limit-x'),\n      limitY: helpers.data(this.element, 'limit-y'),\n      scalarX: helpers.data(this.element, 'scalar-x'),\n      scalarY: helpers.data(this.element, 'scalar-y'),\n      frictionX: helpers.data(this.element, 'friction-x'),\n      frictionY: helpers.data(this.element, 'friction-y'),\n      originX: helpers.data(this.element, 'origin-x'),\n      originY: helpers.data(this.element, 'origin-y'),\n      pointerEvents: helpers.data(this.element, 'pointer-events'),\n      precision: helpers.data(this.element, 'precision'),\n      relativeInput: helpers.data(this.element, 'relative-input'),\n      clipRelativeInput: helpers.data(this.element, 'clip-relative-input'),\n      hoverOnly: helpers.data(this.element, 'hover-only'),\n      inputElement: document.querySelector(helpers.data(this.element, 'input-element')),\n      selector: helpers.data(this.element, 'selector')\n    }\n\n    for (let key in data) {\n      if (data[key] === null) {\n        delete data[key]\n      }\n    }\n\n    objectAssign(this, DEFAULTS, data, options)\n\n    if(!this.inputElement) {\n      this.inputElement = this.element\n    }\n\n    this.calibrationTimer = null\n    this.calibrationFlag = true\n    this.enabled = false\n    this.depthsX = []\n    this.depthsY = []\n    this.raf = null\n\n    this.bounds = null\n    this.elementPositionX = 0\n    this.elementPositionY = 0\n    this.elementWidth = 0\n    this.elementHeight = 0\n\n    this.elementCenterX = 0\n    this.elementCenterY = 0\n\n    this.elementRangeX = 0\n    this.elementRangeY = 0\n\n    this.calibrationX = 0\n    this.calibrationY = 0\n\n    this.inputX = 0\n    this.inputY = 0\n\n    this.motionX = 0\n    this.motionY = 0\n\n    this.velocityX = 0\n    this.velocityY = 0\n\n    this.onMouseMove = this.onMouseMove.bind(this)\n    this.onDeviceOrientation = this.onDeviceOrientation.bind(this)\n    this.onDeviceMotion = this.onDeviceMotion.bind(this)\n    this.onOrientationTimer = this.onOrientationTimer.bind(this)\n    this.onMotionTimer = this.onMotionTimer.bind(this)\n    this.onCalibrationTimer = this.onCalibrationTimer.bind(this)\n    this.onAnimationFrame = this.onAnimationFrame.bind(this)\n    this.onWindowResize = this.onWindowResize.bind(this)\n\n    this.windowWidth = null\n    this.windowHeight = null\n    this.windowCenterX = null\n    this.windowCenterY = null\n    this.windowRadiusX = null\n    this.windowRadiusY = null\n    this.portrait = false\n    this.desktop = !navigator.userAgent.match(/(iPhone|iPod|iPad|Android|BlackBerry|BB10|mobi|tablet|opera mini|nexus 7)/i)\n    this.motionSupport = !!window.DeviceMotionEvent && !this.desktop\n    this.orientationSupport = !!window.DeviceOrientationEvent && !this.desktop\n    this.orientationStatus = 0\n    this.motionStatus = 0\n\n    this.initialise()\n  }\n\n  initialise() {\n    if (this.transform2DSupport === undefined) {\n      this.transform2DSupport = helpers.transformSupport('2D')\n      this.transform3DSupport = helpers.transformSupport('3D')\n    }\n\n    // Configure Context Styles\n    if (this.transform3DSupport) {\n      helpers.accelerate(this.element)\n    }\n\n    let style = window.getComputedStyle(this.element)\n    if (style.getPropertyValue('position') === 'static') {\n      this.element.style.position = 'relative'\n    }\n\n    // Pointer events\n    if(!this.pointerEvents) {\n      this.element.style.pointerEvents = 'none'\n    }\n\n    // Setup\n    this.updateLayers()\n    this.updateDimensions()\n    this.enable()\n    this.queueCalibration(this.calibrationDelay)\n  }\n\n  doReadyCallback() {\n    if(this.onReady) {\n      this.onReady()\n    }\n  }\n\n  updateLayers() {\n    if(this.selector) {\n      this.layers = this.element.querySelectorAll(this.selector)\n    } else {\n      this.layers = this.element.children\n    }\n\n    if(!this.layers.length) {\n      console.warn('ParallaxJS: Your scene does not have any layers.')\n    }\n\n    this.depthsX = []\n    this.depthsY = []\n\n    for (let index = 0; index < this.layers.length; index++) {\n      let layer = this.layers[index]\n\n      if (this.transform3DSupport) {\n        helpers.accelerate(layer)\n      }\n\n      layer.style.position = index ? 'absolute' : 'relative'\n      layer.style.display = 'block'\n      layer.style.left = 0\n      layer.style.top = 0\n\n      let depth = helpers.data(layer, 'depth') || 0\n      this.depthsX.push(helpers.data(layer, 'depth-x') || depth)\n      this.depthsY.push(helpers.data(layer, 'depth-y') || depth)\n    }\n  }\n\n  updateDimensions() {\n    this.windowWidth = window.innerWidth\n    this.windowHeight = window.innerHeight\n    this.windowCenterX = this.windowWidth * this.originX\n    this.windowCenterY = this.windowHeight * this.originY\n    this.windowRadiusX = Math.max(this.windowCenterX, this.windowWidth - this.windowCenterX)\n    this.windowRadiusY = Math.max(this.windowCenterY, this.windowHeight - this.windowCenterY)\n  }\n\n  updateBounds() {\n    this.bounds = this.inputElement.getBoundingClientRect()\n    this.elementPositionX = this.bounds.left\n    this.elementPositionY = this.bounds.top\n    this.elementWidth = this.bounds.width\n    this.elementHeight = this.bounds.height\n    this.elementCenterX = this.elementWidth * this.originX\n    this.elementCenterY = this.elementHeight * this.originY\n    this.elementRangeX = Math.max(this.elementCenterX, this.elementWidth - this.elementCenterX)\n    this.elementRangeY = Math.max(this.elementCenterY, this.elementHeight - this.elementCenterY)\n  }\n\n  queueCalibration(delay) {\n    clearTimeout(this.calibrationTimer)\n    this.calibrationTimer = setTimeout(this.onCalibrationTimer, delay)\n  }\n\n  enable() {\n    if (this.enabled) {\n      return\n    }\n    this.enabled = true\n\n    if (this.orientationSupport) {\n      this.portrait = false\n      window.addEventListener('deviceorientation', this.onDeviceOrientation)\n      this.detectionTimer = setTimeout(this.onOrientationTimer, this.supportDelay)\n    } else if (this.motionSupport) {\n      this.portrait = false\n      window.addEventListener('devicemotion', this.onDeviceMotion)\n      this.detectionTimer = setTimeout(this.onMotionTimer, this.supportDelay)\n    } else {\n      this.calibrationX = 0\n      this.calibrationY = 0\n      this.portrait = false\n      window.addEventListener('mousemove', this.onMouseMove)\n      this.doReadyCallback()\n    }\n\n    window.addEventListener('resize', this.onWindowResize)\n    this.raf = rqAnFr(this.onAnimationFrame)\n  }\n\n  disable() {\n    if (!this.enabled) {\n      return\n    }\n    this.enabled = false\n\n    if (this.orientationSupport) {\n      window.removeEventListener('deviceorientation', this.onDeviceOrientation)\n    } else if (this.motionSupport) {\n      window.removeEventListener('devicemotion', this.onDeviceMotion)\n    } else {\n      window.removeEventListener('mousemove', this.onMouseMove)\n    }\n\n    window.removeEventListener('resize', this.onWindowResize)\n    rqAnFr.cancel(this.raf)\n  }\n\n  calibrate(x, y) {\n    this.calibrateX = x === undefined ? this.calibrateX : x\n    this.calibrateY = y === undefined ? this.calibrateY : y\n  }\n\n  invert(x, y) {\n    this.invertX = x === undefined ? this.invertX : x\n    this.invertY = y === undefined ? this.invertY : y\n  }\n\n  friction(x, y) {\n    this.frictionX = x === undefined ? this.frictionX : x\n    this.frictionY = y === undefined ? this.frictionY : y\n  }\n\n  scalar(x, y) {\n    this.scalarX = x === undefined ? this.scalarX : x\n    this.scalarY = y === undefined ? this.scalarY : y\n  }\n\n  limit(x, y) {\n    this.limitX = x === undefined ? this.limitX : x\n    this.limitY = y === undefined ? this.limitY : y\n  }\n\n  origin(x, y) {\n    this.originX = x === undefined ? this.originX : x\n    this.originY = y === undefined ? this.originY : y\n  }\n\n  setInputElement(element) {\n    this.inputElement = element\n    this.updateDimensions()\n  }\n\n  setPosition(element, x, y) {\n    x = x.toFixed(this.precision) + 'px'\n    y = y.toFixed(this.precision) + 'px'\n    if (this.transform3DSupport) {\n      helpers.css(element, 'transform', 'translate3d(' + x + ',' + y + ',0)')\n    } else if (this.transform2DSupport) {\n      helpers.css(element, 'transform', 'translate(' + x + ',' + y + ')')\n    } else {\n      element.style.left = x\n      element.style.top = y\n    }\n  }\n\n  onOrientationTimer() {\n    if (this.orientationSupport && this.orientationStatus === 0) {\n      this.disable()\n      this.orientationSupport = false\n      this.enable()\n    } else {\n      this.doReadyCallback()\n    }\n  }\n\n  onMotionTimer() {\n    if (this.motionSupport && this.motionStatus === 0) {\n      this.disable()\n      this.motionSupport = false\n      this.enable()\n    } else {\n      this.doReadyCallback()\n    }\n  }\n\n  onCalibrationTimer() {\n    this.calibrationFlag = true\n  }\n\n  onWindowResize() {\n    this.updateDimensions()\n  }\n\n  onAnimationFrame() {\n    this.updateBounds()\n    let calibratedInputX = this.inputX - this.calibrationX,\n        calibratedInputY = this.inputY - this.calibrationY\n    if ((Math.abs(calibratedInputX) > this.calibrationThreshold) || (Math.abs(calibratedInputY) > this.calibrationThreshold)) {\n      this.queueCalibration(0)\n    }\n    if (this.portrait) {\n      this.motionX = this.calibrateX ? calibratedInputY : this.inputY\n      this.motionY = this.calibrateY ? calibratedInputX : this.inputX\n    } else {\n      this.motionX = this.calibrateX ? calibratedInputX : this.inputX\n      this.motionY = this.calibrateY ? calibratedInputY : this.inputY\n    }\n    this.motionX *= this.elementWidth * (this.scalarX / 100)\n    this.motionY *= this.elementHeight * (this.scalarY / 100)\n    if (!isNaN(parseFloat(this.limitX))) {\n      this.motionX = helpers.clamp(this.motionX, -this.limitX, this.limitX)\n    }\n    if (!isNaN(parseFloat(this.limitY))) {\n      this.motionY = helpers.clamp(this.motionY, -this.limitY, this.limitY)\n    }\n    this.velocityX += (this.motionX - this.velocityX) * this.frictionX\n    this.velocityY += (this.motionY - this.velocityY) * this.frictionY\n    for (let index = 0; index < this.layers.length; index++) {\n      let layer = this.layers[index],\n          depthX = this.depthsX[index],\n          depthY = this.depthsY[index],\n          xOffset = this.velocityX * (depthX * (this.invertX ? -1 : 1)),\n          yOffset = this.velocityY * (depthY * (this.invertY ? -1 : 1))\n      this.setPosition(layer, xOffset, yOffset)\n    }\n    this.raf = rqAnFr(this.onAnimationFrame)\n  }\n\n  rotate(beta, gamma){\n    // Extract Rotation\n    let x = (beta || 0) / MAGIC_NUMBER, //  -90 :: 90\n        y = (gamma || 0) / MAGIC_NUMBER // -180 :: 180\n\n    // Detect Orientation Change\n    let portrait = this.windowHeight > this.windowWidth\n    if (this.portrait !== portrait) {\n      this.portrait = portrait\n      this.calibrationFlag = true\n    }\n\n    if (this.calibrationFlag) {\n      this.calibrationFlag = false\n      this.calibrationX = x\n      this.calibrationY = y\n    }\n\n    this.inputX = x\n    this.inputY = y\n  }\n\n  onDeviceOrientation(event) {\n    let beta = event.beta\n    let gamma = event.gamma\n    if (beta !== null && gamma !== null) {\n      this.orientationStatus = 1\n      this.rotate(beta, gamma)\n    }\n  }\n\n  onDeviceMotion(event) {\n    let beta = event.rotationRate.beta\n    let gamma = event.rotationRate.gamma\n    if (beta !== null && gamma !== null) {\n      this.motionStatus = 1\n      this.rotate(beta, gamma)\n    }\n  }\n\n  onMouseMove(event) {\n    let clientX = event.clientX,\n        clientY = event.clientY\n\n    // reset input to center if hoverOnly is set and we're not hovering the element\n    if(this.hoverOnly &&\n      ((clientX < this.elementPositionX || clientX > this.elementPositionX + this.elementWidth) ||\n      (clientY < this.elementPositionY || clientY > this.elementPositionY + this.elementHeight))) {\n        this.inputX = 0\n        this.inputY = 0\n        return\n      }\n\n    if (this.relativeInput) {\n      // Clip mouse coordinates inside element bounds.\n      if (this.clipRelativeInput) {\n        clientX = Math.max(clientX, this.elementPositionX)\n        clientX = Math.min(clientX, this.elementPositionX + this.elementWidth)\n        clientY = Math.max(clientY, this.elementPositionY)\n        clientY = Math.min(clientY, this.elementPositionY + this.elementHeight)\n      }\n      // Calculate input relative to the element.\n      if(this.elementRangeX && this.elementRangeY) {\n        this.inputX = (clientX - this.elementPositionX - this.elementCenterX) / this.elementRangeX\n        this.inputY = (clientY - this.elementPositionY - this.elementCenterY) / this.elementRangeY\n      }\n    } else {\n      // Calculate input relative to the window.\n      if(this.windowRadiusX && this.windowRadiusY) {\n        this.inputX = (clientX - this.windowCenterX) / this.windowRadiusX\n        this.inputY = (clientY - this.windowCenterY) / this.windowRadiusY\n      }\n    }\n  }\n\n  destroy() {\n    this.disable()\n\n    clearTimeout(this.calibrationTimer)\n    clearTimeout(this.detectionTimer)\n\n    this.element.removeAttribute('style')\n    for (let index = 0; index < this.layers.length; index++) {\n      this.layers[index].removeAttribute('style')\n    }\n\n    delete this.element\n    delete this.layers\n  }\n\n  version() {\n    return '3.1.0'\n  }\n\n}\n\nmodule.exports = Parallax\n"
  }
]