Skip to content

Commit

Permalink
Merge pull request #350 from snappmarket/fix/kito/slider
Browse files Browse the repository at this point in the history
Fix slider showing next and prev near end and start
  • Loading branch information
sayjeyhi authored Nov 30, 2020
2 parents 7609df1 + 3645f33 commit 407a6a1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 19 deletions.
2 changes: 1 addition & 1 deletion packages/ui/packages/Carousel/src/core/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ class SliderCore {
// ----------- start init variables -----
this.setSlider(slider);

const sliderClienWidth = this.getSlider().clientWidth;
const sliderClienWidth = this.getSlider().getBoundingClientRect().width;
this.setSliderMainWidth(sliderClienWidth);

const sliderSlidesSelector = childFider({
Expand Down
34 changes: 16 additions & 18 deletions packages/ui/packages/Carousel/src/core/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,30 +351,28 @@ export const transitionendWatcher = params => {
const finalConst = Math.abs(Math.trunc(calcFinalItemPosition(finalPos)));
const firstConst = Math.abs(Math.trunc(calcFirstItemPosition(finalPos)));
const translate3dConst = Math.abs(Math.trunc(getTranslate3d(sliderItems)));
if (finalConst === translate3dConst) {
prevBlock(slider);
nextNone(slider);
let showNext = true;
let showPrev = true;
if (finalConst <= translate3dConst + 50) {
showNext = false;
}
if (!autoWidth) {
if (index >= 0 && finalConst > translate3dConst) {
nextBlock(slider);
}
if (index === 0) {
prevNone(slider);
nextBlock(slider);
}
if (index !== 0) {
prevBlock(slider);
showPrev = false;
}
}
if (firstConst === translate3dConst) {
prevNone(slider);
if (firstConst >= translate3dConst - 50) {
showPrev = false;
}
if (autoWidth) {
if (firstConst < translate3dConst && finalConst !== translate3dConst) {
nextBlock(slider);
prevBlock(slider);
}
if (showNext) {
nextBlock(slider);
} else {
nextNone(slider);
}
if (showPrev) {
prevBlock(slider);
} else {
prevNone(slider);
}
}

Expand Down

0 comments on commit 407a6a1

Please sign in to comment.