Throttle our resize handling. #4

Closed
jdalton opened this Issue Mar 16, 2012 · 5 comments

Projects

None yet

4 participants

@martinAnsty

Looks to me as though it's simply because in the demo a smaller image source doesn't require a vertical scrollbar on the page (because it's shorter than the viewport height). Then when it switches to a larger image all of a sudden there is a scrollbar which makes the viewport narrower, triggering picturefill to switch back to the smaller image which removes the scrollbar again. So there is temporarily this little loop going. You can prove this by setting overflow-y: scroll on the html element, forcing a scrollbar all of the time.

As to why it doesn't occur in Firefox, I'm not too sure. Maybe it doesn't trigger the resize event when it adds/removes a scrollbar.

@scottjehl
Owner

@jdalton, thanks for the detailed report!

Sounds like @martinAnsty's on the right track here - scrollbar's causing the media queries to flicker themselves back and forth. I'm guessing maybe Chrome fires resize events at a faster interval than others? In any case, this could likely use some throttling to keep the resize calls in check.

In general, I think it's time the JS for this thing gets some cleanup attention and browser debug, as folks are likely to start using it now that it's "working." If you've any interest in helping on that, it'd be greatly appreciated!

@jdalton

+1 for throttle.

In general, I think it's time the JS for this thing gets some cleanup attention and browser debug, as folks are likely to start using it now that it's "working." If you've any interest in helping on that, it'd be greatly appreciated!

I'll try to do a quick cleanup gist over the weekend.

@scottjehl
Owner

That would be great if you have time! Thanks

@atdrago

@scottjehl @jdalton Was throttling ever implemented for the resize event?

@scottjehl scottjehl added this to the 2.1 Improvements milestone Apr 7, 2014
@scottjehl scottjehl changed the title from onresize oddity. to Throttle our resize handling. Apr 7, 2014
@scottjehl scottjehl pushed a commit that referenced this issue Apr 15, 2014
Scott Jehl throttle resize handling. fixes #4 83ca89f
@scottjehl scottjehl closed this Apr 15, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment