Last active
September 17, 2021 14:12
-
-
Save dustinleer/94198579606f75fb23c649fddc74cf5e to your computer and use it in GitHub Desktop.
Moving Nav Items
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
var | |
// NAV | |
navbutton = $('.menu-toggle'), | |
navWrap = $('.main-nav-wrapper'), | |
navmenu = $('.main-nav'), | |
servicemenu = $('.service-menu'), | |
// WATCHER | |
watcher = window.matchMedia("(max-width: 1179px)"); | |
// Call listener function at run time | |
windowWidth( watcher ); | |
// Attach listener function on state changes | |
watcher.addListener( windowWidth ); | |
function windowWidth( watcher ) { | |
if ( watcher.matches ) { | |
// If media query matches | |
// console.log('x matches'); | |
servicemenu.addClass('attached-nav').detach('.nav-service').appendTo(navWrap); | |
topmenu.addClass('attached-nav').detach('.nav-top').appendTo(navWrap); | |
} else { | |
// console.log('x does not match'); | |
servicemenu.removeClass('attached-nav').detach().appendTo('.nav-service'); | |
topmenu.removeClass('attached-nav').detach().appendTo('.nav-top'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment