Skip to content

Commit

Permalink
fix: zero duration no-overlap events
Browse files Browse the repository at this point in the history
Thanks to D0HaTeJIJI0 for the fix here

#2110
  • Loading branch information
cutterbl committed Jul 7, 2022
1 parent c2bd6b8 commit b270c68
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/utils/layout-algorithms/no-overlap.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default function ({
const y4 = se2.style.top + se2.style.height

// be friends when overlapped
if ((y3 <= y1 && y1 < y4) || (y1 <= y3 && y3 < y2)) {
if ((y3 <= y1 && y1 <= y4) || (y1 <= y3 && y3 <= y2)) {
// TODO : hashmap would be effective for performance
se1.friends.push(se2)
se2.friends.push(se1)
Expand Down
27 changes: 26 additions & 1 deletion stories/Layout.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ export default {

const Template = (args) => <Calendar {...args} />

const defaultDate = new Date()

export const EventLayout = Template.bind({})
EventLayout.args = {
defaultView: Views.DAY,
defaultDate: new Date(),
defaultDate,
timeslots: 4,
events: createEvents(1),
}
Expand Down Expand Up @@ -174,3 +176,26 @@ export const ZeroDurationOddities = () => {
/>
)
}

export const ZeroDurationOverlap = () => {
return (
<DragAndDropCalendar
defaultDate={defaultDate}
events={[
{
title: 'event a',
start: defaultDate,
end: defaultDate,
},
{
title: 'event b',
start: defaultDate,
end: defaultDate,
},
]}
dayLayoutAlgorithm={'no-overlap'}
scrollToTime={defaultDate}
defaultView={Views.WEEK}
/>
)
}
4 changes: 3 additions & 1 deletion stories/helpers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ const localizer = momentLocalizer(moment)
export const date = (...args) => moment(...args).toDate()

export const Calendar = (props) => (
<BaseCalendar localizer={localizer} {...props} />
<div style={{ height: 650 }}>
<BaseCalendar localizer={localizer} {...props} />
</div>
)

export const DragAndDropCalendar = withDragAndDrop(Calendar)
Expand Down

0 comments on commit b270c68

Please sign in to comment.