Skip to content

Instantly share code, notes, and snippets.

@rachelbaker
Created August 24, 2012 17:38
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rachelbaker/3453300 to your computer and use it in GitHub Desktop.
Save rachelbaker/3453300 to your computer and use it in GitHub Desktop.
jQuery matchMedia event handler for mobile
jQuery(document).ready(function($) {
// load touchdown resposnive nav
$('#site-navigation .menu').Touchdown();
// check window size
if (matchMedia) {
var mq = window.matchMedia("(min-width: 769px)");
mq.addListener(WidthChange);
WidthChange(mq);
}
// load or hide horizontalNav depending on window width
function WidthChange(mq) {
if (mq.matches) {
$('#site-navigation .menu').horizontalNav({});
}
else {
$('#site-navigation .menu').hide();
}
}(window.jQuery)
});
@rachelbaker
Copy link
Author

Fixed duplicating bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment