Skip to content

Commit

Permalink
IE8 compatability fix for missing window.pageYOffset
Browse files Browse the repository at this point in the history
  • Loading branch information
theshortcut committed Apr 2, 2014
1 parent c0f3027 commit a22fd45
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions angular-smooth-scroll-1.6.0.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,13 @@ angular.module('smoothScroll', [])
//
.factory('smoothScroll', ['$timeout', function($timeout){

var getScrollLocation = function() {
return window.pageYOffset ? window.pageYOffset : document.documentElement.scrollTop;
};

var smoothScroll = function (element, options) {
$timeout(function(){
var startLocation = window.pageYOffset,
var startLocation = getScrollLocation(),
timeLapsed = 0,
percentage, position;

Expand Down Expand Up @@ -132,7 +136,7 @@ angular.module('smoothScroll', [])
// Stop the scrolling animation when the anchor is reached (or at the top/bottom of the page)
//
var stopAnimation = function () {
var currentLocation = window.pageYOffset;
var currentLocation = getScrollLocation();
if ( position == endLocation || currentLocation == endLocation || ( (window.innerHeight + currentLocation) >= document.body.scrollHeight ) ) {
clearInterval(runAnimation);
}
Expand All @@ -158,4 +162,4 @@ angular.module('smoothScroll', [])
};

return smoothScroll;
}]);
}]);
2 changes: 1 addition & 1 deletion angular-smooth-scroll-1.6.0.min.js

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

0 comments on commit a22fd45

Please sign in to comment.