File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,8 +2,9 @@ const updateNavBar = () => {
22 const topNavbar = document . getElementById ( 'top-navbar' )
33 const navbarToggler = document . getElementById ( 'navbar-toggler' )
44 const themeIcon = document . getElementById ( 'navbar-theme-icon-svg' )
5+ const scrollContainer = document . querySelector ( 'body' ) ;
56
6- if ( window . scrollY > 40 ) {
7+ if ( scrollContainer . scrollTop > 40 ) {
78 topNavbar ?. classList . remove ( 'transparent-navbar' )
89 topNavbar ?. classList . add ( 'shadow' )
910
@@ -44,8 +45,9 @@ document.addEventListener('DOMContentLoaded', function () {
4445 // When the user scrolls down 80px from the top of the document,
4546 // resize the navbar's padding and the logo's font size
4647 const topNavbar = document . getElementById ( 'top-navbar' )
48+ const scrollContainer = document . querySelector ( 'body' ) ;
4749 if ( topNavbar ?. classList . contains ( 'homepage' ) ) {
48- document . addEventListener ( 'scroll' , updateNavBar )
50+ scrollContainer . addEventListener ( 'scroll' , updateNavBar )
4951 updateNavBar ( )
5052 }
5153
Original file line number Diff line number Diff line change 1- /*
1+ /*
22 Removed smooth scrolling implementation in main.js in favor of
33 simpler css approach.
4- See: https://css-tricks.com/snippets/jquery/smooth-scrolling/
4+ See: https://css-tricks.com/snippets/jquery/smooth-scrolling/
55*/
66* ,
77html {
88 scroll-behavior : smooth !important ;
9+ overflow-y : hidden ;
910}
1011
1112body {
1213 position : relative ;
14+ overflow-y : scroll ;
15+ height : 100vh ;
16+ }
17+
18+ body .scroll-container {
19+ scroll-snap-type : y mandatory ;
20+ }
21+
22+ /*
23+ Enable scroll snap for home page
24+ */
25+ div #home ,
26+ div .section-holder {
27+ scroll-snap-align : start ;
1328}
1429
1530/*
1631 Fixes anchor overlapping with header.
17- See: https://stackoverflow.com/questions/4086107/fixed-page-header-overlaps-in-page-anchors
32+ See: https://stackoverflow.com/questions/4086107/fixed-page-header-overlaps-in-page-anchors
1833 */
1934:target ::before {
2035 content : ' ' ;
Original file line number Diff line number Diff line change 1010 {{ end }}
1111 {{ end }}
1212 < meta name ="description " content ="{{ $siteDescription }} " />
13-
13+
1414 <!-- import common headers -->
1515 {{- partial "header.html" . -}}
1616 {{- partial "opengraph.html" . -}}
17-
17+
1818 <!--================= add analytics if enabled =========================-->
1919 {{- partial "analytics.html" . -}}
2020 {{ with resources.Get "scripts/core/theme-scheme.js" | fingerprint }}
2323 </ script >
2424 {{ end }}
2525 </ head >
26- < body data-bs-spy ="scroll " data-bs-target ="#top-navbar " data-bs-offset ="100 ">
26+ < body data-bs-spy ="scroll " data-bs-target ="#top-navbar " data-bs-offset ="100 " {{ if site.Params.features.scrollSnap.enable | default false }}class =" scroll-container " {{end}} >
2727
2828 <!--- NAVBAR ------------------------->
2929 {{- partial "navigators/navbar.html" . -}}
You can’t perform that action at this time.
0 commit comments