Skip to content

Highlighting fails of highlights wrong item #34

Closed
@andrekampert

Description

@andrekampert

There are two symptoms of a problem with highlighting:

Highlighting not updated

When scrolling larger pages really fast, sometimes the highlighting is not updated due to events being skipped. This is because for some reason we never get a position within the offset, so the update is skipped entirely (line 622)

javascript
if ((Math.abs($(this).offset().top - winScrollTop) < self.options.highlightOffset))

#### Highlight wrong item after clicking in toc

Sometimes, based on the structure of the page, another item is highlighted in the TOC, because after scrolling tocify consider an item on top within the highlightOffset. However, the item below is closer, so should be highlighted instead of the first item within the highlightOffset.
#### Proposed solution

Instead of the first element within the highlightOffset, use the one closest to the current position. I've made this improvement in a fork and will create a pull request.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions