2012-04-12 70 views
2

我目前正在构建一个使用多个flexsliders的网站。这个概念是,当用户点击一个特定的按钮时,它会显示一个带有与按钮相关的特色内容的flexslider,这些都非常简单。在元素上重置flexslider点击

我现在遇到的问题是,flexsliders点击按钮时触发,但是无论何时用户单击不同的按钮,滑块不会重置。

我想尝试使滑块重置为在每次按钮单击时滑动0。我尝试过使用.stop()和插件中的一些回调函数,但我还没有运气。想知道其他人是否曾经遇到过这个问题? (并赢得..)

在footer.php的代码是目前非常标准的问题:

$('.button').click(function() { 
    $('.flexslider').flexslider({ 
     controlNav: true, 
     directionNav: false, 
     slideToStart: 0, 
     pauseOnHover: true, 
    }); 
}); 

回答

0

认为,答案可能在于开始回调函数。尝试是这样的(未经测试)

$('.button').click(function() { 
    $('.flexslider').flexslider({ 
     controlNav: true, 
     directionNav: false, 
     slideToStart: 0, 
     pauseOnHover: true, 
     start: function(slider) { 
      if (slider.currentSlide != 0) { 
       slider.flexAnimate(0)//move the slider to the first slide (Unless the slider is also already on the first slide); 
      } 
     } 
    }); 
}); 
0

使用新的API在行1056 flexslider像 'startAt:0,
//整数:滑块应该开始的幻灯片。数组符号(0 =第一张幻灯片)'

3

我知道这个问题发布已经很久了,但它可能对某人有帮助。

我实际上面临同样的问题。之后,我周围的一些戳设法得到它的工作使用下面的代码:

// Catch the flexslider context 
var slider = $(".flexslider").data("flexslider"); 

// Unset the animating flag so we can move back to the first slide quickly  
slider.animating = false; 

// Move to the first slide and stop the slideshow there 
slider.flexAnimate(0, true, true); 

如果你想在第一滑动返回,但不希望动画停止,只是slider.flexAnimate(0);

替换最后一行

我相信slider.stop()方法不会取消设置animating标志。在我看来它应该,因为这个标志在flexAnimate()函数中用来检查是否实际滑动。如果该标志设置为false,则flexAnimate()函数将突然返回。