-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
66 lines (49 loc) · 1.57 KB
/
app.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// funcionalidades para barra de navegacion
const nav = document.querySelector("#nav-bar");
const botonAbrir = document.querySelector("#boton-abrir");
const botonCerrar =document.querySelector("#boton-cerrar");
const BotonesBarra = document.querySelectorAll("#nav-link")
const botonVolverArriba = document.querySelector("#boton-volver-arriba")
botonAbrir.addEventListener("click", () =>{
nav.classList.add("nav-visible");
} )
botonCerrar.addEventListener("click", () =>{
nav.classList.remove("nav-visible")
})
BotonesBarra.forEach((boton) =>{
boton.addEventListener("click", () =>{
nav.classList.remove("nav-visible")
})
})
//funcionalidades para slider
const sliderContainer = document.querySelector('.slider');
const sliderImages = document.querySelectorAll('.imagen-slider');
const totalImages = sliderImages.length;
let currentIndex = 0;
function showNextImage() {
sliderImages[currentIndex].style.display = 'none';
currentIndex++;
if (currentIndex >= totalImages) {
currentIndex = 0;
}
sliderImages[currentIndex].style.display = 'block';
}
function startTimer() {
sliderImages[currentIndex].style.display = 'block';
setInterval(showNextImage, 5000);
}
window.addEventListener('load', startTimer);
// funcionalidad para el boton volver arriba
window.addEventListener("scroll", () =>{
if(window.scrollY > 200){
botonVolverArriba.classList.add("active-boton")
}else{
botonVolverArriba.classList.remove("active-boton")
}
})
botonVolverArriba.addEventListener("click", () => {
window.scrollTo({
top: 0,
behavior : "smooth"
})
})