mirror of
https://github.com/danbulant/api_docs
synced 2026-06-20 14:51:22 +00:00
Update toc javascript to hopefully be more performant
This commit is contained in:
parent
200a871f85
commit
b147e6a2d7
1 changed files with 4 additions and 2 deletions
|
|
@ -681,9 +681,11 @@
|
||||||
self.calculateHeights();
|
self.calculateHeights();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var scrollTop = $(window).scrollTop();
|
||||||
|
|
||||||
// Determines the index of the closest anchor
|
// Determines the index of the closest anchor
|
||||||
self.cachedAnchors.each(function(idx) {
|
self.cachedAnchors.each(function(idx) {
|
||||||
if (self.cachedHeights[idx] - $(window).scrollTop() < 0) {
|
if (self.cachedHeights[idx] - scrollTop < 0) {
|
||||||
closestAnchorIdx = idx;
|
closestAnchorIdx = idx;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -696,7 +698,7 @@
|
||||||
elem = $('li[data-unique="' + anchorText + '"]');
|
elem = $('li[data-unique="' + anchorText + '"]');
|
||||||
|
|
||||||
// If the `highlightOnScroll` option is true and a next element is found
|
// If the `highlightOnScroll` option is true and a next element is found
|
||||||
if(self.options.highlightOnScroll && elem.length) {
|
if(self.options.highlightOnScroll && elem.length && !elem.hasClass(self.focusClass)) {
|
||||||
|
|
||||||
// Removes highlighting from all of the list item's
|
// Removes highlighting from all of the list item's
|
||||||
self.element.find("." + self.focusClass).removeClass(self.focusClass);
|
self.element.find("." + self.focusClass).removeClass(self.focusClass);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue