2011-12-19 31 views

回答

1

最新的源代码 - https://github.com/fancyapps/fancyBox/zipball/master 包括取决于您导航(滚动使用鼠标或键盘导航键)的方式不同的动画方向。

使用leftright键箭头可以获得水平转换。

无需破解或定制您自己的fancybox版本。

0

检查API,也许有一个选项呢?

如果没有,请找到执行动画的部分代码并将其替换为您自己的。

+0

......这就是我所做的。我会稍微发布一下结果,但是我在“changeIn”和“changeOut”函数中添加了一些代码,并且还跟踪了您要前往的方向。奇迹般有效。可能应该在标准构建(我会提交给github) – mrBallistic 2011-12-19 23:22:54

1

所以,如果其他人稍后遇到这个问题,我就是这么做的。

例如:The Fremont

在plugins.js文件

,我做了我自己的fancybox脚本的版本。 changeIn和changeOut被更新为这样:

if(!isForward){ 
     // move left (backwards) 
     startPos.left = (parseInt(startPos.left, 10) + 1500) + 'px'; 
     wrap.css(startPos).show().animate({ 
       opacity: 1, 
       left: '-=1500px' 
      }, { 
       duration: current.nextSpeed, 
       complete: F._afterZoomIn 
      }); 
     } else { 

    // move right (forwards) 
    startPos.left = (parseInt(startPos.left, 10) - 1500) + 'px'; 
    wrap.css(startPos).show().animate({ 
       opacity: 1, 
       left: '+=1500px' 

      }, { 
       duration: current.nextSpeed, 
       complete: F._afterZoomIn 
     }); 
    } 

和changeOut现在看起来是这样的:

changeOut: function() { 
     var wrap = F.wrap, 
      current = F.current, 
      cleanUp = function() { 
       $(this).trigger('onReset').remove(); 
      }; 

     wrap.removeClass('fancybox-opened'); 

     var leftAmt; 

     if(isForward){ 
      leftAmt = '+=1500px'; 
     } else { 
      leftAmt = '-=1500px'; 
     } 

     if (current.prevEffect === 'elastic') { 
      wrap.animate({ 
       'opacity': 0, 
       left: leftAmt 
      }, { 
       duration: current.prevSpeed, 
       complete: cleanUp 
      }); 

     } 

isForward将在下一/上一个功能

 next: function() { 
     if (F.current) { 
     F.jumpto(F.current.index + 1); 
     isForward = true; 
      } 
     }, 

     prev: function() { 
     if (F.current) { 
     F.jumpto(F.current.index - 1); 
     isForward = false; 
      } 
     }, 

定义,就是这样。请享用!

1

好主意。只是,你的代码中存在一个错误。你必须把

isForward = false; or isForward = true; 

F.jumpto(F.current.index - 1); or F.jumpto(F.current.index + 1); 

两个next和prev功能。因为当你按下next时,它会破坏你的代码,然后你按prev。你可以尝试一下。

next: function() { 
     if (F.current) { 
      isForward = true; 
      F.jumpto(F.current.index + 1); 
     } 
    }, 



prev: function() { 
      if (F.current) { 
       isForward = false; 
       F.jumpto(F.current.index - 1); 
      } 
     },