Skip to content

Commit

Permalink
fix(getWeekView): use correct width of overlapping events
Browse files Browse the repository at this point in the history
  • Loading branch information
mattlewis92 committed Nov 5, 2018
1 parent ae81a95 commit 90c820b
Show file tree
Hide file tree
Showing 3 changed files with 5,086 additions and 777 deletions.
39 changes: 33 additions & 6 deletions src/calendar-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -617,17 +617,44 @@ function getWeekViewHourGrid(
return { ...hour, segments };
});

function getColumnCount(
allEvents: DayViewEvent[],
prevOverlappingEvents: DayViewEvent[]
): number {
const columnCount = Math.max(
...prevOverlappingEvents.map(iEvent => iEvent.left + 1)
);

const nextOverlappingEvents = allEvents
.filter(iEvent => iEvent.left >= columnCount)
.filter(iEvent => {
return (
getOverLappingDayViewEvents(
prevOverlappingEvents,
iEvent.top,
iEvent.top + iEvent.height
).length > 0
);
});

if (nextOverlappingEvents.length > 0) {
return getColumnCount(allEvents, nextOverlappingEvents);
} else {
return columnCount;
}
}

return {
hours,
date: day.date,
events: dayView.events.map(event => {
const overLappingEvents = getOverLappingDayViewEvents(
const columnCount = getColumnCount(
dayView.events,
event.top,
event.top + event.height
);
const columnCount = Math.max(
...overLappingEvents.map(iEvent => iEvent.left + 1)
getOverLappingDayViewEvents(
dayView.events,
event.top,
event.top + event.height
)
);

const width = 100 / columnCount;
Expand Down
Loading

0 comments on commit 90c820b

Please sign in to comment.