Skip to content

Commit

Permalink
fix bug when duration + startTime overlaps 24h
Browse files Browse the repository at this point in the history
  • Loading branch information
fivaz committed May 8, 2024
1 parent 2eb3363 commit 2f57efb
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,12 @@ export function getDivision(timeSlots: string[][], event: AnyEvent) {
}

export function getHeight(event: AnyEvent) {
const durationMinutes = convertTimeToMinutes(event.duration);
const startSlot = getStartSlot(event);
const endSlot = getEndSlot(event);
// the duration is calculated like this instead of just event.duration to sanitize the duration in case it overlaps 24h
const duration = endSlot - startSlot;

return `height: ${(durationMinutes / GRID_CELL_TIME) * NEW_GRID_CELL_HEIGHT}px;`;
return `height: ${duration * NEW_GRID_CELL_HEIGHT}px;`;
}

export function getTop(event: AnyEvent): string {
Expand Down

0 comments on commit 2f57efb

Please sign in to comment.