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,
|
var navBar,
|
||||||
win,
|
win,
|
||||||
stickyNavCssClass = 'stickynav',
|
stickyNavCssClass = 'stickynav',
|
||||||
applyStickNav = function () {
|
winScroll = false,
|
||||||
if (navBar.height() <= win.height()) {
|
|
||||||
navBar.addClass(stickyNavCssClass);
|
|
||||||
} else {
|
|
||||||
navBar.removeClass(stickyNavCssClass);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
enable = function () {
|
enable = function () {
|
||||||
applyStickNav();
|
navBar.addClass(stickyNavCssClass);
|
||||||
win.on('resize', applyStickNav);
|
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 () {
|
init = function () {
|
||||||
navBar = jquery('nav.wy-nav-side:first');
|
navBar = jquery('nav.wy-nav-side:first');
|
||||||
|
|
Loading…
Reference in New Issue
Block a user