given this code:
mql = window.matchMedia("(max-width: 800px)");
mql.addListener(mqlHandler);
function mqlHandler(mql) {
if(mql.matches) {
alert('OK');
};
and this other code:
if(Modernizr.mq("(max-width: 800px)")) {
alert('OK');
};
the matchMedia
version works as expected, it pops the alert when the size of the screen is less than 800px, no matter how many times i resize the page, however, the second one just pops an alert when i reload the page with a screen width less than 800px, if a resize the screen after that no alerts are shown.
I read this from de Modernizr docs, "A max-width or orientation query will be evaluated against the current state, which may change later." This refers to this particular behavior or there are something wrong with the code?