2011-12-19 14 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); 
      } 
     }, 
相關問題