Commit 50dc0d6a authored by Ermolaev Timur's avatar Ermolaev Timur

#114 Немного подправил расчеты

parent a495d104
import Box from '@mui/material/Box'; import Box from '@mui/material/Box';
import Modal from '@mui/material/Modal'; import Modal from '@mui/material/Modal';
import { useEffect, useState } from 'react'; import { useCallback, useEffect, useMemo, useState } from 'react';
export default function ModalTask({modal, handleClose, children}) { export default function ModalTask({ modal, handleClose, children, week }) {
const [windowDimenion, detectHW] = useState({ const [windowDimenion, detectHW] = useState({
winWidth: window.innerWidth, winWidth: window.innerWidth,
...@@ -24,21 +24,30 @@ export default function ModalTask({modal, handleClose, children}) { ...@@ -24,21 +24,30 @@ export default function ModalTask({modal, handleClose, children}) {
} }
}, [windowDimenion]) }, [windowDimenion])
const getYCordinatesToModal = useCallback(() => {
const getYCordinatesToModal = () => { if (week) {
if (windowDimenion.winHeight > modal.yClickСordinates + 450) {
return modal.yClickСordinates - modal.yDivClick
} else {
return modal.yClickСordinates - 450
}
} else {
if (windowDimenion.winHeight > modal.yClickСordinates + 450) { if (windowDimenion.winHeight > modal.yClickСordinates + 450) {
return modal.yClickСordinates - modal.yDiv - modal.yDivClick return modal.yClickСordinates - modal.yDiv - modal.yDivClick
} else { } else {
return modal.yClickСordinates - modal.yDiv - modal.yDivClick - ((modal.yClickСordinates + 450) - windowDimenion.winHeight) - 30 return modal.yClickСordinates - modal.yDiv - modal.yDivClick - ((modal.yClickСordinates + 450) - windowDimenion.winHeight) - 30
} }
} }
const getXCordinatesToModal = () => { }, [windowDimenion.winHeight, modal])
const getXCordinatesToModal = useCallback(() => {
if (windowDimenion.winWidth > modal.xClickСordinates + 270 + modal.xDiv) { if (windowDimenion.winWidth > modal.xClickСordinates + 270 + modal.xDiv) {
return modal.xClickСordinates + modal.xDiv - modal.xDivClick + 10 return modal.xClickСordinates + modal.xDiv - modal.xDivClick + 10
} else { } else {
return windowDimenion.winWidth - (windowDimenion.winWidth - modal.xClickСordinates) - modal.xDivClick - 270 - 80 return windowDimenion.winWidth - (windowDimenion.winWidth - modal.xClickСordinates) - modal.xDivClick - 270 - 80
} }
} }, [windowDimenion.winWidth, modal])
const style = { const style = {
display: 'flex', display: 'flex',
flexDirection: 'column', flexDirection: 'column',
......
...@@ -3,7 +3,7 @@ import { useCallback, useState } from "react"; ...@@ -3,7 +3,7 @@ import { useCallback, useState } from "react";
import CalendarRow from "../../CalendarRow/CalendarRow"; import CalendarRow from "../../CalendarRow/CalendarRow";
import CalendarSmallCell from "../../CalendarSmallCell/CalendarSmallCell"; import CalendarSmallCell from "../../CalendarSmallCell/CalendarSmallCell";
import CalendarStandartCell from "../../CalendarStandartCell/CalendarStandartCell"; import CalendarStandartCell from "../../CalendarStandartCell/CalendarStandartCell";
import ModalTask from "../../../UI/ModalTask/ModalTask" import ModalTask from "../../ModalTask/ModalTask"
import MonthCalendarModalContent from "../../CalendarModalTaskContent/CalendarModalTaskContent"; import MonthCalendarModalContent from "../../CalendarModalTaskContent/CalendarModalTaskContent";
import CalendarRowDay from "./CalendarRowDay/CalendarRowDay"; import CalendarRowDay from "./CalendarRowDay/CalendarRowDay";
......
...@@ -30,7 +30,7 @@ function CalendarWeekTask({ height, width, left, top, task, zIndex, handleOpen, ...@@ -30,7 +30,7 @@ function CalendarWeekTask({ height, width, left, top, task, zIndex, handleOpen,
}); });
setZIndexStyle(100) setZIndexStyle(100)
handleOpen(e) handleOpen(e)
}, [handleOpen, setCurrentTask]) }, [handleOpen, setCurrentTask, month])
const styles = { const styles = {
boxSizing: 'border-box', boxSizing: 'border-box',
......
import { Grid } from "@mui/material"; import { Grid } from "@mui/material";
import { Box } from "@mui/system"; import { Box } from "@mui/system";
import { useCallback, useState } from "react"; import { useCallback, useState } from "react";
import ModalTask from "../../../UI/ModalTask/ModalTask"; import ModalTask from "../../ModalTask/ModalTask";
import MonthCalendarModalContent from "../../CalendarModalTaskContent/CalendarModalTaskContent"; import MonthCalendarModalContent from "../../CalendarModalTaskContent/CalendarModalTaskContent";
import CalendarRow from "../../CalendarRow/CalendarRow"; import CalendarRow from "../../CalendarRow/CalendarRow";
import CalendarSmallCell from "../../CalendarSmallCell/CalendarSmallCell"; import CalendarSmallCell from "../../CalendarSmallCell/CalendarSmallCell";
...@@ -95,6 +95,7 @@ function WeekCalendarBody({ week, hoursInDay, hourFormat, setHourFormat, date, t ...@@ -95,6 +95,7 @@ function WeekCalendarBody({ week, hoursInDay, hourFormat, setHourFormat, date, t
<ModalTask <ModalTask
modal={modal} modal={modal}
handleClose={() => { handleClose() }} handleClose={() => { handleClose() }}
week={true}
> >
<MonthCalendarModalContent <MonthCalendarModalContent
title={currentTask.title} title={currentTask.title}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment