Skip to content

Commit

Permalink
Merge pull request #2005 from pani2004/issue#1995
Browse files Browse the repository at this point in the history
Made the scroll to top functional and added logic for visibility
  • Loading branch information
huamanraj authored Jun 20, 2024
2 parents 18b7328 + 6f7aea4 commit 9ad84d8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
1 change: 1 addition & 0 deletions assets/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@ svg {

#back-to-top-container {
position: fixed;
display: none;
}


Expand Down
19 changes: 14 additions & 5 deletions books.html
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,6 @@ <h2>Quick Links</h2>

</div>


<div id="back-to-top-container" onclick="lenis.scrollTo('#home')" class="right">
<div class="circle1">
<svg id="back-to-top" xmlns="http://www.w3.org/2000/svg" width="30" height="30" fill="currentColor"
Expand All @@ -785,13 +784,9 @@ <h2>Quick Links</h2>
</svg>
</div>
</div>

</div>
</div>




<!-- adding privacy policy and copyright popup-->
<div style="text-align: center; align-items: center;">
<p style="text-align: center">
Expand Down Expand Up @@ -877,6 +872,20 @@ <h1>Privacy Notice</h1>
privacyModal.style.display = "none";
}
}
document.getElementById('back-to-top-container').onclick = function () {// logic for scroll to top
window.scrollTo({
top: 0,
behavior: 'smooth'
});
};
window.onscroll = function () {
const backToTopButton = document.getElementById('back-to-top-container'); // for scroll to top button visibility
if (document.body.scrollTop > 100 || document.documentElement.scrollTop > 100) {
backToTopButton.style.display = 'block';
} else {
backToTopButton.style.display = 'none';
}
};
</script>


Expand Down

0 comments on commit 9ad84d8

Please sign in to comment.