Skip to content

Refactor and fixes to Angular Directive #202

Open
wants to merge 1 commit into from

2 participants

@toddmotto

This PR restructures the Headroom Directive:

  • Uses a .factory() to return the global dependency and register within Angular DI system
  • Allows HeadroomService to be dependency injected
  • Annotated dependencies for the Directive to prevent non-build system minification errors (such as ngAnnotate)
  • Use Angular's internal $document wrapper over window.document Object
  • Fixes a bug with if (options.scroller) that causes [object Window] error
  • Replaced angular.forEach with native Object loop
  • Reduced $destroy callback function to just headroom.destroy argument

One thing we need to discuss is integration of the isolate scope properties (scope: {} etc):

  • Right now these are two-way binding instructions to Angular using =, however this will not update the right properties currently inside the headroom instance. One way to achieve this is setting up $scope.$watch on each property and registering the correct callback and property setter to achieve desired results.
  • Some unit tests can be added but for an integration this size and with such simplicity I'm going to say don't bother
@toddmotto toddmotto changed the title from chore(angular.headroom): Restructure ng headroom to Refactor and fixes to Angular Directive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.