Skip to content

Instantly share code, notes, and snippets.

View joelcrocker's full-sized avatar

Joel Crocker joelcrocker

  • PagerDuty
  • Toronto, ON
View GitHub Profile
angular.module("ui-utils-too", []).
directive("scrollfollow", ["$window", ($window) ->
restrict: "A"
link: (scope, el, attrs) ->
window = angular.element($window)
parent = angular.element(el.parent())
currentOffsetTop = el[0].getBoundingClientRect().top
headerOffsetTop = scope.$eval(attrs.scrollfollow) or 5
# assumes width/padding in px