Skip to content

Commit

Permalink
fix: misplacement of current time indicator (jquense#1239)
Browse files Browse the repository at this point in the history
Hello,
It looked like PR for this issue (jquense#1054) was abandoned and the bug still exists so I've decided to continue jdaberkow's work.
Also I've added check for `getNow` prop, because when you want to implement timezones you may have different `getNow` function depending on which timezone is selected. When user changes the timezone indicator should move to correct position for that timezone.
  • Loading branch information
a-gierczak authored and jquense committed Mar 4, 2019
1 parent 2a870b0 commit 2d6e99e
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/DayColumn.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,22 @@ class DayColumn extends React.Component {
}

componentDidUpdate(prevProps, prevState) {
if (prevProps.isNow !== this.props.isNow) {
const getNowChanged = !dates.eq(
prevProps.getNow(),
this.props.getNow(),
'minutes'
)

if (prevProps.isNow !== this.props.isNow || getNowChanged) {
this.clearTimeIndicatorInterval()

if (this.props.isNow) {
this.setTimeIndicatorPositionUpdateInterval(
const tail =
!getNowChanged &&
dates.eq(prevProps.date, this.props.date, 'minutes') &&
prevState.timeIndicatorPosition === this.state.timeIndicatorPosition
)

this.setTimeIndicatorPositionUpdateInterval(tail)
}
}
}
Expand Down

0 comments on commit 2d6e99e

Please sign in to comment.