Skip to content

Instantly share code, notes, and snippets.

@magnificode
Last active December 29, 2015 00:39
Show Gist options
  • Save magnificode/7587579 to your computer and use it in GitHub Desktop.
Save magnificode/7587579 to your computer and use it in GitHub Desktop.
Edge Case Mobile Nav where the child is relative to a smaller parent. Use this if you want that child to be the full width of the window.
var $window = $(window);
var $daNav = $('.main-head__nav').find('.menu');
function navGrow() { //it's like miracle grow for navs.
var superWide = $window.width();
$daNav.css('width', superWide);
$('.main-head__nav').click(function () {
$daNav.toggleClass('clack');
});
if ($window.width() > 768) {
if ($daNav.hasClass('clack')) {
$daNav.removeClass('clack');
}
$daNav.css('width', '');
}
}
$window.load(navGrow);
$window.resize(function () {
$daNav.css('width', '');
$daNav.removeClass('clack');
navGrow();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment