{"version":3,"sources":["webpack://sal/webpack/universalModuleDefinition","webpack://sal/webpack/bootstrap","webpack://sal/./src/sal.js"],"names":["root","factory","exports","module","define","amd","window","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","options","rootMargin","threshold","animateClassName","disabledClassName","enterEventName","exitEventName","selector","once","disabled","elements","intersectionObserver","fireEvent","entry","event","CustomEvent","bubbles","detail","target","dispatchEvent","disableAnimations","document","body","classList","add","isDisabled","onIntersection","entries","observer","forEach","intersectionRatio","animate","unobserve","remove","reverse","disable","disconnect","enable","IntersectionObserver","filter","querySelectorAll","element","contains","isAnimated","observe","init","settings","Error"],"mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAa,IAAID,IAEjBD,EAAU,IAAIC,IARhB,CASGK,QAAQ,WACX,O,YCTE,IAAIC,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUP,QAGnC,IAAIC,EAASI,EAAiBE,GAAY,CACzCC,EAAGD,EACHE,GAAG,EACHT,QAAS,IAUV,OANAU,EAAQH,GAAUI,KAAKV,EAAOD,QAASC,EAAQA,EAAOD,QAASM,GAG/DL,EAAOQ,GAAI,EAGJR,EAAOD,QA0Df,OArDAM,EAAoBM,EAAIF,EAGxBJ,EAAoBO,EAAIR,EAGxBC,EAAoBQ,EAAI,SAASd,EAASe,EAAMC,GAC3CV,EAAoBW,EAAEjB,EAASe,IAClCG,OAAOC,eAAenB,EAASe,EAAM,CAAEK,YAAY,EAAMC,IAAKL,KAKhEV,EAAoBgB,EAAI,SAAStB,GACX,oBAAXuB,QAA0BA,OAAOC,aAC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,EAAQI,oBAOhCqB,EAAa,kBACjBzB,EAAQS,UAEuB,mBAArBT,EAAQS,UACbT,EAAQS,YASTiB,EAAiB,SAACC,EAASC,GAC/BD,EAAQE,SAAQ,SAAChB,GACXA,EAAMiB,mBAAqB9B,EAAQE,YAvD3B,SAACW,GACfA,EAAMK,OAAOK,UAAUC,IAAIxB,EAAQG,kBACnCS,EAAUZ,EAAQK,eAAgBQ,GAsD9BkB,CAAQlB,GAEJb,EAAQQ,MACVoB,EAASI,UAAUnB,EAAMK,SAEjBlB,EAAQQ,MApDR,SAACK,GACfA,EAAMK,OAAOK,UAAUU,OAAOjC,EAAQG,kBACtCS,EAAUZ,EAAQM,cAAeO,GAmD7BqB,CAAQrB,OAQRsB,EAAU,WACdf,IAEAT,EAAqByB,aACrBzB,EAAuB,MAMnB0B,EAAS,WAtDbhB,SAASC,KAAKC,UAAUU,OAAOjC,EAAQI,mBAyDvCO,EAAuB,IAAI2B,qBAAqBZ,EAAgB,CAC9DzB,WAAYD,EAAQC,WACpBC,UAAWF,EAAQE,aAGrBQ,EAAW,GAAG6B,OAAOpE,KACnBkD,SAASmB,iBAAiBxC,EAAQO,WAClC,SAACkC,GAAD,OAxEe,SAACA,GAAD,OACjBA,EAAQlB,UAAUmB,SAAS1C,EAAQG,kBAuEnBwC,CAAWF,EAASzC,EAAQG,sBAGnC0B,SAAQ,SAACY,GAAD,OAAa9B,EAAqBiC,QAAQH,OAuC9CI,UA/BF,WAAwB,IAAvBC,EAAuB,uDAAZ9C,EAQvB,GAPI8C,IAAa9C,IACfA,EAAU,EAAH,GACFA,EADE,GAEF8C,KAIFlF,OAAO0E,qBAGV,MAFAlB,IAEM2B,MAAM,8KAad,OANKtB,IAGHL,IAFAiB,IAKK,CACL3B,WACAyB,UACAE,Y","file":"sal.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"sal\"] = factory();\n\telse\n\t\troot[\"sal\"] = factory();\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"dist/\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n","/**\n * Sal - Scroll Animation Library\n * Performance focused, lightweight scroll animation library\n */\n\nimport './sal.scss';\n\n/**\n * Default options\n */\nlet options = {\n rootMargin: '0% 50%',\n threshold: 0.5,\n animateClassName: 'sal-animate',\n disabledClassName: 'sal-disabled',\n enterEventName: 'sal:in',\n exitEventName: 'sal:out',\n selector: '[data-sal]',\n once: true,\n disabled: false,\n};\n\n/**\n * Private\n */\nlet elements = [];\nlet intersectionObserver = null;\n\n/**\n * Dispatches the animate event on the intersection observer entry.\n * @param {IntersectionObserverEntry} detail The entry to fire event on.\n */\nconst fireEvent = (name, entry) => {\n const event = new CustomEvent(name, {\n bubbles: true,\n detail: entry,\n });\n\n entry.target.dispatchEvent(event);\n};\n\n/**\n * Launch animation by adding class\n * @param {IntersectionObserverEntry} entry\n */\nconst animate = (entry) => {\n entry.target.classList.add(options.animateClassName);\n fireEvent(options.enterEventName, entry);\n};\n\n/**\n * Reverse animation by removing class\n * @param {IntersectionObserverEntry} entry\n */\nconst reverse = (entry) => {\n entry.target.classList.remove(options.animateClassName);\n fireEvent(options.exitEventName, entry);\n};\n\n/**\n * Check if element was animated\n * @param {Node} element\n */\nconst isAnimated = (element) => (\n element.classList.contains(options.animateClassName)\n);\n\n/**\n * Enable animations by remove class from body\n */\nconst enableAnimations = () => {\n document.body.classList.remove(options.disabledClassName);\n};\n\n/**\n * Disable animations by add class from body\n */\nconst disableAnimations = () => {\n document.body.classList.add(options.disabledClassName);\n};\n\n/**\n * Check if should be disabled\n * @return {Boolean}\n */\nconst isDisabled = () => (\n options.disabled\n || (\n (typeof options.disabled === 'function')\n && options.disabled()\n )\n);\n\n/**\n * IntersectionObserver callback\n * @param {Array} entries\n * @param {IntersectionObserver} observer\n */\nconst onIntersection = (entries, observer) => {\n entries.forEach((entry) => {\n if (entry.intersectionRatio >= options.threshold) {\n animate(entry);\n\n if (options.once) {\n observer.unobserve(entry.target);\n }\n } else if (!options.once) {\n reverse(entry);\n }\n });\n};\n\n/**\n * Disable sal\n */\nconst disable = () => {\n disableAnimations();\n\n intersectionObserver.disconnect();\n intersectionObserver = null;\n};\n\n/**\n * Enable sal by launching new IntersectionObserver\n */\nconst enable = () => {\n enableAnimations();\n\n intersectionObserver = new IntersectionObserver(onIntersection, {\n rootMargin: options.rootMargin,\n threshold: options.threshold,\n });\n\n elements = [].filter.call(\n document.querySelectorAll(options.selector),\n (element) => !isAnimated(element, options.animateClassName),\n );\n\n elements.forEach((element) => intersectionObserver.observe(element));\n};\n\n/**\n * Init\n * @param {Object} settings\n * @return {Object} public API\n */\nconst init = (settings = options) => {\n if (settings !== options) {\n options = {\n ...options,\n ...settings,\n };\n }\n\n if (!window.IntersectionObserver) {\n disableAnimations();\n\n throw Error(`\n Your browser does not support IntersectionObserver!\n Get a polyfill from here:\n https://github.com/w3c/IntersectionObserver/tree/master/polyfill\n `);\n }\n\n if (!isDisabled()) {\n enable();\n } else {\n disableAnimations();\n }\n\n return {\n elements,\n disable,\n enable,\n };\n};\n\nexport default init;\n"],"sourceRoot":""}