-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
34 lines (30 loc) · 950 Bytes
/
script.js
File metadata and controls
34 lines (30 loc) · 950 Bytes
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
28
29
30
31
32
33
34
// eslint-disable-next-line no-unused-vars
function toggleMenu() {
const menu = document.querySelector(".menu-links");
const icon = document.querySelector(".hamburger-icon");
menu.classList.toggle("open");
icon.classList.toggle("open");
}
function openInNewTab(url) {
window.open(url, "_blank").focus();
}
// Seleciona o botão
const backToTopButton = document.getElementById("back-to-top");
// Adiciona um listener de rolagem na janela
window.addEventListener("scroll", () => {
// Verifica a quantidade de rolagem vertical
if (window.scrollY > 300) {
backToTopButton.style.display = "flex";
backToTopButton.style.opacity = "1";
} else {
backToTopButton.style.display = "none";
backToTopButton.style.opacity = "0";
}
});
// Adiciona um listener de clique ao botão
backToTopButton.addEventListener("click", () => {
window.scrollTo({
top: 0,
behavior: "smooth", // Rola suavemente para o topo
});
});