admin管理员组文章数量:1374895
I've been using Flexslider for a while and love it but I've got a custom function I'm trying to achieve that I'm a bit stuck on.
In each slide I have some text with 2 buttons, essentially true or false. Upon clicking one of the buttons they animated depending on if the user has chosen the right answer. No matter what they choose though, after a short delay of a few seconds I want the slideshow to animate to the next slide.
My flexslider call looks like this:
$(window).load(function () {
$('.flexslider').flexslider({
animation: "slide",
animationLoop: false,
slideshow: false,
controlNav: false,
touch: true,
smoothHeight: true
});
});
I've managed to create a bit of javascript so that when a button is clicked it moves to the 2nd slide:
$('.true-or-false .btn').click(function () {
$('.slider').flexslider(0);
});
But it'd be a pain to have to do this for every single button, I tried to find a 'next' function but couldn't get anything to work. In addition to this I tried to add .delay(2000)
but that didn't seem to play well with the above code.
I thought there'd be a delay function for slides in flexslider and I'd only have to find a way to move to the next slide using a custom button. Can anyone shed any light on this?
Thanks for taking the time to read this! Ste
* EDIT *
For some reason when I first tried the code below it didn't work but now adding 'next' does make the slide animate to the next one on clicking the button - now I just need a delay!
$('.true-or-false .btn').click(function () {
$('.slider').flexslider('next');
});
I've been using Flexslider for a while and love it but I've got a custom function I'm trying to achieve that I'm a bit stuck on.
In each slide I have some text with 2 buttons, essentially true or false. Upon clicking one of the buttons they animated depending on if the user has chosen the right answer. No matter what they choose though, after a short delay of a few seconds I want the slideshow to animate to the next slide.
My flexslider call looks like this:
$(window).load(function () {
$('.flexslider').flexslider({
animation: "slide",
animationLoop: false,
slideshow: false,
controlNav: false,
touch: true,
smoothHeight: true
});
});
I've managed to create a bit of javascript so that when a button is clicked it moves to the 2nd slide:
$('.true-or-false .btn').click(function () {
$('.slider').flexslider(0);
});
But it'd be a pain to have to do this for every single button, I tried to find a 'next' function but couldn't get anything to work. In addition to this I tried to add .delay(2000)
but that didn't seem to play well with the above code.
I thought there'd be a delay function for slides in flexslider and I'd only have to find a way to move to the next slide using a custom button. Can anyone shed any light on this?
Thanks for taking the time to read this! Ste
* EDIT *
For some reason when I first tried the code below it didn't work but now adding 'next' does make the slide animate to the next one on clicking the button - now I just need a delay!
$('.true-or-false .btn').click(function () {
$('.slider').flexslider('next');
});
Share
Improve this question
edited Sep 10, 2014 at 10:38
user1406440
asked Sep 10, 2014 at 9:53
user1406440user1406440
1,6653 gold badges35 silver badges74 bronze badges
1 Answer
Reset to default 8It looks like I've managed to get this to work and thought it might be useful to post my solution here incase anyone should be looking to achieve similar functionality with Flexslider. Here is what I came up with:
$('.true-or-false .btn').click(function () {
setTimeout(
function()
{
$('.flexslider').flexslider('next')
}
, 2000);
});
Which when clicking a (custom) button within the Flexslider will move to the next slide but not before a delay, when you can specify.
And just a quick note. The reason I wanted to achieve this effect was because when you click on a button (either true or false) an animation occurred telling the user if they're were correct or not before moving to the next question.
Hope this helps somebody else :)
本文标签: javascriptFlexslider move to next slide (with a delay) on custom button clickStack Overflow
版权声明:本文标题:javascript - Flexslider: move to next slide (with a delay) on custom button click - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743913683a2560845.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论