Skip to content

Commit

Permalink
Fix offset top on directive load
Browse files Browse the repository at this point in the history
  • Loading branch information
rothlis committed Jan 6, 2015
1 parent 39e3d95 commit cca875e
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions sticky.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
angular.module("sticky", []).directive("sticky", ['$window', function($window) {
angular.module("sticky", []).directive("sticky", ['$window', '$timeout', function($window, $timeout) {
return {
link: function(scope, element, attrs) {

Expand Down Expand Up @@ -51,14 +51,15 @@ angular.module("sticky", []).directive("sticky", ['$window', function($window) {
$win.bind("resize", recheckPositions);
}

var item = {
element: element,
isStuck: false,
placeholder: attrs.usePlaceholder !== undefined,
start: element.offset().top
};

scope._stickyElements.push(item);
$timeout(function(){
var item = {
element: element,
isStuck: false,
placeholder: attrs.usePlaceholder !== undefined,
start: element.offset().top
};
scope._stickyElements.push(item);
});

}
};
Expand Down

0 comments on commit cca875e

Please sign in to comment.