Skip to content

Instantly share code, notes, and snippets.

@sanxac
Created April 12, 2010 21:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sanxac/363997 to your computer and use it in GitHub Desktop.
Save sanxac/363997 to your computer and use it in GitHub Desktop.
//This script randomly cycles images with t1 and t2 id tags with a fade effect by jQuery
//by Sanja Curgus 2008
$(document).ready(function()
{
$("#t1").hide();
$("#t2").hide();
var ThumbsCount = 3;
var thumbs = new Array (ThumbsCount);
var t = 0;
while (t <= ThumbsCount){
thumbs[t] = '{pathToTop}img/thumbs/'+{linkID}+t+'.jpg';
t++;
}
$.preloadImages(thumbs);
var i=Math.floor(Math.random()*ThumbsCount);
var j=Math.ceil(Math.random()*ThumbsCount);
if (j == i) j++;
$(".slowFade").attr({
src: "{pathToTop}img/thumbs/"+{linkID}+i+".jpg",
title: {linkID},
alt: {linkID}
});
$(".normFade").attr({
src: "{pathToTop}img/thumbs/"+{linkID}+j+".jpg",
title: {linkID},
alt: {linkID}
});
$(".slowFade").fadeIn("slow");
$(".normFade").fadeIn("normal");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment