@@ -180,6 +180,7 @@ export default {
180180 autoplayTimer: null ,
181181 arrowPrevDisabled: false ,
182182 arrowNextDisabled: false ,
183+ nextSlideIsClone: false ,
183184 breakpointsData: { list: [], current: null },
184185 parallaxData: { translation: 0 , slideshowOffsetTop: null , isVisible: false }
185186 }),
@@ -377,7 +378,7 @@ export default {
377378 this .touch .dragStartX = this .getCurrentMouseX (e)
378379
379380 if (! this .conf .draggingDistance ) {
380- this .updateCurrentTranslation (null , this .touch .dragStartX )
381+ this .updateCurrentTranslation (this .touch .dragStartX )
381382 }
382383 },
383384
@@ -397,7 +398,7 @@ export default {
397398 this .updateCurrentTranslation ()
398399 this .transition .currentTranslation += 100 * dragAmountPercentage
399400 }
400- else this .updateCurrentTranslation (null , this .touch .dragNowX )
401+ else this .updateCurrentTranslation (this .touch .dragNowX )
401402 }
402403 },
403404
@@ -475,20 +476,23 @@ export default {
475476 * Update the current translation of the slides track - for sliding slideshows.
476477 * The resulting translation will be set in percentage and negative value.
477478 *
478- * @param {null | 0 | 1} nextSlideIsClone : wheter the slide to access is a clone, and
479- * if so, if it's the first or last one.
480479 * @param {null | float} currentDragX : whether the slide track is being dragged and if so
481480 * the value of the current drag.
482481 */
483- updateCurrentTranslation (nextSlideIsClone = null , currentMouseX = null ) {
482+ updateCurrentTranslation (currentMouseX = null ) {
484483 let translation = this .getBasicTranslation ()
485- const { fade , infinite , visibleSlides , slideMultiple , gap , gapPx , [ '3d '] : threeD } = this .conf
484+ const { infinite , visibleSlides , slideMultiple , gap , '3d ': threeD } = this .conf
486485
487- if (infinite && nextSlideIsClone !== null ) {
488- translation = (nextSlideIsClone ? this .slidesCount + 1 : 0 ) / visibleSlides
486+ if (infinite && this .nextSlideIsClone !== false ) {
487+ translation = (this .nextSlideIsClone ? this .slidesCount + 1 : 0 ) / visibleSlides
488+ }
489+
490+ if (gap && this .nextSlideIsClone !== 0 ) {
491+ translation += (this .gapsCount / (visibleSlides / slideMultiple)) * gap / 100
489492 }
490493
491494 // If dragging.
495+ if (infinite && this .nextSlideIsClone !== false ) {}
492496 else if (this .touch .dragStartX && currentMouseX) {
493497 let dragPercentage = 0
494498 const dragPercentageStart = (this .touch .dragStartX - this .container .offsetLeft ) / this .container .clientWidth
@@ -503,10 +507,6 @@ export default {
503507
504508 dragPercentage = (dragPercentageStart < 0.5 ? 0 : 1 ) - dragPercentageNow
505509 translation += dragPercentage
506-
507- if (! threeD && gap && visibleSlides > 1 && slideMultiple > 1 ) {
508- translation -= (! gapPx && this .slides .current ? gap * ~~ (this .slides .current / visibleSlides) : 0 )
509- }
510510 }
511511
512512 // Special behavior if multiple visible slides and sliding 1 by 1:
@@ -517,27 +517,15 @@ export default {
517517 // The preferred position is the most center slide amongst the visible ones,
518518 // if `visibleSlides` is an odd number the preferred position can never be at the center,
519519 // so take the closest on the left side.
520- const preferredPosition = Math .ceil (visibleSlides / 2 )
521- const remainingSlides = this .slidesCount - (this .slides .current + 1 )
522- const positionsAfterPreferred = visibleSlides - preferredPosition
523- const preferredPositionIsPassed = remainingSlides < positionsAfterPreferred
520+ const preferredPositionIsPassed = this .slidePosAfterPreferred > 0
524521
525- // Number of first slides Without translation, until we reach the preferred position.
526- const slidesWOTranslation = preferredPosition - 1
527- let subtractFromTranslation = Math .min (slidesWOTranslation, this .slides .current )
522+ // Subtract the first slides without translation, until we reach the preferred position.
523+ let subtractFromTranslation = Math .min (this .preferredPosition , this .slides .current )
528524
529525 // From next position after the preferred position.
530- if (preferredPositionIsPassed) {
531- subtractFromTranslation += positionsAfterPreferred - remainingSlides
532- }
526+ if (preferredPositionIsPassed) subtractFromTranslation += this .slidePosAfterPreferred
533527
534528 translation -= subtractFromTranslation / visibleSlides
535-
536- if (gap && ! gapPx) {
537- if (slidesWOTranslation < this .slides .current ) {
538- translation += (gap / 100 ) * ((this .slides .current - slidesWOTranslation - (preferredPositionIsPassed ? positionsAfterPreferred - remainingSlides : 0 )) / visibleSlides)
539- }
540- }
541529 }
542530 }
543531
@@ -585,7 +573,7 @@ export default {
585573 },
586574
587575 getSlideInRange (index , autoPlaying ) {
588- let clone = null
576+ let clone = false
589577
590578 // If infinite enabled, going out of range takes the first slide from the other end.
591579 if (this .conf .infinite && index === - 1 ) clone = 0
@@ -626,6 +614,7 @@ export default {
626614
627615 // Get the next slide index and whether it's a clone.
628616 const { nextSlide , clone: nextSlideIsClone } = this .getSlideInRange (index, autoPlaying)
617+ this .nextSlideIsClone = nextSlideIsClone
629618
630619 // If the slide is not found don't go further.
631620 if (! this .slides .list [nextSlide]) return
@@ -644,7 +633,7 @@ export default {
644633 // shows up, when the animation ends the real change to the first slide is done
645634 // immediately with no animation.
646635 // Same principle when going beyond first slide.
647- if (nextSlideIsClone !== null ) { // Gives clone id (0 or 1 or null) .
636+ if (nextSlideIsClone !== false ) { // Gives clone id (0 or 1) or false .
648637 setTimeout (() => {
649638 // inside the callback, also check if it is not too late to apply next slide
650639 // (user may have slid fast multiple times) if so cancel callback.
@@ -668,7 +657,7 @@ export default {
668657 if (! breakpointChange) this .slides .focus = nextSlide
669658
670659 // Only apply sliding transition when the slideshow animation type is `slide`.
671- if (! this .conf .fade ) this .updateCurrentTranslation (nextSlideIsClone )
660+ if (! this .conf .fade ) this .updateCurrentTranslation ()
672661
673662 this .slides .activeId = this .slides .list [this .slides .current ].id
674663
@@ -761,8 +750,8 @@ export default {
761750 // ------------------------------- //
762751 conf .slideMultiple = conf .slideMultiple ? conf .visibleSlides : 1
763752
764- conf .gap = this .gap && parseInt (this .gap ) || 0
765- conf .gapPx = this .gap && this .gap .toString ().includes (' px' )
753+ conf .gap = ( this .gap && parseInt (this .gap ) ) || 0
754+ // conf.gapPx = this.gap && this.gap.toString().includes('px')
766755
767756 if (conf .fade || conf .disableArrowsOnEdges || conf .visibleSlides > 1 || conf[' 3d' ]) {
768757 conf .infinite = false
@@ -780,6 +769,35 @@ export default {
780769 slidesCount () {
781770 return this .slides .list .length
782771 },
772+ gapsCount () {
773+ const { fade , '3d ': threeD , infinite , slideMultiple , gap } = this .conf
774+ if (! gap || fade || threeD) return 0
775+
776+ if (this .multipleSlides1by1 && this .slides .current < this .preferredPosition ) return 0
777+ if (! this .slides .current && this .nextSlideIsClone ) return this .slidesCount + 1
778+
779+ let gapsCount = (this .slides .current / slideMultiple + (infinite ? 1 : 0 )) - this .preferredPosition
780+ if (this .multipleSlides1by1 && this .slidePosAfterPreferred > 0 ) {
781+ gapsCount -= this .slidePosAfterPreferred
782+ }
783+
784+ return gapsCount
785+ },
786+ slidesAfterCurrent () {
787+ return this .slidesCount - (this .slides .current + 1 )
788+ },
789+ // When visibleSlides > 1, the preferred position is the most center slide amongst the visible ones.
790+ // If visibleSlides is an odd number the preferred position can never be at the center,
791+ // so take the closest on the left side.
792+ preferredPosition () {
793+ return this .multipleSlides1by1 ? Math .ceil (this .conf .visibleSlides / 2 ) - 1 : 0
794+ },
795+ slidePosAfterPreferred () {
796+ return this .conf .visibleSlides - this .preferredPosition - this .slidesAfterCurrent - 1
797+ },
798+ multipleSlides1by1 () {
799+ return this .conf .visibleSlides > 1 && this .conf .slideMultiple === 1
800+ },
783801 touchEnabled: {
784802 get () {
785803 return this .slidesCount > 1 && this .touchable
@@ -812,6 +830,7 @@ export default {
812830 ' vueperslides--touchable' : this .touchEnabled && ! this .disable ,
813831 ' vueperslides--fixed-height' : this .conf .fixedHeight ,
814832 ' vueperslides--3d' : this .conf [' 3d' ],
833+ ' vueperslides--slide-multiple' : this .conf .slideMultiple > 1 ,
815834 ' vueperslides--bullets-outside' : this .conf .bulletsOutside ,
816835 ' vueperslides--animated' : this .transition .animated // While transitioning.
817836 }
@@ -834,7 +853,7 @@ export default {
834853 },
835854 trackInnerStyles () {
836855 let styles = {}
837- const { fade , [ '3d '] : threeD } = this .conf
856+ const { fade , '3d ': threeD } = this .conf
838857
839858 // Prevent animation if VueperSlides is not yet ready (so that the first clone is not shown before ready).
840859 styles .transitionDuration = (this .isReady ? this .transition .speed : 0 ) + ' ms'
0 commit comments