Skip to content

Commit

Permalink
Slider autoplay bounce prop (#267)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jade-GG authored May 25, 2023
1 parent 588bec8 commit 015af75
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions resources/js/components/Elements/Slider.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
type: Boolean,
default: false,
},
bounce: {
type: Boolean,
default: false,
},
stopOnHover: {
type: Boolean,
default: true,
Expand All @@ -40,6 +44,7 @@
showRight: false,
mounted: false,
hover: false,
direction: 1,
pause: ()=>{},
resume: ()=>{}
}
Expand Down Expand Up @@ -76,9 +81,17 @@
},
autoScroll() {
let next = this.currentSlide + 1
if (next >= this.slidesTotal) {
next = 0
if(this.slidesTotal == 1) {
return
}
let next = this.currentSlide + this.direction
if (next >= this.slidesTotal || next < 0) {
if (this.bounce) {
this.direction = -this.direction
next = this.currentSlide + this.direction
} else {
next = 0
}
}
this.navigate(next)
},
Expand Down

0 comments on commit 015af75

Please sign in to comment.