diff --git a/client/src/components/ClientsPage/ClientsPageCarousel.tsx b/client/src/components/ClientsPage/ClientsPageCarousel.tsx index 44de474..9c6fc29 100644 --- a/client/src/components/ClientsPage/ClientsPageCarousel.tsx +++ b/client/src/components/ClientsPage/ClientsPageCarousel.tsx @@ -50,7 +50,7 @@ const ClientsPageCarousel = () => {

Благодарственные письма

-
+
{ const { setModal } = useStore(); const [selectedImage, setSelectedImage] = useState(currentImage); + const [isZoomed, setIsZoomed] = useState(false); + const currentImageRef = useRef(null); + + useEffect(() => { + setIsZoomed(false); + if (!currentImageRef || !currentImageRef?.current) return; + currentImageRef.current.style.transform = ``; + }, [selectedImage]); + + useEffect(() => { + if (!currentImageRef || !currentImageRef?.current || isZoomed) return; + currentImageRef.current.style.transform = ``; + }, [isZoomed]); const handleOnRightClick = () => { setSelectedImage((prev) => prev + 1); @@ -28,8 +43,29 @@ const ZoomInLetterModal = ({ setModal(null); }; + const handleOnZoomSwitch = ( + event: React.MouseEvent + ) => { + if (!currentImageRef || !currentImageRef?.current) return; + + setIsZoomed((prev) => !prev); + currentImageRef.current.style.transform = `scale(1.5) translate(-5vw, ${ + 200 - 300 * (event.clientY / window.innerHeight) + }px)`; + }; + + function handleOnMouseMove( + event: React.MouseEvent + ): void { + if (!currentImageRef || !currentImageRef?.current || !isZoomed) return; + + currentImageRef.current.style.transform = `scale(1.5) translate(-5vw, ${ + 200 - 300 * (event.clientY / window.innerHeight) + }px)`; + } + return ( -
+
{images.map((image) => { + const isCurrentImage = selectedImage === image.id; + return ( -
- -
+ <> + {isCurrentImage ? ( +
+ +
+ ) : ( +
+ +
+ )} + ); })}
-
- +
+
+ {!isZoomed ? : } +
+
+ +
{ { + return ( + + + + + + + ); +}; + +export default ZoomInIcon; diff --git a/client/src/icons/ZoomOutIcon.tsx b/client/src/icons/ZoomOutIcon.tsx new file mode 100644 index 0000000..a95cef6 --- /dev/null +++ b/client/src/icons/ZoomOutIcon.tsx @@ -0,0 +1,32 @@ +const ZoomOutIcon = () => { + return ( + + + + + + ); +}; + +export default ZoomOutIcon; diff --git a/client/src/pages/ClientsPage/ClientsPage.tsx b/client/src/pages/ClientsPage/ClientsPage.tsx index cf6fe99..986c50b 100644 --- a/client/src/pages/ClientsPage/ClientsPage.tsx +++ b/client/src/pages/ClientsPage/ClientsPage.tsx @@ -3,7 +3,6 @@ import ClientsContainer from "../../components/ClientsPage/ClientsContainer"; import ClientsPageCarousel from "../../components/ClientsPage/ClientsPageCarousel"; const ClientsPage = () => { - console.log("Array.from(5)"); return ( <>