1
1
/*!
2
2
* angular-ui-scroll
3
3
* https://github.com/angular-ui/ui-scroll.git
4
- * Version: 1.3.3 -- 2016-03-16T09:12:39.242Z
4
+ * Version: 1.3.3 -- 2016-03-17T12:18:01.421Z
5
5
* License: MIT
6
6
*/
7
7
@@ -586,15 +586,21 @@ angular.module('ui.scroll', []).directive('uiScrollViewport', function () {
586
586
adapter . reload = reload ;
587
587
588
588
// events and bindings
589
- viewport . bind ( 'resize' , resizeAndScrollHandler ) ;
590
- viewport . bind ( 'scroll' , resizeAndScrollHandler ) ;
589
+ function bindEvents ( ) {
590
+ viewport . bind ( 'resize' , resizeAndScrollHandler ) ;
591
+ viewport . bind ( 'scroll' , resizeAndScrollHandler ) ;
592
+ }
591
593
viewport . bind ( 'mousewheel' , wheelHandler ) ;
592
594
595
+ function unbindEvents ( ) {
596
+ viewport . unbind ( 'resize' , resizeAndScrollHandler ) ;
597
+ viewport . unbind ( 'scroll' , resizeAndScrollHandler ) ;
598
+ }
599
+
593
600
$scope . $on ( '$destroy' , function ( ) {
594
601
// clear the buffer. It is necessary to remove the elements and $destroy the scopes
595
602
buffer . clear ( ) ;
596
- viewport . unbind ( 'resize' , resizeAndScrollHandler ) ;
597
- viewport . unbind ( 'scroll' , resizeAndScrollHandler ) ;
603
+ unbindEvents ( ) ;
598
604
viewport . unbind ( 'mousewheel' , wheelHandler ) ;
599
605
} ) ;
600
606
@@ -634,6 +640,10 @@ angular.module('ui.scroll', []).directive('uiScrollViewport', function () {
634
640
viewport . resetTopPaddingHeight ( ) ;
635
641
viewport . resetBottomPaddingHeight ( ) ;
636
642
643
+ adapter . abCount = 0 ;
644
+ adapter . abfCount = 0 ;
645
+ adapter . sCount = 0 ;
646
+
637
647
if ( arguments . length ) {
638
648
buffer . clear ( arguments [ 0 ] ) ;
639
649
} else {
@@ -755,6 +765,7 @@ angular.module('ui.scroll', []).directive('uiScrollViewport', function () {
755
765
function adjustBuffer ( rid ) {
756
766
// We need the item bindings to be processed before we can do adjustment
757
767
return $timeout ( function ( ) {
768
+ adapter . abCount ++ ;
758
769
processBufferedItems ( rid ) ;
759
770
760
771
if ( viewport . shouldLoadBottom ( ) ) {
@@ -772,6 +783,7 @@ angular.module('ui.scroll', []).directive('uiScrollViewport', function () {
772
783
function adjustBufferAfterFetch ( rid ) {
773
784
// We need the item bindings to be processed before we can do adjustment
774
785
return $timeout ( function ( ) {
786
+ adapter . abfCount ++ ;
775
787
var keepFetching = processBufferedItems ( rid ) ;
776
788
777
789
if ( viewport . shouldLoadBottom ( ) && keepFetching ) {
@@ -787,6 +799,7 @@ angular.module('ui.scroll', []).directive('uiScrollViewport', function () {
787
799
788
800
if ( ! pending . length ) {
789
801
adapter . loading ( false ) ;
802
+ bindEvents ( ) ;
790
803
return adapter . calculateProperties ( ) ;
791
804
}
792
805
@@ -852,7 +865,16 @@ angular.module('ui.scroll', []).directive('uiScrollViewport', function () {
852
865
853
866
function resizeAndScrollHandler ( ) {
854
867
if ( ! $rootScope . $$phase && ! adapter . isLoading ) {
855
- adjustBuffer ( ) ;
868
+ adapter . sCount ++ ;
869
+ if ( viewport . shouldLoadBottom ( ) ) {
870
+ enqueueFetch ( ridActual , true ) ;
871
+ } else if ( viewport . shouldLoadTop ( ) ) {
872
+ enqueueFetch ( ridActual , false ) ;
873
+ }
874
+
875
+ if ( pending . length ) {
876
+ unbindEvents ( ) ;
877
+ }
856
878
}
857
879
}
858
880
0 commit comments