I wanted to do a fadein / out slideShow (#overlayFancy, it only appears when we click on a '.wrapperExtraImg', fancybox plugin style), the code so far works great but now I wanted it to go to the next (#right being #left is 'prev'), and if there is not another one for the first one, the number of images (.wrapperExtraImg) is not fixed so it can have 1 to 300 images. So far I have this but I'm not sure what to do from here:
HTML:
<div id="overlayFancy">
<div class="imgSlide">
<div id="left"></div>
<div id="right"></div>
</div>
</div>
.......
<div id="projectImgs"><?php
foreach ($dataBase->selectAllFromAtable($dataBase->getDetails($idDetails)[0]->description) as $extraImg) { ?>
<div id="<?php echo 'admin/' .$extraImg->extra_image_path; ?>" class="wrapperExtraImg" style="background-image:url(<?php echo 'admin/' .$extraImg->extra_image_path; ?>)"></div>
<?php } ?>
</div>
jQuery:
$(document).on('click', '.wrapperExtraImg' ,function(){
var image = $(this).attr('id');
$('#overlayFancy').stop().animate({
"opacity":"1"
}, 500);
$('.imgSlide').append("<img src="+image+">");
$('.imgSlide').width($('.imgSlide img').width());
});
$(document).on('click', '#overlayFancy' ,function(){
$('#overlayFancy').stop().animate({
"opacity":"0",
}, 300);
$('.imgSlide').children('img').remove();
});
$(document).on('click', '.imgSlide img, #left, #right', function (event) {
event.stopPropagation(); // PARA QUE O SLIDE (#overlayFancy) NÃO DESAPAREÇA SE CLICARMOS NUM DESTES ELEMENTOS
});