{ "version": 3, "sources": ["../../node_modules/throttle-debounce/throttle.js", "../../node_modules/throttle-debounce/debounce.js", "../../src/scripts/lib/intersection-observed.js", "../../src/scripts/featured-pages-grid.js"], "sourcesContent": ["/* eslint-disable no-undefined,no-param-reassign,no-shadow */\n\n/**\n * Throttle execution of a function. Especially useful for rate limiting\n * execution of handlers on events like resize and scroll.\n *\n * @param {number} delay - A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher)\n * are most useful.\n * @param {Function} callback - A function to be executed after delay milliseconds. The `this` context and all arguments are passed through,\n * as-is, to `callback` when the throttled-function is executed.\n * @param {object} [options] - An object to configure options.\n * @param {boolean} [options.noTrailing] - Optional, defaults to false. If noTrailing is true, callback will only execute every `delay` milliseconds\n * while the throttled-function is being called. If noTrailing is false or unspecified, callback will be executed\n * one final time after the last throttled-function call. (After the throttled-function has not been called for\n * `delay` milliseconds, the internal counter is reset).\n * @param {boolean} [options.noLeading] - Optional, defaults to false. If noLeading is false, the first throttled-function call will execute callback\n * immediately. If noLeading is true, the first the callback execution will be skipped. It should be noted that\n * callback will never executed if both noLeading = true and noTrailing = true.\n * @param {boolean} [options.debounceMode] - If `debounceMode` is true (at begin), schedule `clear` to execute after `delay` ms. If `debounceMode` is\n * false (at end), schedule `callback` to execute after `delay` ms.\n *\n * @returns {Function} A new, throttled, function.\n */\nexport default function (delay, callback, options) {\n\tconst {\n\t\tnoTrailing = false,\n\t\tnoLeading = false,\n\t\tdebounceMode = undefined\n\t} = options || {};\n\t/*\n\t * After wrapper has stopped being called, this timeout ensures that\n\t * `callback` is executed at the proper times in `throttle` and `end`\n\t * debounce modes.\n\t */\n\tlet timeoutID;\n\tlet cancelled = false;\n\n\t// Keep track of the last time `callback` was executed.\n\tlet lastExec = 0;\n\n\t// Function to clear existing timeout\n\tfunction clearExistingTimeout() {\n\t\tif (timeoutID) {\n\t\t\tclearTimeout(timeoutID);\n\t\t}\n\t}\n\n\t// Function to cancel next exec\n\tfunction cancel(options) {\n\t\tconst { upcomingOnly = false } = options || {};\n\t\tclearExistingTimeout();\n\t\tcancelled = !upcomingOnly;\n\t}\n\n\t/*\n\t * The `wrapper` function encapsulates all of the throttling / debouncing\n\t * functionality and when executed will limit the rate at which `callback`\n\t * is executed.\n\t */\n\tfunction wrapper(...arguments_) {\n\t\tlet self = this;\n\t\tlet elapsed = Date.now() - lastExec;\n\n\t\tif (cancelled) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Execute `callback` and update the `lastExec` timestamp.\n\t\tfunction exec() {\n\t\t\tlastExec = Date.now();\n\t\t\tcallback.apply(self, arguments_);\n\t\t}\n\n\t\t/*\n\t\t * If `debounceMode` is true (at begin) this is used to clear the flag\n\t\t * to allow future `callback` executions.\n\t\t */\n\t\tfunction clear() {\n\t\t\ttimeoutID = undefined;\n\t\t}\n\n\t\tif (!noLeading && debounceMode && !timeoutID) {\n\t\t\t/*\n\t\t\t * Since `wrapper` is being called for the first time and\n\t\t\t * `debounceMode` is true (at begin), execute `callback`\n\t\t\t * and noLeading != true.\n\t\t\t */\n\t\t\texec();\n\t\t}\n\n\t\tclearExistingTimeout();\n\n\t\tif (debounceMode === undefined && elapsed > delay) {\n\t\t\tif (noLeading) {\n\t\t\t\t/*\n\t\t\t\t * In throttle mode with noLeading, if `delay` time has\n\t\t\t\t * been exceeded, update `lastExec` and schedule `callback`\n\t\t\t\t * to execute after `delay` ms.\n\t\t\t\t */\n\t\t\t\tlastExec = Date.now();\n\t\t\t\tif (!noTrailing) {\n\t\t\t\t\ttimeoutID = setTimeout(debounceMode ? clear : exec, delay);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t/*\n\t\t\t\t * In throttle mode without noLeading, if `delay` time has been exceeded, execute\n\t\t\t\t * `callback`.\n\t\t\t\t */\n\t\t\t\texec();\n\t\t\t}\n\t\t} else if (noTrailing !== true) {\n\t\t\t/*\n\t\t\t * In trailing throttle mode, since `delay` time has not been\n\t\t\t * exceeded, schedule `callback` to execute `delay` ms after most\n\t\t\t * recent execution.\n\t\t\t *\n\t\t\t * If `debounceMode` is true (at begin), schedule `clear` to execute\n\t\t\t * after `delay` ms.\n\t\t\t *\n\t\t\t * If `debounceMode` is false (at end), schedule `callback` to\n\t\t\t * execute after `delay` ms.\n\t\t\t */\n\t\t\ttimeoutID = setTimeout(\n\t\t\t\tdebounceMode ? clear : exec,\n\t\t\t\tdebounceMode === undefined ? delay - elapsed : delay\n\t\t\t);\n\t\t}\n\t}\n\n\twrapper.cancel = cancel;\n\n\t// Return the wrapper function.\n\treturn wrapper;\n}\n", "/* eslint-disable no-undefined */\n\nimport throttle from './throttle.js';\n\n/**\n * Debounce execution of a function. Debouncing, unlike throttling,\n * guarantees that a function is only executed a single time, either at the\n * very beginning of a series of calls, or at the very end.\n *\n * @param {number} delay - A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful.\n * @param {Function} callback - A function to be executed after delay milliseconds. The `this` context and all arguments are passed through, as-is,\n * to `callback` when the debounced-function is executed.\n * @param {object} [options] - An object to configure options.\n * @param {boolean} [options.atBegin] - Optional, defaults to false. If atBegin is false or unspecified, callback will only be executed `delay` milliseconds\n * after the last debounced-function call. If atBegin is true, callback will be executed only at the first debounced-function call.\n * (After the throttled-function has not been called for `delay` milliseconds, the internal counter is reset).\n *\n * @returns {Function} A new, debounced function.\n */\nexport default function (delay, callback, options) {\n\tconst { atBegin = false } = options || {};\n\treturn throttle(delay, callback, { debounceMode: atBegin !== false });\n}\n", "import { throttle } from \"throttle-debounce\";\n\nconst INTERSECTION_OPTS = {\n\trootMargin: \"-50% 0% -50% 0%\",\n\tthreshold: [0.0],\n};\n\n/**\n * abstract class to hold listeners for element visibility\n * implements IntersectionObserver API when available\n * falls back to scroll, resize, and orientationChange listeners if not\n */\nexport default class IntersectionObserved {\n\tconstructor(el) {\n\t\tthis.el = el;\n\t\tthis.imageObserver = null;\n\t\tthis.hasBecomeVisible = false;\n\t}\n\n\t/**\n\t * Add event handlers to determine element visibility\n\t * use either IntersectionObserver API if available\n\t * fallback to use scroll, resize, and orientationChange\n\t */\n\tinitVisibilityCheck(opts) {\n\t\tconst intops = Object.assign(INTERSECTION_OPTS, opts);\n\t\t// console.log(\"intops\", intops);\n\t\tif (\"IntersectionObserver\" in window) {\n\t\t\tthis.imageObserver = new IntersectionObserver(this.intersectionCallback.bind(this), intops);\n\t\t\tthis.imageObserver.observe(this.el);\n\t\t} else {\n\t\t\tthis.throttledIntersectionDelegate = throttle(100, this.insersectionFallback.bind(this));\n\t\t\tdocument.addEventListener(\"scroll\", this.throttledIntersectionDelegate);\n\t\t\twindow.addEventListener(\"resize\", this.throttledIntersectionDelegate);\n\t\t\twindow.addEventListener(\"orientationChange\", this.throttledIntersectionDelegate);\n\t\t\tthis.insersectionFallback();\n\t\t}\n\t}\n\n\t/**\n\t * IntersectionObserver API intersection handler\n\t */\n\tintersectionCallback(entries) {\n\t\t//console.log('intersectionCallback', entries[0]);\n\n\t\tif (entries[0].isIntersecting) {\n\t\t\tthis.imageObserver.unobserve(this.el);\n\t\t\tthis.onBecomeVisible();\n\t\t\treturn;\n\t\t}\n\t}\n\n\t/**\n\t * Fallback visibility events handler\n\t */\n\tinsersectionFallback() {\n\t\tconst scrollTop = window.pageYOffset;\n\t\tif (this.el.offsetTop < window.innerHeight + scrollTop) {\n\t\t\tdocument.removeEventListener(\"scroll\", this.throttledIntersectionDelegate);\n\t\t\twindow.removeEventListener(\"resize\", this.throttledIntersectionDelegate);\n\t\t\twindow.removeEventListener(\"orientationChange\", this.throttledIntersectionDelegate);\n\t\t\tthis.onBecomeVisible();\n\t\t}\n\t}\n\n\t/**\n\t * Init slideshow and non slideshow before after event handlers, timeout, video\n\t */\n\tonBecomeVisible() {\n\t\tthis.hasBecomeVisible = true;\n\t}\n}\n", "/*globals jQuery:false */\nimport IntersectionObserved from \"./lib/intersection-observed.js\";\n\nconst BEFORE_AFTER_TIMEOUT = 1000;\nconst BEFORE_AFTER_FADE_SPEED = 1000;\n\nclass FeaturedBeforeAfter extends IntersectionObserved {\n\tconstructor(el) {\n\t\tsuper(el);\n\n\t\tthis.dom = {\n\t\t\tel,\n\t\t\tbefore: el.querySelector(\".featured-pages-grid__background--before\"),\n\t\t\tafter: el.querySelector(\".featured-pages-grid__background--after\"),\n\t\t\tbackgrounds: el.querySelectorAll(\".featured-pages-grid__background > div\"),\n\t\t};\n\n\t\t// console.log(\"FeaturedBeforeAfter\", this.dom);\n\n\t\tif (!this.dom.before || !this.dom.after || !this.dom.backgrounds) return;\n\n\t\tlet transTimeout = parseInt(el.dataset.beforeAfterTimeout, 10);\n\t\tif (!transTimeout || isNaN(transTimeout)) {\n\t\t\ttransTimeout = BEFORE_AFTER_TIMEOUT;\n\t\t}\n\n\t\t// console.log(\"transTimeout:\", transTimeout);\n\n\t\tlet transSpeed = parseInt(el.dataset.beforeAfterSpeed, 10);\n\t\tif (!transSpeed || isNaN(transSpeed)) {\n\t\t\ttransSpeed = BEFORE_AFTER_FADE_SPEED;\n\t\t}\n\n\t\t// console.log(\"transSpeed:\", transSpeed);\n\n\t\tthis.transTimeout = transTimeout;\n\t\tthis.transSpeed = transSpeed;\n\n\t\t//this.beforeAfterTimeouts = [];\n\n\t\tthis.addBgLoadedListeners();\n\n\t\tthis.beforeVisible = true;\n\n\t\t// start visibility listener\n\t\tthis.initVisibilityCheck({\n\t\t\t//rootMargin: '-20%',\n\t\t});\n\t}\n\n\t// attempt to determine when our items' background images are loaded\n\t// ideally, the initial \"to grid\" anime won't run until all images are loaded\n\taddBgLoadedListeners() {\n\t\tlet bg;\n\n\t\tconst home = this;\n\n\t\t// flags\n\t\tthis.allBgsLoaded = false;\n\t\tthis.bgsToLoad = 0;\n\t\tthis.bgsLoaded = 0;\n\n\t\t// loop the background elements and extract the image url\n\t\t// then add as src to new img el with load listener\n\t\t[...this.dom.backgrounds].forEach((el) => {\n\t\t\tbg = el.style.backgroundImage.slice(4, -1).replace(/['\"]/g, \"\");\n\n\t\t\tif (bg) {\n\t\t\t\tthis.bgsToLoad++;\n\n\t\t\t\tjQuery(\"\")\n\t\t\t\t\t.attr(\"src\", bg)\n\t\t\t\t\t.on(\"load\", function () {\n\t\t\t\t\t\tjQuery(this).remove();\n\n\t\t\t\t\t\thome.bgsLoaded++;\n\n\t\t\t\t\t\t// console.log(\"bg \" + home.bgsLoaded + \" of \" + home.bgsToLoad + \" loaded\");\n\n\t\t\t\t\t\tif (home.bgsLoaded >= home.bgsToLoad) {\n\t\t\t\t\t\t\thome.allBgsLoaded = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t}\n\t\t});\n\n\t\tif (this.bgsLoaded >= this.bgsToLoad) {\n\t\t\tthis.allBgsLoaded = true;\n\t\t}\n\t}\n\n\t/**\n\t * callback from intersection listener(s)\n\t */\n\tonBecomeVisible() {\n\t\t// console.log(\"onBecomeVisible\", this.allBgsLoaded);\n\n\t\tif (this.hasBecomeVisible) return;\n\n\t\t// set inited flag\n\t\tthis.hasBecomeVisible = true;\n\n\t\t// if our items' bg images aren't loaded\n\t\t// check them again on an interval\n\t\t// if not loaded after x number checks, run anime anyway\n\t\tif (this.allBgsLoaded) {\n\t\t\tthis.animateBeforeAfter();\n\t\t} else {\n\t\t\tthis.bgChecks = 0;\n\t\t\tthis.bgCheckID = setInterval(() => {\n\t\t\t\t// console.log(\"bgs loaded check\", this.bgsLoaded, this.bgChecks);\n\n\t\t\t\tthis.bgChecks++;\n\n\t\t\t\tif (this.allBgsLoaded || this.bgChecks > 5) {\n\t\t\t\t\tclearInterval(this.bgCheckID);\n\t\t\t\t\tthis.animateBeforeAfter();\n\t\t\t\t}\n\t\t\t}, 200);\n\t\t}\n\t}\n\n\tanimateBeforeAfter() {\n\t\tsetTimeout(() => {\n\t\t\t//console.log('before after timeout fire!');\n\n\t\t\tif (this.beforeVisible) {\n\t\t\t\tjQuery(this.dom.before).fadeOut(this.transSpeed, () => {\n\t\t\t\t\tthis.beforeVisible = false;\n\t\t\t\t\tthis.animateBeforeAfter();\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tjQuery(this.dom.before).fadeIn(this.transSpeed, () => {\n\t\t\t\t\tthis.beforeVisible = true;\n\t\t\t\t\tthis.animateBeforeAfter();\n\t\t\t\t});\n\t\t\t}\n\t\t}, this.transTimeout);\n\t}\n}\n\njQuery(document).ready(function () {\n\tlet i;\n\n\tlet beforeAfterEls = document.querySelectorAll(\".featured-pages-grid__element--is-before-after\");\n\n\tfor (i = 0; i < beforeAfterEls.length; i++) {\n\t\tnew FeaturedBeforeAfter(beforeAfterEls[i]);\n\t}\n});\n"], "mappings": "MAuBe,SAAAA,EAAUC,EAAOC,EAAUC,EAAS,CAK9CA,IAAAA,EAAAA,GAAW,CAAA,EAJfC,EAAAC,EACCC,WAAAA,EADDF,IAAA,OACc,GADdA,EAAAG,EAAAF,EAECG,UAAAA,EAFDD,IAAA,OAEa,GAFbA,EAAAE,EAAAJ,EAGCK,aAAAA,EAHDD,IAAA,OAGgBE,OAHhBF,EAUIG,EACAC,EAAY,GAGZC,EAAW,EAGf,SAASC,GAAuB,CAC3BH,GACHI,aAAaJ,CAAD,CAEb,CAGQK,SAAAA,EAAOd,EAAS,CACSA,IAAAA,EAAAA,GAAW,CAAA,EAA5Ce,EAAAC,EAAQC,aAAAA,EAARF,IAAA,OAAuB,GAAvBA,EACAH,EAAoB,EACpBF,EAAY,CAACO,CACb,CAOD,SAASC,GAAuB,CAAA,QAAAC,EAAA,UAAA,OAAZC,EAAY,IAAA,MAAAD,CAAA,EAAAE,EAAA,EAAAA,EAAAF,EAAAE,IAAZD,EAAYC,CAAA,EAAA,UAAAA,CAAA,EAC3BC,IAAAA,EAAO,KACPC,EAAUC,KAAKC,IAAL,EAAad,EAE3B,GAAID,EACH,OAID,SAASgB,GAAO,CACff,EAAWa,KAAKC,IAAL,EACX1B,EAAS4B,MAAML,EAAMF,CAArB,CACA,CAMD,SAASQ,GAAQ,CAChBnB,EAAYD,MACZ,CAEG,CAACH,GAAaE,GAAgB,CAACE,GAMlC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AGb,KAAK,mBAGT,KAAK,iBAAmB,GAKpB,KAAK,aACR,KAAK,mBAAmB,GAExB,KAAK,SAAW,EAChB,KAAK,UAAY,YAAY,IAAM,CAGlC,KAAK,YAED,KAAK,cAAgB,KAAK,SAAW,KACxC,cAAc,KAAK,SAAS,EAC5B,KAAK,mBAAmB,EAE1B,EAAG,GAAG,GAER,CAEA,oBAAqB,CACpB,WAAW,IAAM,CAGZ,KAAK,cACR,OAAO,KAAK,IAAI,MAAM,EAAE,QAAQ,KAAK,WAAY,IAAM,CACtD,KAAK,cAAgB,GACrB,KAAK,mBAAmB,CACzB,CAAC,EAED,OAAO,KAAK,IAAI,MAAM,EAAE,OAAO,KAAK,WAAY,IAAM,CACrD,KAAK,cAAgB,GACrB,KAAK,mBAAmB,CACzB,CAAC,CAEH,EAAG,KAAK,YAAY,CACrB,CACD,EAEA,OAAO,QAAQ,EAAE,MAAM,UAAY,CAClC,IAAI,EAEAC,EAAiB,SAAS,iBAAiB,gDAAgD,EAE/F,IAAK,EAAI,EAAG,EAAIA,EAAe,OAAQ,IACtC,IAAIP,EAAoBO,EAAe,CAAC,CAAC,CAE3C,CAAC", "names": ["throttle", "delay", "callback", "options", "_ref$noTrailing", "_ref", "noTrailing", "_ref$noLeading", "noLeading", "_ref$debounceMode", "debounceMode", "undefined", "timeoutID", "cancelled", "lastExec", "clearExistingTimeout", "clearTimeout", "cancel", "_ref2$upcomingOnly", "_ref2", "upcomingOnly", "wrapper", "_len", "arguments_", "_key", "self", "elapsed", "Date", "now", "exec", "apply", "clear", "setTimeout", "INTERSECTION_OPTS", "IntersectionObserved", "el", "opts", "intops", "throttle", "entries", "scrollTop", "BEFORE_AFTER_TIMEOUT", "BEFORE_AFTER_FADE_SPEED", "FeaturedBeforeAfter", "IntersectionObserved", "el", "transTimeout", "transSpeed", "bg", "home", "beforeAfterEls"] }