Skip to content

Commit 1aa427a

Browse files
committed
Fix maths when visibleSlides > 1 & slideMultiple = 1.
1 parent 16997bf commit 1aa427a

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

src/components/vueperslides/vueperslides.vue

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ export default {
504504
dragPercentage = (dragPercentageStart < 0.5 ? 0 : 1) - dragPercentageNow
505505
translation += dragPercentage
506506
507-
if (!threeD && gap) {
507+
if (!threeD && gap && visibleSlides > 1 && slideMultiple > 1) {
508508
translation -= (!gapPx && this.slides.current ? gap * ~~(this.slides.current / visibleSlides) : 0)
509509
}
510510
}
@@ -534,12 +534,8 @@ export default {
534534
translation -= subtractFromTranslation / visibleSlides
535535
536536
if (gap && !gapPx) {
537-
if (slidesWOTranslation < this.slides.current && !preferredPositionIsPassed) {
538-
translation += (gap / 100) * ((this.slides.current - slidesWOTranslation) / visibleSlides)
539-
}
540-
else if (preferredPositionIsPassed) {
541-
subtractFromTranslation += positionsAfterPreferred - remainingSlides
542-
translation += (gap / 100)
537+
if (slidesWOTranslation < this.slides.current) {
538+
translation += (gap / 100) * ((this.slides.current - slidesWOTranslation - (preferredPositionIsPassed ? positionsAfterPreferred - remainingSlides : 0)) / visibleSlides)
543539
}
544540
}
545541
}
@@ -695,8 +691,6 @@ export default {
695691
696692
addSlide (newSlide) {
697693
this.slides.list.push(newSlide)
698-
699-
// If adding the first slide.
700694
return this.slidesCount
701695
},
702696
@@ -719,9 +713,7 @@ export default {
719713
}
720714
721715
// This can only happen if removing and adding slides very fast - like hot reloading.
722-
if (this.slides.current >= this.slidesCount) {
723-
this.goToSlide(0, { autoPlaying: true })
724-
}
716+
if (this.slides.current >= this.slidesCount) this.goToSlide(0, { autoPlaying: true })
725717
},
726718
727719
toggleTouchableOption (isTouchable) {

0 commit comments

Comments
 (0)