{"version":3,"sources":["webpack:///./LeLab.Web/src/js/segmented.entry.js"],"names":["PageComponent","constructor","node","container","this","anchors","querySelectorAll","sections","map","x","getAttribute","join","intersectionObserver","IntersectionObserver","entries","i","length","isIntersecting","active","target","id","rootMargin","forEach","observe","c","classList","remove","querySelector","add","destroy","disconnect"],"mappings":"4FAAA,kBA4CA,IAAIA,IAAc,aA1ClB,MACIC,aAAY,KAAEC,EAAF,UAAQC,IAChBC,KAAKF,KAAOA,EACZE,KAAKC,QAAU,IAAID,KAAKF,KAAKI,iBAAiB,gCAC9CF,KAAKG,SAAWJ,EAAUG,iBAAiBF,KAAKC,QAAQG,IAAIC,GAAKA,EAAEC,aAAa,SAASC,KAAK,MAE9FP,KAAKQ,qBAAuB,IAAIC,qBAC3BC,IACG,IAAK,IAAIC,EAAID,EAAQE,OAAS,EAAGD,GAAK,EAAGA,IACrC,GAAID,EAAQC,GAAGE,eAEX,YADAb,KAAKc,OAAOJ,EAAQC,GAAGI,OAAOC,KAK1C,CACIC,WAAY,sBAIpBjB,KAAKG,SAASe,QAAQb,IAClBL,KAAKQ,qBAAqBW,QAAQd,KAI1CS,OAAOE,EAAK,MACR,IAAKA,EAAI,OACT,MAAMI,EAAI,0BACVpB,KAAKC,QAAQiB,QAAQb,GAAKA,EAAEgB,UAAUC,OAAOF,IAC7CpB,KAAKF,KAAKyB,cAAV,kCAAmDP,EAAnD,OAA2DK,UAAUG,IAAIJ,GAG7EK,UACIzB,KAAKQ,qBAAqBkB,oBAEnB1B,KAAKF,YACLE,KAAKC,eACLD,KAAKG,gBACLH,KAAKQ,0B","file":"segmented.js","sourcesContent":["import { PageComponent } from \"barba\"\r\n\r\nclass Segmented {\r\n constructor({ node, container }) {\r\n this.node = node\r\n this.anchors = [...this.node.querySelectorAll('.segmented__link[href^=\"#\"]')]\r\n this.sections = container.querySelectorAll(this.anchors.map(x => x.getAttribute('href')).join(','))\r\n \r\n this.intersectionObserver = new IntersectionObserver(\r\n (entries) => {\r\n for (let i = entries.length - 1; i >= 0; i--) {\r\n if (entries[i].isIntersecting) {\r\n this.active(entries[i].target.id)\r\n return\r\n }\r\n }\r\n },\r\n {\r\n rootMargin: \"-50% 0px -50% 0px\"\r\n }\r\n )\r\n \r\n this.sections.forEach(x => {\r\n this.intersectionObserver.observe(x)\r\n })\r\n }\r\n\r\n active(id = null) {\r\n if (!id) return\r\n const c = 'segmented__link--active'\r\n this.anchors.forEach(x => x.classList.remove(c))\r\n this.node.querySelector(`.segmented__link[href=\"#${id}\"]`).classList.add(c)\r\n }\r\n\r\n destroy() {\r\n this.intersectionObserver.disconnect()\r\n\r\n delete this.node\r\n delete this.anchors\r\n delete this.sections\r\n delete this.intersectionObserver\r\n }\r\n}\r\n\r\nnew PageComponent(\".segmented\", Segmented)\r\n"],"sourceRoot":""}