harm-less / angular-sticky

Pure javascript AngularJS directive to make elements stick when scrolling
http://harm-less.github.io/angular-sticky
83 stars 38 forks source link

#31 - fix for no sticky at top of screen #32

Closed dotKev closed 7 years ago

dotKev commented 7 years ago

Connected to issue #31.

angular.element($document[0].body) returns an object with matching html elements, even if there is only one. We only need the first element, not wrapped in angular jqLite.

When bodyEl was being used, bodyEl.scrollTop was evaluating to an anonymous function, which made both sticksAtPositionTop(scrolledDistance) and sticksAtPositionBottom(scrolledDistance) return false when at the top of the screen (scrolledDistance was undefined).

This fixes the Simple bottom anchored demo.