admin管理员组文章数量:1320610
I am using this popular carousel (/).
I have placed certain elements inside each slide. At least one of these elements must be selected by the user before moving to the next slide. But I cannot figure out how to prevent the user from manually moving to next slide by clicking the 'next' arrow before selecting an element.
I know that 'next/previous' arrows can be disabled but I do not want to do that as the user might want to go back to previous slide to change his option.
I know that one option is to disable default arrows and introduce my own prev/next arrows and then bind slide changing functionality to it along with condition checking. But it would be great if there is some built-in option in this slider (which I am not able to figure out) as it would minimize my effort.
I am using this popular carousel (http://kenwheeler.github.io/slick/).
I have placed certain elements inside each slide. At least one of these elements must be selected by the user before moving to the next slide. But I cannot figure out how to prevent the user from manually moving to next slide by clicking the 'next' arrow before selecting an element.
I know that 'next/previous' arrows can be disabled but I do not want to do that as the user might want to go back to previous slide to change his option.
I know that one option is to disable default arrows and introduce my own prev/next arrows and then bind slide changing functionality to it along with condition checking. But it would be great if there is some built-in option in this slider (which I am not able to figure out) as it would minimize my effort.
Share Improve this question asked May 1, 2015 at 12:27 darKnightdarKnight 6,48115 gold badges58 silver badges93 bronze badges 2-
1
api is here: github./kenwheeler/slick. You need the
beforeChange
event probably bined with theslickPause
method – Pete Commented May 1, 2015 at 13:24 - slickPause only stops autoplay, not playing of next slide. – darKnight Commented May 2, 2015 at 17:07
1 Answer
Reset to default 5I made a quick modified version of Slick that allows for condition checking when going next, see: http://jsfiddle/alan0xd7/dhxhv5gg/
Basically the slider will only go to next if fnCanGoNext
returns true
.
I've only actually added one line around line #700 on the fiddle. It doesn't handle things like clicking on "previous" when on first slide, but you can probably work from here.
Since Slick is an open source project, don't be afraid to change the code and adapt it to suit your needs. It is fun to see how things work behind the scenes.
Hope this helps!
本文标签: javascriptCheck condition before changing slide in Slick SliderStack Overflow
版权声明:本文标题:javascript - Check condition before changing slide in Slick Slider - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742078753a2419566.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论