-
Notifications
You must be signed in to change notification settings - Fork 20.5k
Description
Originally reported by antti@… at: http://bugs.jquery.com/ticket/14989
It is sometimes annoying that
Currently e.g. if you have a media query in the CSS such as
@media screen and (max-width: 1600px) {
body {background: red;}
}
When the red background is actually applied to the document by the browser, jQuery tells the window width is less than 1600px (1600 - scrollbar width).
This is annoying e.g. in cases where there are some mobile-specific stuff that needs to be done in both, CSS and JS. And they would need to be done at the exactly same width of the document/window.
However, plain JavaScript returns 1600 as the window width when asked at the point of the breakpoint as follows:
console.log(window.innerWidth);
Is it possible to get either
Fixing this would greatly help making consistent code with the CSS media queries.
Possible workarounds currently are:
- Using plain javascript, i.e. window.innerWidth
- Checking $('...').is(':visible') for some element that is visible only in the target width
Here's an example of what I mean: http://jsfiddle.net/aq5vb/
Issue reported for jQuery 2.1.0