1- /* ng-infinite-scroll - v1.1.0 - 2014-04-03 */
1+ /* ng-infinite-scroll - v1.1.1 - 2014-05-14 */
22var mod ;
33
44mod = angular . module ( 'infinite-scroll' , [ ] ) ;
@@ -23,20 +23,31 @@ mod.directive('infiniteScroll', [
2323 container = null ;
2424 immediateCheck = true ;
2525 handler = function ( ) {
26- var containerBottom , elementBottom , remaining , shouldScroll ;
26+ var containerBottom , containerTopOffset , elementBottom , remaining , shouldScroll ;
2727 if ( container === $window ) {
2828 containerBottom = container . height ( ) + container . scrollTop ( ) ;
2929 elementBottom = elem . offset ( ) . top + elem . height ( ) ;
3030 } else {
3131 containerBottom = container . height ( ) ;
32- elementBottom = elem . offset ( ) . top - container . offset ( ) . top + elem . height ( ) ;
32+ containerTopOffset = 0 ;
33+ if ( container . offset ( ) !== void 0 ) {
34+ containerTopOffset = container . offset ( ) . top ;
35+ }
36+ elementBottom = elem . offset ( ) . top - containerTopOffset + elem . height ( ) ;
3337 }
3438 remaining = elementBottom - containerBottom ;
3539 shouldScroll = remaining <= container . height ( ) * scrollDistance + 1 ;
36- if ( shouldScroll && scrollEnabled ) {
37- return scope . infiniteScroll ( ) ;
38- } else if ( shouldScroll ) {
39- return checkWhenEnabled = true ;
40+ if ( shouldScroll ) {
41+ checkWhenEnabled = true ;
42+ if ( scrollEnabled ) {
43+ if ( scope . $$phase || $rootScope . $$phase ) {
44+ return scope . infiniteScroll ( ) ;
45+ } else {
46+ return scope . $apply ( scope . infiniteScroll ) ;
47+ }
48+ }
49+ } else {
50+ return checkWhenEnabled = false ;
4051 }
4152 } ;
4253 throttle = function ( func , wait ) {
@@ -92,7 +103,7 @@ mod.directive('infiniteScroll', [
92103 if ( container != null ) {
93104 container . off ( 'scroll' , handler ) ;
94105 }
95- container = newContainer ;
106+ container = typeof newContainer . last === 'function' ? newContainer . last ( ) : newContainer ;
96107 if ( newContainer != null ) {
97108 return container . on ( 'scroll' , handler ) ;
98109 }
0 commit comments