簡體   English   中英

Fancybox:在鼠標懸停/鼠標懸停時使用它

[英]Fancybox: Getting it to work on mouseover/mouseout

我目前通過以下方式使它工作一半:

jQuery("a.lightbox").fancybox().hover(function() {
    jQuery(this).click();
  }, function() {
    jQuery("#fancybox-overlay").click();
  });

當我將鼠標懸停在縮略圖上時,效果很好,但是當我將鼠標懸停在背景上時, #fancybox-overlay不會禁用fancybox ..有什么想法嗎?

與hoverIntent:

function openFancybox(){
 jQuery(this).trigger("click");
}
function closeFancybox(){
 jQuery.fancybox.close();
}

jQuery("a.lightbox").hoverIntent({
 sensitivity: 100,
 interval:250,
 timeout:0,
 over: openFancybox,
 out: closeFancybox 
}); // hoverIntent

jQuery("#fancybox-content img").hoverIntent({
 sensitivity: 10,
 interval:500,
 timeout:0,
// over: openFancybox,
 out: closeFancybox 
}); // hoverIntent

jQuery("a.lightbox").fancybox({
 'overlayShow' : false,
 'autoScale'   : true
}); // fancybox

答案:

HTML

<a href="image1.jpg" class="lightbox" rel="gallery"><img src="image1.jpg"></a>
<a href="image2.jpg" class="lightbox" rel="gallery"><img src="image2.jpg"></a>​

JS

$("a.lightbox").fancybox({
    'showCloseButton': false
}).hover(function() {
    $(this).click();
    $(".fancybox-overlay").mouseout(function() {
        $.fancybox.close();
    });
});​

演示

使用以下代碼段:

$("a.lightbox").mouseover(function(){
   $("a.lightbox:first").trigger("click");
});

用mouseout事件做同樣的事情... =)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM