Skip to content

Commit 1cf0205

Browse files
eightshonejquense
authored andcommitted
fix: add new method to get correct time indicator top position | fixes 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
1 parent 9117549 commit 1cf0205

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/DayColumn.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class DayColumn extends React.Component {
9797
const current = getNow()
9898

9999
if (current >= min && current <= max) {
100-
const { top } = this.slotMetrics.getRange(current, current)
100+
const top = this.slotMetrics.getCurrentTimePosition(current)
101101
this.setState({ timeIndicatorPosition: top })
102102
} else {
103103
this.clearTimeIndicatorInterval()

src/utils/TimeSlots.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,8 @@ export function getSlotMetrics({ min: start, max: end, step, timeslots }) {
125125
},
126126

127127
getRange(rangeStart, rangeEnd, ignoreMin, ignoreMax) {
128-
if (!ignoreMin)
129-
rangeStart = dates.min(end, dates.max(start, rangeStart))
130-
if (!ignoreMax)
131-
rangeEnd = dates.min(end, dates.max(start, rangeEnd))
128+
if (!ignoreMin) rangeStart = dates.min(end, dates.max(start, rangeStart))
129+
if (!ignoreMax) rangeEnd = dates.min(end, dates.max(start, rangeEnd))
132130

133131
const rangeStartMin = positionFromDate(rangeStart)
134132
const rangeEndMin = positionFromDate(rangeEnd)
@@ -146,5 +144,12 @@ export function getSlotMetrics({ min: start, max: end, step, timeslots }) {
146144
endDate: rangeEnd,
147145
}
148146
},
147+
148+
getCurrentTimePosition(rangeStart) {
149+
const rangeStartMin = positionFromDate(rangeStart)
150+
const top = (rangeStartMin / (step * numSlots)) * 100
151+
152+
return top
153+
},
149154
}
150155
}

0 commit comments

Comments
 (0)