Create a gist now

Instantly share code, notes, and snippets.

@robtarr /js
Created Mar 26, 2012

What would you like to do?
mediaCheck.js
var mediaCheck = function(options) {
var mq,
matchMedia = window.matchMedia !== undefined;
if (matchMedia) {
mqChange = function(mq, options) {
if (mq.matches) {
options.entry();
} else {
options.exit();
}
};
createListener = function(mqDetails) {
mq = window.matchMedia(mqDetails.media);
mq.addListener(function() {
mqChange(mq, mqDetails);
});
mqChange(mq, mqDetails);
};
createListener(options);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment