{"version":3,"file":"sticky-accordion.js","sources":["sticky-accordion/sticky-accordion.js"],"sourcesContent":["\r\n(function ($) {\r\n\t$(document).ready(function () {\r\n\r\n\t\tlet lastPageScrollY = window.scrollY;\r\n\r\n\t\tlet lastActiveItem = 0;\r\n\r\n\t\tlet pageOffsetTop = parseInt($(\"html\").css(\"margin-top\"));\r\n\r\n\t\tif (window.innerWidth > 767) {\r\n\t\t\t$(document).on(\"scroll\", function (evt) {\r\n\r\n\t\t\t\tif ($(window).width() < parseInt($(\":root\").css(\"--breakpoint-md\"))) {\r\n\t\t\t\t\treturn false;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tlet pageScrollTop = window.scrollY;\r\n\r\n\t\t\t\tlet pageScrollBottom = window.scrollY + window.innerHeight;\r\n\r\n\t\t\t\t$(\".sticky-accordion-block\").each(function () {\r\n\r\n\t\t\t\t\tlet stickyAccordionId = $(\".sticky-accordion\", this).attr(\"id\");\r\n\r\n\t\t\t\t\tlet numAccordions = $(\".sticky-accordion > .sticky-accordion-item\", this).length;\r\n\r\n\t\t\t\t\tlet scrollDirection = (pageScrollTop > lastPageScrollY) ? \"down\" : \"up\";\r\n\r\n\t\t\t\t\tlet stickyAccordionScrollOffset = parseInt($(\".sticky-accordion\", this).offset().top);\r\n\r\n\t\t\t\t\tlet scrollingImagesScrollOffset = parseInt($(\".scrolling-images-column\", this).offset().top);\r\n\r\n\t\t\t\t\tlet scrollingImagesColumnHeight = parseInt($(\".scrolling-images-column\", this).height()) + parseInt($(\".scrolling-images-column > .scrolling-image:last-child\", this).css(\"marginTop\"));\r\n\r\n\t\t\t\t\tlet imagesColumnScrollDiff = (stickyAccordionScrollOffset + ($(\".sticky-accordion\", this).outerHeight() / 2)) - scrollingImagesScrollOffset;\r\n\r\n\t\t\t\t\tlet currentActiveItem = Math.ceil(imagesColumnScrollDiff / (scrollingImagesColumnHeight / numAccordions));\r\n\r\n\t\t\t\t\tif (scrollDirection === \"up\") {\r\n\r\n\t\t\t\t\t\tif (stickyAccordionScrollOffset === scrollingImagesScrollOffset) {\r\n\r\n\t\t\t\t\t\t\tcurrentActiveItem = 1;\r\n\r\n\t\t\t\t\t\t} else {\r\n\r\n\t\t\t\t\t\t\tstickyAccordionScrollOffset += parseInt($(\".sticky-accordion\", this).outerHeight());\r\n\r\n\t\t\t\t\t\t\tscrollingImagesScrollOffset += parseInt($(\".scrolling-images-column\", this).height());\r\n\r\n\t\t\t\t\t\t\timagesColumnScrollDiff = scrollingImagesScrollOffset - (stickyAccordionScrollOffset - ($(\".sticky-accordion\", this).outerHeight() / 2));\r\n\r\n\t\t\t\t\t\t\tcurrentActiveItem = numAccordions - Math.floor(imagesColumnScrollDiff / (scrollingImagesColumnHeight / numAccordions));\r\n\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tif (currentActiveItem === 0) {\r\n\t\t\t\t\t\tcurrentActiveItem = 1;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tlet currActiveItemCollapseId = \"#\" + stickyAccordionId + \"-\" + currentActiveItem + \"-collapse\";\r\n\r\n\t\t\t\t\tif (currentActiveItem !== lastActiveItem) {\r\n\r\n\t\t\t\t\t\tif (lastActiveItem > 0) {\r\n\r\n\t\t\t\t\t\t\tlet lastAccordionCollapseObj = bootstrap.Collapse.getOrCreateInstance($(\"#\" + stickyAccordionId + \"-\" + lastActiveItem + \"-collapse\").get(0));\r\n\r\n\t\t\t\t\t\t\tlastAccordionCollapseObj.hide();\r\n\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\tlet currentAccordionCollapseObj = bootstrap.Collapse.getOrCreateInstance($(currActiveItemCollapseId).get(0));\r\n\r\n\t\t\t\t\t\tcurrentAccordionCollapseObj.show();\r\n\r\n\t\t\t\t\t} else {\r\n\r\n\t\t\t\t\t\tlet openAccordionsToCleanUp = $(\".sticky-accordion > .accordion-item > .accordion-collapse\", this).not($(currActiveItemCollapseId, this)).filter(\".show\");\r\n\r\n\t\t\t\t\t\tif (openAccordionsToCleanUp.length > 0) {\r\n\r\n\t\t\t\t\t\t\topenAccordionsToCleanUp.each(function () {\r\n\r\n\t\t\t\t\t\t\t\tlet accordionCollapseObj = bootstrap.Collapse.getOrCreateInstance(this);\r\n\r\n\t\t\t\t\t\t\t\taccordionCollapseObj.hide();\r\n\r\n\t\t\t\t\t\t\t});\r\n\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tlastActiveItem = currentActiveItem;\r\n\r\n\t\t\t\t});\r\n\r\n\t\t\t\tlastPageScrollY = pageScrollTop;\r\n\r\n\t\t\t}).scroll();\r\n\t\t}\r\n\r\n\r\n\t\t$(\".sticky-accordion-block\").each(function () {\r\n\r\n\t\t\tif ($(window).width() < parseInt($(\":root\").css(\"--breakpoint-md\"))) {\r\n\r\n\t\t\t\t$(\".sticky-accordion > .accordion-item:first-child > .accordion-collapse\", this).addClass(\"show\");\r\n\r\n\t\t\t} else {\r\n\r\n\t\t\t\tlet accordionStickyTop = 0;\r\n\r\n\t\t\t\tlet closedAccordionGroupHeight = $(\".sticky-accordion\", this).outerHeight();\r\n\r\n\t\t\t\t$(\".sticky-accordion > .accordion-item > .accordion-collapse\", this).addClass(\"show\");\r\n\r\n\t\t\t\tlet accordionGroupMaxHeight = closedAccordionGroupHeight;\r\n\r\n\t\t\t\t$(\".sticky-accordion > .accordion-item\", this).each(function () {\r\n\r\n\t\t\t\t\tlet openItemHeightDiff = $(this).outerHeight() - $(\".accordion-header\", this).outerHeight();\r\n\r\n\t\t\t\t\tif ((closedAccordionGroupHeight + openItemHeightDiff) > accordionGroupMaxHeight) {\r\n\t\t\t\t\t\taccordionGroupMaxHeight = closedAccordionGroupHeight + openItemHeightDiff;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t});\r\n\r\n\t\t\t\t$(\".sticky-accordion > .accordion-item > .accordion-collapse\", this).removeClass(\"show\");\r\n\r\n\t\t\t\tlet maxContentHeight = $(\".sticky-accordion\", this).position().top + accordionGroupMaxHeight + parseInt($(this).css(\"paddingBottom\"));\r\n\r\n\t\t\t\t// Accordion content will be taller than the user's screen.\r\n\t\t\t\tif (maxContentHeight > $(window).height()) {\r\n\r\n\t\t\t\t\taccordionStickyTop = parseInt($(this).css(\"paddingTop\"));\r\n\r\n\t\t\t\t} else {\r\n\r\n\t\t\t\t\tif (($(window).height() - maxContentHeight) > 100) {\r\n\t\t\t\t\t\t$(this).css(\"--block-padding-top\", (parseInt($(this).css(\"paddingTop\")) + 100) + \"px\");\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\taccordionStickyTop = parseInt($(this).css(\"paddingTop\")) + parseInt($(this).children(\".container:first-child\").outerHeight());\r\n\r\n\t\t\t\t\t$(\".sticky-accordion > .accordion-item:last-child > .accordion-collapse\", this).addClass(\"show\");\r\n\r\n\t\t\t\t\tlet accordionHeightOffset = parseInt($(\".sticky-accordion\", this).outerHeight());\r\n\r\n\t\t\t\t\t$(\".sticky-accordion .accordion-collapse\", this).removeClass(\"show\");\r\n\r\n\t\t\t\t\t$(this).css(\"--sticky-accordion-height-offset\", accordionHeightOffset + \"px\");\r\n\r\n\t\t\t\t\t$(this).addClass(\"sticky-block-title\");\r\n\r\n\t\t\t\t}\r\n\r\n\t\t\t\t$(this).css(\"--accordion-sticky-top\", accordionStickyTop + \"px\");\r\n\r\n\t\t\t}\r\n\r\n\t\t});\r\n\r\n\t});\r\n})(jQuery);\r\n"],"names":["$","document","ready","let","lastPageScrollY","window","scrollY","lastActiveItem","parseInt","css","innerWidth","on","evt","width","pageScrollTop","innerHeight","each","stickyAccordionId","this","attr","numAccordions","length","scrollDirection","stickyAccordionScrollOffset","offset","top","scrollingImagesScrollOffset","scrollingImagesColumnHeight","height","imagesColumnScrollDiff","outerHeight","currentActiveItem","Math","ceil","currActiveItemCollapseId","floor","bootstrap","Collapse","getOrCreateInstance","get","hide","show","openAccordionsToCleanUp","not","filter","scroll","addClass","accordionStickyTop","closedAccordionGroupHe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