Skip to content

Commit 619c49e

Browse files
authored
ADD: scrolling to active TOC if TOC > viewport.
Scrolling to center active TOC element if TOC content is taller then viewport.
1 parent 61086aa commit 619c49e

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

source/js/src/post-details.js

+3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ $(document).ready(function () {
1717

1818
removeCurrentActiveClass();
1919
$currentActiveElement.addClass('active-current');
20+
21+
// Scrolling to center active TOC element if TOC content is taller then viewport.
22+
$tocElement.scrollTop($currentActiveElement.offset().top - $tocElement.offset().top + $tocElement.scrollTop() - ($tocElement.height() / 2));
2023
})
2124
.on('clear.bs.scrollspy', removeCurrentActiveClass);
2225

0 commit comments

Comments
 (0)