jgallen23 / toc

Table of Contents Plugin
http://projects.jga.me/toc/
MIT License
531 stars 111 forks source link

Clicking on menu items that scroll to near the bottom of the document highlight the wrong menu item #1

Open brendanheywood opened 12 years ago

brendanheywood commented 12 years ago

Test case:

http://projects.jga.me/toc/#toc0

Click on any menu item that refers to an item that is within one page height of the bottom of the document, so on my screen these include History down to Contributions. It then smooth scrolls down to this item, but then when the menu highlight code kicks in it detects that it is only up to the Example CSS section which is the first section visible on the page.

I'd just test if the page bottom was hit as part of the scroll and if so explicitly set the menu item to highlight the on that was just clicked and not do the current location detection.

jtwalters commented 12 years ago

I experience the same issue on the link you referenced—the highlightOnScroll option often highlights the wrong item.

+1 on your proposal to detect hitting page-bottom and override the highlightOnScroll feature in that case.