Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/DayColumn.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,10 @@ class DayColumn extends React.Component {
const current = getNow()

if (current >= min && current <= max) {
const { top } = this.slotMetrics.getRange(current, current)
const { top } = this.slotMetrics.getCurrentTimeIndicatorRange(
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since this is only using top maybe change this to "getCurrentTimePosition" instead and only return top

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense

current,
current
)
this.setState({ timeIndicatorPosition: top })
} else {
this.clearTimeIndicatorInterval()
Expand Down
24 changes: 20 additions & 4 deletions src/utils/TimeSlots.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,8 @@ export function getSlotMetrics({ min: start, max: end, step, timeslots }) {
},

getRange(rangeStart, rangeEnd, ignoreMin, ignoreMax) {
if (!ignoreMin)
rangeStart = dates.min(end, dates.max(start, rangeStart))
if (!ignoreMax)
rangeEnd = dates.min(end, dates.max(start, rangeEnd))
if (!ignoreMin) rangeStart = dates.min(end, dates.max(start, rangeStart))
if (!ignoreMax) rangeEnd = dates.min(end, dates.max(start, rangeEnd))

const rangeStartMin = positionFromDate(rangeStart)
const rangeEndMin = positionFromDate(rangeEnd)
Expand All @@ -146,5 +144,23 @@ export function getSlotMetrics({ min: start, max: end, step, timeslots }) {
endDate: rangeEnd,
}
},

getCurrentTimeIndicatorRange(rangeStart, rangeEnd, ignoreMin, ignoreMax) {
if (!ignoreMin) rangeStart = dates.min(end, dates.max(start, rangeStart))
if (!ignoreMax) rangeEnd = dates.min(end, dates.max(start, rangeEnd))

const rangeStartMin = positionFromDate(rangeStart)
const rangeEndMin = positionFromDate(rangeEnd)
const top = (rangeStartMin / (step * numSlots)) * 100

return {
top,
height: (rangeEndMin / (step * numSlots)) * 100 - top,
start: positionFromDate(rangeStart),
startDate: rangeStart,
end: positionFromDate(rangeEnd),
endDate: rangeEnd,
}
},
}
}