简体   繁体   English

带bxSlider的Magnify.js

[英]Magnify.js with bxSlider

I'm trying to implement Magnify.js to a bxSlider slide but I have a problem, the zoom effect just works on the very first image of the slide, once I move to the next one the effect won't work, but it does on the first one. 我正在尝试将Magnify.js实现为bxSlider幻灯片,但是我有一个问题,缩放效果仅适用于幻灯片的第一个图像,一旦移至下一个图像,效果将不起作用,但确实如此在第一个。 All of the slide's images have a "zoom" id which I'm targeting with Magnify . 幻灯片的所有图像都有一个“缩放” ID,我使用Magnify定位。 Is there any way to make it work for the whole slide instead of just the first one? 有什么方法可以使它适用于整个幻灯片,而不只是第一张幻灯片?

Try using the follow snippet: https://jsfiddle.net/L9fe0py3/5/ 尝试使用以下代码段: https : //jsfiddle.net/L9fe0py3/5/

HTML: HTML:

<ul class="bxslider">
  <li><img id="img1" src="http://bxslider.com/images/home_slides/picto.png" data-magnify-src="http://bxslider.com/images/home_slides/picto.png" /></li>
  <li><img id="img2" src="http://bxslider.com/images/home_slides/houses.jpg" data-magnify-src="http://bxslider.com/images/home_slides/houses.jpg"/></li>
  <li><img id="img3" src="http://bxslider.com/images/home_slides/hillside.jpg" data-magnify-src="http://bxslider.com/images/home_slides/hillside.jpg"/></li>
</ul>
<img id="img4" src="http://bxslider.com/images/home_slides/hillside.jpg" data-magnify-src="http://bxslider.com/images/home_slides/hillside.jpg"/>

Javascript: Javascript:

$(document).ready(function() {
    $('.bxslider').bxSlider({
      onSlideAfter:function(e){
        $(e).find('img').magnify();
      }
    });
    $('#img1,#img2,#img3,#img4').magnify();
});

You need to replace the "data-magnify-src" attribute on the <img/> elements to the "big" image URL, and ALSO (EDITED) add the .magnify() function everytime a slide changes. 您需要将<img/>元素上的“ data-magnify-src”属性替换为“大”图像URL,并且每当幻灯片更改时,ALSO(已编辑)也将添加.magnify()函数。

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

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