I'm trying to add a sleep/delay function to make an animation that the div slides out. At the moment it will instantly turn -60em without any delay at all which prevent the div from slide out.
Dunno why setTimeout
ignores the time delay.
for(activeSlide; activeSlide < i; activeSlide++){
animateLeft(activeSlide);
function animateLeft(activeSlide){
div[activeSlide].style.left = step+'em';
step -= 6;
if(step < -60) {
return;
}
setTimeout(animateLeft(activeSlide), 5000);
}
}