Итак, вы хотите, чтобы все это исчезло через x раз и появилось через y?
Не работает ли setTimeout для этого?
.hidden { display: none; }
function myInterval(showInterval , hideInterval) {
var elem = document.getElementById('slideshow');
var targetInterval;
if ((" " + elem.className + " " ).indexOf( " " + hidden + " " ) > -1) {
elem.classList.remove('hidden');
targetInterval = showInterval;
} else {
elem.classList.add('hidden');
targetInterval = hideInterval;
}
setTimeout(function(){ myInterval(showInterval , hideInterval) }, targetInterval);
};
myInterval(showInterval , hideInterval);
// showInterval = how long the animation will be visible
// hideInterval = how long the animation will be hidden
// this will hide it at the start, and show it after the 'hide' interval
// to make it show from the start, add the 'hidden' class on the Element from the start
Или вместо этого вы можете использовать setInterval, если хотите, чтобы это был тот же период показа / скрытия:
setInterval(function(){
document.getElementById('slideshow').classList.toggle('hidden');
}, x); // x is the time for how long the animation will be visible/hidden