question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Current Time Indicator and short Events are offset by step-size number of minutes

See original GitHub issue

Do you want to request a feature or report a bug?

Bug / Regression caused by #1204

What’s the current behavior?

https://codesandbox.io/s/react-big-calendar-example-feofz

  1. Scroll down to current time.
  2. Notice that the current time indicator is off by 15 minutes (one step size)

See related issue with events here: https://codesandbox.io/s/react-big-calendar-example-e1o2n Events shorter than step-size minutes are offset.

What’s the expected behavior?

The current time indicator should be at current time.

Likely cause

https://github.com/intljusticemission/react-big-calendar/blob/7619e592a6e880860c7fc2e9cbc6473ede386955/src/utils/TimeSlots.js#L135-L138

image

When calculating the time line position we hit the top branch of this ternary if. The timeslot step (ex: 15) is subtracted from the number of minutes since calendar min.

A calendar starting at 00:00, ending at 23:59, with current time 14:00 has rangeStart/End 14*60=840. We should be at 58,33% of the day, but (840-15)/(15*96)*100=57,29. 15 minutes…

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:6

github_iconTop GitHub Comments

2reactions
longsleepcommented, Aug 6, 2019

I suggest to revert #1204 the part introducing the breakage until it can be fixed without breaking time ranges for current time indicator and short events.

This does the trick for me:

diff --git a/src/utils/TimeSlots.js b/src/utils/TimeSlots.js
index 06e399d..ded31f4 100644
--- a/src/utils/TimeSlots.js
+++ b/src/utils/TimeSlots.js
@@ -132,10 +132,7 @@ export function getSlotMetrics({ min: start, max: end, step, timeslots }) {
 
       const rangeStartMin = positionFromDate(rangeStart)
       const rangeEndMin = positionFromDate(rangeEnd)
-      const top =
-        rangeEndMin - rangeStartMin < step
-          ? ((rangeStartMin - step) / (step * numSlots)) * 100
-          : (rangeStartMin / (step * numSlots)) * 100
+      const top = (rangeStartMin / (step * numSlots)) * 100;
 
       return {
         top,
0reactions
stianeikelandcommented, Oct 4, 2019

Oh! I just noticed there’s a PR that possibly fixes the event issue over at https://github.com/intljusticemission/react-big-calendar/pull/1462

Read more comments on GitHub >

github_iconTop Results From Across the Web

Current Time Indicator and short Events are offset by step-size ...
The timeslot step (ex: 15) is subtracted from the number of minutes since calendar min. A calendar starting at 00:00, ending at 23:59,...
Read more >
RatingBar - Android Developers
android:isIndicator, Whether this rating bar is an indicator (and ... Gets the current rating (number of stars filled). ... void, setMin(int min).
Read more >
InfoLabels - Official Kodi Wiki
TotalUnWatched, Returns the number of unwatched items in the current container. Container(id).ListItem(offset).Label, Shows ListItem.
Read more >
android - Changing step values in seekbar? - Stack Overflow
I have a seekbar, while moving it I want to change values from 0 to 200. I have a TextView, where I display...
Read more >
Functional Mock-up Interface Specification - FMI standard
A vector of floating point continuous-time variables representing the event indicators used to locate state events.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found