(Fancy) Shortest jQuery Slideshow Plugin
With custom effects
by mpetrovich
HTML
<div class="slideshow fx-zoom">
<img class="selected" src="http://3577.voxcdn.com/site/grid/gridphoto01.png" width="114" height="114" alt="">
<img src="http://3577.voxcdn.com/site/grid/gridphoto02.png" width="114" height="114" alt="">
<img src="http://3577.voxcdn.com/site/grid/gridphoto03.png" width="114" height="114" alt="">
<img src="http://3577.voxcdn.com/site/grid/gridphoto04.png" width="114" height="114" alt="">
</div>
CSS
.slideshow {
position: relative;
overflow: hidden;
width: 114px;
height: 114px;
}
.slideshow > * {
position: absolute;
left: 0;
top: 0;
opacity: 0;
-webkit-transition: all 0.5s;
-moz-transition: all 0.5s;
transition: all 0.5s;
}
.slideshow > .selected {
opacity: 1;
}
/* Slide effect */
.slideshow.fx-slide > * {
left: 100%;
}
.slideshow.fx-slide > .selected {
left: 0;
}
/* Zoom effect */
.slideshow.fx-zoom > * {
left: 25%;
top: 25%;
right: 25%;
bottom: 25%;
width: 50%;
height: 50%;
}
.slideshow.fx-zoom > .selected {
left: 0;
top: 0;
right: auto;
bottom: auto;
width: 100%;
height: 100%;
}
JavaScript
$.fn.cycle = function(delay) {
var $container = this,
slides = this[0].children,
i = 0,
count = slides.length;
setInterval(function() {
$(slides[i]).removeClass("selected");
i = (i + 1) % count;
$(slides[i]).addClass("selected");
}, delay);
};
$(".slideshow").cycle(1500);