{ "version": 3, "sources": ["../../../Vettvangur.Frontend/src/scripts/components/sidebarPosition.ts"], "sourcesContent": ["const SidebarPosition = {\r\n el: {\r\n root: document.querySelectorAll('.layout')\r\n },\r\n \r\n init() {\r\n if(this.el.root) {\r\n this.el.root.forEach((target) => {\r\n const el = {\r\n layout: target,\r\n sidebar: target.querySelector('.layout__sidebar') as HTMLElement,\r\n divider: target.querySelector('.layout__divider'),\r\n sidebarContent: target.querySelector('.layout__sidebar > .side-navigation') as HTMLElement,\r\n content: target.querySelector('.layout__content > .subpage__content') as HTMLElement,\r\n }\r\n\r\n if (el.sidebar && el.sidebarContent?.clientHeight < el.content?.clientHeight) {\r\n let run = false\r\n let bottomPosition = el.sidebar.parentElement.getBoundingClientRect().bottom - (el.sidebar.offsetHeight + 40)\r\n \r\n if (window.innerWidth >= 1200) {\r\n run = true\r\n }\r\n \r\n document.addEventListener('resize', () => {\r\n if (window.innerWidth >= 1200) {\r\n run = true\r\n } else {\r\n run = false\r\n }\r\n })\r\n \r\n if (run) {\r\n this.positionSidebar(el, bottomPosition)\r\n\r\n document.addEventListener('scroll', () => {\r\n bottomPosition = el.sidebar.parentElement.getBoundingClientRect().bottom - (el.sidebar.offsetHeight + 40)\r\n\r\n this.positionSidebar(el, bottomPosition)\r\n })\r\n }\r\n }\r\n })\r\n }\r\n \r\n },\r\n \r\n positionSidebar: (el, bottomPosition) => {\r\n const widthWithoutGap = el.sidebar.parentElement.offsetWidth - 11 * 30\r\n const gapWidth = 30\r\n const colWidth = widthWithoutGap / 12\r\n\r\n if (bottomPosition <= 0) {\r\n el.sidebar.style.top = `${\r\n el.sidebar.parentElement.getBoundingClientRect().bottom - (el.sidebar.offsetHeight + 100)\r\n }px`\r\n } else if (el.layout.getBoundingClientRect().top <= -60) {\r\n el.sidebar.style.top = '-60px'\r\n }\r\n\r\n if (el.layout.getBoundingClientRect().top <= -60) {\r\n el.layout.classList.add('layout--fixed')\r\n el.sidebar.style.width = `${colWidth * 3 + gapWidth * 2}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