zillow / react-slider

Accessible, CSS agnostic, slider component for React.
https://zillow.github.io/react-slider
MIT License
892 stars 231 forks source link

Wrapping _handleResize() logic in a setTimeout of 0 #38

Closed whroman closed 9 years ago

whroman commented 9 years ago

I was facing the issue mentioned in #15, which is that the slider doesn't seem to work if the slider is hidden when the page first loads. Wrapping the logic in _handleResize() with a setTimeout of 0 gives JS (with it's single-threaded nature) enough time to know what the new size of the element is if the previous height and width were 0.

I'm using these changes live on a minesweeper app. The repo lives here. The sliders appear if the client clicks on the "new game" button at the bottom of the screen.

qwtel commented 9 years ago

Seems like a good solution for now. Thanks!