4
4
:class ="vueperslidesClasses"
5
5
aria-label ="Slideshow"
6
6
:style ="vueperslidesStyles" )
7
- p -{{slides.focus}}-{{slides.current}}-
8
7
.vueperslide__content-wrapper.vueperslide__content-wrapper--outside-top (
9
8
v-if ="slidesCount && conf.slideContentOutside === 'top'"
10
9
:class ="conf.slideContentOutsideClass" )
31
30
:link ="lastSlide.link"
32
31
:style ="conf.refreshClonesOnDrag ? getLastSlideStyle() : lastSlide.style"
33
32
aria-hidden ="true" )
34
- template( v-if ="lastSlide.titleSlot" v- slot: slide-title)
33
+ template( v-if ="lastSlide.titleSlot" slot = " slide-title" )
35
34
vnodes( :vnodes ="lastSlide.titleSlot" )
36
- template( v-if ="lastSlide.contentSlot" v- slot: slide-content)
35
+ template( v-if ="lastSlide.contentSlot" slot = " slide-content" )
37
36
vnodes( :vnodes ="lastSlide.contentSlot" )
38
37
slot( :currentSlide ="slides.current" )
39
38
vueper-slide.vueperslide--clone (
45
44
:link ="firstSlide.link"
46
45
:style ="conf.refreshClonesOnDrag ? getFirstSlideStyle() : firstSlide.style"
47
46
aria-hidden ="true" )
48
- template( v-if ="firstSlide.titleSlot" v- slot: slide-title)
47
+ template( v-if ="firstSlide.titleSlot" slot = " slide-title" )
49
48
vnodes( :vnodes ="firstSlide.titleSlot" )
50
- template( v-if ="firstSlide.contentSlot" v- slot: slide-content)
49
+ template( v-if ="firstSlide.contentSlot" slot = " slide-content" )
51
50
vnodes( :vnodes ="firstSlide.contentSlot" )
52
51
53
- .vueperslides__paused ( v-if ="conf.pauseOnHover && $slots.pausedIcon " )
54
- slot( name ="pausedIcon " )
52
+ .vueperslides__paused ( v-if ="conf.pauseOnHover && $slots['pause-icon'] " )
53
+ slot( name ="pause-icon " )
55
54
.vueperslides__arrows (
56
55
:class ="{ 'vueperslides__arrows--outside': conf.arrowsOutside }"
57
56
v-if ="conf.arrows && slidesCount > 1 && !disable" )
61
60
aria-label ="Previous"
62
61
@keyup.left ="previous()"
63
62
@keyup.right ="next()" )
64
- slot( name ="arrowLeft " )
63
+ slot( name ="arrow-left " )
65
64
svg( viewBox ="0 0 24 24" )
66
65
path( d ="M16.2,21c0.3,0,0.5-0.1,0.7-0.3c0.4-0.4,0.4-1,0-1.4L9.6,12L17,4.7c0.4-0.4,0.4-1,0-1.4c-0.4-0.4-1-0.4-1.4,0L6.8,12l8.8,8.7C15.7,20.9,16,21,16.2,21z" )
67
66
button.vueperslides__arrow.vueperslides__arrow--next (
70
69
aria-label ="Next"
71
70
@keyup.left ="previous()"
72
71
@keyup.right ="next()" )
73
- slot( name ="arrowRight " )
72
+ slot( name ="arrow-right " )
74
73
svg( viewBox ="0 0 24 24" )
75
74
path( d ="M7.8,21c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l7.4-7.3L7,4.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l8.8,8.7l-8.8,8.7C8.3,20.9,8,21,7.8,21z" )
76
75
.vueperslides__bullets (
@@ -199,7 +198,8 @@ export default {
199
198
this .setBreakpointConfig (this .getCurrentBreakpoint ())
200
199
}
201
200
202
- this .goToSlide (this .conf .initSlide - 1 , { animation: false })
201
+ const options = { animation: false , autoPlaying: this .conf .autoplay }
202
+ this .goToSlide (this .conf .initSlide - 1 , options)
203
203
this .bindEvents ()
204
204
205
205
// Give it a tick to be mounted in the DOM.
@@ -284,15 +284,15 @@ export default {
284
284
const bp = (this .breakpoints && this .breakpoints [breakpoint]) || {}
285
285
const slideMultipleChanged = bp .slideMultiple && bp .slideMultiple !== this .conf .slideMultiple
286
286
const visibleSlidesChanged = bp .visibleSlides && bp .visibleSlides !== this .conf .visibleSlides
287
- console .log (' changing breakpoint' , bp, slideMultipleChanged, this .slides .focus )
288
287
289
288
// this.conf gets updated by itself when this.breakpointsData.current changes.
290
289
this .breakpointsData .current = breakpoint
290
+ this .slides .current = this .getFirstVisibleSlide (this .slides .focus )
291
291
292
292
if (slideMultipleChanged || visibleSlidesChanged) {
293
- this .slides .current = this .slides .focus
294
- this .goToSlide (this .slides .current )
293
+ this .goToSlide (this .slides .current , { breakpointChange: true })
295
294
}
295
+ else this .updateCurrentTranslation ()
296
296
},
297
297
298
298
bindEvents () {
@@ -473,9 +473,7 @@ export default {
473
473
474
474
// Dragging did not pass conditions to change slide, snap back to current slide.
475
475
cancelSlideChange () {
476
- if (! this .conf .fade ) {
477
- this .updateCurrentTranslation ()
478
- }
476
+ if (! this .conf .fade ) this .updateCurrentTranslation ()
479
477
},
480
478
481
479
getCurrentMouseX (e ) {
@@ -488,7 +486,7 @@ export default {
488
486
getBasicTranslation () {
489
487
let translation = this .slides .current / this .conf .visibleSlides
490
488
491
- if (this .conf .infinite ) translation += 1 / this .conf .visibleSlides // A clone is prepended to the slides track.
489
+ if (this .conf .infinite ) translation += 1 / this .conf .visibleSlides // A clone is prepended to the slides track.
492
490
493
491
return translation
494
492
},
@@ -503,7 +501,6 @@ export default {
503
501
* the value of the current drag.
504
502
*/
505
503
updateCurrentTranslation (nextSlideIsClone = null , currentMouseX = null ) {
506
- // let dragging = currentMouseX
507
504
let translation = this .getBasicTranslation ()
508
505
509
506
if (this .conf .infinite && nextSlideIsClone !== null ) {
@@ -610,19 +607,6 @@ export default {
610
607
611
608
newIndex += index < 0 ? missingItems : 0
612
609
newIndex = this .getFirstVisibleSlide (newIndex)
613
-
614
- // When using slideMultiple & breakpoints, on breakpoint change if slideMultiple has
615
- // changed, the slideshow will snap to the current slide. but current slide is always the
616
- // first of visible slides so by playing around breakpoints we lose the original slide on
617
- // focus. this.slides.focus is here to never lose it.
618
- // E.g.
619
- // slideMultiple = 3, currentSlide = 9 (10th slide), means this is the only visible slide,
620
- // now change breakpoint and slideMultiple = 2, so go to slide index 8 (shows slide 9 & 10)
621
- // now current slide is 8. If we change back to previous breakpoint (slideMultiple = 3),
622
- // current slide index becomes 6! and so on.
623
- if (this .getFirstVisibleSlide (this .slides .focus ) !== newIndex) {
624
- this .slides .focus = newIndex
625
- }
626
610
}
627
611
628
612
// Disable sliding if already on edge with disableArrowsOnEdges.
@@ -634,12 +618,12 @@ export default {
634
618
},
635
619
636
620
// animation = slide transition will be animated.
637
- // autoPlaying = go to the next slide by autoplay - no user intervention.
621
+ // autoPlaying = going to the next slide from autoplay - no user intervention.
638
622
// jumping = after reaching a clone, the callback jumps back to original slide with no animation.
639
- goToSlide (index , { animation = true , autoPlaying = false , jumping = false } = {}) {
623
+ goToSlide (index , { animation = true , autoPlaying = false , jumping = false , breakpointChange = false } = {}) {
640
624
if (! this .slidesCount || this .disable ) return
641
625
642
- if (this .conf .autoplay ) this .pauseAutoplay ()
626
+ if (this .conf .autoplay && autoPlaying ) this .pauseAutoplay ()
643
627
644
628
this .transition .animated = animation
645
629
setTimeout (() => (this .transition .animated = false ), this .transitionSpeed )
@@ -681,21 +665,27 @@ export default {
681
665
}
682
666
683
667
this .slides .current = nextSlide
684
- this .slides .focus = nextSlide
668
+ // Don't change the focus slide if calling goToSlide from breakpoint change.
669
+ // The focused slide is to keep track which slide to snap to when switching
670
+ // between 2 breakpoints that have multiple visible slides.
671
+ if (! breakpointChange) this .slides .focus = nextSlide
685
672
686
673
// Only apply sliding transition when the slideshow animation type is `slide`.
687
674
if (! this .conf .fade ) this .updateCurrentTranslation (nextSlideIsClone)
688
675
689
676
this .slides .activeId = this .slides .list [this .slides .current ].id
690
677
691
- if (this .conf .autoplay && ! (this .conf .pauseOnHover && this .mouseOver )) this .resumeAutoplay ()
678
+ if (this .conf .autoplay && autoPlaying && ! (this .conf .pauseOnHover && this .mouseOver )) {
679
+ this .resumeAutoplay ()
680
+ }
692
681
693
682
if (this .slidesCount ) {
694
- if ( this . $slots . default [ this . slides . current ]) {
695
- // First use of goToSlide is while init, so should not propagate an event.
696
- if ( this . isReady && ! jumping) this .emit (' slide' )
683
+ // First use of goToSlide is while init, so should not propagate an event.
684
+ if ( this . $slots . default [ this . slides . current ] && this . isReady && ! jumping) {
685
+ this .emit (' slide' )
697
686
}
698
687
688
+ // Focus the current bullet for accessibility.
699
689
if (this .isReady && this .conf .bullets && ! autoPlaying && ! jumping && this .$refs .bullet && this .$refs .bullet [this .slides .current ]) {
700
690
this .$refs .bullet [this .slides .current ].focus ()
701
691
}
@@ -754,6 +744,8 @@ export default {
754
744
755
745
beforeDestroy () {
756
746
this .removeEventListeners ()
747
+ document .removeEventListener (' scroll' , this .onScroll )
748
+ window .removeEventListener (' resize' , this .onResize )
757
749
},
758
750
759
751
computed: {
@@ -766,7 +758,7 @@ export default {
766
758
... ((this .$props .breakpoints && this .$props .breakpoints [this .breakpointsData .current ]) || {})
767
759
}
768
760
769
- // Overrides: once config from breakpoints is imported, we can use the conf object
761
+ // Overrides: once config from breakpoints is imported, we can use the ` conf` object
770
762
// and be sure all the options are up to date.
771
763
// ------------------------------- //
772
764
conf .slideMultiple = conf .slideMultiple ? conf .visibleSlides : 1
@@ -775,8 +767,9 @@ export default {
775
767
conf .infinite = false
776
768
}
777
769
778
- conf .arrowsOutside = conf .arrowsOutside || (conf .visibleSlides > 1 && conf .arrowsOutside === null )
779
- conf .bulletsOutside = conf .bulletsOutside || (conf .visibleSlides > 1 && conf .bulletsOutside === null )
770
+ // Place arrows & bullets outside by default if visibleSlides > 1.
771
+ if (conf .visibleSlides > 1 && conf .arrowsOutside === null ) conf .arrowsOutside = true
772
+ if (conf .visibleSlides > 1 && conf .bulletsOutside === null ) conf .bulletsOutside = true
780
773
781
774
if (this .touchEnabled !== conf .touchable ) this .toggleTouchableOption (conf .touchable )
782
775
// ------------------------------- //
@@ -799,10 +792,12 @@ export default {
799
792
return this .slidesCount ? this .slides .list [this .slidesCount - 1 ] : {}
800
793
},
801
794
currentSlide () {
802
- console .log (this .slidesCount , this .slides .current , this .slides .list [this .slides .current ])
803
-
804
795
// Means it didn't have time to update this.slidesCount on hot-reload.
805
- if (this .slides .current > this .slidesCount - 1 ) this .goToSlide (0 , { animation: false })
796
+ if (this .slides .current > this .slidesCount - 1 ) {
797
+ this .goToSlide (0 , { animation: false })
798
+ console .log (' Does not seem to ever happen in the end.' )
799
+ debugger
800
+ }
806
801
807
802
return (this .slidesCount && this .slides .list [this .slides .current ]) || {}
808
803
},
0 commit comments