Unbinding Fancybox on thumbnail fade
I am using fancybox on a series of gallery images.
The user has the option to click a link which fades out certain images of a certain category.
I want to unbind the Fancybox method on the images that are faded but also re-bind when they are at full opacity.
$("#clientsProjects").delegate("#clientsProjects nav a", "click", function() {
$("#clientsProjects .current").removeClass("current");
$(this).parent().addClass("current");
var $filterClass = $(this).attr("class").split(/\s+/);
$.each($filterClass, function(index, item){
if ($filterClass != "all") {
$("#clientsProjects .workThumbs div:not(." + $filterClass + ")").stop().fadeTo("slow", .2, function() {
$(this).unbind("click");
});
$("#clientsProjects .workThumbs div." + $filterClass).stop().fadeTo("开发者_StackOverflow中文版slow", 1);
} else {
$("#clientsProjects .workThumbs div").stop().fadeTo("slow", 1);
}
});
return false;
});
Your code looks a little crazy / long so I'm not going to bother examining it too thoroughly; however your problem seems fairly simple.
When fading an image additionally call .unbind('click.fb')
to unbind fancybox.
And to re-apply it; the fade in methods you're using will accept a callback function that is executed on completion of the animation; within that function you can then bind fancybox onto the objects again.
精彩评论