forked from swaraj-das/Collect-your-GamingTools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
27 lines (25 loc) · 748 Bytes
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
var menuList = document.getElementById("menuList");
menuList.style.maxHeight = "0px";
function toggleMenu() {
if (menuList.style.maxHeight == "0px") {
menuList.style.maxHeight = "160px";
} else {
menuList.style.maxHeight = "0px";
}
}
// Show or hide the scroll-top button based on scroll position
window.addEventListener('scroll', function() {
const scrollTopButton = document.querySelector('.scroll-top');
if (window.pageYOffset > 300) {
scrollTopButton.style.display = 'block';
} else {
scrollTopButton.style.display = 'none';
}
});
// Smooth scroll to top when the button is clicked
function scrollToTop() {
window.scrollTo({
top: 0,
behavior: 'smooth'
});
}