I have made modal window for my img gallery. I want to animate opacity changing of next/prev images inside modal. When i click "next" button i want next modal images fade in smoothly, changing opacity from 0 to 1. At the same time i want current img fade out smoothly too. Please, give me advice how i can achive this? Now, when i click next/prev button i change opacity of images in gallery, not inside modal.
HTML
<div id="content">
<div class="modal-content">
<div class="modal-close">Close</div>
<div class="btnModal-left">Prev</div><!--end btnLeft-->
<div class="btnModal-right">Next</div><!--end btnRight-->
<img src="http://o.aolcdn.com/hss/storage/adam/5d7b5eedccc289bd332af80a1ad5a226/montero-2017-us.jpg"><br>
</div>
</div><!--.modal-content-->
<ul class="gallery">
<li><img src="http://o.aolcdn.com/hss/storage/adam/a1289c4c6916baabb98e4673c7052f8/2014-hyundai-veloster-reflex-chicago.jpg"></li>
<li><img src="http://o.aolcdn.com/hss/storage/adam/a039929c8405451173090144693c1fa0/vw-grc-beetle-chicago.jpg"></li>
<li><img src="http://o.aolcdn.com/dims-shared/dims3/GLOB/crop/1280x850+0+0/resize/628x417!/format/jpg/quality/85/http://o.aolcdn.com/hss/storage/adam/1799bb1e072b82bda13c81563bdf5d0f/01-lingenfelter-reaper-chicago-1.jpg"></li>
</ul>
</div><!--#content-->
CSS
ul.gallery {
position: relative;
display: block;
width: 100%;
}
.gallery li {
display: inline-block;
position: relative;
width: 100px;
height: 100px;
}
.gallery li img {
display:block;
position:relative;
width:100px;
height:70px;
}
.modal-content {
background-color: white;
display: none;
padding: 10px 10px 20px 10px;
position: fixed;
z-index: 1000;
height:350px;
width:500px;
}
.btnModal-left, .btnModal-right {
display:inline-block;
border:1px solid black;
}
.modal-content img {
display: block;
position:relative;
max-height:350px;
max-width:500px;
}
.modal-close {
position: absolute;
z-index: 9999;
right: 15px;
top: 15px;
width: 40px;
height: 20px;
display:block;
overflow:hidden;
border:1px solid black;
opacity:1;
}
Jquery
jQuery(document).ready(function ($) {
var сlicked;
$(".gallery li").click(function() {
$(".modal-content").fadeIn();
$('.modal-content img').attr('src',$(this).find('img').attr('src'));
сlicked = $(this);
});
$(".modal-close").click(function() {
$(".modal-content").fadeOut();
});
$('.btnModal-right').click(function(){
сlicked.find('img').fadeOut().end().next().find('img').fadeIn().trigger('click');
});
$('.btnModal-left').click(function(){
сlicked.find('img').fadeOut().end().prev().find('img').fadeIn().trigger('click');
});
});