简体   繁体   English

如何动态禁用/启用fancybox?

[英]How to disable / enable fancybox on the fly?

We are developing a site with fluid layout (so it works on mobile too), that adjusts itself when resizing the window. 我们正在开发一个布局流畅的网站(因此它也可以在移动设备上使用),可以在调整窗口大小时对其进行自我调整。

Everything is ok but an area when we use fancybox to zoom the images. 一切正常,但是当我们使用fancybox缩放图像时,这是一个区域。 What I want it to disable fancybox when I call our "mobile ajusts" function (triggered by window.resize already) on our gallery, and re-enable it again when when going back to the "desktop" version. 我希望它在我的图库中调用“移动调整”功能(已经由window.resize触发)时禁用fancybox,并在返回“桌面”版本时再次重新启用它。

I've tried a lot of things like preventDefault on 'click', using the $('.case-gallery a').fancybox($.fancybox.cancel) and stuff like that, but it seems that as fancybox is already stored in the DOM element, I'm not being able to disable it and enable it again on the fly - and my knowledge of JS is not really advanced. 我已经尝试过很多事情,例如在'click'上使用preventDefault,使用$('。case-gallery a')。fancybox($。fancybox.cancel)之类的东西,但是似乎fancybox已经存储了在DOM元素中,我无法立即禁用它并再次启用它-而且我对JS的了解还不是很先进。

Any help? 有什么帮助吗?

I have the same problem, and here is my current working thought: 我有同样的问题,这是我目前的工作思路:

jQuery check if event exists on element jQuery检查元素上是否存在事件

use this answer to check a variable property to the DOM... like check if DOM.style.whatever > 10. just my working thought. 使用此答案来检查DOM的可变属性...就像检查DOM.style.whatever> 10.只是我的工作思路。 I have a site that has a carousel of products in DIVs, and i want the not-displayed products to not be clickable based on their DIVs opacity. 我有一个网站,其中包含DIV产品的轮播,并且我希望基于DIV的不透明度,无法点击未显示的产品。 I'll repost in a day if i figure it out. 如果能解决的话,我会在一天内重新发布。

尝试使用此方法监听fancybox onStart事件,然后使用$ .fancybox.cancel()(请不要忘记()。这是一个函数)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM