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:
parent
0838bf7ee6
commit
67e4ed3e16
3 changed files with 14 additions and 7 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue