2
I wanted to make a slideshow fadein/out (#overlayFancy, only appears when we click a '.wrapperExtraImg', fancybox plugin style), the code so far works very well but now I wanted it to be for next (#right, and #left is the 'Prev') and if there is no other come for the first, the number of images (.wrapperExtraImg) is not fixed either have 1 or 300 images. So far I’ve got 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
});
Thank you so much. I really learned
– Miguel
Just one thing, where I implement fadein/out?
– Miguel
@Miguel used fadein/fadeout to replace the Animate opacity that actually only leaves the element totally transparent, but it remains active...
– Jader A. Wagner
Yes, but moving from one to the other (#next, #Prev) would like fadein/out, I tried to implement but did not give here
– Miguel
@Miguel You have to fadeOut at the moment of the click, and at the end of it, change the src and start the fadein... I edited the response and jsfidle.
– Jader A. Wagner