console.log('scripts loaded'); run = true; document.onreadystatechange = function(event) { if (document.readyState === "complete") { console.log('document loaded'); if(slide = document.getElementById("slide-3")) { document.getElementById("slider").setAttribute('data-current-slide',3); //setTimeout(moveSlide, 10, slide); } document.addEventListener("click",function (event) { console.log(event.target); if(event.target.matches('.pause') || event.target.matches('.ico-pause2') ) { console.log("pause requested"); run=false; } }); } } function moveSlide(slide) { if(!run) { slide.setAttribute('style','opacity:0%;margin-left:-100%;z-index:3'); return; } start=0; if(slide.getAttribute('data-position')) { start = parseInt(slide.getAttribute('data-position')); } slide.setAttribute('data-position',start-1); slide.setAttribute('style','opacity:'+(100+start)+'%;margin-left:'+(start-1)+'%;z-index:3'); if(start > -100) { setTimeout(moveSlide, 10, slide); return; } nextSlide(); } function nextSlide() { next = 3; if(current = document.getElementById("slider").getAttribute('data-current-slide')) { next = parseInt(current) -1; } if(next < 1) { next = 3; } console.log("next " + next); console.log("current " + current); next_slide = document.getElementById("slide-"+next); next_slide.setAttribute('data-position',0); next_slide.setAttribute('style','margin-left:0%;z-index:3'); current_slide = document.getElementById("slide-"+current); current_slide.setAttribute('data-position',0); current_slide.setAttribute('style','margin-left:0%;z-index:0'); document.getElementById("slider").setAttribute('data-current-slide',next); setTimeout(moveSlide, 10, next_slide); }