Skip to content

Commit

Permalink
Don't process transitions or updates on Thumbs module if swiper is de…
Browse files Browse the repository at this point in the history
…stroyed (#5582)
  • Loading branch information
JoniVanderheijden authored Apr 1, 2022
1 parent 4cc7ca4 commit 667d89c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/modules/thumbs/thumbs.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ export default function Thumb({ swiper, extendParams, on }) {

function onThumbClick() {
const thumbsSwiper = swiper.thumbs.swiper;
if (!thumbsSwiper) return;
if (!thumbsSwiper || thumbsSwiper.destroyed) return;

const clickedIndex = thumbsSwiper.clickedIndex;
const clickedSlide = thumbsSwiper.clickedSlide;
if (clickedSlide && $(clickedSlide).hasClass(swiper.params.thumbs.slideThumbActiveClass))
Expand Down Expand Up @@ -90,7 +91,7 @@ export default function Thumb({ swiper, extendParams, on }) {

function update(initial) {
const thumbsSwiper = swiper.thumbs.swiper;
if (!thumbsSwiper) return;
if (!thumbsSwiper || thumbsSwiper.destroyed) return;

const slidesPerView =
thumbsSwiper.params.slidesPerView === 'auto'
Expand Down Expand Up @@ -204,18 +205,17 @@ export default function Thumb({ swiper, extendParams, on }) {
update(true);
});
on('slideChange update resize observerUpdate', () => {
if (!swiper.thumbs.swiper) return;
update();
});
on('setTransition', (_s, duration) => {
const thumbsSwiper = swiper.thumbs.swiper;
if (!thumbsSwiper) return;
if (!thumbsSwiper || thumbsSwiper.destroyed) return;
thumbsSwiper.setTransition(duration);
});
on('beforeDestroy', () => {
const thumbsSwiper = swiper.thumbs.swiper;
if (!thumbsSwiper) return;
if (swiperCreated && thumbsSwiper) {
if (!thumbsSwiper || thumbsSwiper.destroyed) return;
if (swiperCreated) {
thumbsSwiper.destroy();
}
});
Expand Down

0 comments on commit 667d89c

Please sign in to comment.