Skip to content

Instantly share code, notes, and snippets.

@anselmh
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anselmh/8862175 to your computer and use it in GitHub Desktop.
Save anselmh/8862175 to your computer and use it in GitHub Desktop.
(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));
(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