<script>
function strip(str, remove) { while (str.length > 0 && remove.indexOf(str.charAt(0)) != -1) { str = str.substr(1); } while (str.length > 0 && remove.indexOf(str.charAt(str.length - 1)) != -1) { str = str.substr(0, str.length - 1); } return str; } function scroll() { console.log('scroll'); window.scrollTo({ left: 0, top: window.innerHeight, behavior: 'smooth' }); sessionStorage.removeItem('forceCheckScroll'); } const forceCheckScroll = sessionStorage.getItem('forceCheckScroll') === 'true'; const checkScroll = strip(window.location.pathname, '/') !== strip('{{ site.baseurl }}', '/'); if (forceCheckScroll || checkScroll) { const maxWidth = "(max-width: 48rem)"; const result = window.matchMedia(maxWidth); if (result.matches) { scroll(); } else { result.addListener((match) => { if (match.media == maxWidth) { if (match.matches) { scroll(); } } }); } }
</script>