From 070950859b380f1f35cf5775431033271f749c7d Mon Sep 17 00:00:00 2001 From: zojgame Date: Tue, 20 Feb 2024 13:13:59 +0500 Subject: [PATCH] Zoom in letter modal done --- .../ClientsPage/ClientsPageCarousel.tsx | 2 +- .../ClientsPage/ZoomInLetterModal.tsx | 90 +++++++++++++++---- client/src/icons/CrossIcon.tsx | 4 +- client/src/icons/ZoomInIcon.tsx | 37 ++++++++ client/src/icons/ZoomOutIcon.tsx | 32 +++++++ client/src/pages/ClientsPage/ClientsPage.tsx | 1 - 6 files changed, 146 insertions(+), 20 deletions(-) create mode 100644 client/src/icons/ZoomInIcon.tsx create mode 100644 client/src/icons/ZoomOutIcon.tsx 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 ( <>