Skip to content

Commit f0a7cee

Browse files
committed
Add slideshow.js
1 parent 95d534c commit f0a7cee

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

javascript/slideshow.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/***
2+
Simple jQuery Slideshow Script
3+
Released by Jon Raasch (jonraasch.com) under FreeBSD license: free to use or modify, not responsible for anything, etc. Please link out to me if you like it :)
4+
***/
5+
6+
function slideSwitch() {
7+
var $active = $('#slideshow IMG.active');
8+
9+
if ( $active.length == 0 ) $active = $('#slideshow IMG:last');
10+
11+
// use this to pull the images in the order they appear in the markup
12+
var $next = $active.next().length ? $active.next()
13+
: $('#slideshow IMG:first');
14+
15+
// uncomment the 3 lines below to pull the images in random order
16+
17+
// var $sibs = $active.siblings();
18+
// var rndNum = Math.floor(Math.random() * $sibs.length );
19+
// var $next = $( $sibs[ rndNum ] );
20+
21+
22+
$active.addClass('last-active');
23+
24+
$next.css({opacity: 0.0})
25+
.addClass('active')
26+
.animate({opacity: 1.0}, 1000, function() {
27+
$active.removeClass('active last-active');
28+
});
29+
}
30+
31+
$(function() {
32+
setInterval( "slideSwitch()", 5000 );
33+
});
34+
35+

0 commit comments

Comments
 (0)