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.

Incorrect thumb height on the initial render

See original GitHub issue

I’m using Scrollbars as a wrapper of the whole page. It works fine, but the [vertical] thumb is 0px high on the initial render. Once I scroll using a wheel / some other means, or resize the window, then the thumb’s height is calculated correctly. I’m getting this only in Chrome, not Firefox.

I’ve set some breakpoints in the code, and it appears that update, and consequently getThumbVerticalHeight, is called only once, before the DOM is painted (the page is completely blank when the breakpoint is triggered). Apparently, having raf is not enough, since it’s still somehow executed before the browser is done painting.

Not sure whose fault it is (React’s or Chrome’s, or maybe it’s Firefox who’s doing it wrong), but as pointed out in a related SO question, the only way to do size-related DOM probes reliably is to have a 0ms timeout before invoking raf. And indeed, once I’ve added the following to the container:

componentDidMount() {
  setTimeout(() => this.refs.scrollbars.forceUpdate(), 0);
}

… the issue went away.

Sorry for not providing a way to repro, this is as much time as I can commit to this, unfortunately.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
alecmevcommented, Apr 27, 2016

Sorry, not yet, simply don’t have the energy. I suppose this can be closed, until further notice. Your call.

0reactions
malte-wesselcommented, Apr 27, 2016

Any updates on this?

Read more comments on GitHub >

github_iconTop Results From Across the Web

JS custom scrollbar thumb sizing problems relative to element ...
this.getFullWidth() gives correct value. Hence, thumb size is correct. Problem lays in thumbPosition , but here is a catch, How does this happen ......
Read more >
Creating Custom Scrollbars with React - This Dot Labs
The thumb's height is finally stored in React state. A useEffect sets an initial height, then creates a ResizeObserver to watch the size...
Read more >
::-moz-range-thumb - CSS: Cascading Style Sheets | MDN
The ::-moz-range-thumb CSS pseudo-element is a Mozilla extension that represents the thumb (i.e., virtual knob) of an of type="range".
Read more >
wp_get_attachment_image_src() | Function
function wp_get_attachment_image_src( $attachment_id, $size = 'thumbnail', $icon = false ) { // Get a thumbnail or intermediate image if there is one.
Read more >
Slider API - Material UI - MUI
If true , the active thumb doesn't swap when moving pointer over a thumb while ... The size of the slider. ... false...
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