Skip to content

Commit

Permalink
Refactored init code.
Browse files Browse the repository at this point in the history
  • Loading branch information
oblador committed Mar 28, 2014
1 parent f4f78ef commit b4d2adf
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 20 deletions.
12 changes: 3 additions & 9 deletions angular-scroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ factory('scrollPosition',
};

var observers = [];
var lastScrollY = getScrollY();
var currentScrollY = 0;
var lastScrollY;
var currentScrollY;

var executeCallbacks = function(){
currentScrollY = lastScrollY;
Expand All @@ -54,13 +54,7 @@ factory('scrollPosition',
}
};

angular.element($document).on('scroll', onScroll);
//Init
executeCallbacks();
//Redo init after reflows and initial anchor jump
angular.element($window).on('load', function() {
$timeout(executeCallbacks, 10);
});
angular.element($document).on('scroll', onScroll).triggerHandler('scroll');

var deprecationWarned = false;
return {
Expand Down
2 changes: 1 addition & 1 deletion angular-scroll.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion angular-scroll.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit b4d2adf

Please sign in to comment.