2017-08-04 121 views
1

美好的一天。fancyBox3 - 如何在點擊打開的圖像時禁用縮放功能

我有這樣的問題:當fancyBox畫廊打開,我只需點擊打開的圖像(幻燈片),圖像是縮放。我需要禁用這種行爲。

在文檔中有建議使用clickContent事件來定製行爲。我採取例如,從文檔,並通過接下來的方式初始化我的畫廊的副本:

$("[data-fancybox]").fancybox({ 
    clickContent : function(current, event) { 
     // return current.type === 'image' ? 'zoom' : false; 
     if (current.type === 'image') { 
      return false; 
     } 
    }, 
    slideShow: false, 
    fullScreen: false, 
    thumbs: false 
}); 

clickContent覆蓋不起作用。我曾嘗試console.log()clickContent事件:

$("[data-fancybox]").fancybox({ 
    clickContent : function(current, event) { 
     // return current.type === 'image' ? 'zoom' : false; 
     console.log('clicking test!'); 
    }, 
    slideShow: false, 
    fullScreen: false, 
    thumbs: false 
}); 

,但我沒有成功。

也許我在某個地方犯了一個錯誤。請糾正我。先謝謝你!

回答

0

更新到v3.1並使用clickContent選項在用戶單擊內容時選擇操作。可能的值:

"close"   - close instance 
"next"   - move to next gallery item 
"nextOrClose"  - move to next gallery item or close if gallery has only one item 
"toggleControls" - show/hide controls 
"zoom"   - zoom image (if loaded successfully) 
false    - do nothing 

它也可以是從列表中返回值的函數。默認值:

clickContent : function(current, event) { 
    return current.type === 'image' ? 'zoom' : false; 
} 

此外,您的代碼段工作正常 - https://codepen.io/anon/pen/GvNdJE

+0

對不起,也許你誤解了我。我有問題**沒有** **打開/關閉動畫**。當圖庫打開時,我希望圖像不要縮放(通過點擊它們)。我希望你的幫助。 –

+1

對不起,我改變了答案。你的代碼片段也可以工作。確保您使用的是v3.1。 – Janis

+0

非常感謝您的回答!我看到你的/我的代碼片段很完美。我一定會檢查版本是3.1。再次感謝你們這樣美好的圖書館。 –