Slick.js, slider sync with beforeChange

白昼怎懂夜的黑 提交于 2019-12-11 15:18:02

问题


I have a problem with setting slick carousel in mode with sync navigation, to work like this:

First transition https://imgur.com/a/Lq1nn

Second transition https://imgur.com/a/ywL3D

Third transition https://imgur.com/a/SbBbf

The way I am doing it now, does not working as it should.

    $main_topic_slider.on('beforeChange', function(currentSlide){
        $main_topic_nav.slick('slickGoTo', currentSlide + 1);

    console.log('SLIDER:'+$main_topic_slider.slick('slickCurrentSlide'));
    console.log('NAV:'+$main_topic_nav.slick('slickCurrentSlide'));
    });

Slides behaviour not as they supposed:

SLIDER:0 NAV:1

SLIDER:0 NAV:1

SLIDER:1 NAV:2

SLIDER:0 NAV:1

SLIDER:1 NAV:2

Here is the way I initialize:

    var settings_main_topic = {
        slidesToShow: 1,
        slidesToScroll: 1,
        arrows: false,
        fade: false,
        autoplay: true,
        autoplaySpeed: 8000,
        asNavFor: $main_topic_nav,
        cssEase: 'cubic-bezier(.25,.46,.45,.94)',
        speed: 1000,
        initialSlide: 0
    },

    settings_main_topic_nav = {
        slidesToShow: 2,
        slidesToScroll: 1,
        arrows: false,
        focusOnSelect: false,
        autoplay: true,
        autoplaySpeed: 8000,
        asNavFor: $main_topic_slider,
        cssEase: 'cubic-bezier(.25,.46,.45,.94)',
        speed: 1000,
        initialSlide: 1
    }

I would appreciate if anyone could help me with this.

来源:https://stackoverflow.com/questions/46543329/slick-js-slider-sync-with-beforechange

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!