I'm coding a small slider
quite simple and I run into a problem that I really do not know what it is.
The slider
works well until you try to go back to the first photo, you see the change of positions showing the malfunction and then it happens again correctly, the lag is between the last and the first photo.
In css I have this:
.cambiaFoto {
opacity: 0;
transition: all 0.8s;
position: absolute;
}
.cambiaFotoActivo {
opacity: 1;
transition: all 0.8s;
position: relative;
}
HTML Code:
<div class="col-sm-5 alinear-der" ng-controller="cambiaFoto">
<img src="img/productos/foto1.png" alt="" class="responsive-img cambiaFoto cambiaFotoActivo">
<img src="img/productos/foto2.png" alt="" class="responsive-img cambiaFoto">
<img src="img/productos/foto3.png" alt="" class="responsive-img cambiaFoto">
</div>
Javascript code:
function cambiaFotoCtrl($scope){
function miniSlider(){
var activo = document.getElementsByClassName('cambiaFotoActivo');
activo = activo[0]
siguiente = activo.nextElementSibling
if (siguiente == null){
siguiente = activo.parentNode.firstElementChild
}
activo.classList.remove('cambiaFotoActivo')
siguiente.classList.add('cambiaFotoActivo')
}
setInterval(miniSlider, 5000)
}
Example in JSfiddle
Does anyone have any idea why there would be a lag?