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tB9B,KAAKK,SAAU,EACfL,KAAKU,cACFV,KAAKU,aAAeV,KAAKQ,cAAaR,KAAKU,YAAc,GAC5D,IAAI,IAAIe,EAAI,EAAGA,EAAIzB,KAAKQ,YAAaiB,IAAKzB,KAAKM,MAAMmB,GAAGC,UAAUC,OAAO,cAAeF,GAAKzB,KAAKU,aAClGV,KAAKW,QAAUK,YAAW,WACtB,EAAKM,MACR,GAAE,IACN,CACJ,G,qBAED,WACIF,aAAapB,KAAKW,SAClBX,KAAKW,QAAU,KACfX,KAAKK,SAAU,EACfL,KAAKD,GAAG2B,UAAUK,OAAO,mBACzB,IAAI,IAAIN,EAAI,EAAGA,EAAIzB,KAAKQ,YAAaiB,IAAKzB,KAAKM,MAAMmB,GAAGC,UAAUK,OAAO,cAC5E,M,gFAhFCjC,GAoFC,SAASkC,EAAWC,GACvBA,EAASC,SAAQ,SAACC,GAEQ,IAAlBA,EAAKC,UACL,IAAItC,EAAaqC,EAExB,GACJ,C","sources":["webpack://nationalspacecentre.web/./wwwroot/app/src/js/list-carousel.js"],"sourcesContent":["import { ResizeObserver as Polyfill } from '@juggle/resize-observer';\r\nconst ResizeObserver = window.ResizeObserver || Polyfill;\r\n\r\nclass ListCarousel {\r\n\r\n constructor(el) {\r\n this.el = el;\r\n this.widthLimit = el.dataset.crossfadeBelow !== '' ? parseInt(el.dataset.crossfadeBelow) : 0;\r\n this.running = false;\r\n this.items = [...el.querySelectorAll('li')];\r\n this.itemsLength = this.items.length;\r\n this.activeIndex = -1;\r\n this.timeout = null;\r\n this.paused = false;\r\n this.resizeRequested = false;\r\n this.resizeTimeout = null;\r\n\r\n if(this.widthLimit > 0) {\r\n\r\n // add resize observer\r\n this.ro = new ResizeObserver(() => {\r\n if(!this.resizeRequested) {\r\n this.resizeRequested = true;\r\n this.resizeTimeout = setTimeout(() => {\r\n this.resize();\r\n this.resizeRequested = false;\r\n this.resizeTimeout = null;\r\n }, 100);\r\n }\r\n });\r\n this.ro.observe(this.el); // Watch dimension changes wrapping element\r\n\r\n }\r\n\r\n // pause carousel on mouseover\r\n this.el.onmouseover = () => {\r\n this.paused = true;\r\n clearTimeout(this.timeout);\r\n }\r\n this.el.onmouseout = () => {\r\n this.paused = false;\r\n if(this.running) {\r\n this.timeout = setTimeout(() => {\r\n this.next();\r\n }, 4000);\r\n }\r\n }\r\n }\r\n\r\n resize() {\r\n let active = this.el.offsetWidth < this.widthLimit;\r\n for(let x = 0; x < this.itemsLength; x++) {\r\n this.items[x].classList.toggle('fade', active);\r\n this.items[x].removeAttribute('hidden');\r\n }\r\n // start / stop\r\n if(active) {\r\n if(!this.running) this.next();\r\n } else {\r\n // turn off and show all list items\r\n if(this.running) this.disable();\r\n }\r\n }\r\n\r\n next() {\r\n if(!this.paused) {\r\n this.el.classList.add('carousel-active');\r\n this.running = true;\r\n this.activeIndex++;\r\n if(this.activeIndex >= this.itemsLength) this.activeIndex = 0;\r\n for(let x = 0; x < this.itemsLength; x++) this.items[x].classList.toggle('item-active', x == this.activeIndex);\r\n this.timeout = setTimeout(() => {\r\n this.next();\r\n }, 4000);\r\n }\r\n }\r\n\r\n disable() {\r\n clearTimeout(this.timeout);\r\n this.timeout = null;\r\n this.running = false;\r\n this.el.classList.remove('carousel-active');\r\n for(let x = 0; x < this.itemsLength; x++) this.items[x].classList.remove('item-active');\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 ListCarousel(node);\r\n }\r\n });\r\n}\r\n\r\n"],"names":["ResizeObserver","window","Polyfill","ListCarousel","el","this","widthLimit","dataset","crossfadeBelow","parseInt","running","items","querySelectorAll","itemsLength","length","activeIndex","timeout","paused","resizeRequested","resizeTimeout","ro","setTimeout","resize","observe","onmouseover","clearTimeout","onmouseout","next","active","offsetWidth","x","classList","toggle","removeAttribute","disable","add","remove","createFrom","wrappers","forEach","node","nodeType"],"sourceRoot":""}