Skip to content

Commit

Permalink
Merge pull request #826 from pani2004/issue#734
Browse files Browse the repository at this point in the history
fix: Fixed the bug
  • Loading branch information
apu52 authored Jun 26, 2024
2 parents fd8b2c7 + 6ab6ce7 commit be88e5a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 23 deletions.
44 changes: 21 additions & 23 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1039,33 +1039,31 @@ <h4>Reach Out To Us</h4>

</footer>

<!-- adding a scrollup btn -->
<a class="goupbtn" href="#"><i class="fa-solid fa-arrow-up"></i></a>
<a class="goupbtn" href="#" onclick="goToTop()"><i class="fa-solid fa-arrow-up"></i></a>

<script>
// Get the button
var mybutton = document.querySelector(".goupbtn");

// When the user scrolls, check if the button should be displayed
window.addEventListener("scroll", function() {
if (window.scrollY > 20) {
mybutton.style.display = "block";
} else {
mybutton.style.display = "none";
}
});

<script>
// Get the button
var mybutton = document.getElementById("goToTopBtn");
// When the user clicks on the button, scroll to the top of the document
function goToTop() {
document.body.scrollTop = 0; // For Safari
document.documentElement.scrollTop = 0; // For Chrome, Firefox, IE and Opera
}
</script>



// When the user scrolls down 20px from the top of the document, show the button
window.onscroll = function () {
scrollFunction();
};

function scrollFunction() {
if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
mybutton.style.display = "block";
} else {
mybutton.style.display = "none";
}
}

// When the user clicks on the button, scroll to the top of the document
function goToTop() {
document.body.scrollTop = 0;
document.documentElement.scrollTop = 0;
}
</script>

<script>
let hamburger = document.querySelector('.hamburger');
Expand Down
1 change: 1 addition & 0 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -2208,6 +2208,7 @@ body {
font-size: 22px;
transition: all 0.5s;
transition: box-shadow 0.3s; /* Added transition for box-shadow */
display: none;
}

.goupbtn:hover {
Expand Down

0 comments on commit be88e5a

Please sign in to comment.