Created
August 24, 2012 17:38
-
-
Save rachelbaker/3453300 to your computer and use it in GitHub Desktop.
jQuery matchMedia event handler for mobile
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
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) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Fixed duplicating bug.