在缩略图淡入淡出时取消绑定 Fancybox [英] Unbinding Fancybox on thumbnail fade

查看:19
本文介绍了在缩略图淡入淡出时取消绑定 Fancybox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一系列画廊图片上使用了 fancybox.

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.

我想在褪色的图像上取消绑定 Fancybox 方法,但在完全不透明时重新绑定.

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("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.

当淡入图像时,额外调用 .unbind('click.fb') 来解除fancybox的绑定.

When fading an image additionally call .unbind('click.fb') to unbind fancybox.

然后重新应用它;您正在使用的淡入方法将接受在动画完成时执行的回调函数;在该函数中,您可以再次将 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.

这篇关于在缩略图淡入淡出时取消绑定 Fancybox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆