From 8ff2691ae8cfa63d97040c1ff0db3cc648f8e941 Mon Sep 17 00:00:00 2001 From: Vladimir Kharlampidi Date: Wed, 2 Feb 2022 12:57:46 +0300 Subject: [PATCH] fix(core): fix slider freeze with enabled observer fixes #5414 --- src/core/update/updateSlides.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/core/update/updateSlides.js b/src/core/update/updateSlides.js index 807ed996b..940d02557 100644 --- a/src/core/update/updateSlides.js +++ b/src/core/update/updateSlides.js @@ -291,10 +291,12 @@ export default function updateSlides() { } if (!isVirtual && !params.cssMode && (params.effect === 'slide' || params.effect === 'fade')) { + const backFaceHiddenClass = `${params.containerModifierClass}backface-hidden`; + const hasClassBackfaceClassAdded = swiper.$el.hasClass(backFaceHiddenClass); if (slidesLength <= params.maxBackfaceHiddenSlides) { - swiper.$el.addClass(`${params.containerModifierClass}backface-hidden`); - } else { - swiper.$el.removeClass(`${params.containerModifierClass}backface-hidden`); + if (!hasClassBackfaceClassAdded) swiper.$el.addClass(backFaceHiddenClass); + } else if (hasClassBackfaceClassAdded) { + swiper.$el.removeClass(backFaceHiddenClass); } } }