[英]fancyBox3 - How to disable zooming when clicking opened image
Good day. 美好的一天。
I have such type of problem: when fancyBox gallery is opened and I just click on opened image (slide), image is zooming. 我遇到这样的问题:当打开fancyBox画廊并且仅单击打开的图像(幻灯片)时,图像正在缩放。 I need to disable such behavior.
我需要禁用这种行为。
In documentation there is advice to use clickContent
event for customizing behavior. 在文档中,建议使用
clickContent
事件自定义行为。 I take example from documentation and initialize my copy of gallery by the next way: 我以文档为例,并通过以下方式初始化我的画廊副本:
$("[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
});
but clickContent
override doesn't work. 但
clickContent
覆盖无效。 I have tried console.log()
clickContent
event: 我尝试过
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
});
but I didn't succeed. 但我没有成功。
Maybe I'm making a mistake somewhere. 也许我在某个地方犯了错误。 Please correct me.
请纠正我。 Thank you in advance!
先感谢您!
Update to v3.1 and use clickContent
option to choose the action when user clicks on the content. 更新到v3.1,并使用
clickContent
选项选择用户单击内容时的操作。 Possible values: 可能的值:
"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
It can also be function that returns value from the list. 它也可以是从列表返回值的函数。 Default value:
默认值:
clickContent : function( current, event ) {
return current.type === 'image' ? 'zoom' : false;
}
Also, your snippet works fine - https://codepen.io/anon/pen/GvNdJE 另外,您的代码段也可以正常工作-https: //codepen.io/anon/pen/GvNdJE
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.