Fancybox 2 title hover on gallery change

前端 未结 1 1679
天涯浪人
天涯浪人 2020-12-22 12:26

First post, so apologies in advance.

I\'m using this How to display fancybox title only on image hover and it works a treat, except when you click prev/next and the

相关标签:
1条回答
  • 2020-12-22 13:06

    As a workaround, you may try adding a function to detect if the mouse is already hovering the fancybox content as in this post .... then show the fancybox title if so.

    $(".fancybox").fancybox({
      helpers: {
        title: {
          type: 'over'
        }
      },
      afterShow: function () {
        $(".fancybox-title").hide();
        // shows/hides title on hover
        $(".fancybox-wrap").hover(function () {
          $(".fancybox-title").stop(true, true).slideDown(200);
        }, function () {
          $(".fancybox-title").stop(true, true).slideUp(200);
        });
        // detects if mouse is already hovering
        $(".fancybox-outer a, .fancybox-outer img").hover(function () {
          $(this).data('timeout', setTimeout(function () {
            $(".fancybox-title").stop(true, true).slideDown(200);
          }, 100));
        }, function () {
          clearTimeout($(this).data('timeout'));
        });
      }
    });
    

    See JSFIDDLE ... it seems to work fine in IE7+ and FF

    0 讨论(0)
提交回复
热议问题