{"version":3,"sources":["webpack:///./LeLab.Web/src/js/bg-img-loaded-class.entry.js"],"names":["PageComponent","constructor","node","this","img","initHandler","init","bind","loadedHandler","loaded","window","requestAnimationFrame","bgImgUrl","getComputedStyle","getPropertyValue","toLowerCase","startsWith","url","replace","Image","src","complete","addEventListener","classes","dataset","bgImgLoadedClass","split","push","isTriggerBack","classList","add","removeEventListener","destroy"],"mappings":"2FAAA,kBA2DA,IAAIA,IAAc,6BAzDlB,MAEIC,aAAY,KAAEC,IACVC,KAAKD,KAAOA,EACZC,KAAKC,IAAM,KAEXD,KAAKE,YAAcF,KAAKG,KAAKC,KAAKJ,MAClCA,KAAKK,cAAgBL,KAAKM,OAAOF,KAAKJ,MAEtCO,OAAOC,sBAAsBR,KAAKE,aAGtCC,OACI,MAAMM,EAAWF,OAAOG,iBAAiBV,KAAKD,MAAMY,iBAAiB,oBAErE,IAAKF,EAASG,cAAcC,WAAW,QAEnC,YADAb,KAAKM,SAIT,IAAIQ,EAAML,EAASM,QAAQ,mBAAoB,IAC/Cf,KAAKC,IAAM,IAAIe,MACfhB,KAAKC,IAAIgB,IAAMH,EAEXd,KAAKC,IAAIiB,SACTlB,KAAKM,SAITN,KAAKC,IAAIkB,iBAAiB,OAAQnB,KAAKK,eAG3CC,SACI,IAAIc,EAAUpB,KAAKD,KAAKsB,QAAQC,iBAChCF,EAAUA,EAAQL,QAAQ,OAAQ,KAClCK,EAAUA,EAAQG,MAAM,KAExBH,EAAQI,KAAKC,cAAkB,UAAY,aAE3CzB,KAAKD,KAAK2B,UAAUC,OAAOP,GAE3BpB,KAAKC,KAAOD,KAAKC,IAAI2B,oBAAoB,OAAQ5B,KAAKK,eACtDL,KAAKC,IAAM,KAGf4B,WACK7B,KAAKC,KAAOD,KAAKC,IAAI2B,oBAAoB,OAAQ5B,KAAKK,sBAEhDL,KAAKD,YACLC,KAAKC,WAELD,KAAKE,mBACLF,KAAKK,mB","file":"bg-img-loaded-class.js","sourcesContent":["import { PageComponent, isTriggerBack } from \"barba\"\r\n\r\nclass IsWithinClass {\r\n\r\n constructor({ node }) {\r\n this.node = node\r\n this.img = null\r\n\r\n this.initHandler = this.init.bind(this)\r\n this.loadedHandler = this.loaded.bind(this)\r\n\r\n window.requestAnimationFrame(this.initHandler)\r\n }\r\n\r\n init() {\r\n const bgImgUrl = window.getComputedStyle(this.node).getPropertyValue(\"background-image\")\r\n\r\n if (!bgImgUrl.toLowerCase().startsWith(\"url(\")) {\r\n this.loaded()\r\n return\r\n }\r\n\r\n let url = bgImgUrl.replace(/^url\\(\"?|\"?\\)$/ig, '')\r\n this.img = new Image()\r\n this.img.src = url\r\n\r\n if (this.img.complete) {\r\n this.loaded()\r\n return\r\n }\r\n\r\n this.img.addEventListener('load', this.loadedHandler)\r\n }\r\n\r\n loaded() {\r\n let classes = this.node.dataset.bgImgLoadedClass\r\n classes = classes.replace(/\\s+/g, \" \")\r\n classes = classes.split(\" \")\r\n\r\n classes.push(isTriggerBack() ? 'is-back' : 'is-foward')\r\n \r\n this.node.classList.add(...classes)\r\n \r\n this.img && this.img.removeEventListener('load', this.loadedHandler)\r\n this.img = null\r\n }\r\n\r\n destroy() {\r\n !this.img || this.img.removeEventListener('load', this.loadedHandler)\r\n \r\n delete this.node\r\n delete this.img\r\n\r\n delete this.initHandler\r\n delete this.loadedHandler\r\n }\r\n\r\n}\r\n\r\nnew PageComponent(\"[data-bg-img-loaded-class]\", IsWithinClass)"],"sourceRoot":""}