1
I am creating a JS to run the code as if it were slides.
<div class="uk-panel uk-panel-box tm-mandato uk-hidden-small widget_recent_entries">
<div class="uk-width-1-1 uk-width-medium-1-4 uk-overlay-hover">
<div class="tm-imagem uk-height-1-1">
...
</div>
</div>
<div class="uk-width-1-1 uk-width-medium-1-4 uk-overlay-hover">
<div class="tm-imagem uk-height-1-1">
...
</div>
</div>
</div>
I made two JS in an attempt to make the slides pass automatically (every 5s) and stop the automatic execution with the mouse’s Hover (it can be in the .tm-mandate class or in the .uk-overlay-Hover). Either way, both codes run automatically, but do not stop running when you have the Hover.
Code 1:
var timer;
function startTimer() {
timer = setInterval(function () {
var noticia = jQuery('.tm-mandato');
var controleActive = noticia.find('.uk-active');
var contadorNoticia = noticia.find('.uk-overlay-hover').length;
var index = controleActive.index();
controleActive.removeClass('uk-active');
if (index < contadorNoticia - 1){
controleActive.next().addClass('uk-active')
} else {
noticia.find('.uk-overlay-hover:first').addClass('uk-active')
}
}, 5000);
}
jQuery(document).ready(function($){
$('tm-mandato .uk-overlay-hover').hover(function (ev) {
clearInterval(timer);
}, function (ev) {
startTimer();
});
});
startTimer();
Code 2
jQuery(document).ready(function($){
var timer = 5000;
$('.tm-mandato > .uk-overlay-hover').mouseenter(function(ev){
clearInterval(timer);
}, setInterval (function(ev){
var noticia = jQuery('.tm-mandato');
var controleActive = noticia.find('.uk-active');
var contadorNoticia = noticia.find('.uk-overlay-hover').length;
var index = controleActive.index();
controleActive.removeClass('uk-active');
if (index < contadorNoticia - 1){
controleActive.next().addClass('uk-active')
} else {
noticia.find('.uk-overlay-hover:first').addClass('uk-active')
}
}, timer));
});
How can I resolve this issue of the Hover?
Good! It really was a great lack of attention... rsrs Thanks for the @sam help
– Wendell Mosquini Pozzatti