Skip to content

Instantly share code, notes, and snippets.

@shirashin
Created August 24, 2014 09:29
Show Gist options
  • Select an option

  • Save shirashin/18b2b5b276c3b302b1f8 to your computer and use it in GitHub Desktop.

Select an option

Save shirashin/18b2b5b276c3b302b1f8 to your computer and use it in GitHub Desktop.
timelinesListApp.directive "whenScrolled", ($window) ->
(scope, element, attr) ->
angular.element($window).bind "scroll", ->
scrollTop = document.body.scrollTop || document.documentElement.scrollTop
clientHeight = $window.innerHeight
scrollHeight = document.body.scrollHeight || document.docomentElement.scrollHeight
clientHeight = window.innerHeight if scrollHeight == clientHeight
remain = scrollHeight - clientHeight - scrollTop
if remain <= 30
scope.$apply(attr.whenScrolled)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment