jCarousel-在按下按钮的第一个或最后一个项目时继续滚动 [英] jCarousel - Continue Scrolling When At First or Last Item On Button Press

查看:88
本文介绍了jCarousel-在按下按钮的第一个或最后一个项目时继续滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

jCarousel遇到了一个问题,即如果开始时启动了一个轮播,并且按下了向左按钮,则该轮播不会滚动.

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 carousels 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.

我的代码示例在这里: http://jsfiddle.net/wquPu/2/

Example of my code is here: http://jsfiddle.net/wquPu/2/.

谢谢.

推荐答案

我不知道您到底在做什么错,但是如果您查看jCarousel演示页面,就会发现您正在尝试的确切演示.这样做,这是非常简单的代码.

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
    });
});

这篇关于jCarousel-在按下按钮的第一个或最后一个项目时继续滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆