Skip to content

Commit

Permalink
Merge pull request kenwheeler#1886 from pazaricha/master
Browse files Browse the repository at this point in the history
Fix bug with "variableWidth: true" and and "rtl: true"
  • Loading branch information
kenwheeler committed Nov 19, 2015
2 parents 2a94d97 + 01db273 commit 63c5454
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions slick/slick.js
Original file line number Diff line number Diff line change
Expand Up @@ -1075,15 +1075,33 @@
targetSlide = _.$slideTrack.children('.slick-slide').eq(slideIndex + _.options.slidesToShow);
}

targetLeft = targetSlide[0] ? targetSlide[0].offsetLeft * -1 : 0;
if (_.options.rtl === true) {
if (targetSlide[0]) {
targetLeft = (_.$slideTrack.width() - targetSlide[0].offsetLeft - targetSlide.width()) * -1;
} else {
targetLeft = 0;
}
} else {
targetLeft = targetSlide[0] ? targetSlide[0].offsetLeft * -1 : 0;
}

if (_.options.centerMode === true) {
if (_.slideCount <= _.options.slidesToShow || _.options.infinite === false) {
targetSlide = _.$slideTrack.children('.slick-slide').eq(slideIndex);
} else {
targetSlide = _.$slideTrack.children('.slick-slide').eq(slideIndex + _.options.slidesToShow + 1);
}
targetLeft = targetSlide[0] ? targetSlide[0].offsetLeft * -1 : 0;

if (_.options.rtl === true) {
if (targetSlide[0]) {
targetLeft = (_.$slideTrack.width() - targetSlide[0].offsetLeft - targetSlide.width()) * -1;
} else {
targetLeft = 0;
}
} else {
targetLeft = targetSlide[0] ? targetSlide[0].offsetLeft * -1 : 0;
}

targetLeft += (_.$list.width() - targetSlide.outerWidth()) / 2;
}
}
Expand Down

0 comments on commit 63c5454

Please sign in to comment.