11/*!
22 * angular-ui-scroll
33 * 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
55 * License: MIT
66 */
77
@@ -586,15 +586,21 @@ angular.module('ui.scroll', []).directive('uiScrollViewport', function () {
586586 adapter . reload = reload ;
587587
588588 // 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+ }
591593 viewport . bind ( 'mousewheel' , wheelHandler ) ;
592594
595+ function unbindEvents ( ) {
596+ viewport . unbind ( 'resize' , resizeAndScrollHandler ) ;
597+ viewport . unbind ( 'scroll' , resizeAndScrollHandler ) ;
598+ }
599+
593600 $scope . $on ( '$destroy' , function ( ) {
594601 // clear the buffer. It is necessary to remove the elements and $destroy the scopes
595602 buffer . clear ( ) ;
596- viewport . unbind ( 'resize' , resizeAndScrollHandler ) ;
597- viewport . unbind ( 'scroll' , resizeAndScrollHandler ) ;
603+ unbindEvents ( ) ;
598604 viewport . unbind ( 'mousewheel' , wheelHandler ) ;
599605 } ) ;
600606
@@ -634,6 +640,10 @@ angular.module('ui.scroll', []).directive('uiScrollViewport', function () {
634640 viewport . resetTopPaddingHeight ( ) ;
635641 viewport . resetBottomPaddingHeight ( ) ;
636642
643+ adapter . abCount = 0 ;
644+ adapter . abfCount = 0 ;
645+ adapter . sCount = 0 ;
646+
637647 if ( arguments . length ) {
638648 buffer . clear ( arguments [ 0 ] ) ;
639649 } else {
@@ -755,6 +765,7 @@ angular.module('ui.scroll', []).directive('uiScrollViewport', function () {
755765 function adjustBuffer ( rid ) {
756766 // We need the item bindings to be processed before we can do adjustment
757767 return $timeout ( function ( ) {
768+ adapter . abCount ++ ;
758769 processBufferedItems ( rid ) ;
759770
760771 if ( viewport . shouldLoadBottom ( ) ) {
@@ -772,6 +783,7 @@ angular.module('ui.scroll', []).directive('uiScrollViewport', function () {
772783 function adjustBufferAfterFetch ( rid ) {
773784 // We need the item bindings to be processed before we can do adjustment
774785 return $timeout ( function ( ) {
786+ adapter . abfCount ++ ;
775787 var keepFetching = processBufferedItems ( rid ) ;
776788
777789 if ( viewport . shouldLoadBottom ( ) && keepFetching ) {
@@ -787,6 +799,7 @@ angular.module('ui.scroll', []).directive('uiScrollViewport', function () {
787799
788800 if ( ! pending . length ) {
789801 adapter . loading ( false ) ;
802+ bindEvents ( ) ;
790803 return adapter . calculateProperties ( ) ;
791804 }
792805
@@ -852,7 +865,16 @@ angular.module('ui.scroll', []).directive('uiScrollViewport', function () {
852865
853866 function resizeAndScrollHandler ( ) {
854867 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+ }
856878 }
857879 }
858880
0 commit comments