kenwheeler / slick

the last carousel you'll ever need
kenwheeler.github.io/slick
MIT License
28.41k stars 5.88k forks source link

Incorrect positioning for .slick-track when 'slickGoTo' is used for default selected slider #3567

Open ovylehzhanin opened 6 years ago

ovylehzhanin commented 6 years ago

Could be reproduced here: https://codepen.io/AlexeyVylegzhanin/pen/aaRgpw/?editors=0010

====================================================================

Steps to reproduce the problem

  1. Setup two carousels that related via asNavFor property:

====================================================================

What is the expected behaviour?

value for transform: property should be translate3d(0px, 0px, 0px);.

====================================================================

What is observed behaviour?

value for transform: property is translate3d(-168px, 0px, 0px);. As result .slick-track positioned out of his place

image

====================================================================

More Details

Slick 1.8.1

I guess that this issue related for #1370 Left translate is wrong when centerMode is true and there is only one slide.

CamilleScholtz commented 5 years ago

I was able to fix this by changing

        if (_.slideCount <= _.options.slidesToShow) {
            _.slideOffset = 0;
            verticalOffset = 0;
        }

to

        if (_.slideCount < _.options.slidesToShow) {
            _.slideOffset -= _.slideWidth * (_.options.slidesToShow - _.slideCount);
            verticalOffset = 0;
        }