Skip to content

Commit

Permalink
Scroll to top button fix (#291)
Browse files Browse the repository at this point in the history
  • Loading branch information
zalabhavy authored Jun 16, 2024
1 parent 659d5a1 commit 471e416
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions gamerules.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@
<img src="./images/home1.png" alt="Back to Home" class="home-icon">
</a>
</div>
<div class="back-up" >
<a class="gotopbtn" href=""><i class="fa fa-arrow-up" aria-hidden="true"></i></a></div>

<div class="back-up">
<a class="gotopbtn" href="javascript:void(0);"><i class="fa fa-arrow-up" aria-hidden="true"></i></a>
</div>

<div class="container">

<h1>How To Play?</h1>
Expand Down Expand Up @@ -266,7 +264,24 @@ <h2>Summary</h2>
</div>
</div>
<div>

<script>
//Scrollto top button
const topButton = document.querySelector('.back-up');
window.onscroll = function() {scrollFunction()};
function scrollFunction()
{
if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
topButton.style.display = "block";
} else {
topButton.style.display = "none";
}
}
topButton.addEventListener('click', function(event) {
event.preventDefault();
window.scrollTo({ top: 0, behavior: 'smooth' });
});

</script>

</body>
</html>

0 comments on commit 471e416

Please sign in to comment.