Open legos opened 11 years ago
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);
}
>>>>
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?