Skip to content

Commit

Permalink
[FE-Fix] 타임라인 블록 계산 로직 수정 (#257)
Browse files Browse the repository at this point in the history
  • Loading branch information
dioo1461 authored Feb 21, 2025
1 parent 08c49bf commit ec26be0
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions frontend/src/features/timeline-schedule/ui/timelineHelper.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getMinuteDiff } from '@/utils/date';
import { getMinuteDiff, MINUTE_IN_MILLISECONDS } from '@/utils/date';

import type { Participant } from '../model';

Expand Down Expand Up @@ -65,9 +65,15 @@ export const calculateBlockStyle = (
blockStart: Date,
blockEnd: Date,
) => {
const durationMinutes = getMinuteDiff(blockStart, blockEnd);
// Clamp block start and end within the grid's boundaries
const clampedBlockStart = new Date(Math.max(blockStart.getTime(), gridStart.getTime()));
const gridEndTime =
gridStart.getTime() + GRID_HORIZONTAL_COUNT * MINUTES_PER_GRID * MINUTE_IN_MILLISECONDS;
const clampedBlockEnd = new Date(Math.min(blockEnd.getTime(), gridEndTime));

const durationMinutes = getMinuteDiff(clampedBlockStart, clampedBlockEnd);
const width = durationMinutes * PIXELS_PER_MINUTE;
const left = Math.max(getMinuteDiff(gridStart, blockStart) * PIXELS_PER_MINUTE, 0);
const left = getMinuteDiff(gridStart, clampedBlockStart) * PIXELS_PER_MINUTE;

return { left, width };
};
Expand Down

0 comments on commit ec26be0

Please sign in to comment.