Skip to content

Commit 4fd9fbd

Browse files
committed
update toc experience.
1 parent 72f8389 commit 4fd9fbd

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

docs/_layouts/stdlib-reference.html

+17
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,12 @@
315315
var pageName = path.substr(firstSlash);
316316
var dotLoc = pageName.lastIndexOf(".");
317317
if (dotLoc == -1)
318+
{
318319
dotLoc = pageName.length;
320+
if (!pageName.endsWith("/"))
321+
pageName += "/";
322+
pageName += "index";
323+
}
319324
var currentPageID = pageName.substr(0, dotLoc);
320325

321326
var tocLists = document.getElementsByClassName("toc_root_list");
@@ -356,8 +361,20 @@
356361
curItem.getAttribute("class").startsWith("toc_root_list"))
357362
break;
358363
}
364+
// Restore scrollbar position.
365+
window.onbeforeunload = function() {
366+
window.name = window.scrollY;
367+
};
368+
if (window.name.length() != 0)
369+
{
370+
var lastScrollPosition = parseInt(window.name);
371+
tocColumn.scroll(0, lastScrollPosition);
372+
}
373+
// Ensure the selected item is visible.
359374
if (selectedItem != null)
375+
{
360376
selectedItem.scrollIntoView(true);
377+
}
361378
var subItems = selectedItem.getElementsByTagName("li");
362379
var subSectionTitles = [];
363380
var subSectionTitleStrs = [];

0 commit comments

Comments
 (0)