围绕滑块图像控制javascript

时间:2012-11-28 10:04:36

标签: javascript jquery html css

我使用了来自这个网站http://www.joezimjs.com/demos/roundabout-demo/的圆形滑块我需要在旋转器中只显示三个图像。如果我使用超过7张图像,则旋转器中有五张图像。可能有任意数量的图像,但应在旋转器中显示三个。如何解决这个问题?

脚本:

(function($) {

var $descriptions = $('#carousel-descriptions').children('li'),
    $controls = $('#carousel-controls').find('span'),
    $carousel = $('#carousel')
        .roundabout({childSelector:"a", minOpacity:1, autoplay:true, autoplayDuration:5000, autoplayPauseOnHover:true })
        .on('focus', 'a', function() {
            var slideNum = $carousel.roundabout("getChildInFocus");

            $descriptions.add($controls).removeClass('current');
            $($descriptions.get(slideNum)).addClass('current');
            $($controls.get(slideNum)).addClass('current');

        });

$controls.on('click dblclick', function() {
    var slideNum = -1,
        i = 0, len = $controls.length;

    for (; i<len; i++) {
        if (this === $controls.get(i)) {
            slideNum = i;
            break;
        }
    }

    if (slideNum >= 0) {
        $controls.removeClass('current');
        $(this).addClass('current');
        $carousel.roundabout('animateToChild', slideNum);
    }
});

}(jQuery));

0 个答案:

没有答案