Last active
August 29, 2015 14:02
-
-
Save pixelhijack/298d387778dee7138911 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
//============================== | |
//JAVASCRIPT @MEDIA QUERIES | |
//================================ | |
var widthMax832px = window.matchMedia('(max-width: 832px)'); | |
console.log('widthMax832px: ', widthMax832px); | |
//always check if window.matchMedia exist (older IE can crash on this. If still needed, use Paul Irish polyfill) | |
if(window.matchMedia && window.matchMedia("(max-width: 1201px)").matches) { | |
console.log('js:@media: width of browser: less then 1201px'); | |
} else { | |
console.log('js:@media: width of browser: more then 1201px'); | |
}; | |
widthMax832px.addListener(function(changed) { | |
if(changed.matches) { | |
console.log('js:@media: width of browser: CHANGED TO less then 832px'); | |
} else { | |
console.log('js:@media: width of browser: CHANGED TO more then 832px'); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment