Delay in Enable and disable fancybox close button

那年仲夏 提交于 2019-12-11 03:34:08

问题


When fancybox fires the popup I want to have the close button disabled and just enable it after x seconds.

Is there any solution?

Thanks in Advance.


回答1:


This one is fun.

If you want to hide the close button to prevent the closing at least during 10 seconds, you may also want to disable closing on click either inside or outside fancybox .... so try setTimeout inside the afterShow callback like :

$(".fancybox").fancybox({
    closeClick: false, // prevents closing when clicking INSIDE fancybox 
    helpers: { overlay: { closeClick: false } }, // prevents closing when clicking OUTSIDE fancybox
    afterShow: function() {
        $(".fancybox-close").hide(); // hide close button
        setTimeout(function() {
            $(".fancybox-close").fadeIn();
        }, 10000); // show close button after 10 seconds
    }
});​

See DEMO

NOTE : this is for fancybox v2.1.3+




回答2:


for all users of fancybox the current latest version hide/show close icon with showCloseButton doesn't work any more. After looking into the fancybox code i figured out closeBtn should be set to false. Use 'closeBtn' : false to hide CloseIcon. Thanks



来源:https://stackoverflow.com/questions/13928018/delay-in-enable-and-disable-fancybox-close-button

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!