File tree Expand file tree Collapse file tree 3 files changed +12
-8
lines changed Expand file tree Collapse file tree 3 files changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -103,7 +103,7 @@ angular.module('ui.scroll', [])
103
103
104
104
let onRenderHandlers = [ ] ;
105
105
function onRenderHandlersRunner ( ) {
106
- onRenderHandlers . forEach ( handler => handler ( ) ) ;
106
+ onRenderHandlers . forEach ( handler => handler . run ( ) ) ;
107
107
onRenderHandlers = [ ] ;
108
108
}
109
109
function persistDatasourceIndex ( datasource , propName ) {
@@ -112,7 +112,11 @@ angular.module('ui.scroll', [])
112
112
if ( Number . isInteger ( datasource [ propName ] ) ) {
113
113
getter = datasource [ propName ] ;
114
114
if ( Number . isInteger ( getter ) ) {
115
- onRenderHandlers . push ( ( ) => datasource [ propName ] = getter ) ;
115
+ onRenderHandlers = onRenderHandlers . filter ( handler => handler . id !== propName ) ;
116
+ onRenderHandlers . push ( {
117
+ id : propName ,
118
+ run : ( ) => datasource [ propName ] = getter
119
+ } ) ;
116
120
}
117
121
}
118
122
}
Original file line number Diff line number Diff line change @@ -85,7 +85,7 @@ describe('uiScroll user min/max indicies.', () => {
85
85
) ;
86
86
} ) ;
87
87
88
- it ( 'should work when the viewport is big enough to include more than 1 pack of item' , ( ) => {
88
+ it ( 'should work when the viewport is big enough to include more than 1 pack of item (last) ' , ( ) => {
89
89
const viewportHeight = 450 ;
90
90
const _topItemsCount = Math . round ( viewportHeight * 0.5 / itemHeight ) ;
91
91
const _topPackCount = Math . ceil ( _topItemsCount / bufferSize ) ;
@@ -100,7 +100,7 @@ describe('uiScroll user min/max indicies.', () => {
100
100
) ;
101
101
} ) ;
102
102
103
- it ( 'should work when the viewport is big enough to include more than 1 pack of item' , ( ) => {
103
+ it ( 'should work when the viewport is big enough to include more than 1 pack of item (first) ' , ( ) => {
104
104
const viewportHeight = 450 ;
105
105
const _topItemsCount = Math . round ( viewportHeight * 0.5 / itemHeight ) ;
106
106
const _topPackCount = Math . ceil ( _topItemsCount / bufferSize ) ;
@@ -122,6 +122,7 @@ describe('uiScroll user min/max indicies.', () => {
122
122
beforeEach ( ( ) => {
123
123
datasource . min = userMinIndex ;
124
124
datasource . max = userMaxIndex ;
125
+ datasource . init ( ) ;
125
126
} ) ;
126
127
127
128
it ( 'should persist user maxIndex after reload' , ( ) => {
Original file line number Diff line number Diff line change @@ -188,14 +188,13 @@ angular.module('ui.scroll.test.datasources', [])
188
188
] )
189
189
190
190
191
- . factory ( 'myResponsiveDatasource' , [
192
- '$log' , '$timeout' , '$rootScope' ,
193
- function ( ) {
191
+ . factory ( 'myResponsiveDatasource' , function ( ) {
194
192
var datasource = {
195
193
data : [ ] ,
196
194
min : 1 ,
197
195
max : 30 ,
198
196
init : function ( ) {
197
+ this . data = [ ] ;
199
198
for ( var i = this . min ; i <= this . max ; i ++ ) {
200
199
this . data . push ( 'item' + i ) ;
201
200
}
@@ -218,4 +217,4 @@ angular.module('ui.scroll.test.datasources', [])
218
217
datasource . init ( ) ;
219
218
return datasource ;
220
219
}
221
- ] ) ;
220
+ ) ;
You can’t perform that action at this time.
0 commit comments