Skip to content

Commit c2a60ee

Browse files
committed
fix console errors when not using infinite scrolling
1 parent 578783c commit c2a60ee

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/block/carousel/frontend-carousel.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -491,9 +491,9 @@ class _StackableCarousel {
491491
onWheel = e => {
492492
const sliderElScrollLeft = this.sliderEl.scrollLeft
493493
const lastSlideOffset = this.slideEls[ this.slideEls.length - 1 ].offsetLeft
494-
const firstCloneOffset = this.clones[ 0 ].offsetLeft
495494
const slidesOffset = this.slideEls.map( slide => slide.offsetLeft )
496-
const clonesOffset = this.clones.map( slide => slide.offsetLeft )
495+
const firstCloneOffset = this.infiniteScroll && this.clones.length ? this.clones[ 0 ].offsetLeft : 0
496+
const clonesOffset = this.infiniteScroll && this.clones.length ? this.clones.map( slide => slide.offsetLeft ) : []
497497
if ( this.type === 'fade' ) {
498498
if ( this.wheelTimeout ) {
499499
return
@@ -549,7 +549,7 @@ class _StackableCarousel {
549549
let dx = e.clientX - this.initialClientX
550550
const sliderElScrollLeft = this.sliderEl.scrollLeft
551551
const lastSlideOffsetLeft = this.slideEls[ this.slideEls.length - 1 ].offsetLeft
552-
const firstCloneOffsetLeft = this.clones[ 0 ].offsetLeft
552+
const firstCloneOffsetLeft = this.infiniteScroll && this.clones.length ? this.clones[ 0 ].offsetLeft : 0
553553

554554
if ( this.type === 'slide' ) {
555555
if ( this.infiniteScroll && sliderElScrollLeft === 0 && dx > 0 ) {

0 commit comments

Comments
 (0)