forked from openkylin/platform_build
am 3ab162e7: docs: script update to account for double-nested list items when scrolling sidenav into view
* commit '3ab162e71cbe88ec4d2207c39b9f3d2d7f4c965c': docs: script update to account for double-nested list items when scrolling sidenav into view
This commit is contained in:
commit
2e426cf07c
|
@ -502,14 +502,25 @@ function scrollIntoView(nav) {
|
|||
if (navObj.is(':visible')) {
|
||||
var selected = $(".selected", navObj);
|
||||
if (selected.length == 0) return;
|
||||
if (selected.is("div")) selected = selected.parent();
|
||||
if (selected.is("div")) selected = selected.parent(); // when the selected item is a parent
|
||||
|
||||
var scrolling = document.getElementById(nav);
|
||||
var navHeight = navObj.height();
|
||||
var offsetTop = selected.position().top;
|
||||
if (selected.parent().parent().is(".toggle-list")) offsetTop += selected.parent().parent().position().top;
|
||||
if(offsetTop > navHeight - 92) {
|
||||
scrolling.scrollTop = offsetTop - navHeight + 92;
|
||||
|
||||
// handle nested items
|
||||
if (selected.parent().parent().is(".toggle-list")) {
|
||||
selected = selected.parent().parent();
|
||||
// handle second level nested items
|
||||
if (selected.parent().parent().is(".toggle-list")) {
|
||||
selected = selected.parent().parent();
|
||||
}
|
||||
offsetTop += selected.position().top;
|
||||
}
|
||||
|
||||
// 180px from the bottom of the list is the threshold
|
||||
if(offsetTop > navHeight - 180) {
|
||||
scrolling.scrollTop = offsetTop - navHeight + 180;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue