jCarousel - Continue Scrolling When At First or Last Item On Button Press
I am encountering an issue with jCarousel whereby if a the carousel has started at the beginning and the left button is pressed the carousel doesn't scroll.
What is supposed to happen is that if the carou开发者_运维问答sels first item is displayed and the left button is pressed, the carousel should circle to the end item. At the moment, this does not happen. The carousel just stops working.
This only happens when the carousel is first loaded.
Example of my code is here: http://jsfiddle.net/wquPu/2/.
Thanks.
I don't know exactly what you are doing wrong, but if you look at the jCarousel demo pages you will find a demo of exactly what you are trying to do and it's very simple code.
http://sorgalla.com/projects/jcarousel/examples/static_auto.html
function mycarousel_initCallback(carousel)
{
// Disable autoscrolling if the user clicks the prev or next button.
carousel.buttonNext.bind('click', function() {
carousel.startAuto(0);
});
carousel.buttonPrev.bind('click', function() {
carousel.startAuto(0);
});
// Pause autoscrolling if the user moves with the cursor over the clip.
carousel.clip.hover(function() {
carousel.stopAuto();
}, function() {
carousel.startAuto();
});
};
jQuery(document).ready(function() {
jQuery('#mycarousel').jcarousel({
auto: 2,
wrap: 'last',
initCallback: mycarousel_initCallback
});
});
精彩评论