Created
January 12, 2016 11:17
-
-
Save teebot/1ef8b4e679ca2642a00f to your computer and use it in GitHub Desktop.
sticky scroll directive in coffeescript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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