Skip to content

Instantly share code, notes, and snippets.

@jdlich
Created August 29, 2010 02:42
Show Gist options
  • Save jdlich/555892 to your computer and use it in GitHub Desktop.
Save jdlich/555892 to your computer and use it in GitHub Desktop.
//
// Gallery Script
//
// first thumbnail starts out as being selected
$('#photo_gallery ul li:first-child img').addClass('selected');
// set the last thumbnail's margin to 0
$('#photo_gallery ul li:last-child').addClass('last');
// all thumbnails should begin with lower opacity
$('#photo_gallery ul img').animate({ opacity: 0.75 }).hover(
// on mouseover:
function(e) {
var thumbnail = $(e.target);
// remove selected status from all thumbnails
thumbnail.parent().siblings().children().removeClass('selected');
// change opacity back to 100%
thumbnail.stop().animate({ opacity: 1 }, "fast");
// select thumbnail
thumbnail.addClass('selected');
// update image with thumbnail image
var new_photo = thumbnail.attr('src').replace('_thumbnail','');
$('#photo_gallery img#main').attr('src', new_photo);
},
// on mouseout:
function(e) {
// drop opacity back down to 75%
$(this).stop().animate({ opacity: 0.75 });
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment