Last active
August 29, 2015 13:56
-
-
Save anselmh/8862175 to your computer and use it in GitHub Desktop.
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
(function (global) { | |
'use strict'; | |
window.matchMedia = window.matchMedia || function (media) { | |
if (!Modernizr) { | |
throw new Error('Reference Error: Modernizr is undefined'); | |
} | |
return { | |
matches: Modernizr.mq(media) | |
}; | |
}; | |
}(window)); |
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
(function (global) { | |
'use strict'; | |
window.matchMedia = window.matchMedia || function (media) { | |
var direction; | |
if (media.indexOf('height')) { | |
direction = 'innerHeight'; | |
} else { | |
direction = 'innerWidth'; | |
} | |
var num; | |
num = media.replace(/^\D+/g, ''); | |
var match; | |
var minMax; | |
if (media.indexOf('min')) { | |
if (window.direction > num) { | |
match = true; | |
} else { | |
match = false; | |
} | |
} else { | |
if (window.direction < num) { | |
match = true; | |
} else { | |
match = false; | |
} | |
} | |
return { | |
matches: match | |
}; | |
}; | |
}(window)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment