Prevent initial scroll to section nav (#3411)

* Prevent initial scroll to section nav

On pages taht contain a section nav (sub navigation) the previous `scrollIntoView` led to an initial scroll position start at the section nav. See the store or server settings for examples.

This fixes it so that the scroll vertical position always starts at 0.

* Mobile: Prevent anchors from disappearing underneath the fixed header

* Add content padding top to scroll padding
This commit is contained in:
d11n
2022-02-06 12:39:52 +01:00
committed by GitHub
parent f66b1b644f
commit ce174d507d
2 changed files with 6 additions and 2 deletions

View File

@@ -22,7 +22,7 @@
<script>
(function () {
const activeEl = document.querySelector('#SectionNav .nav .active')
if (activeEl) activeEl.scrollIntoView({ inline: 'center' })
if (activeEl) activeEl.scrollIntoView({ block: 'end', inline: 'center' })
})()
</script>
}

View File

@@ -357,6 +357,10 @@
@media (max-width: 991px) {
:root {
--header-height: var(--mobile-header-height);
--content-padding-top: var(--btcpay-space-m);
/* Prevent anchors from disappearing underneath the fixed header */
scroll-padding: calc(var(--header-height) + var(--content-padding-top));
}
#mainMenu {
@@ -469,7 +473,7 @@
#mainContent > section {
margin-top: var(--header-height);
padding: var(--btcpay-space-m) var(--btcpay-space-m) var(--btcpay-space-xl);
padding: var(--content-padding-top) var(--btcpay-space-m) var(--btcpay-space-xl);
}
#SectionNav {