From a4e351ffdbe2f03e57fa22dddfa635ffc2c039ba Mon Sep 17 00:00:00 2001 From: Vladimir Kharlampidi Date: Mon, 23 Aug 2021 10:28:33 +0300 Subject: [PATCH] fix(zoom): zoom elements only in `swiper-zoom-container` fixes #4847 --- src/modules/zoom/zoom.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/modules/zoom/zoom.js b/src/modules/zoom/zoom.js index ff9c99216..948c5e9af 100644 --- a/src/modules/zoom/zoom.js +++ b/src/modules/zoom/zoom.js @@ -97,7 +97,10 @@ export default function Zoom({ swiper, extendParams, on, emit }) { if (!gesture.$slideEl || !gesture.$slideEl.length) { gesture.$slideEl = $(e.target).closest(`.${swiper.params.slideClass}`); if (gesture.$slideEl.length === 0) gesture.$slideEl = swiper.slides.eq(swiper.activeIndex); - gesture.$imageEl = gesture.$slideEl.find('img, svg, canvas, picture, .swiper-zoom-target'); + gesture.$imageEl = gesture.$slideEl + .find(`.${params.containerClass}`) + .eq(0) + .find('img, svg, canvas, picture, .swiper-zoom-target'); gesture.$imageWrapEl = gesture.$imageEl.parent(`.${params.containerClass}`); gesture.maxRatio = gesture.$imageWrapEl.attr('data-swiper-zoom') || params.maxRatio; if (gesture.$imageWrapEl.length === 0) { @@ -341,7 +344,10 @@ export default function Zoom({ swiper, extendParams, on, emit }) { } } - gesture.$imageEl = gesture.$slideEl.find('img, svg, canvas, picture, .swiper-zoom-target'); + gesture.$imageEl = gesture.$slideEl + .find(`.${params.containerClass}`) + .eq(0) + .find('img, svg, canvas, picture, .swiper-zoom-target'); gesture.$imageWrapEl = gesture.$imageEl.parent(`.${params.containerClass}`); } if ( @@ -440,7 +446,10 @@ export default function Zoom({ swiper, extendParams, on, emit }) { } else { gesture.$slideEl = swiper.slides.eq(swiper.activeIndex); } - gesture.$imageEl = gesture.$slideEl.find('img, svg, canvas, picture, .swiper-zoom-target'); + gesture.$imageEl = gesture.$slideEl + .find(`.${params.containerClass}`) + .eq(0) + .find('img, svg, canvas, picture, .swiper-zoom-target'); gesture.$imageWrapEl = gesture.$imageEl.parent(`.${params.containerClass}`); } if (