6

我面临这样一种情况,当幻灯片更改时我必须触发一个事件,但是我的滑块不支持这一点。前后都支持(http://www.woothemes.com/flexslider/#highlighter_298

有没有办法让我在幻灯片更改时触发功能?

这是演示滑块的网址:http: //flexslider.woothemes.com/thumbnail-slider.html

    $(window).load(function() {
      // The slider being synced must be initialized first
      $('#carousel').flexslider({
        animation: "slide",
        controlNav: false,
        start: function(){},            //Callback: function(slider) - Fires when the slider loads the first slide
        before: function(){},           //Callback: function(slider) - Fires asynchronously with each slider animation
        after: function(){},            //Callback: function(slider) - Fires after each slider animation completes
        animationLoop: false,
        slideshow: false,
        itemWidth: 210,
        itemMargin: 5,
        asNavFor: '#slider'
      });

      $('#slider').flexslider({
        animation: "slide",
        controlNav: false,
        animationLoop: false,
        slideshow: false,
        sync: "#carousel"
      });
    });

在我的幻灯片中,我有 rel 属性,我想在幻灯片处于活动状态时使用该属性(将 .flex-active-slide 添加到活动幻灯片中)。

<div class="flexslider">
  <ul class="slides">
    <li rel="divid1" class="flex-active-slide">
      <img src="slide1.jpg" />
    </li>
    <li rel="divid2">
      <img src="slide2.jpg" />
    </li>
    <li rel="divid3">
      <img src="slide3.jpg" />
    </li>
    <li rel="divid4">
      <img src="slide4.jpg" />
    </li>
    <!-- items mirrored twice, total of 12 -->
  </ul>
</div>

当前规定(之前:和之后:)允许您在活动幻灯片之前获取幻灯片的 rel 属性。有没有办法获取活动幻灯片的 rel 属性?

4

1 回答 1

11

beforeor回调允许您将after函数绑定到动画开始或结束的事件。所以如果你想在幻灯片动画结束后获取活动幻灯片的 rel 属性,你可以这样调用它。

$('#slider').flexslider({
    animation: "slide",
    controlNav: false,
    animationLoop: false,
    after: function(){
        var active_rel = $(this).find('.flex-active-slide').attr('rel');
        //do something
    },
    slideshow: false,
    sync: "#carousel"
});
于 2013-10-05T06:35:43.003 回答