Skip to content
This repository has been archived by the owner on Aug 10, 2020. It is now read-only.

Commit

Permalink
Merge pull request #28 from seutje/patch-1
Browse files Browse the repository at this point in the history
Tolerance causes the highlighting of nav elements to seem inaccurate
  • Loading branch information
paulirish committed Dec 2, 2011
2 parents dd94613 + e826324 commit f7c0cfd
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions js/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,11 @@
timeout = false, // so gonna clear this later, you have NO idea
last = false, // makes sure the previous link gets un-activated
check = function() {
var scroll = $scrollable.scrollTop(),
height = $body.height(),
tolerance = $window.height() * ( scroll / height );
var scroll = $scrollable.scrollTop();

$.each( cache, function( i, v ) {
// if we're past the link's section, activate it
if ( scroll + tolerance > v.target.position().top ) {
if ( scroll + $navheight > v.target.position().top ) {
last && last.removeClass('active');
last = v.link.addClass('active');
} else {
Expand Down

0 comments on commit f7c0cfd

Please sign in to comment.