I'm making an automatic fadeIn / Out slider but I'd like to implement controls too (next / prev), the problem is that I can not connect these two features. For example, if it is on slide1 and I load it on next
(slide2) the automatic part will change again to slide2 instead of switching to slide3, since slide2 is where we are.
HTML:
<a href="project.php?name=Orange_Summer_Day" data-sliderHighlight="1" class="containerHigh" style="background-image:url(hola.jpg);">
<a href="project.php?name=Orange_Summer_Day" data-sliderHighlight="2" class="containerHigh" style="background-image:url(hey.jpg);">
<a href="project.php?name=Orange_Summer_Day" data-sliderHighlight="3" class="containerHigh" style="background-image:url(hi.jpg);">
JQUERY: controls:
function sliderHighlights() {
$(".containerHigh:gt(0)").hide();
$(document).on('click', '#nextHighlight', function() {
$('.containerHigh').stop().fadeOut(500);
var highlightOn = parseInt($('.containerHigh:visible').attr('data-sliderHighlight'));
var highlightNext = highlightOn+1;
if(highlightOn == $('.containerHigh').length) {
highlightNext = 1;
}
$('.containerHigh[data-sliderHighlight="' +highlightNext+ '"]').stop().fadeIn(500);
});
$(document).on('click', '#prevHighlight', function() {
$('.containerHigh').stop().fadeOut(500);
var highlightOn = parseInt($('.containerHigh:visible').attr('data-sliderHighlight'));
var highlightprev = highlightOn-1;
if(highlightOn == 1) {
highlightprev = $('.containerHigh').length;
}
$('.containerHigh[data-sliderHighlight="' +highlightprev+ '"]').stop().fadeIn(500);
});
}
JQUERY: autoSlider
function autoSliderHighlights() {
setInterval(function() {
$('.containerHigh:visible')
.fadeOut(800).next().fadeIn(800).end().appendTo('#sliderHighlight');
}, 5000);
}
NOTE: Each of them alone works well, only when I try to join the two is there incoherence. Any tips?