{"version":3,"sources":["webpack:///./src/tc/js/components/Component.js","webpack:///./src/tc/js/components/InspirationBoard.js"],"names":["domTree","WeakMap","configuration","Component","el","config","arguments","length","undefined","_classCallCheck","this","Error","$el","jQuery","$","set","hasOwnProperty","dom","setupDefaults","addListeners","get","elements","_component","__webpack_require__","InspirationBoard","_possibleConstructorReturn","__proto__","Object","getPrototypeOf","call","$window","window","$inspirations","find","on","findMiddleElement","bind","deviceMiddle","height","each","index","element","rect","getBoundingClientRect","y","addClass","removeClass"],"mappings":"ohBAAA,IAAMA,EAAU,IAAIC,QACdC,EAAgB,IAAID,QA4BpBE,aAOJ,SAAAA,EAAYC,GAAgB,IAAZC,EAAYC,UAAAC,OAAA,QAAAC,IAAAF,UAAA,GAAAA,UAAA,MAC1B,+FAD0BG,CAAAC,KAAAP,QACR,IAAPC,EACT,MAAM,IAAIO,MAAM,wEASlBD,KAAKE,IAAMR,aAAcS,EAAST,EAAKU,EAAEV,GAEjB,IAApBM,KAAKE,IAAIL,SAEbP,EAAQe,IAAIL,SACZR,EAAca,IAAIL,KAAML,GAEpBK,KAAKL,OAAOW,eAAe,SAC7BN,KAAKO,IAAMP,KAAKL,OAAOY,KAGzBP,KAAKQ,gBACLR,KAAKS,0IAuCL,OAAOjB,EAAckB,IAAIV,gCA6BnBW,GACNA,OACKX,KAAKO,IACLI,GAGLrB,EAAQe,IAAIL,KAAMW,mBAYlB,OAAOrB,EAAQoB,IAAIV,yBAIRP,mXCrJfmB,EAAAC,EAAA,6CAEMC,cACJ,SAAAA,EAAYpB,GAAI,mGAAAK,CAAAC,KAAAc,oKAAAC,CAAAf,MAAAc,EAAAE,WAAAC,OAAAC,eAAAJ,IAAAK,KAAAnB,KACRN,6XAINM,KAAKO,KACHa,QAAShB,EAAEiB,QACXC,cAAetB,KAAKE,IAAIqB,KAAK,2EAK/BvB,KAAKO,IAAIa,QAAQI,GAAG,qBAAwBxB,KAAKyB,kBAAjDC,KAA4C1B,mDAI5C,IAAM2B,EAAe3B,KAAKO,IAAIa,QAAQQ,SAAW,EAEjD5B,KAAKO,IAAIe,cAAcO,KAAK,SAACC,EAAOC,GAClC,IAAMC,EAAOD,EAAQE,wBAEjBD,EAAKE,GAAKP,GAAgBK,EAAKE,EAAIF,EAAKJ,QAAUD,EACpDvB,EAAE2B,GAASI,SAAS,WAEpB/B,EAAE2B,GAASK,YAAY,gCAMhBtB","file":"39.8d1fc39a4cdf0ba576bb.js","sourcesContent":["const domTree = new WeakMap();\nconst configuration = new WeakMap();\n\n/**\n * Component is a class that should be extended for every component that's being made. It\n * is a helper class to keep the code uniform.\n *\n * __PLEASE NOTE__: This is only to be extended, not instantiated.\n *\n * @example\n * import Component from 'component';\n *\n * class Foo extends Component {\n * construction(el){\n * super(el);\n * }\n *\n * setupDefaults(){\n * // ...defaults go here\n * }\n *\n * addListeners(){\n * // ...listeners go here\n * }\n * }\n *\n * // Create a new Foo component\n * new Foo('.foo');\n */\nclass Component {\n /**\n * Component constructor - see {@link config} on how to pass in additional configuration to the constructor\n *\n * @param {string|Object} el - Main DOM element, you can pass a string such as `'.foo'` __or__ a jQuery object such as `$('.foo')`\n * @param {Object} [config={ }] - Additional component configuration; reachable with `this.config`\n */\n constructor(el, config = {}){\n if (typeof el === 'undefined') {\n throw new Error('You must provide an element as a String type or a jQuery object type');\n }\n\n /**\n * Main class element, this will be a jQuery instance\n * This can be reachable at any time in your superclass with `this.$el`\n *\n * @type {Object}\n */\n this.$el = el instanceof jQuery ? el : $(el);\n\n if (this.$el.length === 0) return;\n\n domTree.set(this, {});\n configuration.set(this, config);\n\n if (this.config.hasOwnProperty('dom')) {\n this.dom = this.config.dom;\n }\n\n this.setupDefaults();\n this.addListeners();\n }\n\n /**\n * This method is used for override;\n * It's called directly after the element and configuration have been set up\n * @abstract\n */\n setupDefaults(){}\n\n /**\n * This method is used for override;\n * It's called directly after `setupDefaults()`, so everything is ready and setup at this point.\n * @abstract\n */\n addListeners(){}\n\n /**\n * Get component configuration\n *\n * @example\n * class Foo extends Component {\n * construction(el, config){\n * super(el, config);\n * }\n *\n * setupDefaults(){\n * console.log(this.config.name); // Outputs \"Foo\"\n * }\n * }\n *\n * // Create a new Foo component with some configuration\n * new Foo('.foo', {\n * name: 'Foo'\n * });\n *\n * @type {Object}\n */\n get config(){\n return configuration.get(this);\n }\n\n /**\n * Set DOM object\n *\n * @example\n * class Foo extends Component {\n * construction(el){\n * super(el);\n * }\n *\n * setupDefaults(){\n * this.dom = {\n * $container: this.$el.find('.container')\n * }\n * }\n *\n * addListeners(){\n * //DOM object is available\n * console.log(this.dom.$container);\n * }\n * }\n *\n * // Create a new Foo component\n * new Foo('.foo');\n *\n * @type {Object}\n */\n set dom(elements){\n elements = {\n ...this.dom,\n ...elements\n };\n\n domTree.set(this, elements);\n }\n\n /**\n * Get DOM object\n *\n * @example\n * this.dom\n *\n * @type {Object}\n */\n get dom(){\n return domTree.get(this);\n }\n}\n\nexport default Component;\n\n\n\n// WEBPACK FOOTER //\n// ./src/tc/js/components/Component.js","import Component from 'component';\n\nclass InspirationBoard extends Component {\n constructor(el) {\n super(el);\n }\n\n setupDefaults() {\n this.dom = {\n $window: $(window),\n $inspirations: this.$el.find('.inspiration-board__inspiration')\n };\n }\n\n addListeners() {\n this.dom.$window.on('scroll resize load', ::this.findMiddleElement);\n }\n\n findMiddleElement() {\n const deviceMiddle = this.dom.$window.height() / 2;\n\n this.dom.$inspirations.each((index, element) => {\n const rect = element.getBoundingClientRect();\n\n if (rect.y <= deviceMiddle && rect.y + rect.height >= deviceMiddle) {\n $(element).addClass('in-view');\n } else {\n $(element).removeClass('in-view');\n }\n });\n }\n}\n\nexport default InspirationBoard;\n\n\n\n// WEBPACK FOOTER //\n// ./src/tc/js/components/InspirationBoard.js"],"sourceRoot":""}