@@ -93,20 +93,21 @@ angular.module('ui.scroll', [])
9393 function Buffer ( itemName , $scope , linker , bufferSize ) {
9494 const buffer = Object . create ( Array . prototype ) ;
9595
96- function reset ( origin ) {
97- buffer . eof = false ;
98- buffer . bof = false ;
99- buffer . first = origin ;
100- buffer . next = origin ;
101- buffer . minIndex = origin ;
102- buffer . maxIndex = origin ;
103- buffer . minIndexUser = null ;
104- buffer . maxIndexUser = null ;
105- }
106-
10796 angular . extend ( buffer , {
10897 size : bufferSize ,
10998
99+ reset ( startIndex ) {
100+ buffer . remove ( 0 , buffer . length ) ;
101+ buffer . eof = false ;
102+ buffer . bof = false ;
103+ buffer . first = startIndex ;
104+ buffer . next = startIndex ;
105+ buffer . minIndex = startIndex ;
106+ buffer . maxIndex = startIndex ;
107+ buffer . minIndexUser = null ;
108+ buffer . maxIndexUser = null ;
109+ } ,
110+
110111 append ( items ) {
111112 items . forEach ( ( item ) => {
112113 ++ buffer . next ;
@@ -176,16 +177,9 @@ angular.module('ui.scroll', [])
176177
177178 setLower ( ) {
178179 buffer . minIndex = buffer . bof ? buffer . minIndex = buffer . first : Math . min ( buffer . first , buffer . minIndex ) ;
179- } ,
180-
181- // clears the buffer
182- clear ( ) {
183- buffer . remove ( 0 , buffer . length ) ;
184- arguments . length ? reset ( arguments [ 0 ] ) : reset ( 1 ) ;
185180 }
186- } ) ;
187181
188- reset ( 1 ) ;
182+ } ) ;
189183
190184 return buffer ;
191185 }
@@ -656,7 +650,7 @@ angular.module('ui.scroll', [])
656650
657651 $scope . $on ( '$destroy' , ( ) => {
658652 // clear the buffer. It is necessary to remove the elements and $destroy the scopes
659- buffer . clear ( ) ;
653+ // ******* buffer.clear(); there is no need to reset the buffer especially because the elements are not destroyed by this anyway
660654 unbindEvents ( ) ;
661655 viewport . unbind ( 'mousewheel' , wheelHandler ) ;
662656 } ) ;
@@ -691,7 +685,7 @@ angular.module('ui.scroll', [])
691685 if ( arguments . length )
692686 startIndex = arguments [ 0 ] ;
693687
694- buffer . clear ( startIndex ) ;
688+ buffer . reset ( startIndex ) ;
695689
696690 return adjustBuffer ( ridActual ) ;
697691 }
0 commit comments