Skip to content

Instantly share code, notes, and snippets.

@teebot
Created January 12, 2016 11:17
Show Gist options
  • Save teebot/1ef8b4e679ca2642a00f to your computer and use it in GitHub Desktop.
Save teebot/1ef8b4e679ca2642a00f to your computer and use it in GitHub Desktop.
sticky scroll directive in coffeescript
appDirectives.directive 'stickyScroll', ->
return {
restrict: 'A'
link: (scope, element, attr) ->
unregisterWatch = scope.$watch(
-> return element[0].scrollHeight,
->
element[0].scrollTop = element[0].scrollHeight
)
element.on '$destroy', ->
unregisterWatch()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment