Skip to content

Instantly share code, notes, and snippets.

@Luxiyalu
Created September 30, 2014 09:05
Show Gist options
  • Save Luxiyalu/71d984807f3325811614 to your computer and use it in GitHub Desktop.
Save Luxiyalu/71d984807f3325811614 to your computer and use it in GitHub Desktop.
AngularJS Directive: Scroll
app.directive 'scroll', ($window) ->
restrict: 'A'
($scope, $element, $attr) ->
win = angular.element($window)
$scope.$watch ->
scrollX: window.scrollX
scrollY: window.scrollY
, (newVal, oldVal) ->
$scope.scrollX = newVal.scrollY
$scope.scrollY = newVal.scrollY
, true
win.bind 'scroll', ->
$scope.$apply()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment