Skip to content

Commit

Permalink
Scrollspy acting up when targets are hidden
Browse files Browse the repository at this point in the history
If elements are hidden using `display: none;` which are targets mapped by scrollspy, the plugin might select an incorrect or no menu item.

Checking if the target is visible solved this.
  • Loading branch information
jasny committed Oct 22, 2013
1 parent 9673c25 commit 5a38a57
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions js/scrollspy.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@

return ($href
&& $href.length
&& $href.is(':visible')
&& [[ $href[offsetMethod]().top + (!$.isWindow(self.$scrollElement.get(0)) && self.$scrollElement.scrollTop()), href ]]) || null
})
.sort(function (a, b) { return a[0] - b[0] })
Expand Down

1 comment on commit 5a38a57

@musukvl
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


Is :visible in Firefox, but invisible in Chrome.

Please sign in to comment.