am bc36e229
: am d1d606b4
: am c774a312
: Merge "fix sidebar autoscroll when the selected doc is not visible. bug: 9676913" into jb-mr2-docs
* commit 'bc36e22992e11e9a3856f1c78bb73ee44a748e92': fix sidebar autoscroll when the selected doc is not visible. bug: 9676913
This commit is contained in:
commit
3c70a5caf9
1 changed files with 12 additions and 7 deletions
|
@ -819,13 +819,18 @@ function scrollIntoView(nav) {
|
|||
|
||||
if ($nav.is(':visible')) {
|
||||
var $selected = $(".selected", $nav);
|
||||
if ($selected.length == 0) return;
|
||||
if ($selected.length == 0) {
|
||||
// If no selected item found, exit
|
||||
return;
|
||||
}
|
||||
|
||||
var selectedOffset = $selected.offset().top; // measure offset from top, relative to entire page
|
||||
if (selectedOffset > $nav.height() * .8) { // multiply nav height by .8 so we move up any
|
||||
// items more than 80% down the nav
|
||||
// scroll the item up by an amount 125px less than the window height (account for site header)
|
||||
// and then multiply nav height by .8 to match the 80% threshold used above
|
||||
api.scrollTo(0, selectedOffset - 125 - ($nav.height() * .8), false);
|
||||
|
||||
var selectedOffset = $selected.position().top;
|
||||
if (selectedOffset + 90 > $nav.height()) { // add 90 so that we scroll up even
|
||||
// if the current item is close to the bottom
|
||||
api.scrollTo(0, selectedOffset - ($nav.height() / 4), false); // scroll the item into view
|
||||
// to be 1/4 of the way from the top
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue