{"version":3,"sources":["webpack:///./js/modules/high-output-2019/navigation.js","webpack:///../node_modules/lodash/throttle.js"],"names":["__webpack_require__","r","__webpack_exports__","lodash_throttle__WEBPACK_IMPORTED_MODULE_0__","lodash_throttle__WEBPACK_IMPORTED_MODULE_0___default","n","$navigation","$","$header","$mobileToggle","isMobile","window","matchMedia","matches","directionBuffer","lastScroll","updateDirectionBuffer","throttle","direction","pageYOffset","undefined","unshift","length","slice","handleScrollDown","every","x","hasClass","removeClass","addEventListener","headerOffsetHeight","offset","top","height","addClass","on","toggleClass","debounce","isObject","FUNC_ERROR_TEXT","module","exports","func","wait","options","leading","trailing","TypeError","maxWait"],"mappings":"uGAAAA,EAAAC,EAAAC,GAAA,IAAAC,EAAAH,EAAA,KAAAI,EAAAJ,EAAAK,EAAAF,GAEMG,EAAcC,EAAE,cAChBC,EAAUD,EAAE,cACZE,EAAgBF,EAAE,4BAClBG,EAAW,kBAAMC,OAAOC,WAAW,sBAAsBC,SAC3DC,EAAkB,GAClBC,EAAa,EAEXC,EAAwBC,IAAS,WACrC,IAAIC,EAEAH,EAAaJ,OAAOQ,YACtBD,EAAY,OACHH,EAAaJ,OAAOQ,cAC7BD,EAAY,WAGIE,IAAdF,IAIJJ,EAAgBO,QAAQH,GAEpBJ,EAAgBQ,OAAS,IAC3BR,EAAkBA,EAAgBS,MAAM,EAAG,MAE5C,IAyBH,SAASC,IACYV,EAAgBW,MAAM,SAAAC,GAAC,MAAU,SAANA,MAK1ChB,KACGJ,EAAYqB,SAAS,YAK5BrB,EAAYsB,YAAY,WAnCtBtB,GAAeE,GAAWC,IAK5BE,OAAOkB,iBAAiB,SAAU,WAiCpC,IAEQC,EAlCAf,EAAaJ,OAAOQ,YACtBK,IACST,EAAaJ,OAAOQ,cAgC3BW,EADetB,EAAQuB,SACWC,IAAMxB,EAAQyB,SAClDvB,IACEC,OAAOQ,YAAcW,GACvBxB,EAAYsB,YAAY,WACxBtB,EAAYsB,YAAY,WAExBtB,EAAY4B,SAAS,UAKE,IAAvBvB,OAAOQ,aACTb,EAAYsB,YAAY,UACxBtB,EAAYsB,YAAY,YAExBtB,EAAY4B,SAAS,WA3CrBlB,IACAD,EAAaJ,OAAOQ,cAGtBV,EAAc0B,GAAG,QAAS,WACxB7B,EAAY8B,YAAY,aAG1BZ,0BCjDF,IAAAa,EAAerC,EAAQ,GACvBsC,EAAetC,EAAQ,GAGvBuC,EAAA,sBAgEAC,EAAAC,QAlBA,SAAAC,EAAAC,EAAAC,GACA,IAAAC,GAAA,EACAC,GAAA,EAEA,sBAAAJ,EACA,UAAAK,UAAAR,GAMA,OAJAD,EAAAM,KACAC,EAAA,YAAAD,MAAAC,UACAC,EAAA,aAAAF,MAAAE,YAEAT,EAAAK,EAAAC,EAAA,CACAE,UACAG,QAAAL,EACAG","file":"high-output-navigation-6f40563a7c09b4e9170f.js","sourcesContent":["import throttle from 'lodash/throttle';\r\n\r\nconst $navigation = $('.js-ho-nav');\r\nconst $header = $('.js-header');\r\nconst $mobileToggle = $('.js-ho-nav-mobile-toggle');\r\nconst isMobile = () => window.matchMedia('(max-width: 991px)').matches;\r\nlet directionBuffer = [];\r\nlet lastScroll = 0;\r\n\r\nconst updateDirectionBuffer = throttle(() => {\r\n let direction;\r\n\r\n if (lastScroll < window.pageYOffset) {\r\n direction = 'DOWN';\r\n } else if (lastScroll > window.pageYOffset) {\r\n direction = 'UP';\r\n }\r\n\r\n if (direction === undefined) {\r\n return;\r\n }\r\n\r\n directionBuffer.unshift(direction);\r\n\r\n if (directionBuffer.length > 5) {\r\n directionBuffer = directionBuffer.slice(0, 5);\r\n }\r\n}, 35);\r\n\r\nif ($navigation && $header && $mobileToggle) {\r\n bindNavigation();\r\n}\r\n\r\nfunction bindNavigation() {\r\n window.addEventListener('scroll', () => {\r\n if (lastScroll < window.pageYOffset) {\r\n handleScrollDown();\r\n } else if (lastScroll > window.pageYOffset) {\r\n handleScrollUp();\r\n }\r\n\r\n updateDirectionBuffer();\r\n lastScroll = window.pageYOffset;\r\n });\r\n\r\n $mobileToggle.on('click', () => {\r\n $navigation.toggleClass('is-open');\r\n });\r\n\r\n handleScrollDown();\r\n}\r\n\r\nfunction handleScrollDown() {\r\n const movingDown = directionBuffer.every(x => x === 'DOWN');\r\n if (!movingDown) {\r\n return;\r\n }\r\n\r\n if (isMobile()) {\r\n if (!$navigation.hasClass('is-open')) {\r\n $navigation.removeClass('active');\r\n }\r\n return;\r\n }\r\n $navigation.removeClass('active');\r\n}\r\n\r\nfunction handleScrollUp() {\r\n const headerOffset = $header.offset();\r\n const headerOffsetHeight = headerOffset.top + $header.height();\r\n if (isMobile()) {\r\n if (window.pageYOffset < headerOffsetHeight) {\r\n $navigation.removeClass('is-open');\r\n $navigation.removeClass('active');\r\n } else {\r\n $navigation.addClass('active');\r\n }\r\n return;\r\n }\r\n\r\n if (window.pageYOffset === 0) {\r\n $navigation.removeClass('active');\r\n $navigation.removeClass('is-open');\r\n } else {\r\n $navigation.addClass('active');\r\n }\r\n}\r\n","var debounce = require('./debounce'),\n isObject = require('./isObject');\n\n/** Error message constants. */\nvar FUNC_ERROR_TEXT = 'Expected a function';\n\n/**\n * Creates a throttled function that only invokes `func` at most once per\n * every `wait` milliseconds. The throttled function comes with a `cancel`\n * method to cancel delayed `func` invocations and a `flush` method to\n * immediately invoke them. Provide `options` to indicate whether `func`\n * should be invoked on the leading and/or trailing edge of the `wait`\n * timeout. The `func` is invoked with the last arguments provided to the\n * throttled function. Subsequent calls to the throttled function return the\n * result of the last `func` invocation.\n *\n * **Note:** If `leading` and `trailing` options are `true`, `func` is\n * invoked on the trailing edge of the timeout only if the throttled function\n * is invoked more than once during the `wait` timeout.\n *\n * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred\n * until to the next tick, similar to `setTimeout` with a timeout of `0`.\n *\n * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)\n * for details over the differences between `_.throttle` and `_.debounce`.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Function\n * @param {Function} func The function to throttle.\n * @param {number} [wait=0] The number of milliseconds to throttle invocations to.\n * @param {Object} [options={}] The options object.\n * @param {boolean} [options.leading=true]\n * Specify invoking on the leading edge of the timeout.\n * @param {boolean} [options.trailing=true]\n * Specify invoking on the trailing edge of the timeout.\n * @returns {Function} Returns the new throttled function.\n * @example\n *\n * // Avoid excessively updating the position while scrolling.\n * jQuery(window).on('scroll', _.throttle(updatePosition, 100));\n *\n * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.\n * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });\n * jQuery(element).on('click', throttled);\n *\n * // Cancel the trailing throttled invocation.\n * jQuery(window).on('popstate', throttled.cancel);\n */\nfunction throttle(func, wait, options) {\n var leading = true,\n trailing = true;\n\n if (typeof func != 'function') {\n throw new TypeError(FUNC_ERROR_TEXT);\n }\n if (isObject(options)) {\n leading = 'leading' in options ? !!options.leading : leading;\n trailing = 'trailing' in options ? !!options.trailing : trailing;\n }\n return debounce(func, wait, {\n 'leading': leading,\n 'maxWait': wait,\n 'trailing': trailing\n });\n}\n\nmodule.exports = throttle;\n"],"sourceRoot":""}