mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
made sticky nav actually stick even on long menus
This commit is contained in:
parent
f105785b06
commit
c6f7a1771e
|
@ -21,16 +21,19 @@ window.SphinxRtdTheme = (function (jquery) {
|
|||
var navBar,
|
||||
win,
|
||||
stickyNavCssClass = 'stickynav',
|
||||
applyStickNav = function () {
|
||||
if (navBar.height() <= win.height()) {
|
||||
navBar.addClass(stickyNavCssClass);
|
||||
} else {
|
||||
navBar.removeClass(stickyNavCssClass);
|
||||
}
|
||||
},
|
||||
winScroll = false,
|
||||
enable = function () {
|
||||
applyStickNav();
|
||||
win.on('resize', applyStickNav);
|
||||
navBar.addClass(stickyNavCssClass);
|
||||
win.on('scroll', function() { // set flag on scroll event
|
||||
winScroll = true;
|
||||
});
|
||||
// use setInterval to only handle a subset of scroll events so we don't kill scroll performance
|
||||
setInterval(function() {
|
||||
if (winScroll) {
|
||||
winScroll = false;
|
||||
navBar.scrollTop(win.scrollTop());
|
||||
}
|
||||
}, 100);
|
||||
},
|
||||
init = function () {
|
||||
navBar = jquery('nav.wy-nav-side:first');
|
||||
|
|
Loading…
Reference in New Issue
Block a user