Skip to content

Instantly share code, notes, and snippets.

@markreale
Created May 28, 2013 19:35
Show Gist options
  • Save markreale/5665460 to your computer and use it in GitHub Desktop.
Save markreale/5665460 to your computer and use it in GitHub Desktop.
Check when an interface passes a media query threshold.
var checker = 0;
$(window).resize(function(){
if(window.matchMedia){
var mq = window.matchMedia( "(min-width: 940px)" );
var aMatch = mq.matches;
if(checker == 0){
if(aMatch) {
return;
}
else{
// it is mobile
checker = 1;
}
}
else{
if(aMatch) {
// it is desktop
checker = 0;
}
else{
return;
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment