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 srinidhikMS committed Jul 13, 2020
1 parent 377fd19 commit 0822663
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 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: 10 additions & 3 deletions src/utils/TimeSlots.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ export function getSlotMetrics({ min: start, max: end, step, timeslots }) {
return dates.gt(dates.merge(end, date), end, 'minutes')
},

getRange(rangeStart, rangeEnd) {
rangeStart = dates.min(end, dates.max(start, rangeStart))
rangeEnd = dates.min(end, dates.max(start, rangeEnd))
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))

const rangeStartMin = positionFromDate(rangeStart)
const rangeEndMin = positionFromDate(rangeEnd)
Expand All @@ -141,5 +141,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 0822663

Please sign in to comment.