Skip to content

Commit

Permalink
Merge pull request #226 from sergiovilar/master
Browse files Browse the repository at this point in the history
Fixed infinite-scroll-immediate-check behavior
  • Loading branch information
sroze committed Jan 14, 2016
2 parents 03bac29 + 68c505d commit f2fbba2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
12 changes: 8 additions & 4 deletions build/ng-infinite-scroll.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* ng-infinite-scroll - v1.2.0 - 2015-02-14 */
/* ng-infinite-scroll - v1.2.0 - 2015-12-02 */
var mod;

mod = angular.module('infinite-scroll', []);
Expand All @@ -17,7 +17,7 @@ mod.directive('infiniteScroll', [
infiniteScrollListenForEvent: '@'
},
link: function(scope, elem, attrs) {
var changeContainer, checkWhenEnabled, container, handleInfiniteScrollContainer, handleInfiniteScrollDisabled, handleInfiniteScrollDistance, handleInfiniteScrollUseDocumentBottom, handler, height, immediateCheck, offsetTop, pageYOffset, scrollDistance, scrollEnabled, throttle, unregisterEventListener, useDocumentBottom, windowElement;
var changeContainer, checkInterval, checkWhenEnabled, container, handleInfiniteScrollContainer, handleInfiniteScrollDisabled, handleInfiniteScrollDistance, handleInfiniteScrollUseDocumentBottom, handler, height, immediateCheck, offsetTop, pageYOffset, scrollDistance, scrollEnabled, throttle, unregisterEventListener, useDocumentBottom, windowElement;
windowElement = angular.element($window);
scrollDistance = null;
scrollEnabled = null;
Expand All @@ -26,6 +26,7 @@ mod.directive('infiniteScroll', [
immediateCheck = true;
useDocumentBottom = false;
unregisterEventListener = null;
checkInterval = false;
height = function(elem) {
elem = elem[0] || elem;
if (isNaN(elem.offsetHeight)) {
Expand Down Expand Up @@ -76,6 +77,9 @@ mod.directive('infiniteScroll', [
}
}
} else {
if (checkInterval) {
$interval.cancel(checkInterval);
}
return checkWhenEnabled = false;
}
};
Expand Down Expand Up @@ -175,11 +179,11 @@ mod.directive('infiniteScroll', [
if (attrs.infiniteScrollImmediateCheck != null) {
immediateCheck = scope.$eval(attrs.infiniteScrollImmediateCheck);
}
return $interval((function() {
return checkInterval = $interval((function() {
if (immediateCheck) {
return handler();
}
}), 0, 1);
}), 0);
}
};
}
Expand Down
4 changes: 2 additions & 2 deletions build/ng-infinite-scroll.min.js

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

6 changes: 4 additions & 2 deletions src/infinite-scroll.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ mod.directive 'infiniteScroll', ['$rootScope', '$window', '$interval', 'THROTTLE
immediateCheck = true
useDocumentBottom = false
unregisterEventListener = null
checkInterval = false

height = (elem) ->
elem = elem[0] or elem
Expand Down Expand Up @@ -71,6 +72,7 @@ mod.directive 'infiniteScroll', ['$rootScope', '$window', '$interval', 'THROTTLE
else
scope.$apply(scope.infiniteScroll)
else
if checkInterval then $interval.cancel checkInterval
checkWhenEnabled = false

# The optional THROTTLE_MILLISECONDS configuration value specifies
Expand Down Expand Up @@ -198,8 +200,8 @@ mod.directive 'infiniteScroll', ['$rootScope', '$window', '$interval', 'THROTTLE
if attrs.infiniteScrollImmediateCheck?
immediateCheck = scope.$eval(attrs.infiniteScrollImmediateCheck)

$interval (->
checkInterval = $interval (->
if immediateCheck
handler()
), 0, 1
), 0
]

0 comments on commit f2fbba2

Please sign in to comment.