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,MAASrC,CAAA,CAAKsC,MAAA,GAASxC,CAAA,CAAOoB,MAAA;MAAA,CAMd,MAAnBpB,CAAA,CAAOY,OAAA,KAAsC,MAAjBT,CAAA,KAC9BH,CAAA,CAAOd,KAAA,CAAM6B,IAAA,CAAK,MAAMf,CAAA,CAAOW,OAAA,GAC/BX,CAAA,CAAOY,OAAA,IAAU,GAEbZ,CAAA,CAAOT,KAAA,KAAUU,CAAA,KAA2B,MAAnBD,CAAA,CAAOP,OAAA,UAC7B+B,kBAAA,CAAmBiB,MAAA,CAAO1C,CAAA,EAAU,IAGF,MAAnC,KAAKyB,kBAAA,CAAmBF,MAAA,SACrBoB,UAAA,OASY,MAAnB1C,CAAA,CAAOY,OAAA,KAAqC,MAAjBT,CAAA,KAC7BH,CAAA,CAAOT,KAAA,CAAMwB,IAAA,CAAK,MAAMf,CAAA,CAAOW,OAAA,GAC/BX,CAAA,CAAOY,OAAA,IAAU,IAEM,MAAnBZ,CAAA,CAAOP,OAAA,UACJ+B,kBAAA,CAAmBiB,MAAA,CAAO1C,CAAA,EAAU,IAGF,MAAnC,KAAKyB,kBAAA,CAAmBF,MAAA,SACrBoB,UAAA;IAAA;EAAA,GAYfvC,CAAA,CAAAkB,SAAA,CAAAe,iBAAA;IAAA,KACOT,kBAAA,GAAqBC,MAAA,CAAOC,WAAA,OAC5BI,gBAAA;EAAA,GAQP9B,CAAA,CAAAkB,SAAA,CAAAqB,UAAA;IAAAd,MAAA,CAESe,mBAAA,CAAoB,UAAU,KAAKX,yBAAA,GAAAJ,MAAA,CACnCe,mBAAA,CAAoB,UAAU,KAAKR,0BAAA;EAAA,GAQ5ChC,CAAA,CAAAkB,SAAA,CAAAuB,OAAA;IAAA,KACOX,gBAAA;EAAA,GAAA9B,CAAA;AAAA","sources":["webpack://WebpackConfig.Web/./app/src/js/hunt-watch.js","webpack://WebpackConfig.Web/../src/throttle.js","webpack://WebpackConfig.Web/../src/index.js"],"sourcesContent":["import hunt from 'huntjs';\r\n\r\nclass HuntItem {\r\n constructor(el) {\r\n\r\n // store for later\r\n this.el = el;\r\n\r\n let huntConfig = {\r\n enter: (el) => {\r\n el.classList.add('hunt-in');\r\n }\r\n };\r\n\r\n if (el.dataset.watch != 'once') {\r\n huntConfig.leave = (el) => {\r\n el.classList.remove('hunt-in');\r\n };\r\n huntConfig.persist = true\r\n }\r\n\r\n // create hunt\r\n new hunt(el, huntConfig);\r\n }\r\n}\r\n\r\n// export the default function to create\r\nexport function createFrom(wrappers) {\r\n wrappers.forEach((node) => {\r\n // if node is an element\r\n if (node.nodeType === 1) {\r\n new HuntItem(node);\r\n }\r\n });\r\n}","const DEFAULT_THROTTLE_INTERVAL = 100\n\n/**\n * Throttles method execution to prevent some performance bottlenecks\n * @param {Function} fn method to throttle\n * @param {Number} interval milliseconds for the method to be delayed\n */\nfunction throttle(fn, interval = DEFAULT_THROTTLE_INTERVAL) {\n let inThrottle\n let lastFunc\n let lastRan\n\n return function() {\n if (inThrottle === true) {\n clearTimeout(lastFunc)\n lastFunc = setTimeout(function() {\n if (Date.now() - lastRan >= interval) {\n fn.apply(this, arguments)\n lastRan = Date.now()\n }\n }, interval - (Date.now() - lastRan))\n } else {\n fn.apply(this, arguments)\n lastRan = Date.now()\n inThrottle = true\n }\n }\n}\n\nexport default throttle\n","import noop from './noop'\nimport throttle from './throttle'\n\n/**\n * Constructor for element that should be hunted\n * @constructor Hunted\n * @param {Node} element\n * @param {Object} config\n */\nclass Hunted {\n constructor(element, config) {\n this.element = element\n\n // instantiate element as not visible\n this.visible = false\n\n // extend properties from config or fallback to prototype values\n for (var prop in config) {\n if (Object.hasOwnProperty.call(config, prop)) {\n this[prop] = config[prop]\n }\n }\n\n // replace options with dataset if present\n if (typeof element.dataset !== 'undefined') {\n if (typeof element.dataset.huntPersist !== 'undefined') {\n try {\n this.persist = JSON.parse(element.dataset.huntPersist)\n } catch (e) {}\n }\n if (typeof element.dataset.huntOffset !== 'undefined') {\n try {\n this.offset = JSON.parse(element.dataset.huntOffset)\n } catch (e) {}\n }\n }\n }\n}\n\n// protoype values\nHunted.prototype.offset = 0\nHunted.prototype.persist = false\nHunted.prototype.enter = noop\nHunted.prototype.leave = noop\n\n/**\n * Creates and initializes observer\n * @constructor Hunt\n * @param {Node|NodeList|Array} target\n * @param {Object} options\n */\nclass Hunt {\n constructor(target, options) {\n // sanity check for first argument\n const isValidTarget =\n (target && target.nodeType === 1) || typeof target.length === 'number'\n if (!isValidTarget) {\n throw new TypeError(\n 'hunt: observer first argument should be a node or a list of nodes'\n )\n }\n // sanity check for second argument\n if (typeof options !== 'object') {\n throw new TypeError('hunt: observer second argument should be an object')\n }\n\n // turn target to array\n if (target.nodeType === 1) {\n this.__huntedElements__ = [new Hunted(target, options)]\n } else {\n const targetArray = [].slice.call(target)\n this.__huntedElements__ = targetArray.map((t) => new Hunted(t, options))\n }\n\n // hoist viewport metrics\n this.__viewportHeight__ = window.innerHeight\n\n // connect observer and pass in throttle interval\n this.__connect__(options.throttleInterval)\n }\n\n /**\n * Assign throttled actions and add listeners\n * @param {Number} throttleInterval\n * @method __connect__\n * @memberof Hunt\n */\n __connect__(throttleInterval) {\n // throttle actions\n this.__throttledHuntElements__ = throttle(\n this.__huntElements__.bind(this),\n throttleInterval\n )\n this.__throttledUpdateMetrics__ = throttle(\n this.__updateMetrics__.bind(this),\n throttleInterval\n )\n\n // add listeners\n window.addEventListener('scroll', this.__throttledHuntElements__)\n window.addEventListener('resize', this.__throttledUpdateMetrics__)\n\n // run first check\n this.__huntElements__()\n }\n\n /**\n * Checks if hunted elements are visible and apply callbacks\n * @method __huntElements__\n * @memberof Hunt\n */\n __huntElements__() {\n let position = this.__huntedElements__.length\n\n while (position) {\n --position\n const hunted = this.__huntedElements__[position]\n const rect = hunted.element.getBoundingClientRect()\n const isOnViewport =\n rect.top - hunted.offset < this.__viewportHeight__ &&\n rect.top >= -(rect.height + hunted.offset)\n\n /*\n * trigger (enter) event if element comes from a non visible state and the scrolled\n * viewport has reached the visible range of the element without exceeding it\n */\n if (hunted.visible === false && isOnViewport === true) {\n hunted.enter.call(null, hunted.element)\n hunted.visible = true\n // when the leave callback method is not set and hunting should not persist remove element\n if (hunted.leave === noop && hunted.persist !== true) {\n this.__huntedElements__.splice(position, 1)\n\n // end observer activity when there are no more elements\n if (this.__huntedElements__.length === 0) {\n this.disconnect()\n }\n }\n }\n\n /*\n * trigger (leave) event if element comes from a visible state\n * and it's out of the visible range its bottom or top limit\n */\n if (hunted.visible === true && isOnViewport === false) {\n hunted.leave.call(null, hunted.element)\n hunted.visible = false\n // when hunting should not persist remove element\n if (hunted.persist !== true) {\n this.__huntedElements__.splice(position, 1)\n\n // end observer activity when there are no more elements\n if (this.__huntedElements__.length === 0) {\n this.disconnect()\n }\n }\n }\n }\n }\n\n /**\n * Update viewport tracked height and runs a check\n * @method __updateMetrics__\n * @memberof Hunt\n */\n __updateMetrics__() {\n this.__viewportHeight__ = window.innerHeight\n this.__huntElements__()\n }\n\n /**\n * Remove listeners and stops observing elements\n * @method disconnect\n * @memberof Hunt\n */\n disconnect() {\n // remove listeners\n window.removeEventListener('scroll', this.__throttledHuntElements__)\n window.removeEventListener('resize', this.__throttledUpdateMetrics__)\n }\n\n /**\n * __huntElements__ public alias\n * @method trigger\n * @memberof Hunt\n */\n trigger() {\n this.__huntElements__()\n }\n}\n\nexport default Hunt\n"],"names":["hunt","HuntItem","_createClass","el","_classCallCheck","huntConfig","enter","classList","add","dataset","watch","leave","remove","persist","createFrom","wrappers","forEach","node","nodeType","e","n","t","i","s","o","clearTimeout","setTimeout","Date","now","apply","arguments","element","visible","Object","hasOwnProperty","call","huntPersist","JSON","parse","huntOffset","offset","prototype","length","TypeError","__huntedElements__","slice","map","__viewportHeight__","window","innerHeight","__connect__","throttleInterval","__throttledHuntElements__","__huntElements__","bind","__throttledUpdateMetrics__","__updateMetrics__","addEventListener","getBoundingClientRect","top","height","splice","disconnect","removeEventListener","trigger"],"sourceRoot":""}