Attempting to achieve a fade-out, fade-in animation using JavaScript and CSS. Here is the CSS animation code:
@keyframes fade-in{
0%{
opacity: 0%;
}
100%{
opacity: 100%;
}
}
@keyframes fade-out{
0%{
opacity: 100%;
}
100%{
opacity: 0%;
}
}
Implemented a script to toggle display between sections with the animations in between:
function changingDisplay(section){
for(i=0;i<section.length;i++){
if(window.getComputedStyle(section[i]).display == 'grid'){
if(i+1 == section.length){
section[i].style.animation = 'fade-out 500ms'
section[i].style.display = 'none'
section[0].style.display ='grid'
section[0].style.animation = 'fade-in 500ms'
break;
}
}
}
}
The issue I'm facing is that only the last animation appears - the fade-in without preceding fade-out. Any suggestions?