Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Back to top button #533

Merged
merged 1 commit into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -1956,7 +1956,7 @@ button:hover {

#backToTopBtn {
position: fixed;
bottom: 130px;
bottom: 50px;
right: 31px;
height: 50px;
width: 50px;
Expand All @@ -1969,7 +1969,7 @@ button:hover {
border-radius: 50%;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
transition: 500ms;
display: none; /* Initially hide the button */
display: none;
justify-content: center;
align-items: center;
z-index: 9999;
Expand All @@ -1981,7 +1981,9 @@ button:hover {
transform: scale(1.05);
box-shadow: 0 8px 12px rgba(0, 0, 0, 0.2);
}

.indexpage #backToTopBtn {
bottom: 130px;
}

.header {
margin-top: 100px;
Expand Down
4 changes: 3 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,9 @@
</lottie-player>
</div>
</div>
<button id="backToTopBtn" title="Back to Top" aria-label="Back to Top"><i class="fas fa-arrow-up"></i></button>
<div class="indexpage">
<button id="backToTopBtn" title="Back to Top" aria-label="Back to Top" onclick="backToTop()"><i class="fas fa-arrow-up"></i></button>
</div>
<!-- Generate snowflakes dynamically with JavaScript -->
<div class="snowflakes">
<div id="particles-js"></div>
Expand Down
34 changes: 18 additions & 16 deletions js/backToTopBtn.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
document.addEventListener("DOMContentLoaded", function () {
const backToTopButton = document.getElementById('backToTopBtn');

let backToTopBtn = document.getElementById("backToTopBtn");
window.addEventListener('scroll', handleScroll);
handleScroll();

window.onscroll = function() {
scrollFunction();
};

function scrollFunction() {
if (document.body.scrollTop > 200 || document.documentElement.scrollTop > 200) {
backToTopBtn.style.display = "block";
} else {
backToTopBtn.style.display = "none";
function handleScroll() {
if (window.scrollY === 0) {
backToTopButton.classList.add('disabled');
backToTopButton.style.display = 'none'; // Hide button at top
} else {
backToTopButton.classList.remove('disabled');
backToTopButton.style.display = 'block'; // Show button when scrolling
}
}
}

window.startSimulation = function() {
backToTopButton.style.display = 'none';
}

backToTopBtn.addEventListener("click", function() {
window.scrollTo({
top: 0,
behavior: 'smooth'
});
window.backToTop = function () {
window.scrollTo({ top: 0, behavior: 'smooth' });
}
});
48 changes: 24 additions & 24 deletions js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -885,16 +885,16 @@ function effect() {
loader.style.display = "none";
document.querySelector(".unload").style.display = "block";
document.querySelector(".snowflakes").style.display = "block";
var backToTopBtn = document.getElementById("backToTopBtn");
backToTopBtn.style.display = "block";
// var backToTopBtn = document.getElementById("backToTopBtn");
// backToTopBtn.style.display = "block";
}



var loader = document.querySelector(".loader");
window.addEventListener('load', () => {
var backToTopBtn = document.getElementById("backToTopBtn");
backToTopBtn.style.display = "none";
// var backToTopBtn = document.getElementById("backToTopBtn");
// backToTopBtn.style.display = "none";
setTimeout(effect, 4000);
})

Expand All @@ -904,26 +904,26 @@ function changeColor() {
}

document.addEventListener("DOMContentLoaded", function () {
var backToTopBtn = document.getElementById("backToTopBtn");
backToTopBtn.style.display = "block";
backToTopBtn.addEventListener("click", function () {
scrollToTop();
scrollToForm();
});

function scrollToTop() {
window.scrollTo({
top: 0,
behavior: "smooth"
});
}
function scrollToForm() {
const formElement = document.getElementById("box");
formElement.scrollTo({
top: 0,
behavior: "smooth"
});
}
// var backToTopBtn = document.getElementById("backToTopBtn");
// backToTopBtn.style.display = "block";
// backToTopBtn.addEventListener("click", function () {
// scrollToTop();
// scrollToForm();
// });

// function scrollToTop() {
// window.scrollTo({
// top: 0,
// behavior: "smooth"
// });
// }
// function scrollToForm() {
// const formElement = document.getElementById("box");
// formElement.scrollTo({
// top: 0,
// behavior: "smooth"
// });
// }

document.querySelector("#reload").addEventListener("click", () => {
window.location.reload();
Expand Down
33 changes: 3 additions & 30 deletions pages/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,33 +58,6 @@
}

}
#backToTopBtn {
position: fixed;
bottom: 50px;
right: 31px;
height: 50px;
width: 50px;
padding: 10px 15px;
font-size: 20px;
cursor: pointer;
border: none;
background: linear-gradient(#1845ad, #23a2f6);
color: white;
border-radius: 50%;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
transition: 500ms;
display: none; /* Initially hide the button */
justify-content: center;
align-items: center;
z-index: 9999;
}

#backToTopBtn:hover {
background: linear-gradient(to right, #ff512f, #f09819);
opacity: 1;
transform: scale(1.05);
box-shadow: 0 8px 12px rgba(0, 0, 0, 0.2);
}

</style>

Expand Down Expand Up @@ -130,7 +103,7 @@
const circles = document.querySelectorAll(".circle");

circles.forEach(function (circle) {
circle.x = 0;
circle.x = 0;
circle.y = 0;
});

Expand Down Expand Up @@ -163,8 +136,8 @@
});
</script>
<div>
<button id="backToTopBtn" title="Back to Top" aria-label="Back to Top"><i class="fas fa-arrow-up"></i></button>
</div>
<button id="backToTopBtn" title="Back to Top" aria-label="Back to Top" onclick="backToTop()"><i class="fas fa-arrow-up"></i></button>
</div>
<div class="snowflakes" style="display: block;">
<div id="particles-js"></div>
</div>
Expand Down
31 changes: 2 additions & 29 deletions pages/contributors.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,33 +60,6 @@
}

}
#backToTopBtn {
position: fixed;
bottom: 50px;
right: 31px;
height: 50px;
width: 50px;
padding: 10px 15px;
font-size: 20px;
cursor: pointer;
border: none;
background: linear-gradient(#1845ad, #23a2f6);
color: white;
border-radius: 50%;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
transition: 500ms;
display: none; /* Initially hide the button */
justify-content: center;
align-items: center;
z-index: 9999;
}

#backToTopBtn:hover {
background: linear-gradient(to right, #ff512f, #f09819);
opacity: 1;
transform: scale(1.05);
box-shadow: 0 8px 12px rgba(0, 0, 0, 0.2);
}
</style>


Expand Down Expand Up @@ -164,8 +137,8 @@
});
</script>
<div>
<button id="backToTopBtn" title="Back to Top" aria-label="Back to Top"><i class="fas fa-arrow-up"></i></button>
</div>
<button id="backToTopBtn" title="Back to Top" aria-label="Back to Top" onclick="backToTop()"><i class="fas fa-arrow-up"></i></button>
</div>
<div class="snowflakes" style="display: block;">
<div id="particles-js"></div>
</div>
Expand Down
31 changes: 2 additions & 29 deletions pages/faq.html
Original file line number Diff line number Diff line change
Expand Up @@ -92,33 +92,6 @@
}

}
#backToTopBtn {
position: fixed;
bottom: 50px;
right: 31px;
height: 50px;
width: 50px;
padding: 10px 15px;
font-size: 20px;
cursor: pointer;
border: none;
background: linear-gradient(#1845ad, #23a2f6);
color: white;
border-radius: 50%;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
transition: 500ms;
display: none; /* Initially hide the button */
justify-content: center;
align-items: center;
z-index: 9999;
}

#backToTopBtn:hover {
background: linear-gradient(to right, #ff512f, #f09819);
opacity: 1;
transform: scale(1.05);
box-shadow: 0 8px 12px rgba(0, 0, 0, 0.2);
}
</style>


Expand Down Expand Up @@ -196,8 +169,8 @@
});
</script>
<div>
<button id="backToTopBtn" title="Back to Top" aria-label="Back to Top"><i class="fas fa-arrow-up"></i></button>
</div>
<button id="backToTopBtn" title="Back to Top" aria-label="Back to Top" onclick="backToTop()"><i class="fas fa-arrow-up"></i></button>
</div>
<div class="snowflakes" style="display: block;">
<div id="particles-js"></div>
</div>
Expand Down
29 changes: 1 addition & 28 deletions pages/features.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,33 +58,6 @@
}

}
#backToTopBtn {
position: fixed;
bottom: 50px;
right: 31px;
height: 50px;
width: 50px;
padding: 10px 15px;
font-size: 20px;
cursor: pointer;
border: none;
background: linear-gradient(#1845ad, #23a2f6);
color: white;
border-radius: 50%;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
transition: 500ms;
display: none; /* Initially hide the button */
justify-content: center;
align-items: center;
z-index: 9999;
}

#backToTopBtn:hover {
background: linear-gradient(to right, #ff512f, #f09819);
opacity: 1;
transform: scale(1.05);
box-shadow: 0 8px 12px rgba(0, 0, 0, 0.2);
}
</style>


Expand Down Expand Up @@ -161,7 +134,7 @@
animateCircles();
});
</script>
<button id="backToTopBtn" title="Back to Top" aria-label="Back to Top"><i class="fas fa-arrow-up"></i></button>
<button id="backToTopBtn" title="Back to Top" aria-label="Back to Top" onclick="backToTop()"><i class="fas fa-arrow-up"></i></button>
<div class="snowflakes" style="display: block;">
<div id="particles-js"></div>
</div>
Expand Down
31 changes: 2 additions & 29 deletions pages/feedback.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,33 +60,6 @@
}

}
#backToTopBtn {
position: fixed;
bottom: 50px;
right: 31px;
height: 50px;
width: 50px;
padding: 10px 15px;
font-size: 20px;
cursor: pointer;
border: none;
background: linear-gradient(#1845ad, #23a2f6);
color: white;
border-radius: 50%;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
transition: 500ms;
display: none; /* Initially hide the button */
justify-content: center;
align-items: center;
z-index: 9999;
}

#backToTopBtn:hover {
background: linear-gradient(to right, #ff512f, #f09819);
opacity: 1;
transform: scale(1.05);
box-shadow: 0 8px 12px rgba(0, 0, 0, 0.2);
}

</style>
</head>
Expand Down Expand Up @@ -125,8 +98,8 @@
<div class="circle"></div>
</div>

<button id="backToTopBtn" title="Back to Top" aria-label="Back to Top"><i class="fas fa-arrow-up"></i></button>
<div class="snowflakes" style="display: block;">
<button id="backToTopBtn" title="Back to Top" aria-label="Back to Top" onclick="backToTop()"><i class="fas fa-arrow-up"></i></button>
<div class="snowflakes" style="display: block;">
<div id="particles-js"></div>
</div>
<div class="navHeader">
Expand Down
Loading
Loading