I would like to replace the if / else with Case because I believe it will be better for understanding the code since it will be a little long, but I can not access the Array that will have the conditions to activate the actions. Is the error in code or logic?
ex:
window.onscroll = function animaMenu() {
var menu = [pageYOffset > 70 , pageYOffset > 800 ];
switch (menu) {
case 0:
var x = document.getElementById("nav").className = "navegacao-movel"
break
case 1:
var x = document.getElementById("ball").className = "movimento"
alert("teste")
break
}
}
window.onload = animaMenu();
This code is what I want to change
window.onscroll = function animaMenu() {
if (pageYOffset > 70) {
document.getElementById("nav").className = "navegacao-movel"
} else if (pageYOffset > 800) {
document.getElementById("nav").className = "navegacao"
} else if (pageYOffset > 1600) {
document.getElementById("section").className = "hover"
}
}
window.onload = animaMenu();