我在我的网站上使用iosSlider。我需要更改滑块的动画速度。

我已阅读iosSlider中的文档。我发现必须使用autoSlideTransTimer来控制滑块速度。但是我做不到。

这是我的JavaScript代码:

function InitImageSlider() {
$('.iosSlider').iosSlider
    desktopClickDrag: true,
    snapToChildren: true,
    infiniteSlider: true,
    navSlideSelector: '.slider .navigation li',
    onSlideComplete: function(args) {
        if(!args.slideChanged) return false;

        $(args.sliderObject).find('.slider-info').attr('style', '');

        $(args.currentSlideObject).find('.slider-info').animate({
            left: '15px',
            opacity: '.9'
        }, 'easeOutQuint');
    },
    onSliderLoaded: function(args) {
        $(args.sliderObject).find('.slider-info').attr('style', '');

        $(args.currentSlideObject).find('.slider-info').animate({
            left: '15px',
            opacity: '.9'
        }, 'easeOutQuint');
    },
    onSlideChange: function(args) {
        $('.slider .navigation li').removeClass('active');
        $('.slider .navigation li:eq(' + (args.currentSlideNumber - 1) + ')').addClass('active');
    },
    autoSlide: true,
    scrollbar: true,
    scrollbarContainer: '.sliderContainer .scrollbarContainer',
    scrollbarMargin: '0',
    scrollbarBorderRadius: '0',
    keyboardControls: true
});
}

最佳答案

我也使用iosSlider,这对我有用:

$('.iosSlider').iosSlider({
        snapToChildren: true,
        scrollbar: false,
        scrollbarHide: true,
        desktopClickDrag: true,
        infiniteSlider: true,
        autoSlideTransTimer: 2000,
        navPrevSelector: '#sl-left',
        navNextSelector: '#sl-right',
        onSlideChange: slideChange,
        onSliderLoaded: slideChange,
        responsiveSlideContainer: false,
        responsiveSlides: false,
        autoSlide: true
    });


明显慢于:

$('.iosSlider').iosSlider({
        snapToChildren: true,
        scrollbar: false,
        scrollbarHide: true,
        desktopClickDrag: true,
        infiniteSlider: true,
        autoSlideTransTimer: 100,
        navPrevSelector: '#sl-left',
        navNextSelector: '#sl-right',
        onSlideChange: slideChange,
        onSliderLoaded: slideChange,
        responsiveSlideContainer: false,
        responsiveSlides: false,
        autoSlide: true
    });


所以autoSlideTransTimer为我工作!

09-25 16:24