mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
Merge pull request #220 from snide/fix-safari-overscroll
Fix Safari over-scroll bug, fixes #218
This commit is contained in:
commit
f1208215d7
|
@ -49,29 +49,30 @@ window.SphinxRtdTheme = (function (jquery) {
|
|||
var navBar,
|
||||
win,
|
||||
winScroll = false,
|
||||
winResize = false,
|
||||
linkScroll = false,
|
||||
winPosition = 0,
|
||||
winHeight,
|
||||
docHeight,
|
||||
enable = function () {
|
||||
init();
|
||||
reset();
|
||||
win.on('hashchange', reset);
|
||||
|
||||
// Set scrolling
|
||||
// Set scroll monitor
|
||||
win.on('scroll', function () {
|
||||
if (!linkScroll) {
|
||||
winScroll = true;
|
||||
}
|
||||
});
|
||||
setInterval(function () {
|
||||
if (winScroll) {
|
||||
winScroll = false;
|
||||
var newWinPosition = win.scrollTop(),
|
||||
navPosition = navBar.scrollTop(),
|
||||
newNavPosition = navPosition + (newWinPosition - winPosition);
|
||||
navBar.scrollTop(newNavPosition);
|
||||
winPosition = newWinPosition;
|
||||
}
|
||||
}, 25);
|
||||
setInterval(function () { if (winScroll) scroll(); }, 25);
|
||||
|
||||
// Set resize monitor
|
||||
win.on('resize', function () {
|
||||
winResize = true;
|
||||
});
|
||||
setInterval(function () { if (winResize) resize(); }, 25);
|
||||
resize();
|
||||
},
|
||||
init = function () {
|
||||
navBar = jquery('nav.wy-nav-side:first');
|
||||
|
@ -95,6 +96,23 @@ window.SphinxRtdTheme = (function (jquery) {
|
|||
}
|
||||
}
|
||||
},
|
||||
scroll = function () {
|
||||
winScroll = false;
|
||||
var newWinPosition = win.scrollTop(),
|
||||
winBottom = newWinPosition + winHeight,
|
||||
navPosition = navBar.scrollTop(),
|
||||
newNavPosition = navPosition + (newWinPosition - winPosition);
|
||||
if (newWinPosition < 0 || winBottom > docHeight) {
|
||||
return;
|
||||
}
|
||||
navBar.scrollTop(newNavPosition);
|
||||
winPosition = newWinPosition;
|
||||
},
|
||||
resize = function () {
|
||||
winResize = false;
|
||||
winHeight = win.height();
|
||||
docHeight = $(document).height();
|
||||
},
|
||||
hashChange = function () {
|
||||
linkScroll = true;
|
||||
win.one('hashchange', function () {
|
||||
|
|
Loading…
Reference in New Issue
Block a user