{"version":3,"sources":["webpack:///./LeLab.Web/src/utils/scroll-to-node.js"],"names":["ScrollToNode","node","windowScrollY","window","scrollY","nodeMarginTop","parseInt","getComputedStyle","getPropertyValue","scrollToY","offsetTop","segmentedHeight","document","querySelector","matchMedia","matches","navHeight","scrollTo"],"mappings":"0FASe,SAASA,EAAaC,GACjC,MAAMC,EAAgBC,OAAOC,QACvBC,EAAgBC,SAASH,OAAOI,iBAAiBN,GAAMO,iBAAiB,eAE9E,IAAIC,EAAYR,EAAKS,UAAYL,EAIjC,MAAMM,EACGC,SAASC,cAAc,eAGrBV,OAAOW,WAAW,sBAAsBC,QAAU,GAF9C,EAKfN,GAAwBE,EAGxB,MAAMK,EACEb,OAAOW,WAAW,sBAAsBC,QACjC,GAEPb,GAAiBO,EAAY,GACtB,GAEJ,EAGXA,GAAwBO,EAExBP,GAAwB,EAExBN,OAAOc,SAAS,EAAGR,GAzCvB","file":"scroll-to-node.dafc9bd5.js","sourcesContent":["/**\r\n * Scroll to node (consider sticky elements)\r\n *\r\n * It is recommended to call this method with requestAnimationFrame\r\n * if it's execution doesn't need to be in the same JS task.\r\n *\r\n * Ex. window.requestAnimationFrame(() => scrollToNode(node))\r\n */\r\n\r\nexport default function ScrollToNode(node) {\r\n const windowScrollY = window.scrollY\r\n const nodeMarginTop = parseInt(window.getComputedStyle(node).getPropertyValue('margin-top'))\r\n\r\n let scrollToY = node.offsetTop - nodeMarginTop\r\n\r\n\r\n // If present, segmented height when sticky on top\r\n const segmentedHeight = (function () {\r\n if (!document.querySelector('.segmented')) {\r\n return 0\r\n }\r\n return window.matchMedia(\"(min-width: 992px)\").matches ? 64 : 0\r\n })()\r\n\r\n scrollToY = scrollToY - segmentedHeight\r\n\r\n // Nav height\r\n const navHeight = (function () {\r\n if (window.matchMedia(\"(min-width: 768px)\").matches) {\r\n return 72\r\n }\r\n if (windowScrollY >= scrollToY - 56) {\r\n return 56\r\n }\r\n return 0\r\n })()\r\n\r\n scrollToY = scrollToY - navHeight\r\n\r\n scrollToY = scrollToY + 1 // Offset for subpixel\r\n\r\n window.scrollTo(0, scrollToY)\r\n}"],"sourceRoot":""}