Skip to content

Commit

Permalink
Merge pull request #53 from Genez-io/feat/blog
Browse files Browse the repository at this point in the history
add navbar scroll
  • Loading branch information
Tudor-Ang authored Jan 17, 2024
2 parents d9d834f + f6d676a commit f332cc0
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 4 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"Target":"scss/index.6d2080b550cc05ce13432c8b9deaac36ea7af77f0c625ac52c7064fe702ff8bd.css","MediaType":"text/css","Data":{"Integrity":"sha256-bSCAtVDMBc4TQyyLneqsNup6938MYlrFLHBk/nAv+L0="}}
{"Target":"scss/index.362fa1d8af095ff1850c9ae47075e624039cd06a946538b5b05c801636d38a32.css","MediaType":"text/css","Data":{"Integrity":"sha256-Ni+h2K8JX/GFDJrkcHXmJAOc0GqUZTi1sFyAFjbTijI="}}
10 changes: 10 additions & 0 deletions themes/genezio-theme/assets/scss/navbar.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
.navbarEffect {
position: sticky !important;
top: 0;
background-color: #333;
color: #fff;
// padding: 10px;
transition: top 0.1s ease-in-out;
z-index: 1000;
}

@media (min-width: 992px) {
nav {
.navbar-collapse,
Expand Down
17 changes: 17 additions & 0 deletions themes/genezio-theme/layouts/_default/baseof.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,21 @@
></script>
<!-- End of HubSpot Embed Code -->
</body>

<script>
let lastScrollTop = 0;
const navbar = document.getElementById("navbar");

window.addEventListener("scroll", function () {
const scrollTop = window.pageYOffset || document.documentElement.scrollTop;

if (scrollTop > lastScrollTop && scrollTop > navbar.offsetHeight) {
navbar.style.top = `-${navbar.offsetHeight}px`;
} else {
navbar.style.top = "0";
}

lastScrollTop = scrollTop;
});
</script>
</html>
3 changes: 2 additions & 1 deletion themes/genezio-theme/layouts/partials/blogHeader.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<nav
id="navbar"
style="border-bottom: 1px solid #e2d9f3; z-index: 99999; background-color: #f1ecf9"
class="navbar navbar-expand-lg p-0 px-3"
class="navbar navbarEffect navbar-expand-lg p-0 px-3"
>
<div
class="container px-4 py-4"
Expand Down
3 changes: 2 additions & 1 deletion themes/genezio-theme/layouts/partials/header.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<nav
id="navbar"
style="border-bottom: 1px solid rgba(255, 255, 255, 0.1); z-index: 99999"
class="navbar navbar-expand-lg p-0 bg-dark px-3"
class="navbar navbarEffect navbar-expand-lg p-0 bg-dark px-3"
>
<div
class="container px-4 py-4"
Expand Down

0 comments on commit f332cc0

Please sign in to comment.