This is the (fairly simple) JS code I use:
$(document).ready(function() {
$(".button-list .next").click(function() {
project = $(this).parents().filter(".projektweb").eq(0);
currentimg = project.find(".images-list li.current");
nextimg = currentimg.next();
firstimg = project.find(".images-list li:first");
currentimg.removeClass("current");
if (nextimg.is("li")) nextimg.addClass("current");
else firstimg.addClass("current");
return false;
});
$(".button-list .prev").click(function() {
project = $(this).parents().filter(".projektweb").eq(0);
currentimg = project.find(".images-list li.current");
previmg = currentimg.prev();
lastimg = project.find(".images-list li:last");
currentimg.removeClass("current");
if (previmg.is("li")) previmg.addClass("current");
else lastimg.addClass("current");
return false;
});
});
And here is what the HTML code for the image list looks like:
<ul class="images-list">
<li class="current"><img src="img/1.jpg" alt="" /></li>
<li><img src="img/1b.jpg" alt="" /></li>
</ul>
<ul class="button-list"> <li><a class="button prev" href="#">←</a></li>
<li><a class="button next" href="#">→</a></li></ul>
CSS:
.images-list {
height: 460px;
list-style-type:none;
float:left;
width: 460px;
overflow:hidden;
position:relative;
}
.images-list img {
height: 460px;
width: 460px;
display:block;
}
.images-list li {
display:none;
}
.images-list li.current {
display:block;
}
What I would like to do is to animate the images when they come and go - right now they just appear, which is good, but a little more eye candy would be good.
Can someone help me here? Is it even possible to do so? Thank!!
source
share