I'm trying to start if statement from number 0 when the window is loaded but it's ignoring the 0 and starting from 1, can somebody please help me understand how this work.
showAnime = () => {
let counter = 0;
setInterval(() => {
counter++;
if (counter === 0) {
console.log(counter);
// when window is loaded this condition should start first
this.setState({
animateRightOne: "animated fadeInRightBig delay-one"
});
} else if (counter === 1) {
console.log(counter);
this.setState({
animateRightTwo: "animated fadeInRightBig delay-two"
});
} else if (counter === 2) {
console.log(counter);
this.setState({
animateRightThree: "animated fadeInRightBig delay-three"
});
} else if (counter === 3) {
console.log(counter);
this.setState({
animateLeftFour: "animated fadeInLeftBig delay-four"
});
} else if (counter === 4) {
console.log(counter);
this.setState({
animateRightFive: "animated fadeInRightBig delay-five"
});
} else if (counter === 5) {
console.log(counter);
this.setState({
animateRightSix: "animated fadeInRightBig delay-six"
});
} else if (counter === 6) {
counter = 0;
}
}, 7000);
};
Aucun commentaire:
Enregistrer un commentaire