Skip to content

Instantly share code, notes, and snippets.

@josetapadas
Created July 25, 2014 14:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save josetapadas/f9eec8ca7d9f214f0918 to your computer and use it in GitHub Desktop.
Save josetapadas/f9eec8ca7d9f214f0918 to your computer and use it in GitHub Desktop.
Dynamic single shot media query
var mediaQueryListElement = window.matchMedia("all and (min-width: 666px)");
function call_me(name) {
console.log("És um " + name);
mediaQueryListElement.removeListener(call_me.caller);
}
mediaQueryListElement.addListener(function() {
call_me("sugar");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment