[
  {
    "path": ".babelrc",
    "content": "{\n  \"presets\": [\n    \"@babel/preset-env\"\n  ],\n  \"plugins\": [\n    \"@babel/plugin-proposal-class-properties\"\n  ]\n}"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/bug_report.md",
    "content": "---\nname: Bug report\nabout: Create a report to help us improve\ntitle: ''\nlabels: bug\nassignees: ''\n\n---\n\n**lax.js version**\nPlease note, only bugs in v2.0 or later will be fixed.\n\n**Describe the bug**\nA clear and concise description of what the bug is.\n\n**Code**\nPlease provide a link to a repo or code example of the issue in question.\n"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/feature_request.md",
    "content": "---\nname: Feature request\nabout: Suggest an idea for this project\ntitle: ''\nlabels: ''\nassignees: ''\n\n---\n\n**Is your feature request related to a problem? Please describe.**\nA clear and concise description of what the problem is. Ex. I'm always frustrated when [...]\n\n**Describe the solution you'd like**\nA clear and concise description of what you want to happen.\n\n**Describe alternatives you've considered**\nA clear and concise description of any alternative solutions or features you've considered.\n\n**Additional context**\nAdd any other context or screenshots about the feature request here.\n"
  },
  {
    "path": ".gitignore",
    "content": "node_modules/\n.DS_Store\nLaxLogo.sketch"
  },
  {
    "path": "LICENSE",
    "content": "MIT License\n\nCopyright (c) 2020 Alex Fox\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "# Archive Notice\nDue to other commitments I am unable to continue maintaining this project. As far as I know it still works, but there are likely better, more up to date alterantives out there. \n\n# lax.js\n\nSimple & lightweight (<4kb gzipped) vanilla JavaScript library to create smooth & beautiful animations when you scroll. \n\n![Lax 2.0 Gif](https://i.imgur.com/XNvvAOv.gif)\n\n[>> DEMO <<](https://alexfox.dev/lax.js/)\n\n---\n## What's new with Lax.js 2.0\nLax.js 2.0 has been completely re-written with a focus on modularity and flexibility giving you more tools to create awesome animations.\n- New javascript animation syntax, allowing for more advanced effect combos\n- Use any value to drive animations, for example mouse position, time of day .. and of course scroll!\n- Animations can be given inertia when scrolling\n- Create custom CSS bindings \n- Animation easings\n- And much more..\n\n## Examples\n- [Scroll effect](https://alexfox.dev/lax.js/examples/scroll)\n- [Horizontal snap scroll](https://alexfox.dev/lax.js/examples/snap-scroll)\n- [Inertia](https://alexfox.dev/lax.js/examples/inertia)\n- [Video/Gif playback](https://alexfox.dev/lax.js/examples/sprite)\n- [Cursor position](https://alexfox.dev/lax.js/examples/cursor)\n- [Text input](https://alexfox.dev/lax.js/examples/input)\n- [Update HTML content](https://alexfox.dev/lax.js/examples/on-update)\n- [Preset Explorer](https://alexfox.dev/lax.js/preset-explorer)\n\n\n# Documentation\n\n### 1. Getting started\n\n- [Setup](#setup)\n- [Using presets](#using-presets)\n- [Usage with UI frameworks](#dom-behavior-and-usage-with-frameworks)\n- [Adding drivers](#adding-drivers)\n- [Adding elements](#adding-elements)\n\n### 2. Going deeper\n\n- [Custom animations](#custom-animations)\n- [Optimising performance](#optimising-performance)\n\n### 3. Glossary\n\n- [CSS properties](#css-properties)\n- [Special values](#special-values)\n- [Supported easings](#supported-easings)\n\n# Getting started\n\n### NPM Setup\n\n```bash\n# https://www.npmjs.com/package/lax.js\n\nnpm install lax.js\nyarn add lax.js\n```\n```js\nimport lax from 'lax.js'\n```\n\n### HTML setup\n\n```html\n<script src=\"path-to-lax.min.js\"></script>\n<!-- or via CDN -->\n<script src=\"https://cdn.jsdelivr.net/npm/lax.js\" ></script>\n```\n\n\n## Setup\n\nTo implement lax you need to create at least one _driver_, to provide values for animations, as well as the element animation bindings. Below is a simple example:\n\n```html\n<!-- JS -->\n<script>\n  window.onload = function () {\n    lax.init()\n\n    // Add a driver that we use to control our animations\n    lax.addDriver('scrollY', function () {\n      return window.scrollY\n    })\n\n    // Add animation bindings to elements\n    lax.addElements('.selector', {\n      scrollY: {\n        translateX: [\n          [\"elInY\", \"elCenterY\", \"elOutY\"],\n          [0, 'screenWidth/2', 'screenWidth'],\n        ]\n      }\n    })\n  }\n</script>\n\n<!-- HTML -->\n<div class=\"selector\">Hello</div>\n```\n\n## Using presets\n\nThe easiest way to get started is to use presets via html classes. For example: \n\n```html\n<div class=\"lax lax_preset_fadeIn:50:100 lax_preset_spin\"></div>\n```\n\nMultiple presets can be chained together and they can be customised to suit your needs. Use the [preset explorer](https://alexfox.dev/lax.js/preset-explorer) to explore effects and see a simple example [here](https://alexfox.dev/lax.js/examples/html-inline).\n\n## DOM behavior and usage with Frameworks \n\nTo increase performance, `lax.js` indexes the list of elements to animate when the page loads. If you're using a library like React, Vue or EmberJS, it is likely that you are adding elements after the initial window.onload. Because of this you will need to call `lax.addElements` when you add components to the DOM that you want to animate, and `lax.removeElements` when the component unmounts.\n\nPlease find a React example [here](https://codesandbox.io/s/laxjs-react-example-nc4h7). Other examples will be available soon for Vue.js and Angular.\n\n## Adding drivers\n\nDrivers provide the values that _drive_ your animations. To set up a driver just call `lax.addDriver` with a name and a function which returns a number. This method is called every frame to calculate the animations so keep the method as computationally _light_ as possible. The example below will be the most common use case for lax which returns the scrollY position of the window.\n\n```javascript\nlax.addDriver(\n  'scrollY',                          // Driver name\n  function(laxFrame) {                     \n    return window.scrollY    // Value method\n  },\n  { }                                 // Options\n)\n```\n\n### Driver options\n\n#### `inertiaEnabled: boolean = false`\n\nIf enabled, the driver will calculate the speed at which its value is changing. Used to add inertia to elements using the [inertia element option](#inertia-number).\n\nSee this in action in the [here](https://alexfox.dev/lax.js/examples/inertia).\n\n#### `frameStep: number = 1`\n\nBy default each driver updates its value every animation frame, around ~60 times per second. You can use the `frameStep` to reduce frequency of the driver value updating. For example a value of `2` would only update ~30 times per second and a value of `60` would only update about once per second.\n\n## Adding elements\n\nYou can add lax animations to an element using the `addElements` method:\n\n```javascript\nlax.addElements(\n  '.selector',  // Element selector rule\n  {             // Animation data\n    scrollY: {  \n      opacity: [\n        [0, 100],\n        [1, 0]\n      ]\n    }\n  },\n  {             \n    style: {}   // Element options\n  }\n)\n```\n\n### Element options\n\n#### `style: StyleObject`\n\nAdd static CSS to each element, for example:\n\n```css\n{\n  transform: '200ms scale ease-in-out';\n}\n```\n\n#### `elements: Array<DOM nodes>`\n\nPass references to raw DOM elements to allow for more flexible selection patterns. In this case, a unique `selector` must still be passed as the first argument, however it does _not_ need to be a valid DOM selector.\n\nThis allows the library to tag the elements for removal later. Example:\n\n```js\nconst myDomElements = $('.selector')\n\n{\n  elements: myDomElements\n}\n```\n\n#### `onUpdate: (driverValues: Object, domElement: DomElement) => void`\nA method called every frame with the current driverValues and domElement. This could be used to toggle classes on an element or set innerHTML. See it in action [here](https://alexfox.dev/lax.js/examples/on-update).\n\nThe driver values are formatted as follows:\n```js\n{\n  scrollY: [  // Driver name\n    100,      // Driver value\n    0         // Driver inertia\n  ]\n}\n```\n\n# Going deeper\n\n## Custom animations\nCustom animations are defined using an object.\n\n```javascript\n// Animation data\n{\n  scrollY: {                // Driver name\n    translateX: [           // CSS property\n      ['elInY', 'elOutY'],  // Driver value map\n      [0, 'screenWidth'],   // Animation value map\n      {\n        inertia: 10        // Options\n      }\n    ],\n    opacity: [\n      // etc\n    ]\n  }\n}\n```\n\n### Driver name\nThe name of the driver you want to use as a source of values to map to your animation, for example, the document's scrollY position. Read about adding drivers [here](#adding-drivers).\n\n### CSS property\nThe name of the CSS property you want to animate, for example `opacity` or `rotate`. See a list of supported properties [here](#css-properties).\n\n> Some CSS properties, for example `box-shadow`, require a custom function to build the style string. To do this use the [cssFn](#cssfn-value-number--string) element option.\n\n### Value maps\nThe value maps are used to interpolate the driver value and output a value for your CSS property. For example:\n\n```javascript\n[0, 200, 800]  // Driver value map\n[0, 10,  20]   // Animation value map\n\n// Result\n\n| In  | Out |\n| --- | --- |\n| 0   | 0   |\n| 100 | 5   |\n| 200 | 10  |\n| 500 | 15  |\n| 800 | 20  |\n```\n\nWithin the maps you can use strings for simple formulas as well as use special values. e.g:\n\n```javascript\n['elInY', 'elCenterY-200', 'elCenterY',\n```\n\nSee a list of available values [here](#special-values).\n\nYou can also use mobile breakpoints within driver value maps and animation maps for more flexibility.\n\n```javascript\nscrollY: {\n  translateX: [\n    ['elInY', 'elCenterY', 'elOutY'],\n    {\n      500: [10, 20, 50], // Screen width < 500\n      900: [30, 40, 60], // Screen width > 500 and < 900\n      1400: [30, 40, 60], // Screen width > 900\n    },\n  ];\n}\n```\n\n### Options\n\n#### `modValue: number | undefined`\nSet this option to modulus the value from the driver, for example if you want to loop the animation value as the driver value continues to increase.\n\n#### `frameStep: number = 1`\nBy default each animation updates its value every animation frame, around ~60 times per second. You can use the `frameStep` to reduce frequency of the animation updating. For example a value of `2` would only update ~30 times per second and a value of `60` would only update about once per second.\n\n#### `inertia: number`\nUse to add inertia to your animations. Use in combination with the [inertiaEnabled](#inertiaenabled-boolean--false) driver option.\n\nSee inertia in action [here](https://alexfox.dev/lax.js/examples/inertia).\n\n\n#### `inertiaMode: \"normal\" | \"absolute\"`\nUse in combination with `inertia`. If set to `absolute` the inertia value will always be a positive number via the `Math.abs` operator.\n\n#### `cssUnit: string = \"\"`\nDefine the unit to be appended to the end of the value, for example \nFor example `px` `deg`\n\n#### `cssFn: (value: number, domElement: DomElement) => number | string`\nSome CSS properties require more complex strings as values. For example, `box-shadow` has multiple values that could be modified by a lax animation.\n\n```javascript\n// Box-shadow example\n(val) => {\n  return `${val}px ${val}px ${val}px rgba(0,0,0,0.5)`;\n};\n```\n\n#### `easing: string`\nSee a list of available values [here](#supported-easings).\n\n## Optimising performance\nLax.js has been designed to be performant but there are a few things to bare in mind when creating your websites.\n- Smaller elements perform better. \n- Postion `fixed` and `absolute` elements perform best as they do not trigger a layout change when updated.\n- Off-screen elements do not need to be updated so consider that when creating your animation value maps.\n- The css properties `blur`, `hue-rotate` and `brightness` are graphically intensive and do not run as smoothly as the other available properties.\n\n# Glossary\n\n## CSS properties\n\n| name       |\n| ---------- |\n| opacity    |\n| scaleX     |\n| scaleY     |\n| scale      |\n| skewX      |\n| skewY      |\n| skew       |\n| rotateX    |\n| rotateY    |\n| rotate     |\n| translateX |\n| translateY |\n| translateZ |\n| blur       |\n| hue-rotate |\n| brightness |\n\n## Special values\n\n| key          | value                                                                            |\n| ------------ | -------------------------------------------------------------------------------- |\n| screenWidth  | current width of the screen                                                      |\n| screenHeight | current height of the screen                                                     |\n| pageWidth    | width of the document                                                            |\n| pageHeight   | height of the document                                                           |\n| elWidth      | width of the element                                                             |\n| elHeight     | height of the element                                                            |\n| elInY        | window scrollY position when element will appear at the bottom of the screen     |\n| elOutY       | window scrollY position when element will disappear at the top of the screen     |\n| elCenterY    | window scrollY position when element will be centered vertically on the screen   |\n| elInX        | window scrollX position when element will appear at the right of the screen      |\n| elOutX       | window scrollX position when element will disappear at the left of the screen    |\n| elCenterX    | window scrollX position when element will be centered horizontally on the screen |\n| index        | index of the element when added using `lax.addElements`                          |\n\n## Supported easings\n\n| name           |\n| -------------- |\n| easeInQuad     |\n| easeOutQuad    |\n| easeInOutQuad  |\n| easeInCubic    |\n| easeOutCubic   |\n| easeInOutCubic |\n| easeInQuart    |\n| easeOutQuart   |\n| easeInOutQuart |\n| easeInQuint    |\n| easeOutQuint   |\n| easeInOutQuint |\n| easeOutBounce  |\n| easeInBounce   |\n| easeOutBack    |\n| easeInBack     |\n"
  },
  {
    "path": "docs/examples/cursor.html",
    "content": "<head>\n  <script type=\"application/javascript\" src=\"../lib/lax.min.js\"></script>\n  <script type=\"application/javascript\">\n\n    window.onload = function () {\n      lax.init()\n\n      // Setup mouse move listener\n      document.addEventListener('mousemove', function (e) {\n        lax.__cursorX = e.clientX\n        lax.__cursorY = e.clientY\n      }, false)\n\n      // Add lax driver for cursorX\n      lax.addDriver('cursorX', function () {\n        return lax.__cursorX || 0\n      })\n\n      // Add lax driver for cursorY\n      lax.addDriver('cursorY', function () {\n        return lax.__cursorY || 0\n      })\n\n      // Add lax driver for cursorXY\n      lax.addDriver('cursorDistanceFromCenter', function () {\n        var pageHeight = document.body.scrollHeight\n        var pageWidth = document.body.scrollWidth\n\n        var pageCenterX = pageWidth / 2\n        var pageCenterY = pageHeight / 2\n\n        var absDistanceFromCenterY = Math.abs((lax.__cursorY || 0) - pageCenterY) / pageCenterY\n        var absDistanceFromCenterX = Math.abs((lax.__cursorX || 0) - pageCenterX) / pageCenterX\n\n        return absDistanceFromCenterX + absDistanceFromCenterY\n      })\n\n      lax.addElements(\".text\", {\n        'cursorX': {\n          \"translateX\": [\n            [0, 'screenWidth'],\n            ['index * 10', 'index * -10'],\n          ],\n        },\n        'cursorY': {\n          \"translateY\": [\n            [0, 'screenHeight'],\n            ['index * 10', 'index * -10'],\n          ],\n        },\n        'cursorDistanceFromCenter': {\n          \"scale\": [\n            [0, 1],\n            [1, '1 + (index * 0.05 )'],\n          ],\n        }\n      })\n\n      lax.addElements(\".container\", {\n        'cursorX': {\n          \"filter\": [\n            [0, 'screenWidth'],\n            [0, 'screenWidth/2'],\n            {\n              \"cssFn\": (val) => {\n                return `hue-rotate(${val % 360}deg)`\n              }\n            }\n          ],\n        },\n      })\n    }\n\n  </script>\n</head>\n\n<style>\n  body {\n    padding: 0;\n    margin: 0;\n    font-family: Arial, Helvetica, sans-serif;\n  }\n\n  .text {\n    width: 100vw;\n    text-align: center;\n    position: fixed;\n    top: 0;\n    left: 0;\n    margin-top: calc(50vh - 40px);\n    z-index: 1000;\n    font-size: 100px;\n    transform-origin: 50% 50%;\n  }\n\n  .text.a {\n    color: #a94fe4;\n  }\n\n  .text.b {\n    color: #68e4f1;\n  }\n\n  .text.c {\n    color: #ffe773;\n  }\n\n  .text.d {\n    color: #f544ad;\n  }\n\n  .container {\n    background-color: #f5922c;\n    position: fixed;\n    width: 100vw;\n    height: 100vh;\n  }\n</style>\n\n<body>\n  <div class=\"container\">\n    <h1 class='text a'>Lax.js</h1>\n    <h1 class='text b'>Lax.js</h1>\n    <h1 class='text c'>Lax.js</h1>\n    <h1 class='text d'>Lax.js</h1>\n    <h1 class='text a'>Lax.js</h1>\n    <h1 class='text b'>Lax.js</h1>\n    <h1 class='text c'>Lax.js</h1>\n    <h1 class='text d'>Lax.js</h1>\n    <h1 class='text a'>Lax.js</h1>\n    <h1 class='text b'>Lax.js</h1>\n    <h1 class='text c'>Lax.js</h1>\n    <h1 class='text d'>Lax.js</h1>\n    <h1 class='text a'>Lax.js</h1>\n    <h1 class='text b'>Lax.js</h1>\n    <h1 class='text c'>Lax.js</h1>\n    <h1 class='text d'>Lax.js</h1>\n    <h1 class='text a'>Lax.js</h1>\n    <h1 class='text b'>Lax.js</h1>\n    <h1 class='text c'>Lax.js</h1>\n    <h1 class='text d'>Lax.js</h1>\n  </div>\n</body>"
  },
  {
    "path": "docs/examples/html-inline.html",
    "content": "<head>\n  <script type=\"application/javascript\" src=\"../lib/lax.min.js\"></script>\n  <script type=\"application/javascript\">\n\n    window.onload = function () {\n      lax.init()\n\n      lax.addDriver('scrollY', function () {\n        return window.scrollY\n      })\n    }\n\n  </script>\n</head>\n\n<style>\n  .square {\n    height: 200px;\n    width: 200px;\n    background-color: #a26ddc;\n    margin-bottom: 0px;\n    margin-left: -100px;\n    margin-top: -100px;\n    left: 50vw;\n    top: 50vh;\n    position: fixed;\n  }\n\n  body {\n    padding: 0;\n    background-color: #dedbde;\n    background-image: linear-gradient(rgba(255, 255, 255, .2) 50%, transparent 50%, transparent);\n    margin: 0;\n    background-size: 700px 700px;\n    height: 1000000px;\n  }\n</style>\n\n<body>\n  <div class=\"square lax lax_preset_spin:400:360 lax_preset_flipX\"></div>\n</body>"
  },
  {
    "path": "docs/examples/inertia.html",
    "content": "<head>\n  <script type=\"application/javascript\" src=\"../lib/lax.min.js\"></script>\n  <script type=\"application/javascript\">\n\n    window.onload = function () {\n      lax.init()\n\n      lax.addDriver('scrollY', function () {\n        return window.scrollY\n      }, { inertiaEnabled: true })\n\n      lax.addElements(\".circle\", {\n        scrollY: {\n          perspective: [\n            [0],\n            [1000],\n          ],\n          rotateX: [\n            [0],\n            [0],\n            {\n              inertia: -1\n            }\n          ],\n          \"box-shadow\": [\n            [0],\n            [0],\n            {\n              inertia: -1,\n              cssFn: (val) => {\n                return `0px ${Math.abs(val)}px 30px rgba(0,0,0,0.2)`\n              }\n            }\n          ],\n          translateY: [\n            [0],\n            [0],\n            {\n              inertia: -1\n            }\n          ],\n          brightness: [\n            [0],\n            [1],\n            {\n              inertia: -0.01\n            }\n          ]\n        },\n      })\n    }\n  </script>\n</head>\n\n<style>\n  .circle {\n    height: 200px;\n    width: 200px;\n    background-color: #a26ddc;\n    margin-bottom: 0px;\n    margin-left: -100px;\n    margin-top: -100px;\n    border-radius: 20px;\n    left: 50vw;\n    top: 50vh;\n    position: fixed;\n  }\n\n  body {\n    padding: 0;\n    background-color: #dedbde;\n    background-image: linear-gradient(rgba(255, 255, 255, .2) 50%, transparent 50%, transparent);\n    margin: 0;\n    background-size: 700px 700px;\n    height: 1000000px;\n  }\n</style>\n\n<body>\n  <div class=\"circle\">\n  </div>\n</body>"
  },
  {
    "path": "docs/examples/input.html",
    "content": "<head>\n  <script type=\"application/javascript\" src=\"../lib/lax.min.js\"></script>\n  <script type=\"application/javascript\">\n\n    window.onload = function () {\n      lax.init()\n\n      const input = document.getElementById('input')\n\n      // Add lax driver for inputLength\n      lax.addDriver('inputLength', function () {\n        return input.value.length\n      })\n\n      lax.addElements(\"#input\", {\n        'inputLength': {\n          \"rotate\": [\n            [0, 100],\n            [0, 360],\n          ],\n        }\n      })\n    }\n\n  </script>\n</head>\n\n<style>\n  body {\n    padding: 0;\n    margin: 0;\n    font-family: Arial, Helvetica, sans-serif;\n  }\n\n  #input {\n    text-align: center;\n    width: calc(100vw - 200px);\n    transform-origin: center;\n    margin-left: 100px;\n    margin-top: calc(50vh - 50px);\n    position: fixed;\n    font-size: 40px;\n    border: 0;\n    outline: 0;\n    background-color: #f544ad;\n    padding: 20px;\n    box-sizing: border-box;\n    color: white;\n    border-radius: 50px;\n  }\n</style>\n\n<body>\n  <input id='input' placeholder=\"type something...\" autocomplete=\"false\" autofocus />\n</body>"
  },
  {
    "path": "docs/examples/on-update.html",
    "content": "<head>\n  <script type=\"application/javascript\" src=\"../lib/lax.min.js\"></script>\n  <script type=\"application/javascript\">\n\n    window.onload = function () {\n      lax.init()\n\n      lax.addDriver('scrollY', function () {\n        return window.scrollY\n      })\n\n      lax.addElements(\"#text\", {}, {\n        onUpdate: function (driverValues, domElement) {\n          const scrollY = driverValues.scrollY[0]\n\n          const oCount = Math.floor((scrollY / 10) + 1)\n          const oString = Array.from({ length: oCount }, (v, i) => \"o\").join(\"\")\n          domElement.innerHTML = \"scr\" + oString + \"ll\"\n\n          if (scrollY > 1000) {\n            domElement.classList.add('pink')\n          } else {\n            domElement.classList.remove('pink')\n          }\n        }\n      })\n    }\n  </script>\n</head>\n\n<style>\n  #text {\n    width: calc(100vw - 40px);\n    left: 20;\n    top: 20;\n    position: fixed;\n    font-size: 60px;\n    font-family: sans-serif;\n    color: #a26ddc;\n    overflow-wrap: anywhere;\n    font-weight: bold;\n  }\n\n  #text.pink {\n    color: #ff568c;\n  }\n\n  body {\n    padding: 0;\n    background-color: #dedbde;\n    background-image: linear-gradient(rgba(255, 255, 255, .2) 50%, transparent 50%, transparent);\n    margin: 0;\n    background-size: 700px 700px;\n    height: 1000000px;\n  }\n</style>\n\n<body>\n  <div id=\"text\">\n  </div>\n</body>"
  },
  {
    "path": "docs/examples/scroll.html",
    "content": "<head>\n  <script type=\"application/javascript\" src=\"../lib/lax.min.js\"></script>\n  <script type=\"application/javascript\">\n\n    window.onload = function () {\n      lax.init()\n\n      lax.addDriver('scrollY', function () {\n        return window.scrollY\n      })\n\n      const container = document.querySelector('.container')\n      const count = 100\n\n      for (let i = 0; i < count; i++) {\n        const el = document.createElement('div')\n        el.className = \"circle\"\n        container.appendChild(el)\n      }\n\n      lax.addElements(\".circle\", {\n        scrollY: {\n          translateX: [\n            [\"elInY\", \"elCenterY\", \"elOutY\"],\n            [0, 'screenWidth/2', 'screenWidth'],\n            {\n              easing: 'easeInOutQuart',\n            }\n          ],\n          opacity: [\n            [\"elInY\", \"elCenterY\", \"elOutY\"],\n            [0, 1, 0],\n            {\n              easing: 'easeInOutCubic'\n            }\n          ],\n          \"border-radius\": [\n            [\"elInY+200\", \"elCenterY\", \"elOutY-200\"],\n            [0, 100, 0],\n            {\n              easing: 'easeInOutQuint',\n            }\n          ],\n          \"box-shadow\": [\n            [\"elInY+200\", \"elCenterY\", \"elOutY-200\"],\n            [50, 0, 50],\n            {\n              easing: 'easeInOutQuint',\n              cssFn: (val) => {\n                return `${val}px ${val}px ${val}px rgba(0,0,0,0.5)`\n              }\n            }\n          ],\n        }\n      })\n    }\n  </script>\n</head>\n\n<style>\n  .circle {\n    height: 100px;\n    width: 100px;\n    background-color: #a26ddc;\n    margin-bottom: 0px;\n    margin-left: -50px;\n    margin-bottom: 40px;\n    position: relative;\n  }\n\n  .container {\n    padding-top: 50vh;\n    width: 100vw;\n    overflow-y: hidden;\n  }\n\n  body {\n    padding: 0;\n    margin: 0;\n    padding: 0;\n    background-color: #dedbde;\n    background-image: linear-gradient(rgba(255, 255, 255, .2) 50%, transparent 50%, transparent);\n    margin: 0;\n    background-size: 700px 700px;\n  }\n</style>\n\n<body>\n  <div class=\"container\">\n  </div>\n</body>"
  },
  {
    "path": "docs/examples/snap-scroll.html",
    "content": "<head>\n  <script type=\"application/javascript\" src=\"../lib/lax.min.js\"></script>\n  <meta name=\"viewport\" content=\"width=device-width, initial-scale=0.8, maximum-scale=0.8, minimum-scale=0.8\">\n\n  <link href=\"https://fonts.googleapis.com/css2?family=Comfortaa:wght@300;700&display=swap\" rel=\"stylesheet\">\n  <script type=\"application/javascript\">\n\n    window.onload = function () {\n      lax.init()\n\n      const container = document.querySelector('.container')\n\n      lax.addDriver('containerScrollX', function () {\n        return container.scrollLeft\n      })\n\n      lax.addElements(\".bg\", {\n        containerScrollX: {\n          \"opacity\": [\n            [\"screenWidth * (index-1)\", \"screenWidth * index\", \"screenWidth * (index+1)\"],\n            [0, 1, 0],\n          ],\n        }\n      })\n\n      const imageAnimationMap = [\"elCenterX-elWidth\", \"elCenterX\", \"elCenterX+elWidth\"]\n      const textAnimationMap = [\"elCenterX-(elWidth/3)\", \"elCenterX\", \"elCenterX+(elWidth/3)\"]\n\n      lax.addElements(\".page h1\", {\n        containerScrollX: {\n          translateY: [\n            textAnimationMap,\n            [200, 0, 200],\n            {\n              easing: 'easeInOutQuad',\n            }\n          ],\n          opacity: [\n            textAnimationMap,\n            [0, 1, 0],\n          ],\n        }\n      })\n\n      lax.addElements(\".page p\", {\n        containerScrollX: {\n          translateY: [\n            textAnimationMap,\n            [500, 0, 500],\n            {\n              easing: 'easeInOutQuad',\n            }\n          ],\n          opacity: [\n            textAnimationMap,\n            [0, 1, 0],\n          ],\n        }\n      })\n\n      lax.addElements(\".page .image\", {\n        containerScrollX: {\n          translateY: [\n            imageAnimationMap,\n            [-100, 0, -100],\n            {\n              easing: 'easeInOutQuad',\n            }\n          ],\n          scale: [\n            imageAnimationMap,\n            [0.8, 1, 0.8],\n            {\n              easing: 'easeInOutQuad',\n            }\n          ],\n        }\n      })\n    }\n  </script>\n</head>\n\n<style>\n  .background {\n    width: 100vw;\n    height: 100vh;\n    position: fixed;\n    left: 0;\n    background-size: cover;\n  }\n\n  .page {\n    flex-shrink: 0;\n    width: 100vw;\n    height: 100vh;\n    scroll-snap-align: center;\n    scroll-snap-stop: always;\n    position: relative;\n    display: inline-block;\n    background-size: cover;\n  }\n\n  .bg {\n    width: 100vw;\n    height: 100vh;\n    position: fixed;\n    background-size: cover;\n  }\n\n  .image {\n    height: 60vh;\n    width: 80%;\n    left: 10%;\n    position: absolute;\n    transform-origin: center top;\n    background-repeat: no-repeat;\n    background-position: center center;\n    background-size: contain;\n    top: 5vh;\n  }\n\n  .container {\n    display: flex;\n    overflow-x: auto;\n    overflow-y: hidden;\n    scroll-snap-type: x mandatory;\n    direction: ltr;\n    width: 100vw;\n    -webkit-overflow-scrolling: touch;\n  }\n\n  h1 {\n    top: 67vh;\n    position: absolute;\n    width: 100%;\n    font-weight: 100;\n    text-align: center;\n    color: white;\n    font-weight: 800;\n    font-size: 60px;\n  }\n\n  p {\n    top: 70vh;\n    position: absolute;\n    width: 100%;\n    font-weight: 100;\n    text-align: center;\n    color: white;\n    font-size: 18px;\n    line-height: 28px;\n    padding: 10vh;\n    padding-left: 200px;\n    padding-right: 200px;\n    box-sizing: border-box;\n  }\n\n  @media only screen and (max-width: 600px) {\n    p {\n      padding: 50px;\n      top: 55vh;\n    }\n\n    h1 {\n      top: 48vh;\n    }\n\n    .image {\n      top: -2vh;\n    }\n  }\n\n  body {\n    padding: 0;\n    margin: 0;\n    background-color: black;\n    overflow-y: hidden;\n    overflow-x: hidden;\n    font-family: 'Comfortaa', arial;\n  }\n\n  html {\n    height: 100vh;\n    overflow: hidden;\n  }\n\n  #controls {\n    position: fixed;\n    top: 0;\n    left: 0;\n  }\n</style>\n\n<body>\n  <div class=\"background\">\n    <div class=\"bg\" style=\"background-image: url('../assets/bg3.jpg');\"></div>\n    <div class=\"bg\" style=\"background-image: url('../assets/bg1.jpg');\"></div>\n    <div class=\"bg\" style=\"background-image: url('../assets/bg2.jpg');\"></div>\n  </div>\n\n  <div class=\"container\" id=\"scroller\">\n    <div class=\"page\">\n      <div class=\"image\" style=\"background-image: url('../assets/shoe3.png');\"></div>\n      <h1>Superstar</h1>\n      <p>\n        Classics never go out of style. An instant icon since their debut, adidas Superstar Shoes first rose to fame on\n        the basketball courts of the '70s and haven't slowed their roll since.\n      </p>\n    </div>\n\n    <div class=\"page\"\">\n      <div class=\" image\" style=\"background-image: url('../assets/shoe1.png');\"></div>\n    <h1>Retrorun</h1>\n    <p>\n      Retro design with a modern twist. Check out a busy side street or stroll to the corner store in these adidas\n      running-inspired shoes. Suede overlays and contrast 3-Stripes give the flexible upper a sleek, sporty finish.\n    </p>\n  </div>\n\n  <div class=\"page\">\n    <div class=\"image\" style=\"background-image: url('../assets/shoe2.png');\"></div>\n    <h1>Grand Court</h1>\n    <p>\n      A '70s style reborn. These shoes take inspiration from iconic sport styles of the past and move them into the\n      future. The shoes craft an everyday look with a leather-like upper.\n    </p>\n  </div>\n</body>"
  },
  {
    "path": "docs/examples/sprite.html",
    "content": "<head>\n  <script type=\"application/javascript\" src=\"../lib/lax.min.js\"></script>\n  <script type=\"application/javascript\">\n\n    window.onload = function () {\n      lax.init()\n\n      lax.addDriver('scrollY', function () {\n        return window.scrollY\n      })\n\n      const frameWidth = 370\n      const frameCount = 12\n\n      lax.addElements(\".sprite\", {\n        scrollY: {\n          \"background-position\": [\n            [0, 1e9],\n            [0, 1e9],\n            {\n              cssFn: function (val) {\n                const frame = Math.floor(val / 10) % frameCount\n                const x = frame * frameWidth\n\n                return `-${x}px 0px`\n              },\n            }\n          ]\n        }\n      })\n    }\n  </script>\n</head>\n\n<style>\n  .sprite {\n    height: 370px;\n    width: 370px;\n    background-image: url('../assets/spritesheet.jpg');\n    background-repeat: no-repeat;\n    position: fixed;\n    left: calc(50vw - 185px);\n    top: calc(50vh - 185px);\n  }\n\n  body {\n    padding: 0;\n    background-color: #dedbde;\n    background-image: linear-gradient(rgba(255, 255, 255, .2) 50%, transparent 50%, transparent);\n    margin: 0;\n    background-size: 700px 700px;\n    height: 1000000px;\n  }\n</style>\n\n<body>\n  <div class=\"sprite\">\n  </div>\n</body>"
  },
  {
    "path": "docs/index.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n\n<head>\n  <meta name=\"viewport\" content=\"width=device-width, initial-scale=0.5, maximum-scale=0.5, minimum-scale=0.5\">\n\n  <link href=\"https://fonts.googleapis.com/css?family=Montserrat:300,600,800\" rel=\"stylesheet\">\n  <script src=\"./lib/lax.min.js\"></script>\n\n  <script type=\"text/javascript\">\n    window.scrollTo(0, 0)\n\n    window.onload = function () {\n\n      lax.init()\n\n      lax.addDriver(\n        \"scrollY\",\n        function () {\n          return document.documentElement.scrollTop;\n        },\n        { frameStep: 1 }\n      );\n\n      lax.addElements(\".letter-x\", {\n        scrollY: {\n          translateY: [[-400, 0, 100], [300, 0, 100]],\n          scale: [[100, \"screenHeight\"], [0.25, 10]],\n          opacity: [[0, \"screenHeight/2\", \"screenHeight\"], [1, 1, 0]],\n        }\n      });\n\n      lax.addElements(\".letter-l\", {\n        scrollY: {\n          translateY: [[-400, 0], [100, 0]],\n          translateX: [[0, \"screenHeight\"], [0, 400]],\n          opacity: [[0, \"screenHeight/2\"], [1, 0]]\n        }\n      });\n\n      lax.addElements(\".letter-a\", {\n        scrollY: {\n          translateY: [[-400, 0], [200, 0]],\n          translateX: [[0, \"screenHeight\"], [0, -400]],\n          opacity: [[0, \"screenHeight/2\"], [1, 0]]\n        }\n      });\n\n      lax.addElements(\".scrolldown\", {\n        scrollY: {\n          \"letter-spacing\": [\n            [0, \"screenHeight\"],\n            [0, 150],\n            {\n              cssUnit: \"px\"\n            }\n          ],\n          opacity: [[\"screenHeight*0.25\", \"screenHeight*0.75\"], [1, 0]],\n          translateX: [[0, \"screenHeight\"], [0, 80]],\n        }\n      });\n\n      lax.addElements(\".oooh\", {\n        scrollY: {\n          translateX: [[\"elInY\", \"elOutY\"], [0, \"screenWidth-200\"]]\n        }\n      });\n\n      lax.addElements(\".aaah\", {\n        scrollY: {\n          translateX: [[\"elInY\", \"elOutY\"], [0, \"-screenWidth-200\"]]\n        }\n      });\n\n      lax.addElements(\".wheee\", {\n        scrollY: {\n          translateX: [[\"elInY\", \"elOutY\"], [-400, \"screenWidth+100\"]],\n          skewX: [[\"elInY\", \"elOutY\"], [40, -40]],\n        }\n      });\n\n      lax.addElements(\".bubble\", {\n        scrollY: {\n          translateY: [\n            [\"screenHeight/4\", \"screenHeight * 3\"],\n            [\"Math.random()*screenHeight\", \"Math.random()*screenHeight*3\"]\n          ],\n          opacity: [\n            [\"screenHeight/4\", \"screenHeight/2\"],\n            [0, 1]\n          ],\n          scale: [[0], [\"(Math.random()*0.8)+0.2\"]],\n          translateX: [[0], [\"index*(screenWidth/25)-50\"]],\n          transform: [\n            [0, 4000],\n            [0, \"(Math.random() + 0.8) * 1000\"],\n            {\n              cssFn: function (val) {\n                return `rotateX(${val % 360}deg)`\n              }\n            }\n          ],\n          rotate: [\n            [0, 4000],\n            [0, \"(Math.random() - 0.5) * 1000\"],\n          ],\n        }\n      });\n\n      lax.addElements('#pinkZag', {\n        scrollY: {\n          translateY: [\n            [\"elInY\", \"elOutY\"],\n            [0, -300]\n          ],\n        }\n      })\n\n      lax.addElements('#tealZag', {\n        scrollY: {\n          translateY: [\n            [\"elInY\", \"elOutY\"],\n            [0, 200]\n          ],\n        }\n      })\n\n      lax.addElements('#purpleZag', {\n        scrollY: {\n          translateY: [\n            [\"elInY\", \"elOutY\"],\n            [0, 700]\n          ],\n        }\n      })\n\n      lax.addElements(\".downarrows img\", {\n        scrollY: {\n          translateY: [\n            [0, 200],\n            [0, 200]\n          ],\n          opacity: [\n            [0, \"screenHeight\"],\n            [1, 0]\n          ]\n        }\n      })\n\n      lax.addElements(\".bottombutton\", {\n        scrollY: {\n          \"background-position\": [\n            [\"elInY\", \"elOutY\"],\n            [0, 400],\n            {\n              cssFn: function (val) {\n                return `${val}px 0`\n              }\n            }\n          ],\n          scale: [\n            [\"elInY\", \"elCenterY\"],\n            [3, 1],\n          ]\n        },\n\n      })\n    }\n  </script>\n\n  <style>\n    html {\n      overflow-x: hidden;\n      width: 100%;\n    }\n\n    body {\n      padding: 0;\n      overflow-x: hidden;\n      width: 100%;\n      background-color: #242224;\n      margin: 0;\n      height: 480vh;\n      color: white;\n      font-family: \"Montserrat\", sans-serif;\n      position: relative;\n    }\n\n    .bottombutton {\n      background-image: url(./assets/button-bg.jpg);\n      width: 250px;\n      height: 70px;\n      background-size: 160px;\n      color: white;\n      font-weight: 800;\n      text-align: center;\n      line-height: 70px;\n      font-size: 30px;\n      text-decoration: none;\n      position: absolute;\n      top: 425vh;\n      border-radius: 20px;\n      left: 50vw;\n      margin-left: -125px;\n      z-index: 100;\n      pointer-events: all;\n      cursor: pointer;\n    }\n\n    .bottombg {\n      background-color: #8d77ed;\n      width: 100vw;\n      height: 100vh;\n      top: 380vh;\n      z-index: 50;\n      position: absolute;\n    }\n\n    .letter-l {\n      margin-top: 100px;\n      width: 200px;\n      left: 50vw;\n      margin-left: -75px;\n      position: fixed;\n      left: 50vw;\n      margin-left: -75px;\n    }\n\n    .letter-a {\n      margin-top: 158px;\n      position: fixed;\n      left: 50vw;\n      margin-left: -77px;\n      width: 150px;\n    }\n\n    .letter-x {\n      margin-top: 85px;\n      position: fixed;\n      left: 50vw;\n      margin-left: -300px;\n      transform: scale(0.25);\n      transform-origin: 50% 50%;\n      width: 600px;\n      height: 600px;\n    }\n\n    .letter-x img {\n      width: 600px;\n      position: absolute;\n    }\n\n    .scrolldown {\n      bottom: 90px;\n      height: 40px;\n      position: fixed;\n      width: 300vw;\n      left: -100vw;\n      font-size: 40px;\n      text-align: center;\n    }\n\n    .oooh {\n      font-size: 150px;\n      position: absolute;\n      left: 0;\n      top: 140vh;\n    }\n\n    .aaah {\n      font-size: 150px;\n      position: absolute;\n      right: 0;\n      top: 170vh;\n    }\n\n    .wheee {\n      top: 230vh;\n      position: absolute;\n      left: 0;\n      height: 50px;\n      font-size: 100px;\n    }\n\n    .downarrows {\n      bottom: 60px;\n      position: fixed;\n      left: 50vw;\n      width: 70px;\n      margin-left: -35px;\n      height: 26px;\n    }\n\n    .downarrows img {\n      width: 70px;\n      position: absolute;\n    }\n\n    .bubbles {\n      top: -100vh;\n      position: fixed;\n      -webkit-transform: translate3d(0, 0, 0);\n      z-index: 5;\n    }\n\n    .bubble {\n      width: 140px;\n      height: 140px;\n      opacity: 1;\n      position: absolute;\n    }\n\n    .bubble.red {\n      background: #a94fe4;\n    }\n\n    .bubble.blue {\n      background: #68e4f1;\n    }\n\n    .bubble.yellow {\n      background: #ffe773;\n    }\n\n    .zags {\n      margin-top: 250vh;\n      z-index: 100;\n      position: relative;\n      overflow: hidden;\n      height: 150vh;\n    }\n\n    .zag {\n      width: 100vw;\n      height: 150vh;\n      position: absolute;\n    }\n\n    #pinkZag {\n      background-image: url(./assets/pink-zag.png);\n      background-size: 200px;\n      background-repeat: repeat-x;\n      background-position-y: bottom;\n    }\n\n    #tealZag {\n      background-image: url(./assets/teal-zag.png);\n      background-size: 200px;\n      background-repeat: repeat-x;\n      background-position-y: bottom;\n    }\n\n    #purpleZag {\n      background-image: url(./assets/purple-zag.png);\n      background-size: 200px;\n      background-repeat: repeat-x;\n      background-position-y: bottom;\n    }\n\n    .bottom {\n      margin-top: 400vh;\n    }\n  </style>\n</head>\n\n\n<body>\n  <img src=\"./assets/l.png\" class=\"letter-l\" />\n  <img src=\"./assets/a.png\" class=\"letter-a\" />\n  <div class=\"letter-x\">\n    <img src=\"./assets/x.png\" />\n  </div>\n\n  <h2 class=\"scrolldown\">scroll down</h2>\n\n  <div class=\"downarrows\">\n    <img src=\"./assets/downarrow.png\" />\n  </div>\n\n  <div class=\"zags\">\n    <div id=\"pinkZag\" class=\"zag\"></div>\n    <div id=\"tealZag\" class=\"zag\"></div>\n    <div id=\"purpleZag\" class=\"zag\"></div>\n  </div>\n\n  <div class=\"bubbles\">\n    <div class=\"bubble blue\"></div>\n    <div class=\"bubble red\"></div>\n    <div class=\"bubble yellow\"></div>\n    <div class=\"bubble red\"></div>\n    <div class=\"bubble blue\"></div>\n    <div class=\"bubble yellow\"></div>\n    <div class=\"bubble blue\"></div>\n    <div class=\"bubble red\"></div>\n    <div class=\"bubble yellow\"></div>\n    <div class=\"bubble red\"></div>\n    <div class=\"bubble blue\"></div>\n    <div class=\"bubble blue\"></div>\n    <div class=\"bubble red\"></div>\n    <div class=\"bubble yellow\"></div>\n    <div class=\"bubble red\"></div>\n    <div class=\"bubble blue\"></div>\n    <div class=\"bubble yellow\"></div>\n    <div class=\"bubble blue\"></div>\n    <div class=\"bubble red\"></div>\n    <div class=\"bubble yellow\"></div>\n    <div class=\"bubble red\"></div>\n    <div class=\"bubble blue\"></div>\n    <div class=\"bubble yellow\"></div>\n    <div class=\"bubble blue\"></div>\n    <div class=\"bubble red\"></div>\n  </div>\n\n  <h1 class=\"oooh\">oooh</h1>\n  <h1 class=\"aaah\">aaah</h1>\n\n  <h1 class=\"wheee\">wheee!</h1>\n\n  <div class=\"bottombg\"></div>\n\n  <a href=\"https://github.com/alexfoxy/lax.js\">\n    <div class=\"bottombutton\">\n      Get lax.js\n    </div>\n  </a>\n\n\n  <a href=\"https://github.com/alexfoxy/lax.js\" class=\"github-corner\" aria-label=\"View source on GitHub\"><svg width=\"80\"\n      height=\"80\" viewBox=\"0 0 250 250\"\n      style=\"fill:#fff; color:#151513; position: absolute; top: 0; border: 0; right: 0;\" aria-hidden=\"true\">\n      <path d=\"M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z\"></path>\n      <path\n        d=\"M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2\"\n        fill=\"currentColor\" style=\"transform-origin: 130px 106px;\" class=\"octo-arm\"></path>\n      <path\n        d=\"M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z\"\n        fill=\"currentColor\" class=\"octo-body\"></path>\n    </svg></a>\n  <style>\n    .github-corner:hover .octo-arm {\n      animation: octocat-wave 560ms ease-in-out\n    }\n\n    @keyframes octocat-wave {\n\n      0%,\n      100% {\n        transform: rotate(0)\n      }\n\n      20%,\n      60% {\n        transform: rotate(-25deg)\n      }\n\n      40%,\n      80% {\n        transform: rotate(10deg)\n      }\n    }\n\n    @media (max-width:500px) {\n      .github-corner:hover .octo-arm {\n        animation: none\n      }\n\n      .github-corner .octo-arm {\n        animation: octocat-wave 560ms ease-in-out\n      }\n    }\n  </style>\n</body>"
  },
  {
    "path": "docs/preset-explorer.html",
    "content": "<head>\n  <script src=\"https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js\"></script>\n\n  <script type=\"application/javascript\" src=\"./lib/lax.min.js\"></script>\n  <script type=\"application/javascript\">\n\n    window.copyPreset = function () {\n      const input = document.getElementById(\"presetString\")\n\n      input.select()\n      input.setSelectionRange(0, 99999)\n\n      document.execCommand(\"copy\")\n\n      alert(\"Copied the text: \" + input.value)\n    }\n\n    window.onload = function () {\n\n      /*\n        Setup control data\n      */\n\n      const baseSettings = {\n        fade: [\n          {\n            name: 'Distance',\n            limits: [100, window.innerHeight / 3],\n            value: window.innerHeight / 4\n          },\n          {\n            name: 'Starting Opacity',\n            limits: [0, 0.9],\n            step: 0.1,\n            value: 0\n          }\n        ],\n        blur: [\n          {\n            name: 'Distance',\n            limits: [100, window.innerHeight / 3],\n            value: window.innerHeight / 4\n          },\n          {\n            name: 'Strength',\n            limits: [0, 50],\n            value: 20\n          }\n        ],\n        spin: [\n          {\n            name: 'Distance',\n            limits: [10, 3000],\n            value: window.innerHeight\n          },\n          {\n            name: 'Stength',\n            limits: [1, 360],\n            value: 360\n          }\n        ],\n        scale: [\n          {\n            name: 'Distance',\n            limits: [50, window.innerHeight / 3],\n            value: window.innerHeight / 4\n          },\n          {\n            name: 'Starting Scale',\n            limits: [0, 1],\n            step: 0.1,\n            value: 0.6\n          }\n        ],\n        slide: [\n          {\n            name: 'Distance',\n            limits: [50, window.innerHeight],\n            value: window.innerHeight / 4\n          },\n          {\n            name: 'Amount',\n            limits: [-1000, 1000],\n            value: 500\n          }\n        ]\n      }\n\n      const enabledPresets = [\"fadeInOut\", \"seesaw\"]\n\n      const controlData = {\n        fadeIn: [...baseSettings.fade],\n        fadeOut: [...baseSettings.fade],\n        fadeInOut: [...baseSettings.fade],\n        scaleIn: [...baseSettings.scale],\n        scaleOut: [...baseSettings.scale],\n        scaleInOut: [...baseSettings.scale],\n        slideX: [...baseSettings.slide],\n        slideY: [...baseSettings.slide],\n        jiggle: [\n          {\n            name: 'Distance',\n            limits: [40, 200],\n            value: 50\n          },\n          {\n            name: 'Stength',\n            limits: [1, 100],\n            value: 20\n          }\n        ],\n        seesaw: [\n          {\n            name: 'Distance',\n            limits: [40, 200],\n            value: 140\n          },\n          {\n            name: 'Stength',\n            limits: [1, 40],\n            value: 20\n          }\n        ],\n        zigzag: [\n          {\n            name: 'Distance',\n            limits: [40, 200],\n            value: 170\n          },\n          {\n            name: 'Stength',\n            limits: [1, 500],\n            value: 200\n          }\n        ],\n        hueRotate: [...baseSettings.spin],\n        spin: [...baseSettings.spin],\n        flipX: [...baseSettings.spin],\n        flipY: [...baseSettings.spin],\n        blurIn: [...baseSettings.blur],\n        blurOur: [...baseSettings.blur],\n        blurInOut: [...baseSettings.blur],\n      }\n\n      /* \n        UI Update methods\n      */\n\n      function updateLaxSettings() {\n        lax.removeElements(\"#laxLogo\")\n\n        const presets = []\n\n        enabledPresets.forEach((presetName) => {\n          const control = controlData[presetName]\n          const controlStr = control ? \":\" + control.map(c => c.value).join(\":\") : ''\n          const settingString = `${presetName}${controlStr}`\n          presets.push(settingString)\n        })\n\n        lax.addElements(\"#laxLogo\", {\n          scrollY: {\n            presets\n          }\n        })\n\n        presetString.value = presets.map((p) => {\n          return `lax_preset_${p}`\n        }).join(\" \")\n      }\n\n      function onSliderUpdate(name, value) {\n        const valueEl = document.getElementById(name + '-value')\n        if (valueEl) valueEl.innerHTML = value\n        updateLaxSettings()\n      }\n\n      function onCheckBoxUpdate(controlName) {\n        const index = enabledPresets.indexOf(controlName)\n        const enabled = index >= 0\n        const sliders = document.getElementById(controlName + \"-controls\")\n\n        if (enabled) {\n          enabledPresets.splice(index, 1)\n          if (sliders) sliders.classList.remove('visible')\n        } else {\n          enabledPresets.push(controlName)\n          if (sliders) sliders.classList.add('visible')\n        }\n\n        const checkbox = document.getElementById(controlName + \"-checkbox\")\n        if (checkbox) checkbox.checked = !enabled\n      }\n\n      /*\n        Build UI\n      */\n\n      const controlsContainer = document.getElementById('controlsContainer')\n      const presetString = document.getElementById('presetString')\n\n      function renderSlider(control, controlName) {\n        const container = document.createElement('div')\n        container.className = \"slider\"\n\n        const slider = document.createElement('input')\n        const id = [controlName.toLowerCase(), control.name.toLowerCase()].join(\"-\")\n\n        slider.type = 'range'\n        slider.min = control.limits[0]\n        slider.max = control.limits[1]\n        slider.step = control.step || 1\n        slider.value = control.value\n        slider.oninput = function (el) {\n          control.value = el.target.value\n          onSliderUpdate(id, el.target.value)\n        }\n\n        const labelContainer = document.createElement('div')\n        labelContainer.className = \"labelContainer\"\n\n        const label = document.createElement('label')\n        label.innerHTML = control.name\n\n        const value = document.createElement('label')\n        value.innerHTML = control.value\n        value.id = id + \"-value\"\n\n        labelContainer.appendChild(label)\n        labelContainer.appendChild(value)\n        container.appendChild(labelContainer)\n        container.appendChild(slider)\n\n        return container\n      }\n\n      function renderCheckbox(controlName) {\n        const container = document.createElement('div')\n        container.className = \"checkBox\"\n\n        const checkbox = document.createElement('input')\n        checkbox.id = controlName + \"-checkbox\"\n        checkbox.type = \"checkbox\"\n\n        const enabled = enabledPresets.indexOf(controlName) > -1\n        checkbox.checked = enabled\n\n        const id = [controlName.toLowerCase(), name.toLowerCase()].join()\n\n        checkbox.oninput = function (el) {\n          [\"blur\", \"scale\", \"fade\"].forEach((type) => {\n            if (controlName.includes(type)) {\n              enabledPresets.forEach((presetName) => {\n                if (presetName !== controlName && presetName.includes(type)) {\n                  onCheckBoxUpdate(presetName, true)\n                }\n              })\n            }\n          })\n\n          onCheckBoxUpdate(controlName, enabled)\n          updateLaxSettings()\n        }\n\n        const label = document.createElement('label')\n        label.innerHTML = controlName\n\n        container.appendChild(label)\n        container.appendChild(checkbox)\n\n        return container\n      }\n\n      function renderControl(controlName) {\n        const controls = controlData[controlName]\n        const container = document.createElement('div')\n        container.className = 'control'\n\n        const checkbox = renderCheckbox(controlName)\n        container.appendChild(checkbox)\n\n        const sliderControls = document.createElement('div')\n        sliderControls.className = 'sliderControls'\n        sliderControls.id = controlName + \"-controls\"\n\n        controls.forEach((control, i) => {\n          const slider = renderSlider(control, controlName)\n          sliderControls.appendChild(slider)\n        })\n\n        const enabled = enabledPresets.indexOf(controlName) > -1\n        if (enabled) sliderControls.classList.add(\"visible\")\n\n        container.appendChild(sliderControls)\n        controlsContainer.appendChild(container)\n      }\n\n      Object.keys(controlData).forEach((controlName) => renderControl(controlName))\n\n      /*\n        Initialise lax\n      */\n\n      lax.init()\n\n      lax.addDriver('scrollY', function () {\n        return window.scrollY\n      })\n\n      updateLaxSettings()\n    }\n\n  </script>\n</head>\n\n<style>\n  body {\n    padding: 0;\n    background-color: #dedbde;\n    background-image: linear-gradient(rgba(255, 255, 255, .2) 50%, transparent 50%, transparent);\n    margin: 0;\n    background-size: 700px 700px;\n    height: 220vh;\n    font-family: 'Montserrat', sans-serif;\n    overflow-x: hidden;\n  }\n\n  #laxLogo {\n    margin-top: 100vh;\n    left: 0;\n    z-index: 1000;\n    font-size: 100px;\n    text-align: center;\n    transform-origin: 50% 50%;\n    color: #a94fe4;\n    width: 240px;\n    margin-left: calc(50vw - 150px - 120px);\n    position: absolute;\n    pointer-events: none;\n  }\n\n  .hint {\n    left: 0;\n    width: 100%;\n    opacity: 0.2;\n    z-index: 1000;\n    font-size: 24px;\n    text-align: center;\n    position: absolute;\n    margin-bottom: 0;\n  }\n\n  #controlsContainer {\n    position: fixed;\n    width: 300px;\n    background: white;\n    height: 100vh;\n    box-shadow: 0px 0px 15px 3px rgba(0, 0, 0, 0.2);\n    padding: 20;\n    box-sizing: border-box;\n    overflow-y: auto;\n    padding-bottom: 100px;\n  }\n\n  #controlsContainer h1 {\n    margin: 0;\n    font-size: 20px;\n    margin-bottom: 20px;\n  }\n\n  #canvas {\n    width: calc(100vw - 300px);\n    margin-left: 300px;\n    position: relative;\n    height: 220vh;\n  }\n\n  #presetString {\n    background: #4a525a;\n    color: white;\n    font-family: monospace;\n    padding: 10px;\n    border: 0;\n    border-radius: 10px;\n    width: 195px;\n    margin-right: 5px;\n    outline: none;\n  }\n\n  #presetStringContainer {\n    position: fixed;\n    bottom: 0;\n    background: #e1e8e8;\n    left: 0;\n    width: 260px;\n    padding: 20px 20px;\n  }\n\n  .control {\n    border-top: 1px solid #d8d7d7;\n  }\n\n  .checkBox,\n  .labelContainer {\n    display: flex;\n    align-items: baseline;\n    justify-content: space-between;\n    ;\n  }\n\n  .sliderControls {\n    height: 0px;\n    overflow-y: hidden;\n    overflow-x: visible;\n    transition: height 200ms ease-out;\n  }\n\n  .sliderControls.visible {\n    height: 105px;\n  }\n\n  .slider input {\n    width: 100%;\n    margin-bottom: 10px;\n    margin-top: 5px;\n  }\n\n  label {\n    font-weight: lighter;\n    font-size: 14px;\n  }\n\n  .checkBox label {\n    font-weight: 800;\n    margin-bottom: 15px;\n    margin-top: 15px;\n  }\n\n  #copyButton {\n    border: 0;\n    width: 55px;\n    height: 36px;\n    padding: 0;\n    margin: 0;\n    background: #a26ddc;\n    border-radius: 10px;\n    font-family: inherit;\n    font-weight: bold;\n    color: white;\n    outline: none;\n  }\n\n  #copyButton:hover {\n    opacity: 0.8;\n    cursor: pointer;\n  }\n\n  #presetTextHelper {\n    margin-bottom: 10px;\n    font-size: 12px;\n    display: flex;\n    justify-content: space-between;\n  }\n</style>\n\n<body>\n  <div id=\"controlsContainer\">\n    <h1>Lax preset explorer</h1>\n\n    <div id=\"presetStringContainer\">\n      <div id=\"presetTextHelper\">\n        <span>Preset code</span>\n        <a href=\"https://github.com/alexfoxy/lax.js#using-presets\">How to use</a>\n      </div>\n\n      <input id=\"presetString\" />\n      <button onclick=\"copyPreset()\" id=\"copyButton\">Copy</button>\n    </div>\n  </div>\n\n  <div id=\"canvas\">\n    <h4 class='hint' style=\"top: 120px;\">Scroll Down..</h4>\n    <h4 class='hint' style=\"bottom: 140px;\">Scroll Up..</h4>\n\n    <img src=\"assets/lax.png\" id=\"laxLogo\" />\n  </div>\n\n</body>"
  },
  {
    "path": "jsconfig.json",
    "content": "{\n  \"compilerOptions\": {\n    \"checkJs\": true\n  },\n}"
  },
  {
    "path": "lib/lax.js",
    "content": "\"use strict\";\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nfunction _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }\n\nfunction _nonIterableRest() { throw new TypeError(\"Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\n\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\n\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }\n\nfunction _iterableToArrayLimit(arr, i) { if (typeof Symbol === \"undefined\" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i[\"return\"] != null) _i[\"return\"](); } finally { if (_d) throw _e; } } return _arr; }\n\nfunction _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }\n\n(function () {\n  var inOutMap = function inOutMap() {\n    var y = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 30;\n    return [\"elInY+elHeight\", \"elCenterY-\".concat(y), \"elCenterY\", \"elCenterY+\".concat(y), \"elOutY-elHeight\"];\n  };\n\n  var laxPresets = {\n    fadeInOut: function fadeInOut() {\n      var y = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 30;\n      var str = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;\n      return {\n        \"opacity\": [inOutMap(y), [str, 1, 1, 1, str]]\n      };\n    },\n    fadeIn: function fadeIn() {\n      var y = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'elCenterY';\n      var str = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;\n      return {\n        \"opacity\": [[\"elInY+elHeight\", y], [str, 1]]\n      };\n    },\n    fadeOut: function fadeOut() {\n      var y = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'elCenterY';\n      var str = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;\n      return {\n        \"opacity\": [[y, \"elOutY-elHeight\"], [1, str]]\n      };\n    },\n    blurInOut: function blurInOut() {\n      var y = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 100;\n      var str = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 20;\n      return {\n        \"blur\": [inOutMap(y), [str, 0, 0, 0, str]]\n      };\n    },\n    blurIn: function blurIn() {\n      var y = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'elCenterY';\n      var str = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 20;\n      return {\n        \"blur\": [[\"elInY+elHeight\", y], [str, 0]]\n      };\n    },\n    blurOut: function blurOut() {\n      var y = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'elCenterY';\n      var str = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 20;\n      return {\n        \"opacity\": [[y, \"elOutY-elHeight\"], [0, str]]\n      };\n    },\n    scaleInOut: function scaleInOut() {\n      var y = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 100;\n      var str = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0.6;\n      return {\n        \"scale\": [inOutMap(y), [str, 1, 1, 1, str]]\n      };\n    },\n    scaleIn: function scaleIn() {\n      var y = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'elCenterY';\n      var str = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0.6;\n      return {\n        \"scale\": [[\"elInY+elHeight\", y], [str, 1]]\n      };\n    },\n    scaleOut: function scaleOut() {\n      var y = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'elCenterY';\n      var str = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0.6;\n      return {\n        \"scale\": [[y, \"elOutY-elHeight\"], [1, str]]\n      };\n    },\n    slideX: function slideX() {\n      var y = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;\n      var str = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 500;\n      return {\n        \"translateX\": [['elInY', y], [0, str]]\n      };\n    },\n    slideY: function slideY() {\n      var y = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;\n      var str = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 500;\n      return {\n        \"translateY\": [['elInY', y], [0, str]]\n      };\n    },\n    spin: function spin() {\n      var y = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1000;\n      var str = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 360;\n      return {\n        \"rotate\": [[0, y], [0, str], {\n          modValue: y\n        }]\n      };\n    },\n    flipX: function flipX() {\n      var y = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1000;\n      var str = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 360;\n      return {\n        \"rotateX\": [[0, y], [0, str], {\n          modValue: y\n        }]\n      };\n    },\n    flipY: function flipY() {\n      var y = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1000;\n      var str = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 360;\n      return {\n        \"rotateY\": [[0, y], [0, str], {\n          modValue: y\n        }]\n      };\n    },\n    jiggle: function jiggle() {\n      var y = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 50;\n      var str = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 40;\n      return {\n        \"skewX\": [[0, y * 1, y * 2, y * 3, y * 4], [0, str, 0, -str, 0], {\n          modValue: y * 4\n        }]\n      };\n    },\n    seesaw: function seesaw() {\n      var y = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 50;\n      var str = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 40;\n      return {\n        \"skewY\": [[0, y * 1, y * 2, y * 3, y * 4], [0, str, 0, -str, 0], {\n          modValue: y * 4\n        }]\n      };\n    },\n    zigzag: function zigzag() {\n      var y = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 100;\n      var str = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 100;\n      return {\n        \"translateX\": [[0, y * 1, y * 2, y * 3, y * 4], [0, str, 0, -str, 0], {\n          modValue: y * 4\n        }]\n      };\n    },\n    hueRotate: function hueRotate() {\n      var y = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 600;\n      var str = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 360;\n      return {\n        \"hue-rotate\": [[0, y], [0, str], {\n          modValue: y\n        }]\n      };\n    }\n  };\n\n  var laxInstance = function () {\n    var transformKeys = [\"perspective\", \"scaleX\", \"scaleY\", \"scale\", \"skewX\", \"skewY\", \"skew\", \"rotateX\", \"rotateY\", \"rotate\"];\n    var filterKeys = [\"blur\", \"hue-rotate\", \"brightness\"];\n    var translate3dKeys = [\"translateX\", \"translateY\", \"translateZ\"];\n    var pxUnits = [\"perspective\", \"border-radius\", \"blur\", \"translateX\", \"translateY\", \"translateZ\"];\n    var degUnits = [\"hue-rotate\", \"rotate\", \"rotateX\", \"rotateY\", \"skew\", \"skewX\", \"skewY\"];\n\n    function getArrayValues(arr, windowWidth) {\n      if (Array.isArray(arr)) return arr;\n      var keys = Object.keys(arr).map(function (x) {\n        return parseInt(x);\n      }).sort(function (a, b) {\n        return a > b ? 1 : -1;\n      });\n      var retKey = keys[keys.length - 1];\n\n      for (var i = 0; i < keys.length; i++) {\n        var key = keys[i];\n\n        if (windowWidth < key) {\n          retKey = key;\n          break;\n        }\n      }\n\n      return arr[retKey];\n    }\n\n    function lerp(start, end, t) {\n      return start * (1 - t) + end * t;\n    }\n\n    function invlerp(a, b, v) {\n      return (v - a) / (b - a);\n    }\n\n    function interpolate(arrA, arrB, v, easingFn) {\n      var k = 0;\n      arrA.forEach(function (a) {\n        if (a < v) k++;\n      });\n\n      if (k <= 0) {\n        return arrB[0];\n      }\n\n      if (k >= arrA.length) {\n        return arrB[arrA.length - 1];\n      }\n\n      var j = k - 1;\n      var vector = invlerp(arrA[j], arrA[k], v);\n      if (easingFn) vector = easingFn(vector);\n      var lerpVal = lerp(arrB[j], arrB[k], vector);\n      return lerpVal;\n    }\n\n    var easings = {\n      easeInQuad: function easeInQuad(t) {\n        return t * t;\n      },\n      easeOutQuad: function easeOutQuad(t) {\n        return t * (2 - t);\n      },\n      easeInOutQuad: function easeInOutQuad(t) {\n        return t < .5 ? 2 * t * t : -1 + (4 - 2 * t) * t;\n      },\n      easeInCubic: function easeInCubic(t) {\n        return t * t * t;\n      },\n      easeOutCubic: function easeOutCubic(t) {\n        return --t * t * t + 1;\n      },\n      easeInOutCubic: function easeInOutCubic(t) {\n        return t < .5 ? 4 * t * t * t : (t - 1) * (2 * t - 2) * (2 * t - 2) + 1;\n      },\n      easeInQuart: function easeInQuart(t) {\n        return t * t * t * t;\n      },\n      easeOutQuart: function easeOutQuart(t) {\n        return 1 - --t * t * t * t;\n      },\n      easeInOutQuart: function easeInOutQuart(t) {\n        return t < .5 ? 8 * t * t * t * t : 1 - 8 * --t * t * t * t;\n      },\n      easeInQuint: function easeInQuint(t) {\n        return t * t * t * t * t;\n      },\n      easeOutQuint: function easeOutQuint(t) {\n        return 1 + --t * t * t * t * t;\n      },\n      easeInOutQuint: function easeInOutQuint(t) {\n        return t < .5 ? 16 * t * t * t * t * t : 1 + 16 * --t * t * t * t * t;\n      },\n      easeOutBounce: function easeOutBounce(t) {\n        var n1 = 7.5625;\n        var d1 = 2.75;\n\n        if (t < 1 / d1) {\n          return n1 * t * t;\n        } else if (t < 2 / d1) {\n          return n1 * (t -= 1.5 / d1) * t + 0.75;\n        } else if (t < 2.5 / d1) {\n          return n1 * (t -= 2.25 / d1) * t + 0.9375;\n        } else {\n          return n1 * (t -= 2.625 / d1) * t + 0.984375;\n        }\n      },\n      easeInBounce: function easeInBounce(t) {\n        return 1 - easings.easeOutBounce(1 - t);\n      },\n      easeOutBack: function easeOutBack(t) {\n        var c1 = 1.70158;\n        var c3 = c1 + 1;\n        return 1 + c3 * Math.pow(t - 1, 3) + c1 * Math.pow(t - 1, 2);\n      },\n      easeInBack: function easeInBack(t) {\n        var c1 = 1.70158;\n        var c3 = c1 + 1;\n        return c3 * t * t * t - c1 * t * t;\n      }\n    };\n\n    function flattenStyles(styles) {\n      var flattenedStyles = {\n        transform: '',\n        filter: ''\n      };\n      var translate3dValues = {\n        translateX: 0.00001,\n        translateY: 0.00001,\n        translateZ: 0.00001\n      };\n      Object.keys(styles).forEach(function (key) {\n        var val = styles[key];\n        var unit = pxUnits.includes(key) ? 'px' : degUnits.includes(key) ? 'deg' : '';\n\n        if (translate3dKeys.includes(key)) {\n          translate3dValues[key] = val;\n        } else if (transformKeys.includes(key)) {\n          flattenedStyles.transform += \"\".concat(key, \"(\").concat(val).concat(unit, \") \");\n        } else if (filterKeys.includes(key)) {\n          flattenedStyles.filter += \"\".concat(key, \"(\").concat(val).concat(unit, \") \");\n        } else {\n          flattenedStyles[key] = \"\".concat(val).concat(unit, \" \");\n        }\n      });\n      flattenedStyles.transform = \"translate3d(\".concat(translate3dValues.translateX, \"px, \").concat(translate3dValues.translateY, \"px, \").concat(translate3dValues.translateZ, \"px) \").concat(flattenedStyles.transform);\n      return flattenedStyles;\n    } // https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollY#Notes\n\n\n    function getScrollPosition() {\n      var supportPageOffset = window.pageXOffset !== undefined;\n      var isCSS1Compat = (document.compatMode || '') === 'CSS1Compat';\n      var x = supportPageOffset ? window.pageXOffset : isCSS1Compat ? document.documentElement.scrollLeft : document.body.scrollLeft;\n      var y = supportPageOffset ? window.pageYOffset : isCSS1Compat ? document.documentElement.scrollTop : document.body.scrollTop;\n      return [y, x];\n    }\n\n    function parseValue(val, _ref, index) {\n      var width = _ref.width,\n          height = _ref.height,\n          x = _ref.x,\n          y = _ref.y;\n\n      if (typeof val === 'number') {\n        return val;\n      }\n\n      var pageHeight = document.body.scrollHeight;\n      var pageWidth = document.body.scrollWidth;\n      var screenWidth = window.innerWidth;\n      var screenHeight = window.innerHeight;\n\n      var _getScrollPosition = getScrollPosition(),\n          _getScrollPosition2 = _slicedToArray(_getScrollPosition, 2),\n          scrollTop = _getScrollPosition2[0],\n          scrollLeft = _getScrollPosition2[1];\n\n      var left = x + scrollLeft;\n      var right = left + width;\n      var top = y + scrollTop;\n      var bottom = top + height;\n      return Function(\"return \".concat(val.replace(/screenWidth/g, screenWidth).replace(/screenHeight/g, screenHeight).replace(/pageHeight/g, pageHeight).replace(/pageWidth/g, pageWidth).replace(/elWidth/g, width).replace(/elHeight/g, height).replace(/elInY/g, top - screenHeight).replace(/elOutY/g, bottom).replace(/elCenterY/g, top + height / 2 - screenHeight / 2).replace(/elInX/g, left - screenWidth).replace(/elOutX/g, right).replace(/elCenterX/g, left + width / 2 - screenWidth / 2).replace(/index/g, index)))();\n    }\n\n    var LaxDriver = function LaxDriver(name, getValueFn) {\n      var _this = this;\n\n      var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n\n      _classCallCheck(this, LaxDriver);\n\n      _defineProperty(this, \"getValueFn\", void 0);\n\n      _defineProperty(this, \"name\", '');\n\n      _defineProperty(this, \"lastValue\", 0);\n\n      _defineProperty(this, \"frameStep\", 1);\n\n      _defineProperty(this, \"m1\", 0);\n\n      _defineProperty(this, \"m2\", 0);\n\n      _defineProperty(this, \"inertia\", 0);\n\n      _defineProperty(this, \"inertiaEnabled\", false);\n\n      _defineProperty(this, \"getValue\", function (frame) {\n        var value = _this.lastValue;\n\n        if (frame % _this.frameStep === 0) {\n          value = _this.getValueFn(frame);\n        }\n\n        if (_this.inertiaEnabled) {\n          var delta = value - _this.lastValue;\n          var damping = 0.8;\n          _this.m1 = _this.m1 * damping + delta * (1 - damping);\n          _this.m2 = _this.m2 * damping + _this.m1 * (1 - damping);\n          _this.inertia = Math.round(_this.m2 * 5000) / 15000;\n        }\n\n        _this.lastValue = value;\n        return [_this.lastValue, _this.inertia];\n      });\n\n      this.name = name;\n      this.getValueFn = getValueFn;\n      Object.keys(options).forEach(function (key) {\n        _this[key] = options[key];\n      });\n      this.lastValue = this.getValueFn(0);\n    };\n\n    var LaxElement = function LaxElement(selector, laxInstance, domElement, transformsData) {\n      var _this2 = this;\n\n      var groupIndex = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;\n\n      var _options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};\n\n      _classCallCheck(this, LaxElement);\n\n      _defineProperty(this, \"domElement\", void 0);\n\n      _defineProperty(this, \"transformsData\", void 0);\n\n      _defineProperty(this, \"styles\", {});\n\n      _defineProperty(this, \"selector\", '');\n\n      _defineProperty(this, \"groupIndex\", 0);\n\n      _defineProperty(this, \"laxInstance\", void 0);\n\n      _defineProperty(this, \"onUpdate\", void 0);\n\n      _defineProperty(this, \"update\", function (driverValues, frame) {\n        var transforms = _this2.transforms;\n        var styles = {};\n\n        for (var driverName in transforms) {\n          var styleBindings = transforms[driverName];\n\n          if (!driverValues[driverName]) {\n            console.error(\"No lax driver with name: \", driverName);\n          }\n\n          var _driverValues$driverN = _slicedToArray(driverValues[driverName], 2),\n              value = _driverValues$driverN[0],\n              inertiaValue = _driverValues$driverN[1];\n\n          for (var key in styleBindings) {\n            var _styleBindings$key = _slicedToArray(styleBindings[key], 3),\n                arr1 = _styleBindings$key[0],\n                arr2 = _styleBindings$key[1],\n                _styleBindings$key$ = _styleBindings$key[2],\n                options = _styleBindings$key$ === void 0 ? {} : _styleBindings$key$;\n\n            var modValue = options.modValue,\n                _options$frameStep = options.frameStep,\n                frameStep = _options$frameStep === void 0 ? 1 : _options$frameStep,\n                easing = options.easing,\n                inertia = options.inertia,\n                inertiaMode = options.inertiaMode,\n                cssFn = options.cssFn,\n                _options$cssUnit = options.cssUnit,\n                cssUnit = _options$cssUnit === void 0 ? '' : _options$cssUnit;\n            var easingFn = easings[easing];\n\n            if (frame % frameStep === 0) {\n              var v = modValue ? value % modValue : value;\n              var interpolatedValue = interpolate(arr1, arr2, v, easingFn);\n\n              if (inertia) {\n                var inertiaExtra = inertiaValue * inertia;\n                if (inertiaMode === 'absolute') inertiaExtra = Math.abs(inertiaExtra);\n                interpolatedValue += inertiaExtra;\n              }\n\n              var unit = cssUnit || pxUnits.includes(key) ? 'px' : degUnits.includes(key) ? 'deg' : '';\n              var dp = unit === 'px' ? 0 : 3;\n              var val = interpolatedValue.toFixed(dp);\n              styles[key] = cssFn ? cssFn(val, _this2.domElement) : val + cssUnit;\n            }\n          }\n        }\n\n        _this2.applyStyles(styles);\n\n        if (_this2.onUpdate) _this2.onUpdate(driverValues, _this2.domElement);\n      });\n\n      _defineProperty(this, \"calculateTransforms\", function () {\n        _this2.transforms = {};\n        var windowWidth = _this2.laxInstance.windowWidth;\n\n        var _loop = function _loop(driverName) {\n          var styleBindings = _this2.transformsData[driverName];\n          var parsedStyleBindings = {};\n          var _styleBindings$preset = styleBindings.presets,\n              presets = _styleBindings$preset === void 0 ? [] : _styleBindings$preset;\n          presets.forEach(function (presetString) {\n            var _presetString$split = presetString.split(\":\"),\n                _presetString$split2 = _slicedToArray(_presetString$split, 3),\n                presetName = _presetString$split2[0],\n                y = _presetString$split2[1],\n                str = _presetString$split2[2];\n\n            var presetFn = window.lax.presets[presetName];\n\n            if (!presetFn) {\n              console.error(\"Lax preset cannot be found with name: \", presetName);\n            } else {\n              var preset = presetFn(y, str);\n              Object.keys(preset).forEach(function (key) {\n                styleBindings[key] = preset[key];\n              });\n            }\n          });\n          delete styleBindings.presets;\n\n          var _loop2 = function _loop2(key) {\n            var _styleBindings$key2 = _slicedToArray(styleBindings[key], 3),\n                _styleBindings$key2$ = _styleBindings$key2[0],\n                arr1 = _styleBindings$key2$ === void 0 ? [-1e9, 1e9] : _styleBindings$key2$,\n                _styleBindings$key2$2 = _styleBindings$key2[1],\n                arr2 = _styleBindings$key2$2 === void 0 ? [-1e9, 1e9] : _styleBindings$key2$2,\n                _styleBindings$key2$3 = _styleBindings$key2[2],\n                options = _styleBindings$key2$3 === void 0 ? {} : _styleBindings$key2$3;\n\n            var bounds = _this2.domElement.getBoundingClientRect();\n\n            var parsedArr1 = getArrayValues(arr1, windowWidth).map(function (i) {\n              return parseValue(i, bounds, _this2.groupIndex);\n            });\n            var parsedArr2 = getArrayValues(arr2, windowWidth).map(function (i) {\n              return parseValue(i, bounds, _this2.groupIndex);\n            });\n            parsedStyleBindings[key] = [parsedArr1, parsedArr2, options];\n          };\n\n          for (var key in styleBindings) {\n            _loop2(key);\n          }\n\n          _this2.transforms[driverName] = parsedStyleBindings;\n        };\n\n        for (var driverName in _this2.transformsData) {\n          _loop(driverName);\n        }\n      });\n\n      _defineProperty(this, \"applyStyles\", function (styles) {\n        var mergedStyles = flattenStyles(styles);\n        Object.keys(mergedStyles).forEach(function (key) {\n          _this2.domElement.style.setProperty(key, mergedStyles[key]);\n        });\n      });\n\n      this.selector = selector;\n      this.laxInstance = laxInstance;\n      this.domElement = domElement;\n      this.transformsData = transformsData;\n      this.groupIndex = groupIndex;\n      var _options$style = _options.style,\n          style = _options$style === void 0 ? {} : _options$style,\n          onUpdate = _options.onUpdate;\n      Object.keys(style).forEach(function (key) {\n        domElement.style.setProperty(key, style[key]);\n      });\n      if (onUpdate) this.onUpdate = onUpdate;\n      this.calculateTransforms();\n    };\n\n    var Lax = function Lax() {\n      var _this3 = this;\n\n      _classCallCheck(this, Lax);\n\n      _defineProperty(this, \"drivers\", []);\n\n      _defineProperty(this, \"elements\", []);\n\n      _defineProperty(this, \"frame\", 0);\n\n      _defineProperty(this, \"debug\", false);\n\n      _defineProperty(this, \"windowWidth\", 0);\n\n      _defineProperty(this, \"windowHeight\", 0);\n\n      _defineProperty(this, \"presets\", laxPresets);\n\n      _defineProperty(this, \"debugData\", {\n        frameLengths: []\n      });\n\n      _defineProperty(this, \"init\", function () {\n        _this3.findAndAddElements();\n\n        window.requestAnimationFrame(_this3.onAnimationFrame);\n        _this3.windowWidth = document.body.clientWidth;\n        _this3.windowHeight = document.body.clientHeight;\n        window.onresize = _this3.onWindowResize;\n      });\n\n      _defineProperty(this, \"onWindowResize\", function () {\n        var changed = document.body.clientWidth !== _this3.windowWidth || document.body.clientHeight !== _this3.windowHeight;\n\n        if (changed) {\n          _this3.windowWidth = document.body.clientWidth;\n          _this3.windowHeight = document.body.clientHeight;\n\n          _this3.elements.forEach(function (el) {\n            return el.calculateTransforms();\n          });\n        }\n      });\n\n      _defineProperty(this, \"onAnimationFrame\", function (e) {\n        if (_this3.debug) {\n          _this3.debugData.frameStart = Date.now();\n        }\n\n        var driverValues = {};\n\n        _this3.drivers.forEach(function (driver) {\n          driverValues[driver.name] = driver.getValue(_this3.frame);\n        });\n\n        _this3.elements.forEach(function (element) {\n          element.update(driverValues, _this3.frame);\n        });\n\n        if (_this3.debug) {\n          _this3.debugData.frameLengths.push(Date.now() - _this3.debugData.frameStart);\n        }\n\n        if (_this3.frame % 60 === 0 && _this3.debug) {\n          var averageFrameTime = Math.ceil(_this3.debugData.frameLengths.reduce(function (a, b) {\n            return a + b;\n          }, 0) / 60);\n          console.log(\"Average frame calculation time: \".concat(averageFrameTime, \"ms\"));\n          _this3.debugData.frameLengths = [];\n        }\n\n        _this3.frame++;\n        window.requestAnimationFrame(_this3.onAnimationFrame);\n      });\n\n      _defineProperty(this, \"addDriver\", function (name, getValueFn) {\n        var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n\n        _this3.drivers.push(new LaxDriver(name, getValueFn, options));\n      });\n\n      _defineProperty(this, \"removeDriver\", function (name) {\n        _this3.drivers = _this3.drivers.filter(function (driver) {\n          return driver.name !== name;\n        });\n      });\n\n      _defineProperty(this, \"findAndAddElements\", function () {\n        _this3.elements = [];\n        var elements = document.querySelectorAll(\".lax\");\n        elements.forEach(function (domElement) {\n          var driverName = \"scrollY\";\n          var presets = [];\n          domElement.classList.forEach(function (className) {\n            if (className.includes(\"lax_preset\")) {\n              var preset = className.replace(\"lax_preset_\", \"\");\n              presets.push(preset);\n            }\n          });\n\n          var transforms = _defineProperty({}, driverName, {\n            presets: presets\n          });\n\n          _this3.elements.push(new LaxElement('.lax', _this3, domElement, transforms, 0, {}));\n        });\n      });\n\n      _defineProperty(this, \"addElements\", function (selector, transforms, options) {\n        var domElements = document.querySelectorAll(selector);\n        domElements.forEach(function (domElement, i) {\n          _this3.elements.push(new LaxElement(selector, _this3, domElement, transforms, i, options));\n        });\n      });\n\n      _defineProperty(this, \"removeElements\", function (selector) {\n        _this3.elements = _this3.elements.filter(function (element) {\n          return element.selector !== selector;\n        });\n      });\n\n      _defineProperty(this, \"addElement\", function (domElement, transforms, options) {\n        _this3.elements.push(new LaxElement('', _this3, domElement, transforms, 0, options));\n      });\n\n      _defineProperty(this, \"removeElement\", function (domElement) {\n        _this3.elements = _this3.elements.filter(function (element) {\n          return element.domElement !== domElement;\n        });\n      });\n    };\n\n    return new Lax();\n  }();\n\n  if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') module.exports = laxInstance;else window.lax = laxInstance;\n})();"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"lax.js\",\n  \"version\": \"2.0.3\",\n  \"scripts\": {\n    \"build\": \"babel src -d lib && uglifyjs lib/lax.js -o lib/lax.min.js -c -m && gzip -c lib/lax.min.js > lib/lax.min.js.gz && cp lib/lax.min.js docs/lib/lax.min.js\"\n  },\n  \"devDependencies\": {\n    \"@babel/cli\": \"^7.12.1\",\n    \"@babel/core\": \"^7.12.3\",\n    \"@babel/plugin-proposal-class-properties\": \"^7.12.1\",\n    \"@babel/preset-env\": \"^7.12.1\",\n    \"uglify-js\": \"^3.9.4\"\n  },\n  \"description\": \"Simple & lightweight (<4kb gzipped) vanilla JavaScript library to create smooth & beautiful animations when you scroll.\",\n  \"license\": \"MIT\",\n  \"author\": \"alexfoxy@gmail.com\",\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"https://github.com/alexfoxy/lax.js\"\n  },\n  \"main\": \"lib/lax.min.js\",\n  \"keywords\": [\n    \"javascript\",\n    \"lax\",\n    \"laxxx\",\n    \"lax.js\",\n    \"laxjs\",\n    \"parallax\",\n    \"scroll\",\n    \"animation\",\n    \"effects\",\n    \"css\",\n    \"html\"\n  ],\n  \"dependencies\": {}\n}"
  },
  {
    "path": "src/lax.js",
    "content": "(() => {\n  const inOutMap = (y = 30) => {\n    return [\"elInY+elHeight\", `elCenterY-${y}`, \"elCenterY\", `elCenterY+${y}`, \"elOutY-elHeight\"]\n  }\n\n  const laxPresets = {\n    fadeInOut: (y = 30, str = 0) => ({\n      \"opacity\": [\n        inOutMap(y),\n        [str, 1, 1, 1, str]\n      ],\n    }),\n    fadeIn: (y = 'elCenterY', str = 0) => ({\n      \"opacity\": [\n        [\"elInY+elHeight\", y],\n        [str, 1],\n      ],\n    }),\n    fadeOut: (y = 'elCenterY', str = 0) => ({\n      \"opacity\": [\n        [y, \"elOutY-elHeight\"],\n        [1, str],\n      ],\n    }),\n    blurInOut: (y = 100, str = 20) => ({\n      \"blur\": [\n        inOutMap(y),\n        [str, 0, 0, 0, str],\n      ],\n    }),\n    blurIn: (y = 'elCenterY', str = 20) => ({\n      \"blur\": [\n        [\"elInY+elHeight\", y],\n        [str, 0],\n      ],\n    }),\n    blurOut: (y = 'elCenterY', str = 20) => ({\n      \"opacity\": [\n        [y, \"elOutY-elHeight\"],\n        [0, str],\n      ],\n    }),\n    scaleInOut: (y = 100, str = 0.6) => ({\n      \"scale\": [\n        inOutMap(y),\n        [str, 1, 1, 1, str],\n      ],\n    }),\n    scaleIn: (y = 'elCenterY', str = 0.6) => ({\n      \"scale\": [\n        [\"elInY+elHeight\", y],\n        [str, 1],\n      ],\n    }),\n    scaleOut: (y = 'elCenterY', str = 0.6) => ({\n      \"scale\": [\n        [y, \"elOutY-elHeight\"],\n        [1, str],\n      ],\n    }),\n    slideX: (y = 0, str = 500) => ({\n      \"translateX\": [\n        ['elInY', y],\n        [0, str],\n      ],\n    }),\n    slideY: (y = 0, str = 500) => ({\n      \"translateY\": [\n        ['elInY', y],\n        [0, str],\n      ],\n    }),\n    spin: (y = 1000, str = 360) => ({\n      \"rotate\": [\n        [0, y],\n        [0, str],\n        {\n          modValue: y,\n        }\n      ],\n    }),\n    flipX: (y = 1000, str = 360) => ({\n      \"rotateX\": [\n        [0, y],\n        [0, str],\n        {\n          modValue: y\n        }\n      ],\n    }),\n    flipY: (y = 1000, str = 360) => ({\n      \"rotateY\": [\n        [0, y],\n        [0, str],\n        {\n          modValue: y\n        }\n      ],\n    }),\n    jiggle: (y = 50, str = 40) => ({\n      \"skewX\": [\n        [0, y * 1, y * 2, y * 3, y * 4],\n        [0, str, 0, -str, 0],\n        {\n          modValue: y * 4,\n        }\n      ],\n    }),\n    seesaw: (y = 50, str = 40) => ({\n      \"skewY\": [\n        [0, y * 1, y * 2, y * 3, y * 4],\n        [0, str, 0, -str, 0],\n        {\n          modValue: y * 4,\n        }\n      ],\n    }),\n    zigzag: (y = 100, str = 100) => ({\n      \"translateX\": [\n        [0, y * 1, y * 2, y * 3, y * 4],\n        [0, str, 0, -str, 0],\n        {\n          modValue: y * 4,\n        }\n      ],\n    }),\n    hueRotate: (y = 600, str = 360) => ({\n      \"hue-rotate\": [\n        [0, y],\n        [0, str],\n        {\n          modValue: y,\n        }\n      ],\n    }),\n  }\n\n  const laxInstance = (() => {\n    const transformKeys = [\"perspective\", \"scaleX\", \"scaleY\", \"scale\", \"skewX\", \"skewY\", \"skew\", \"rotateX\", \"rotateY\", \"rotate\"]\n    const filterKeys = [\"blur\", \"hue-rotate\", \"brightness\"]\n    const translate3dKeys = [\"translateX\", \"translateY\", \"translateZ\"]\n\n    const pxUnits = [\"perspective\", \"border-radius\", \"blur\", \"translateX\", \"translateY\", \"translateZ\"]\n    const degUnits = [\"hue-rotate\", \"rotate\", \"rotateX\", \"rotateY\", \"skew\", \"skewX\", \"skewY\"]\n\n    function getArrayValues(arr, windowWidth) {\n      if (Array.isArray(arr)) return arr\n\n      const keys = Object.keys(arr).map(x => parseInt(x)).sort((a, b) => a > b ? 1 : -1)\n\n      let retKey = keys[keys.length - 1]\n      for (let i = 0; i < keys.length; i++) {\n        const key = keys[i]\n        if (windowWidth < key) {\n          retKey = key\n          break\n        }\n      }\n\n      return arr[retKey]\n    }\n\n    function lerp(start, end, t) {\n      return start * (1 - t) + end * t\n    }\n\n    function invlerp(a, b, v) {\n      return (v - a) / (b - a)\n    }\n\n    function interpolate(arrA, arrB, v, easingFn) {\n      let k = 0\n\n      arrA.forEach((a) => {\n        if (a < v) k++\n      })\n\n      if (k <= 0) {\n        return arrB[0]\n      }\n\n      if (k >= arrA.length) {\n        return arrB[arrA.length - 1]\n      }\n\n      const j = k - 1\n\n      let vector = invlerp(arrA[j], arrA[k], v)\n      if (easingFn) vector = easingFn(vector)\n      const lerpVal = lerp(arrB[j], arrB[k], vector)\n      return lerpVal\n    }\n\n    const easings = {\n      easeInQuad: t => t * t,\n      easeOutQuad: t => t * (2 - t),\n      easeInOutQuad: t => t < .5 ? 2 * t * t : -1 + (4 - 2 * t) * t,\n      easeInCubic: t => t * t * t,\n      easeOutCubic: t => (--t) * t * t + 1,\n      easeInOutCubic: t => t < .5 ? 4 * t * t * t : (t - 1) * (2 * t - 2) * (2 * t - 2) + 1,\n      easeInQuart: t => t * t * t * t,\n      easeOutQuart: t => 1 - (--t) * t * t * t,\n      easeInOutQuart: t => t < .5 ? 8 * t * t * t * t : 1 - 8 * (--t) * t * t * t,\n      easeInQuint: t => t * t * t * t * t,\n      easeOutQuint: t => 1 + (--t) * t * t * t * t,\n      easeInOutQuint: t => t < .5 ? 16 * t * t * t * t * t : 1 + 16 * (--t) * t * t * t * t,\n      easeOutBounce: t => {\n        const n1 = 7.5625\n        const d1 = 2.75\n\n        if (t < 1 / d1) {\n          return n1 * t * t\n        } else if (t < 2 / d1) {\n          return n1 * (t -= 1.5 / d1) * t + 0.75\n        } else if (t < 2.5 / d1) {\n          return n1 * (t -= 2.25 / d1) * t + 0.9375\n        } else {\n          return n1 * (t -= 2.625 / d1) * t + 0.984375\n        }\n      },\n      easeInBounce: t => {\n        return 1 - easings.easeOutBounce(1 - t)\n      },\n      easeOutBack: t => {\n        const c1 = 1.70158\n        const c3 = c1 + 1\n\n        return 1 + c3 * Math.pow(t - 1, 3) + c1 * Math.pow(t - 1, 2)\n      },\n      easeInBack: t => {\n        const c1 = 1.70158\n        const c3 = c1 + 1\n\n        return c3 * t * t * t - c1 * t * t\n      },\n    }\n\n    function flattenStyles(styles) {\n      const flattenedStyles = {\n        transform: '',\n        filter: ''\n      }\n\n      const translate3dValues = {\n        translateX: 0.00001,\n        translateY: 0.00001,\n        translateZ: 0.00001\n      }\n\n      Object.keys(styles).forEach((key) => {\n        const val = styles[key]\n        const unit = pxUnits.includes(key) ? 'px' : (degUnits.includes(key) ? 'deg' : '')\n\n        if (translate3dKeys.includes(key)) {\n          translate3dValues[key] = val\n        } else if (transformKeys.includes(key)) {\n          flattenedStyles.transform += `${key}(${val}${unit}) `\n        } else if (filterKeys.includes(key)) {\n          flattenedStyles.filter += `${key}(${val}${unit}) `\n        } else {\n          flattenedStyles[key] = `${val}${unit} `\n        }\n      })\n\n      flattenedStyles.transform = `translate3d(${translate3dValues.translateX}px, ${translate3dValues.translateY}px, ${translate3dValues.translateZ}px) ${flattenedStyles.transform}`\n\n      return flattenedStyles\n    }\n\n    // https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollY#Notes\n    function getScrollPosition() {\n      const supportPageOffset = window.pageXOffset !== undefined\n      const isCSS1Compat = ((document.compatMode || '') === 'CSS1Compat')\n\n      const x = supportPageOffset ? window.pageXOffset : isCSS1Compat ? document.documentElement.scrollLeft : document.body.scrollLeft\n      const y = supportPageOffset ? window.pageYOffset : isCSS1Compat ? document.documentElement.scrollTop : document.body.scrollTop\n\n      return [y, x]\n    }\n\n    function parseValue(val, { width, height, x, y }, index) {\n      if (typeof val === 'number') {\n        return val\n      }\n\n      const pageHeight = document.body.scrollHeight\n      const pageWidth = document.body.scrollWidth\n      const screenWidth = window.innerWidth\n      const screenHeight = window.innerHeight\n      const [scrollTop, scrollLeft] = getScrollPosition()\n\n      const left = x + scrollLeft\n      const right = left + width\n      const top = y + scrollTop\n      const bottom = top + height\n\n      return Function(`return ${val\n        .replace(/screenWidth/g, screenWidth)\n        .replace(/screenHeight/g, screenHeight)\n        .replace(/pageHeight/g, pageHeight)\n        .replace(/pageWidth/g, pageWidth)\n        .replace(/elWidth/g, width)\n        .replace(/elHeight/g, height)\n        .replace(/elInY/g, top - screenHeight)\n        .replace(/elOutY/g, bottom)\n        .replace(/elCenterY/g, top + (height / 2) - (screenHeight / 2))\n        .replace(/elInX/g, left - screenWidth)\n        .replace(/elOutX/g, right)\n        .replace(/elCenterX/g, left + (width / 2) - (screenWidth / 2))\n        .replace(/index/g, index)\n        }`)()\n    }\n\n    class LaxDriver {\n      getValueFn\n      name = ''\n      lastValue = 0\n      frameStep = 1\n      m1 = 0\n\n      m2 = 0\n      inertia = 0\n      inertiaEnabled = false\n\n\n      constructor(name, getValueFn, options = {}) {\n        this.name = name\n        this.getValueFn = getValueFn\n\n        Object.keys(options).forEach((key) => {\n          this[key] = options[key]\n        })\n\n        this.lastValue = this.getValueFn(0)\n      }\n\n      getValue = (frame) => {\n        let value = this.lastValue\n\n        if (frame % this.frameStep === 0) {\n          value = this.getValueFn(frame)\n        }\n\n        if (this.inertiaEnabled) {\n          const delta = value - this.lastValue\n          const damping = 0.8\n\n          this.m1 = this.m1 * damping + delta * (1 - damping)\n          this.m2 = this.m2 * damping + this.m1 * (1 - damping)\n          this.inertia = Math.round(this.m2 * 5000) / 15000\n        }\n\n        this.lastValue = value\n        return [this.lastValue, this.inertia]\n      }\n    }\n\n    class LaxElement {\n      domElement\n      transformsData\n      styles = {}\n      selector = ''\n\n      groupIndex = 0\n      laxInstance\n\n      onUpdate\n\n      constructor(selector, laxInstance, domElement, transformsData, groupIndex = 0, options = {}) {\n        this.selector = selector\n        this.laxInstance = laxInstance\n        this.domElement = domElement\n        this.transformsData = transformsData\n        this.groupIndex = groupIndex\n\n        const { style = {}, onUpdate } = options\n\n        Object.keys(style).forEach(key => {\n          domElement.style.setProperty(key, style[key])\n        })\n\n        if (onUpdate) this.onUpdate = onUpdate\n\n        this.calculateTransforms()\n      }\n\n      update = (driverValues, frame) => {\n        const { transforms } = this\n\n        const styles = {}\n\n        for (let driverName in transforms) {\n          const styleBindings = transforms[driverName]\n\n          if (!driverValues[driverName]) {\n            console.error(\"No lax driver with name: \", driverName)\n          }\n\n          const [value, inertiaValue] = driverValues[driverName]\n\n          for (let key in styleBindings) {\n            const [arr1, arr2, options = {}] = styleBindings[key]\n            const { modValue, frameStep = 1, easing, inertia, inertiaMode, cssFn, cssUnit = '' } = options\n\n            const easingFn = easings[easing]\n\n            if (frame % frameStep === 0) {\n              const v = modValue ? value % modValue : value\n\n              let interpolatedValue = interpolate(arr1, arr2, v, easingFn)\n\n              if (inertia) {\n                let inertiaExtra = inertiaValue * inertia\n                if (inertiaMode === 'absolute') inertiaExtra = Math.abs((inertiaExtra))\n                interpolatedValue += inertiaExtra\n              }\n\n              const unit = cssUnit || pxUnits.includes(key) ? 'px' : (degUnits.includes(key) ? 'deg' : '')\n              const dp = unit === 'px' ? 0 : 3\n              const val = interpolatedValue.toFixed(dp)\n              styles[key] = cssFn ? cssFn(val, this.domElement) : val + cssUnit\n            }\n          }\n        }\n\n        this.applyStyles(styles)\n        if (this.onUpdate) this.onUpdate(driverValues, this.domElement)\n      }\n\n      calculateTransforms = () => {\n        this.transforms = {}\n        const windowWidth = this.laxInstance.windowWidth\n\n        for (let driverName in this.transformsData) {\n          let styleBindings = this.transformsData[driverName]\n\n          const parsedStyleBindings = {}\n\n          const { presets = [] } = styleBindings\n\n          presets.forEach((presetString) => {\n\n            const [presetName, y, str] = presetString.split(\":\")\n\n            const presetFn = window.lax.presets[presetName]\n\n            if (!presetFn) {\n              console.error(\"Lax preset cannot be found with name: \", presetName)\n            } else {\n              const preset = presetFn(y, str)\n\n              Object.keys(preset).forEach((key) => {\n                styleBindings[key] = preset[key]\n              })\n            }\n          })\n\n          delete styleBindings.presets\n\n          for (let key in styleBindings) {\n            let [arr1 = [-1e9, 1e9], arr2 = [-1e9, 1e9], options = {}] = styleBindings[key]\n\n            const saveTransform = this.domElement.style.transform\n            this.domElement.style.removeProperty(\"transform\")\n            const bounds = this.domElement.getBoundingClientRect()\n            this.domElement.style.transform = saveTransform\n\n            const parsedArr1 = getArrayValues(arr1, windowWidth).map(i => parseValue(i, bounds, this.groupIndex))\n            const parsedArr2 = getArrayValues(arr2, windowWidth).map(i => parseValue(i, bounds, this.groupIndex))\n\n            parsedStyleBindings[key] = [parsedArr1, parsedArr2, options]\n          }\n\n          this.transforms[driverName] = parsedStyleBindings\n        }\n      }\n\n      applyStyles = (styles) => {\n        const mergedStyles = flattenStyles(styles)\n\n        Object.keys(mergedStyles).forEach((key) => {\n          this.domElement.style.setProperty(key, mergedStyles[key])\n        })\n      }\n    }\n\n    class Lax {\n      drivers = []\n      elements = []\n      frame = 0\n\n      debug = false\n\n      windowWidth = 0\n      windowHeight = 0\n      presets = laxPresets\n\n      debugData = {\n        frameLengths: []\n      }\n\n      init = () => {\n        this.findAndAddElements()\n\n        window.requestAnimationFrame(this.onAnimationFrame)\n        this.windowWidth = document.body.clientWidth\n        this.windowHeight = document.body.clientHeight\n\n        window.onresize = this.onWindowResize\n      }\n\n      onWindowResize = () => {\n        const changed = document.body.clientWidth !== this.windowWidth ||\n          document.body.clientHeight !== this.windowHeight\n\n        if (changed) {\n          this.windowWidth = document.body.clientWidth\n          this.windowHeight = document.body.clientHeight\n          this.elements.forEach(el => el.calculateTransforms())\n        }\n      }\n\n      onAnimationFrame = (e) => {\n        if (this.debug) {\n          this.debugData.frameStart = Date.now()\n        }\n\n        const driverValues = {}\n\n        this.drivers.forEach((driver) => {\n          driverValues[driver.name] = driver.getValue(this.frame)\n        })\n\n        this.elements.forEach((element) => {\n          element.update(driverValues, this.frame)\n        })\n\n        if (this.debug) {\n          this.debugData.frameLengths.push(Date.now() - this.debugData.frameStart)\n        }\n\n        if (this.frame % 60 === 0 && this.debug) {\n          const averageFrameTime = Math.ceil((this.debugData.frameLengths.reduce((a, b) => a + b, 0) / 60))\n          console.log(`Average frame calculation time: ${averageFrameTime}ms`)\n          this.debugData.frameLengths = []\n        }\n\n        this.frame++\n\n        window.requestAnimationFrame(this.onAnimationFrame)\n      }\n\n      addDriver = (name, getValueFn, options = {}) => {\n        this.drivers.push(\n          new LaxDriver(name, getValueFn, options)\n        )\n      }\n\n      removeDriver = (name) => {\n        this.drivers = this.drivers.filter(driver => driver.name !== name)\n      }\n\n      findAndAddElements = () => {\n        this.elements = []\n        const elements = document.querySelectorAll(\".lax\")\n\n        elements.forEach((domElement) => {\n          const driverName = \"scrollY\"\n          const presets = []\n\n          domElement.classList.forEach((className) => {\n            if (className.includes(\"lax_preset\")) {\n              const preset = className.replace(\"lax_preset_\", \"\")\n              presets.push(preset)\n            }\n          })\n\n          const transforms = {\n            [driverName]: {\n              presets\n            }\n          }\n\n          this.elements.push(new LaxElement('.lax', this, domElement, transforms, 0, {}))\n        })\n      }\n\n      addElements = (selector, transforms, options = {}) => {\n        const domElements = options.domElements || document.querySelectorAll(selector)\n\n        domElements.forEach((domElement, i) => {\n          this.elements.push(new LaxElement(selector, this, domElement, transforms, i, options))\n        })\n      }\n\n      removeElements = (selector) => {\n        this.elements = this.elements.filter(element => element.selector !== selector)\n      }\n\n      addElement = (domElement, transforms, options) => {\n        this.elements.push(new LaxElement('', this, domElement, transforms, 0, options))\n      }\n\n      removeElement = (domElement) => {\n        this.elements = this.elements.filter(element => element.domElement !== domElement)\n      }\n    }\n\n    return new Lax()\n  })()\n\n  if (typeof module !== 'undefined' && typeof module.exports !== 'undefined')\n    module.exports = laxInstance\n  else\n    window.lax = laxInstance\n})()\n"
  }
]