Skip to content
This repository has been archived by the owner on May 30, 2022. It is now read-only.

Commit

Permalink
fix(macScrollSpy): Fixed not selecting last anchor when scroll to the…
Browse files Browse the repository at this point in the history
… bottom
  • Loading branch information
adrianlee44 committed Oct 22, 2013
1 parent 7bc6d91 commit cf10435
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/directives/scroll_spy.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ angular.module("Mac").directive("macScrollSpy", [
scrollHeight = this.scrollHeight or element[0].scrollHeight
maxScroll = scrollHeight - spyElement.height()

return true if scrollTop >= maxScroll or not scrollSpy.registered.length
return true unless scrollSpy.registered.length

# Select the last anchor when scrollTop is over maxScroll
if scrollTop >= maxScroll and scrollSpy.active.id isnt scrollSpy.last().id
return scrollSpy.setActive scrollSpy.last()

for i in [0..scrollSpy.registered.length - 1]
anchors = scrollSpy.registered
Expand Down
3 changes: 3 additions & 0 deletions src/services/scroll_spy.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ angular.module("Mac").service("scrollSpy", [
@registered[i..i] = []
break

last: ->
@registered[@registered.length - 1]

setActive: (anchor) ->
@active = anchor
listener(anchor) for listener in @listeners
Expand Down

0 comments on commit cf10435

Please sign in to comment.