Skip to content

Commit

Permalink
Bugfix: Check for existence of swiper instance before picking the sli…
Browse files Browse the repository at this point in the history
…de index. (#11703)
  • Loading branch information
jeffersonrabb authored and sirreal committed Mar 27, 2019
1 parent a0204eb commit 21f9072
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions extensions/blocks/slideshow/slideshow.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,14 @@ class Slideshow extends Component {
delay !== prevProps.delay ||
images !== prevProps.images
) {
const realIndex =
images.length === prevProps.images.length
? this.swiperInstance.realIndex
: prevProps.images.length;
let realIndex;
if ( ! this.swiperIndex ) {
realIndex = 0;
} else if ( images.length === prevProps.images.length ) {
realIndex = this.swiperInstance.realIndex;
} else {
realIndex = prevProps.images.length;
}
this.swiperInstance && this.swiperInstance.destroy( true, true );
this.buildSwiper( realIndex )
.then( swiper => {
Expand Down

0 comments on commit 21f9072

Please sign in to comment.