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', [])
103103
104104 let onRenderHandlers = [ ] ;
105105 function onRenderHandlersRunner ( ) {
106- onRenderHandlers . forEach ( handler => handler ( ) ) ;
106+ onRenderHandlers . forEach ( handler => handler . run ( ) ) ;
107107 onRenderHandlers = [ ] ;
108108 }
109109 function persistDatasourceIndex ( datasource , propName ) {
@@ -112,7 +112,11 @@ angular.module('ui.scroll', [])
112112 if ( Number . isInteger ( datasource [ propName ] ) ) {
113113 getter = datasource [ propName ] ;
114114 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+ } ) ;
116120 }
117121 }
118122 }
Original file line number Diff line number Diff line change @@ -85,7 +85,7 @@ describe('uiScroll user min/max indicies.', () => {
8585 ) ;
8686 } ) ;
8787
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) ' , ( ) => {
8989 const viewportHeight = 450 ;
9090 const _topItemsCount = Math . round ( viewportHeight * 0.5 / itemHeight ) ;
9191 const _topPackCount = Math . ceil ( _topItemsCount / bufferSize ) ;
@@ -100,7 +100,7 @@ describe('uiScroll user min/max indicies.', () => {
100100 ) ;
101101 } ) ;
102102
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) ' , ( ) => {
104104 const viewportHeight = 450 ;
105105 const _topItemsCount = Math . round ( viewportHeight * 0.5 / itemHeight ) ;
106106 const _topPackCount = Math . ceil ( _topItemsCount / bufferSize ) ;
@@ -122,6 +122,7 @@ describe('uiScroll user min/max indicies.', () => {
122122 beforeEach ( ( ) => {
123123 datasource . min = userMinIndex ;
124124 datasource . max = userMaxIndex ;
125+ datasource . init ( ) ;
125126 } ) ;
126127
127128 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', [])
188188 ] )
189189
190190
191- . factory ( 'myResponsiveDatasource' , [
192- '$log' , '$timeout' , '$rootScope' ,
193- function ( ) {
191+ . factory ( 'myResponsiveDatasource' , function ( ) {
194192 var datasource = {
195193 data : [ ] ,
196194 min : 1 ,
197195 max : 30 ,
198196 init : function ( ) {
197+ this . data = [ ] ;
199198 for ( var i = this . min ; i <= this . max ; i ++ ) {
200199 this . data . push ( 'item' + i ) ;
201200 }
@@ -218,4 +217,4 @@ angular.module('ui.scroll.test.datasources', [])
218217 datasource . init ( ) ;
219218 return datasource ;
220219 }
221- ] ) ;
220+ ) ;
You can’t perform that action at this time.
0 commit comments