Skip to content

Commit 2be565e

Browse files
authored
fix (carousel): clamp the current slide to the slide range (#3701)
1 parent 3186d15 commit 2be565e

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/block/carousel/frontend-carousel.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -677,8 +677,9 @@ class _StackableCarousel {
677677
return result
678678
}, { slide: 1, offsetDiff: 1000 } )
679679

680-
if ( this.infiniteScroll && slide > this.slideEls.length ) {
681-
slide -= this.slideEls.length
680+
if ( this.infiniteScroll ) {
681+
// Clamp clone indexes back to the original slide range.
682+
slide = ( ( slide - 1 ) % this.slideEls.length ) + 1
682683
}
683684

684685
this.currentSlide = slide

0 commit comments

Comments
 (0)