{"version":3,"file":"sticky-header.min.js?v=f84938edff0472656a41","mappings":"48BAIA,IAIqBA,EAAY,WAK7B,SAAAA,EAAYC,I,4FAAIC,CAAA,KAAAF,GACZG,KAAKF,GAAKA,EAEVE,KAAKC,aAAgBH,EAAGG,aACxBD,KAAKE,aAAeF,KAAKC,aAAaE,UACtCH,KAAKI,UAAYN,EAAGK,UAGpBH,KAAKK,WAAaC,SAASC,KAAKC,aAEhCR,KAAKS,kBACT,C,UAeC,O,EAbDZ,E,EAiEC,EAAAa,IAAA,OAAAC,MA9DD,WAEI,IAAMC,EAAgBN,SAASO,eAAe,iBAE3CD,EACsB,IAAIf,EAAae,GAGtCE,QAAQC,KAAK,4DAErB,K,EAbA,EAAAL,IAAA,kBAAAC,MAoBA,WACI,IAAMH,EAAeF,SAASC,KAAKC,aAC/BA,IAAiBR,KAAKK,aACtBL,KAAKK,WAAaG,EAClBR,KAAKgB,gBAEb,GAEA,CAAAN,IAAA,qBAAAC,MAGA,WACIX,KAAKiB,mBAGkBC,OAAOC,QAAUD,OAAOC,QAAUD,OAAOE,cAE1CpB,KAAKE,aAAeF,KAAKI,WAC3CJ,KAAKF,GAAGuB,UAAUC,IAAI,QACtBtB,KAAKF,GAAGyB,aAAa,gBAAiB,UAGtCvB,KAAKF,GAAGuB,UAAUG,OAAO,QACzBxB,KAAKF,GAAGyB,aAAa,gBAAiB,SAE9C,GAEA,CAAAb,IAAA,mBAAAC,MAGA,WAAmB,IAAAc,EAAA,KACfP,OAAOQ,iBAAiB,UAAU,WAC9BD,EAAKE,oBACT,IACArB,SAASC,KAAKmB,iBAAiB,UAAU,WACrCD,EAAKT,eACT,GACJ,GAEA,CAAAN,IAAA,gBAAAC,MAGA,WACIX,KAAKE,aAAeF,KAAKC,aAAaE,UACtCH,KAAKI,UAAYJ,KAAKF,GAAGK,SAC7B,M,8EApDCN,CAAA,CA/B4B,E","sources":["webpack://huntington.com-toolkit/./src/assets/toolkit/scripts/ui/StickyHeader.js"],"sourcesContent":["//@ts-check\r\n\r\nlet activeStickyHeader;\r\n\r\n/**\r\n * This represents the UI component for the product sticky header, which floats at the top of\r\n * the page after passing its rendering parameter\r\n */\r\nexport default class StickyHeader {\r\n /**\r\n * This creates the passing component. It also defines the event listener.\r\n * @param {HTMLElement} el - The dom element of the passing component\r\n */\r\n constructor(el) {\r\n this.el = el;\r\n /**@type {HTMLElement} */\r\n this.offsetParent = (el.offsetParent);\r\n this.scrollOffset = this.offsetParent.offsetTop;\r\n this.topOffset = el.offsetTop; //The offset from it's parent container\r\n\r\n //Need to check against this due to the possibility of alerts appearing and being dismissed.\r\n this.bodyHeight = document.body.clientHeight;\r\n\r\n this.setEventHandlers();\r\n }\r\n\r\n /**\r\n * Initializes the sticky header on the page.\r\n */\r\n static init() {\r\n /**@type {HTMLElement} */\r\n const stickyHeader = (document.getElementById('sticky-header'));\r\n\r\n if(stickyHeader) {\r\n activeStickyHeader = new StickyHeader(stickyHeader);\r\n }\r\n else {\r\n console.warn('No sticky header component present. Please try reloading.')\r\n }\r\n }\r\n\r\n /**\r\n * Checks the stored body height against the current body height.\r\n * This can change due to alerts and other dynamic content populating\r\n * and also being dismissed.\r\n */\r\n checkBodyHeight() {\r\n const clientHeight = document.body.clientHeight;\r\n if (clientHeight !== this.bodyHeight) {\r\n this.bodyHeight = clientHeight;\r\n this.updateOffsets();\r\n }\r\n }\r\n\r\n /**\r\n * Toggles the show class of the sticky header.\r\n */\r\n toggleStickyHeader() {\r\n this.checkBodyHeight();\r\n\r\n // pageYOffset is the IE11 version of scrollY.\r\n const scrollDistance = window.scrollY ? window.scrollY : window.pageYOffset;\r\n\r\n if (scrollDistance >= this.scrollOffset + this.topOffset) {\r\n this.el.classList.add('show');\r\n this.el.setAttribute('aria-expanded', 'true');\r\n }\r\n else{\r\n this.el.classList.remove('show');\r\n this.el.setAttribute('aria-expanded', 'false');\r\n }\r\n }\r\n\r\n /**\r\n * Sets the event listeners for the sticky header component.\r\n */\r\n setEventHandlers() {\r\n window.addEventListener('scroll', () => {\r\n this.toggleStickyHeader();\r\n }) ;\r\n document.body.addEventListener('resize', () => {\r\n this.updateOffsets();\r\n });\r\n }\r\n\r\n /**\r\n * Updates the offset values of the sticky header.\r\n */\r\n updateOffsets() {\r\n this.scrollOffset = this.offsetParent.offsetTop;\r\n this.topOffset = this.el.offsetTop;\r\n }\r\n}"],"names":["StickyHeader","el","_classCallCheck","this","offsetParent","scrollOffset","offsetTop","topOffset","bodyHeight","document","body","clientHeight","setEventHandlers","key","value","stickyHeader","getElementById","console","warn","updateOffsets","checkBodyHeight","window","scrollY","pageYOffset","classList","add","setAttribute","remove","_this","addEventListener","toggleStickyHeader"],"sourceRoot":""}