Fancybox 3-使用触发器在Fancybox中打开图像,但不单击图像

问题描述

我正在尝试找到一种方法,仅在单击触发器(通过属性data-fancybox-href)时使用Fancybox 3打开图像。单击源图像本身时,它不应打开fancybox,而应打开其他页面(默认属性href)。但是,Fancybox必须使用源图像,因为只有这样animationEffect: "zoom"才会发生。

这似乎出乎意料地困难,我在Fancybox 3中没有找到解决该问题的集成方法。我将不胜感激。

这是一个基本示例和JSFiddle。在这种情况下,btn会在图像上触发click事件,从而打开Fancybox,或者图像本身打开Fancybox。我只希望第一个发生,而不要在图像上发生。

<div class="product">
    <div class="media">
        <a href="https://www.google.com/" class="product-image-link" data-fancybox="shop-gallery" data-fancybox-href="https://cdn.pixabay.com/photo/2015/12/01/20/28/road-1072823__340.jpg">
      <img width="280" height="200" src="https://cdn.pixabay.com/photo/2015/12/01/20/28/road-1072823__340.jpg">
    </a>
    </div>
    <span class="product-lightbox-btn">Expand</span>
</div>

<script>
$( "[data-fancybox]" ).fancybox(
    {
        animationEffect: "zoom",beforeLoad : function(instance,current) {
            // Alternative img link
            var dataFancyboxHref = current.opts.$orig.attr( "data-fancybox-href" );
                this.src = dataFancyboxHref;
        },}
);

$( ".product-lightbox-btn" ).click( function() {
    $(this).closest( '.product' ).find( '.product-image-link' ).trigger( 'click' );
});
</script>

https://jsfiddle.net/v1n3e2zy/

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...