fancybox navigation arrows

给你一囗甜甜゛ 提交于 2020-01-06 01:55:32

问题


I've tried for hours to resolve this issue. I would sincerely appreciate some help.

I'm trying to implement a jquery animation for the navigation arrows that appear once a [grouped] item is opened up in fancybox. The left or right navigation arrows appear after hovering over the #fancybox-left or #fancybox-right portion that divides the object. For instance, I've positioned the right arrow (defined as #fancybox-right-ico) by setting "right: -__px" under #fancybox-right:hover span so that the arrow is just outside of #fancyboxcontent.

I want to use the jquery animation function so that the #fancybox-right-ico appears to slide out from under #fancyboxcontent instead of just appearing as it does by default.

I've tried using this tutorial for reference.

Where should I place the following code in the fancybox files and how should I label '#navigation a', '#navigation > li', and 'a'?

$(function() {

 $('#navigation a').stop().animate({'marginLeft':'-85px'},1000);

 $('#navigation > li').hover(
  function () {
   $('a',$(this)).stop().animate({'marginLeft':'-2px'},200);
  },
  function () {
   $('a',$(this)).stop().animate({'marginLeft':'-85px'},200);
  }
 );
});

Thanks so much.


回答1:


Try something like this (demo):

$("a").fancybox({
  onComplete: function() {
    $('#fancybox-left-ico, #fancybox-right-ico').css({
      opacity: 0
    });
    $('#fancybox-left, #fancybox-right').hover(function(e) {
      var enter = (e.type === "mouseenter"),
        dir = ($(this).is('#fancybox-left')) ?
          { left : (enter) ? '-30px' : 0 }:
          { right: (enter) ? '-30px' : 0 };
      dir.opacity = (enter) ? 1 : 0;
      $(this).find('span').stop().animate(dir, 400);
    });
  }
});

It doesn't slide out from under the image because the hoverable area needs to overlap it... if it was under, the hover wouldn't work.



来源:https://stackoverflow.com/questions/7536456/fancybox-navigation-arrows

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