Add offset option to scrollspy initialization (#3354)
## Fix ToC Scroll-Spy Highlighting Issue ### Problem When clicking on a ToC link in the sidebar, the page scrolls to the correct section, but the ToC highlights the *previous* section instead of the current one. The correct section only gets highlighted after scrolling down a few pixels. ### Root Cause The `scrollspy` in `assets/js/common.js` was initialized without an offset parameter, so it didn't account for the fixed navigation header height (~56px). ### Solution Added `offset: 100` parameter to the scrollspy initialization to properly detect when a section becomes visible, accounting for the header and some buffer space. ### Changes - Modified `assets/js/common.js`: Added offset parameter to scrollspy configuration ### Testing - [x] ToC correctly highlights the current section immediately after clicking - [x] Headings remain visible (not hidden under header) - [x] Smooth scrolling works as expected --------- Co-authored-by: Maruan <alshedivat@users.noreply.github.com>
This commit is contained in:
parent
0d07f7ca51
commit
729f136fb0
@ -28,6 +28,7 @@ $(document).ready(function () {
|
||||
Toc.init($myNav);
|
||||
$("body").scrollspy({
|
||||
target: navSelector,
|
||||
offset: 100,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user