From 2c39fcda252c90d48846a99d1f14f59cd0f9a716 Mon Sep 17 00:00:00 2001 From: Fedor Katurov Date: Mon, 20 Jun 2022 10:42:08 +0700 Subject: [PATCH] fixed swiper default width to 100% --- src/components/node/NodeImageSwiperBlock/index.tsx | 9 ++++----- .../node/NodeImageSwiperBlock/styles.module.scss | 4 ++++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/components/node/NodeImageSwiperBlock/index.tsx b/src/components/node/NodeImageSwiperBlock/index.tsx index 7e73f61f..e0acd2d3 100644 --- a/src/components/node/NodeImageSwiperBlock/index.tsx +++ b/src/components/node/NodeImageSwiperBlock/index.tsx @@ -53,11 +53,10 @@ const NodeImageSwiperBlock: FC = observer(({ node }) => { [images, controlledSwiper, showPhotoSwiper] ); - // TODO: remove it if swiper 8 fixed sliding to first slide on init - // useEffect(() => { - // controlledSwiper?.slideTo(0, 0); - // return () => controlledSwiper?.slideTo(0, 0); - // }, [images, node?.id]); + useEffect(() => { + controlledSwiper?.slideTo(0, 0); + return () => controlledSwiper?.slideTo(0, 0); + }, [images, node?.id]); useEffect(() => { if (isModalActive) { diff --git a/src/components/node/NodeImageSwiperBlock/styles.module.scss b/src/components/node/NodeImageSwiperBlock/styles.module.scss index dc800a8f..01fd3847 100644 --- a/src/components/node/NodeImageSwiperBlock/styles.module.scss +++ b/src/components/node/NodeImageSwiperBlock/styles.module.scss @@ -7,6 +7,10 @@ justify-content: center; width: 100%; + :global(.swiper) { + width: 100%; + } + :global(.swiper-pagination) { left: 50%; bottom: $gap * 2;