@@ -523,6 +523,7 @@ angular.module('ui.scroll', [])
523
523
const itemName = match [ 1 ] ;
524
524
const datasourceName = match [ 2 ] ;
525
525
const bufferSize = Math . max ( 3 , + attr . bufferSize || 10 ) ;
526
+ var startIndex = + attr . startIndex || 1 ;
526
527
527
528
return function link ( $scope , element , $attr , controllers , linker ) {
528
529
// starting from angular 1.2 compileLinker usage is deprecated
@@ -647,44 +648,29 @@ angular.module('ui.scroll', [])
647
648
648
649
adapter . reload = reload ;
649
650
650
- // events and bindings
651
- function bindEvents ( ) {
652
- viewport . bind ( 'resize' , resizeAndScrollHandler ) ;
653
- viewport . bind ( 'scroll' , resizeAndScrollHandler ) ;
654
- }
655
- viewport . bind ( 'mousewheel' , wheelHandler ) ;
656
-
657
- function unbindEvents ( ) {
658
- viewport . unbind ( 'resize' , resizeAndScrollHandler ) ;
659
- viewport . unbind ( 'scroll' , resizeAndScrollHandler ) ;
660
- }
661
-
662
651
$scope . $on ( '$destroy' , ( ) => {
663
652
// clear the buffer. It is necessary to remove the elements and $destroy the scopes
664
653
buffer . clear ( ) ;
665
654
unbindEvents ( ) ;
666
655
viewport . unbind ( 'mousewheel' , wheelHandler ) ;
667
656
} ) ;
668
657
669
- // update events (deprecated since v1.1.0, unsupported since 1.2.0)
670
- ( ( ) => {
671
- const eventListener = datasource . scope ? datasource . scope . $new ( ) : $scope . $new ( ) ;
672
-
673
- eventListener . $on ( 'insert.item' , ( ) => unsupportedMethod ( 'insert' ) ) ;
674
-
675
- eventListener . $on ( 'update.items' , ( ) => unsupportedMethod ( 'update' ) ) ;
676
-
677
- eventListener . $on ( 'delete.items' , ( ) => unsupportedMethod ( 'delete' ) ) ;
678
-
679
- function unsupportedMethod ( token ) {
680
- throw new Error ( token + ' event is no longer supported - use applyUpdates instead' ) ;
681
- }
682
- } ) ( ) ;
658
+ viewport . bind ( 'mousewheel' , wheelHandler ) ;
683
659
684
660
reload ( ) ;
685
661
686
662
/* Functions definitions */
687
663
664
+ function bindEvents ( ) {
665
+ viewport . bind ( 'resize' , resizeAndScrollHandler ) ;
666
+ viewport . bind ( 'scroll' , resizeAndScrollHandler ) ;
667
+ }
668
+
669
+ function unbindEvents ( ) {
670
+ viewport . unbind ( 'resize' , resizeAndScrollHandler ) ;
671
+ viewport . unbind ( 'scroll' , resizeAndScrollHandler ) ;
672
+ }
673
+
688
674
function dismissPendingRequests ( ) {
689
675
ridActual ++ ;
690
676
pending = [ ] ;
@@ -696,15 +682,10 @@ angular.module('ui.scroll', [])
696
682
viewport . resetTopPadding ( ) ;
697
683
viewport . resetBottomPadding ( ) ;
698
684
699
- adapter . abCount = 0 ;
700
- adapter . abfCount = 0 ;
701
- adapter . sCount = 0 ;
685
+ if ( arguments . length )
686
+ startIndex = arguments [ 0 ] ;
702
687
703
- if ( arguments . length ) {
704
- buffer . clear ( arguments [ 0 ] ) ;
705
- } else {
706
- buffer . clear ( ) ;
707
- }
688
+ buffer . clear ( startIndex ) ;
708
689
709
690
return adjustBuffer ( ridActual ) ;
710
691
}
@@ -812,7 +793,6 @@ angular.module('ui.scroll', [])
812
793
function adjustBuffer ( rid ) {
813
794
// We need the item bindings to be processed before we can do adjustment
814
795
return $timeout ( ( ) => {
815
- adapter . abCount ++ ;
816
796
processBufferedItems ( rid ) ;
817
797
818
798
if ( viewport . shouldLoadBottom ( ) ) {
@@ -830,7 +810,6 @@ angular.module('ui.scroll', [])
830
810
function adjustBufferAfterFetch ( rid ) {
831
811
// We need the item bindings to be processed before we can do adjustment
832
812
return $timeout ( ( ) => {
833
- adapter . abfCount ++ ;
834
813
let keepFetching = processBufferedItems ( rid ) ;
835
814
836
815
if ( viewport . shouldLoadBottom ( ) && keepFetching ) {
@@ -911,7 +890,6 @@ angular.module('ui.scroll', [])
911
890
912
891
function resizeAndScrollHandler ( ) {
913
892
if ( ! $rootScope . $$phase && ! adapter . isLoading ) {
914
- adapter . sCount ++ ;
915
893
if ( viewport . shouldLoadBottom ( ) ) {
916
894
enqueueFetch ( ridActual , true ) ;
917
895
} else if ( viewport . shouldLoadTop ( ) ) {
0 commit comments