From 87d78f3f7821b272db41b6fb035e7d9e8f6afd02 Mon Sep 17 00:00:00 2001 From: zojgame Date: Mon, 1 Jul 2024 10:48:13 +0500 Subject: [PATCH] init --- .../SequenceWing/MobileFloorDescription.tsx | 7 +- .../SequenceWing/SequenceWing.tsx | 123 ++++++++++++++---- 2 files changed, 102 insertions(+), 28 deletions(-) diff --git a/client/src/components/complexWingPage/SequenceWing/MobileFloorDescription.tsx b/client/src/components/complexWingPage/SequenceWing/MobileFloorDescription.tsx index 7d48fb0..b5cac69 100644 --- a/client/src/components/complexWingPage/SequenceWing/MobileFloorDescription.tsx +++ b/client/src/components/complexWingPage/SequenceWing/MobileFloorDescription.tsx @@ -7,16 +7,20 @@ import RightArrowSliderIcon from "../../icons/RightArrowSliderIcon"; interface MobileFloorDescriptionProps { descriptionFloor: IDesctiptionFloor | null; floorApartments: IAparmentRes[]; + onClick: ( + e: React.MouseEvent> + ) => void; } const MobileFloorDescription = ({ descriptionFloor, floorApartments, + onClick, }: MobileFloorDescriptionProps) => { return ( <>
@@ -107,6 +111,7 @@ const MobileFloorDescription = ({ text="Explore" icon={} iconPos="right" + onClick={onClick} />
diff --git a/client/src/components/complexWingPage/SequenceWing/SequenceWing.tsx b/client/src/components/complexWingPage/SequenceWing/SequenceWing.tsx index 09e2f74..0d3c095 100644 --- a/client/src/components/complexWingPage/SequenceWing/SequenceWing.tsx +++ b/client/src/components/complexWingPage/SequenceWing/SequenceWing.tsx @@ -25,6 +25,7 @@ import WingSignatures from "./WingSignatures"; import { isMobile } from "react-device-detect"; import FloorsHighlighting from "./FloorsHighlighting"; import MobileFloorDescription from "./MobileFloorDescription"; +import WingFloorModal from "../../modals/mobile/WingFloorModal"; const skyGardenFloor = 22; @@ -95,17 +96,49 @@ const SequenceWing = () => { setIsWrapperHovered(false); }; - const handleOnFloorClick = () => { - if (!currentHoveredFloor && !currentHoveredApartments) return; - setSelectedApartments(currentHoveredApartments); - setCurrentFloor(currentHoveredFloor); - if (!isMobile) { - setIsFloorSidebar(true); - setIsSkygardenSidebar(false); - setIsSidebar(true); + const handleOnFloorClick = (e: MouseEvent | any) => { + const isFloorClicked = Boolean(e.currentTarget.dataset.id); + if (isFloorClicked) { + // detect mouse pos + const screenWidth = window.innerWidth; + const screenHeight = window.innerHeight; + // >1072 + if (screenWidth > laptopWidth) { + const _top = screenWidth / 2 - screenHeight / 2; + setMousePos([e.clientX - 384, e.clientY + Math.abs(_top) - 20]); + } else { + // 640-1072 + if (screenWidth > mobileWidht) { + const _top = screenHeight / 4; + const _left = laptopWidth - screenWidth; + setMousePos([ + e.clientX - 440 + _left, + e.clientY + Math.abs(_top) + 20, + ]); + // <640 + } else { + const _top = screenHeight / 2.5; + const _left = laptopWidth - screenWidth; + setMousePos([ + e.clientX - 440 + _left, + e.clientY + Math.abs(_top) + 20, + ]); + } + } + + //detect currentFloor, current sidebar and apartment on floor + if (!currentHoveredFloor && !currentHoveredApartments) return; + setSelectedApartments(currentHoveredApartments); + setCurrentFloor(currentHoveredFloor); + if (!isMobile) { + setIsFloorSidebar(true); + setIsSkygardenSidebar(false); + setIsSidebar(true); + } else { + setIsDescriptionFloorMobile(true); + } } else { - setIsDescriptionFloorMobile(true); - // setModal(); + setIsDescriptionFloorMobile(false); } }; @@ -122,27 +155,54 @@ const SequenceWing = () => { function handleMouseMove( e: MouseEvent> | any ) { - setMousePos([e.clientX - 384, e.clientY + Math.abs(top) - 20]); + const isFloorClicked = Boolean(e.target.dataset.id); + if (isFloorClicked) { + setMousePos([e.clientX - 384, e.clientY + Math.abs(top) - 20]); + } else { + setIsDescriptionFloorMobile(false); + } } function handleOnMouseDown(e: MouseEvent | any) { - const screenWidth = window.innerWidth; - const screenHeight = window.innerHeight; - // >1072 - if (screenWidth > laptopWidth) { - const _top = screenWidth / 2 - screenHeight / 2; - setMousePos([e.clientX - 384, e.clientY + Math.abs(_top) - 20]); - } else { - // 640-1072 - if (screenWidth > mobileWidht) { - const _top = screenHeight / 4; - const _left = laptopWidth - screenWidth; - setMousePos([e.clientX - 440 + _left, e.clientY + Math.abs(_top) + 20]); - // <640 + const isFloorClicked = Boolean(e.target.dataset.id); + if (isFloorClicked) { + // detect mouse pos + const screenWidth = window.innerWidth; + const screenHeight = window.innerHeight; + // >1072 + if (screenWidth > laptopWidth) { + const _top = screenWidth / 2 - screenHeight / 2; + setMousePos([e.clientX - 384, e.clientY + Math.abs(_top) - 20]); } else { - const _top = screenHeight / 2.5; - const _left = laptopWidth - screenWidth; - setMousePos([e.clientX - 440 + _left, e.clientY + Math.abs(_top) + 20]); + // 640-1072 + if (screenWidth > mobileWidht) { + const _top = screenHeight / 4; + const _left = laptopWidth - screenWidth; + setMousePos([ + e.clientX - 440 + _left, + e.clientY + Math.abs(_top) + 20, + ]); + // <640 + } else { + const _top = screenHeight / 2.5; + const _left = laptopWidth - screenWidth; + setMousePos([ + e.clientX - 440 + _left, + e.clientY + Math.abs(_top) + 20, + ]); + } + } + + //detect currentFloor, current sidebar and apartment on floor + if (!currentHoveredFloor && !currentHoveredApartments) return; + setSelectedApartments(currentHoveredApartments); + setCurrentFloor(currentHoveredFloor); + if (!isMobile) { + setIsFloorSidebar(true); + setIsSkygardenSidebar(false); + setIsSidebar(true); + } else { + setIsDescriptionFloorMobile(true); } } } @@ -173,6 +233,14 @@ const SequenceWing = () => { } } + const handleOnExploreClick = ( + e: MouseEvent> + ) => { + e.stopPropagation(); + setModal(); + setIsDescriptionFloorMobile(false); + }; + useEffect(() => { handleResize(); window.addEventListener("resize", handleResize); @@ -336,6 +404,7 @@ const SequenceWing = () => { }} >