Skip to content

Instantly share code, notes, and snippets.

@zackd
Created March 9, 2010 19:21
Show Gist options
  • Save zackd/326977 to your computer and use it in GitHub Desktop.
Save zackd/326977 to your computer and use it in GitHub Desktop.
galleria - handle just one image
// is a fix for this bug : http://code.google.com/p/galleria/issues/detail?id=62
onImage : function(image,caption,thumb) {
// fetch the thumbnail container
var _li = thumb.parents('li');
// count items
var n = parseInt(_li.siblings().length);
if (typeof n == 'undefined' || n == 0) {
// disable click behaviour
$.galleria.clickNext = false;
}
else if (typeof n == 'number' && n != 0){
// enable click behaviour
$.galleria.clickNext = true;
// fade in the image & caption
if(! ($.browser.mozilla && navigator.appVersion.indexOf("Win")!=-1) ) { // FF/Win fades large images terribly slow
image.css('display','none').fadeIn(500);
}
// fade out inactive thumbnail
_li.siblings().children('img.selected').fadeTo(300,0.3);
// fade in active thumbnail
thumb.fadeTo('fast',1).addClass('selected');
// this will add a class to landscape images allowing extra margin
if (image.height() < image.width()) {
$('#galleriaContentBox').addClass('landscape');
} else {
$('#galleriaContentBox').removeClass('landscape');
}
}
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment