Created
May 28, 2013 19:35
-
-
Save markreale/5665460 to your computer and use it in GitHub Desktop.
Check when an interface passes a media query threshold.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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