-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No throttling on resize event handlers. #1990
Comments
@danigulyas care to issue a PR for this? it looks like a very reasonable solution, though I haven't run into the problem myself AFAIK so it's hard for me to tell! |
I'd prefer to use |
@shilman sure thing, somewhere on the weekend. |
So i dug into this more, did a little timeline action, turns out the resize is kind of slow in general, i've tested the same html inside and outside the context of Storybook, it was similarly slow, which is in a way understandable for a while (this browser stuff is still good for free!). However, after taking a second look on See, @Hypnosphi: I couldn't find requestAnimationFrame or something similar in the lib which the sidebar is implemented with, but that's not really a performance bottleneck in my opinion (you can check the timeline of rerenders with @shilman: So yup, this issue i guess is solved, given that it didn't exist to begin with, what do you think? |
@shilman @Hypnosphi @danielduan I just took a peek at the code and im 99.99% sure the issue lies because we dispatch And MDN even has a page dedicated to how to throttle resize events. Also im 99.99% sure this code is not resizing, adding componentDidMount() {
window.addEventListener('resize', this.onResize);
}
componentWillUnmount() {
window.removeEventListener('resize', this.onResize);
} But I'll have a PR out for this in the next couple of days when I have time :) |
In that case, a we shouldn't be running |
Why? I'd like the resizing to be smooth UPD: OK, it's not about resizing itself, it's about updating dimension numbers. Then throttling on ~200 ms sounds reasonable |
@Hypnosphi @danielduan Done! I took a slightly different approach and delayed state update until the user stops dragging for 50ms using |
Released as |
Issue
When you resize windows fast, everything is laggy, and you feel like:
My take on this:
Cause
The resize event handler is not throttled.
Solution
Apart from that
Thank you for making this!
<3
-Dan
The text was updated successfully, but these errors were encountered: