@@ -93,20 +93,21 @@ angular.module('ui.scroll', [])
93
93
function Buffer ( itemName , $scope , linker , bufferSize ) {
94
94
const buffer = Object . create ( Array . prototype ) ;
95
95
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
-
107
96
angular . extend ( buffer , {
108
97
size : bufferSize ,
109
98
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
+
110
111
append ( items ) {
111
112
items . forEach ( ( item ) => {
112
113
++ buffer . next ;
@@ -176,16 +177,9 @@ angular.module('ui.scroll', [])
176
177
177
178
setLower ( ) {
178
179
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 ) ;
185
180
}
186
- } ) ;
187
181
188
- reset ( 1 ) ;
182
+ } ) ;
189
183
190
184
return buffer ;
191
185
}
@@ -656,7 +650,7 @@ angular.module('ui.scroll', [])
656
650
657
651
$scope . $on ( '$destroy' , ( ) => {
658
652
// 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
660
654
unbindEvents ( ) ;
661
655
viewport . unbind ( 'mousewheel' , wheelHandler ) ;
662
656
} ) ;
@@ -691,7 +685,7 @@ angular.module('ui.scroll', [])
691
685
if ( arguments . length )
692
686
startIndex = arguments [ 0 ] ;
693
687
694
- buffer . clear ( startIndex ) ;
688
+ buffer . reset ( startIndex ) ;
695
689
696
690
return adjustBuffer ( ridActual ) ;
697
691
}
0 commit comments