For study and knowledge issues, how could I clean a setInterval and then according to some event I can continue to run it again.
'use strict';
var imgAtual = 0;
var arrImg = ['images/relatorio.jpg', 'images/clp.jpg', 'images/estudo-viabilidade.jpg', 'images/padrao.jpg'];
function mudarImagem(){
var imgElm = document.querySelector('.img-slide');
if(imgAtual < arrImg.length){
imgElm.setAttribute('src',arrImg[imgAtual]);
imgAtual++;
console.log(imgAtual);
}else{
imgAtual = 0;
imgElm.setAttribute('src',arrImg[imgAtual]);
imgAtual++;
}
imgElm.addEventListener('click',function(){
clearInterval(mudando);
})
}
var mudando = setInterval(function(){
mudarImagem();
},1000);