chore: block position calculator improved

This commit is contained in:
Aaryan Khandelwal 2023-09-06 22:24:19 +05:30
parent a6d904593e
commit ea3f13b540
2 changed files with 8 additions and 7 deletions

View File

@ -57,13 +57,14 @@ export const YearChartView: FC<any> = () => {
className="relative flex h-full flex-col overflow-hidden whitespace-nowrap"
style={{ width: `${currentViewData?.data.width}px` }}
>
<div
<div className="relative h-full w-full flex-1 flex justify-center">
{/* <div
className={`relative h-full w-full flex-1 flex justify-center ${
["sat", "sun"].includes(monthWeek?.dayData?.shortTitle || "")
? `bg-custom-background-90`
: ``
}`}
>
> */}
{/* {monthDay?.today && (
<div className="absolute top-0 bottom-0 w-[1px] bg-red-500" />
)} */}

View File

@ -156,12 +156,12 @@ export const getYearChartItemPositionWidthInYear = (
// position code starts
const positionTimeDifference: number = startDate.getTime() - itemStartDate.getTime();
const positionDaysDifference: number = Math.abs(
Math.floor(positionTimeDifference / (1000 * 60 * 60 * 24))
const positionWeeksDifference: number = Math.abs(
Math.floor(positionTimeDifference / (1000 * 60 * 60 * 24 * 7))
);
scrollPosition = positionDaysDifference * chartData.data.width;
scrollPosition = positionWeeksDifference * chartData.data.width;
var diffMonths = (itemStartDate.getFullYear() - startDate.getFullYear()) * 12;
let diffMonths = (itemStartDate.getFullYear() - startDate.getFullYear()) * 12;
diffMonths -= startDate.getMonth();
diffMonths += itemStartDate.getMonth();
@ -171,7 +171,7 @@ export const getYearChartItemPositionWidthInYear = (
// width code starts
const widthTimeDifference: number = itemStartDate.getTime() - itemTargetDate.getTime();
const widthDaysDifference: number = Math.abs(
Math.floor(widthTimeDifference / (1000 * 60 * 60 * 24))
Math.floor(widthTimeDifference / (1000 * 60 * 60 * 24 * 7))
);
scrollWidth = (widthDaysDifference + 1) * chartData.data.width + 1;
// width code ends