1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-24 20:36:40 +07:00

(nextjs) fixed image slider initial position

This commit is contained in:
Fedor Katurov 2022-01-19 14:22:47 +07:00
parent 0838bf7ee6
commit 67e4ed3e16
3 changed files with 14 additions and 7 deletions

View file

@ -1,6 +1,4 @@
import React, { FC, useCallback, useState } from 'react';
import React, { FC, useCallback, useEffect, useState } from 'react';
import SwiperCore, { Keyboard, Navigation, Pagination, SwiperOptions } from 'swiper';
import { Swiper, SwiperSlide } from 'swiper/react';
@ -52,6 +50,10 @@ const NodeImageSwiperBlock: FC<IProps> = ({ node }) => {
[images, controlledSwiper, showPhotoSwiper]
);
useEffect(() => {
controlledSwiper?.slideTo(0, 0);
}, [images]);
if (!images?.length) {
return null;
}