It's twice as complicated as it needs to be if you want floating nav at all widths. I removed it for low width's. This required finding a way to check if the window size changed. So there is like 3x as much code as needed otherwise.
Primarily how it works is the container for navigation has a class NavStatic. This class contains properties for where the navigation normally sits. What we do is create a second css class called NavFloat that sets things like position: fixed; top: 0px; other parts of the menu may need adjustments as well and thats why the code swaps classes to other elements.
Unfortunately without me redoing this for a stock theme as you can see above my navTab div is wrapped into 2 other div's. The menu left exists because of our style having left and right background sections. Furthermore I added a seperate div to contain the whole thing which isn't needed in the stock style version i dont think. However if you look closely I add a class for modbarmargin if the moderator bar is present. This is very much needed otherwise the moderator bar gets covered up.
I will help more when I feel better and have more time.
top: -48px !important;
position: fixed !important;
box-shadow: white 0px 20px 20px;
The XenForo.updateVisibleNavigationTabs(); may not be needed at this time but it wont hurt too much either.