Skip to content

Commit

Permalink
fix: add new method to get correct time indicator top position | fixes
Browse files Browse the repository at this point in the history
…jquense#1396 (jquense#1447)

* fix: add new method to get correct time indicator top position

* fix(current time indicator): remove unnecessary fields

* fix(current time indicator): rename function

* fix(current time indicator): remove unnecessary code and arguments
  • Loading branch information
eightshone authored and jquense committed Sep 10, 2019
1 parent 9117549 commit 1cf0205
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
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
},
}
}

0 comments on commit 1cf0205

Please sign in to comment.