Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Last item in TOC keeps getting set to active #26

Open
legos opened this issue Jul 29, 2013 · 1 comment
Open

Last item in TOC keeps getting set to active #26

legos opened this issue Jul 29, 2013 · 1 comment

Comments

@legos
Copy link

legos commented Jul 29, 2013

I'm not sure what's going on but the last item in my TOC keeps being set as the active one when I scroll to the top of the page. Any thoughts?

@scinart
Copy link

scinart commented Feb 12, 2014

with following hackings, I managed to let it working, at least it seems to work on my github.io
I'm not quite familiar with jQuery though.

  for (var i = 0, c = headingOffsets.length; i < c; i++) {
    if (headingOffsets[i] >= top) {
      $('li', self).removeClass(activeClassName);
<<<<
      highlighted = $('li:eq('+(i-1)+')', self).addClass(activeClassName);
====
      highlighted = $('li:eq('+((i-1)<0?0:i-1)+')', self).addClass(activeClassName);
>>>>
      opts.onHighlight(highlighted);
      break;
    }
  }
<<<<
====
  // added by scinart.
  if (i == headingOffsets.length)
  {
    $('li', self).removeClass(activeClassName);
    highlighted = $('li:eq('+(i-1)+')', self).addClass(activeClassName);
    opts.onHighlight(highlighted);
  }
>>>>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants