-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
36 lines (24 loc) · 829 Bytes
/
index.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
// Variables
// Seleccionar los elementos necesarios
document.addEventListener("DOMContentLoaded", function(){
iniciarApp();
});
// Funciones
function iniciarApp(){
scrollNav();
};
function scrollNav(){
const navPrimary = document.querySelector(".nav__primary");
const navSecundary = document.querySelector(".nav__secundary");
const ctaHero = document.querySelector(".cta--hero")
// const body = document.querySelector('body');
window.addEventListener('scroll', function() {
if( ctaHero.getBoundingClientRect().top < 0){
navPrimary.classList.add("nav--opacity");
navSecundary.classList.add("nav--normal");
} else{
navPrimary.classList.remove("nav--opacity");
navSecundary.classList.remove("nav--normal");
}
})
}