Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add new method to get correct time indicator top position | fixes #1396 #1447

Merged
merged 4 commits into from
Sep 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion src/DayColumn.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class DayColumn extends React.Component {
const current = getNow()

if (current >= min && current <= max) {
const { top } = this.slotMetrics.getRange(current, current)
const top = this.slotMetrics.getCurrentTimePosition(current)
this.setState({ timeIndicatorPosition: top })
} else {
this.clearTimeIndicatorInterval()
Expand Down
13 changes: 9 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,12 @@ export function getSlotMetrics({ min: start, max: end, step, timeslots }) {
endDate: rangeEnd,
}
},

getCurrentTimePosition(rangeStart) {
const rangeStartMin = positionFromDate(rangeStart)
const top = (rangeStartMin / (step * numSlots)) * 100

return top
},
}
}