-
Notifications
You must be signed in to change notification settings - Fork 15
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
Width calculation is wrong #3
Comments
It looks like if you write a media query, it calculates the width of the window, not the visible area as you describe: http://cl.ly/image/060H2M212r3q - the media query is triggered at 800px though the visible area is only ~780px; Feel free to test against this: http://jsbin.com/idujaz/3 Now it's possible this is an operating system level thing (i.e Mac OS X Lion+ don't have visible scrollbars). But I'd rather err on the side of reporting when then browser thinks it should trigger a media query. |
That's not true. The media query fires on the viewport width not the window width. If your browser uses invisible scrollbars (like Lion+) the viewport and window width are identical, and FitWeird probably calculates as expected. But if regular scrollbars (as if the window had overflow:auto defined) are used in the browser (like Snow Leopard down and probably Windows everything) then the calculation is wrong. When the scrollbar is active, you can see the viewport is narrower than the window. In the test case you posted the media query hasn't fired yet, but according to FitWeird it should have: Note: I'm on Snow Leopard using Chrome. |
Ok. Cool. I'll work on it. |
I did it the lazy way because jQuery was available:
The innerWidth and outerWidth were giving me issues cross-browser. It might be more reliable to test:
But I'm not certain what happens if elems are positioned outside the viewport. Could be wonky. I can test on SnowLeopard if you think you've got a fix. |
It was I'm not sure we'll need full browser support as this should cover most web developers && browsers that support media queries. |
@brendanf let me know if this update works for you, i can't really test snow leopard. |
No dice. The MDN article says innerWidth does include the scrollbar, so I think that won't work. |
Just tried testing using If you absolutely position an element off canvas, measuring the Maybe try using |
Published mine here (with a few improvements for readability based on your code): |
The calculation is wrong. See screenshot: http://cl.ly/IyNp
xScope shows the measured width in the bottom left. The FitWeird value is 15px (the scrollbar) too wide.
The little black box is a jQuery doodad I use during dev. Its code looks like this:
The text was updated successfully, but these errors were encountered: