diff --git a/src/DayColumn.js b/src/DayColumn.js index df968c14c..bbc0bcf28 100644 --- a/src/DayColumn.js +++ b/src/DayColumn.js @@ -165,7 +165,9 @@ class DayColumn extends React.Component { rtl: isRtl, selected, startAccessor, + step, titleAccessor, + timeslots, tooltipAccessor, } = this.props @@ -174,6 +176,7 @@ class DayColumn extends React.Component { startAccessor, endAccessor, slotMetrics: this.slotMetrics, + minimumStartDifference: Math.ceil((step * timeslots) / 2), }) return styledEvents.map(({ event, style }, idx) => { diff --git a/src/utils/DayEventLayout.js b/src/utils/DayEventLayout.js index 27c6cde2e..b9e87c0d4 100644 --- a/src/utils/DayEventLayout.js +++ b/src/utils/DayEventLayout.js @@ -90,12 +90,12 @@ class Event { /** * Return true if event a and b is considered to be on the same row. */ -function onSameRow(a, b) { +function onSameRow(a, b, minimumStartDifference) { return ( // Occupies the same start slot. - Math.abs(b.start - a.start) <= 30 || + Math.abs(b.start - a.start) < minimumStartDifference || // A's start slot overlaps with b's end slot. - (a.start > b.start && a.start < b.end) + (b.start > a.start && b.start < a.end) ) } @@ -129,7 +129,7 @@ function sortByRender(events) { return sorted } -function getStyledEvents({ events, ...props }) { +function getStyledEvents({ events, minimumStartDifference, ...props }) { // Create proxy events and order them so that we don't have // to fiddle with z-indexes. const proxies = events.map(event => new Event(event, props)) @@ -144,7 +144,9 @@ function getStyledEvents({ events, ...props }) { // Check if this event can go into a container event. const container = containerEvents.find( - c => c.end > event.start || Math.abs(event.start - c.start) < 30 + c => + c.end > event.start || + Math.abs(event.start - c.start) < minimumStartDifference ) // Couldn't find a container — that means this event is a container. @@ -161,7 +163,7 @@ function getStyledEvents({ events, ...props }) { // Start looking from behind. let row = null for (let j = container.rows.length - 1; !row && j >= 0; j--) { - if (onSameRow(container.rows[j], event)) { + if (onSameRow(container.rows[j], event, minimumStartDifference)) { row = container.rows[j] } }