@@ -104,16 +104,14 @@ angular.module('ui.scroll', [])
104104 Object . defineProperty ( datasource , propName , {
105105 set : ( value ) => {
106106 indexStore [ propName ] = value ;
107- $timeout ( ( ) => {
108- buffer [ propUserName ] = value ;
109- if ( ! pending . length ) {
110- let topPaddingHeightOld = viewport . topDataPos ( ) ;
111- viewport . adjustPadding ( ) ;
112- if ( propName === 'minIndex' ) {
113- viewport . adjustScrollTopAfterMinIndexSet ( topPaddingHeightOld ) ;
114- }
107+ buffer [ propUserName ] = value ;
108+ if ( ! pending . length ) {
109+ let topPaddingHeightOld = viewport . topDataPos ( ) ;
110+ viewport . adjustPadding ( ) ;
111+ if ( propName === 'minIndex' ) {
112+ viewport . adjustScrollTopAfterMinIndexSet ( topPaddingHeightOld ) ;
115113 }
116- } ) ;
114+ }
117115 } ,
118116 get : ( ) => indexStore [ propName ]
119117 } ) ;
@@ -333,52 +331,49 @@ angular.module('ui.scroll', [])
333331 let updates = updateDOM ( ) ;
334332
335333 // We need the item bindings to be processed before we can do adjustment
336- $scope . $apply ( ( ) => $timeout ( ( ) => {
334+ ! $scope . $$phase && $scope . $digest ( ) ;
337335
338- // show elements after data binging has been done
339- updates . inserted . forEach ( w => w . element . removeClass ( 'ng-hide' ) ) ;
340- updates . prepended . forEach ( w => w . element . removeClass ( 'ng-hide' ) ) ;
336+ updates . inserted . forEach ( w => w . element . removeClass ( 'ng-hide' ) ) ;
337+ updates . prepended . forEach ( w => w . element . removeClass ( 'ng-hide' ) ) ;
341338
342- if ( isInvalid ( rid ) ) {
343- return ;
344- }
339+ if ( isInvalid ( rid ) ) {
340+ return ;
341+ }
345342
346- updatePaddings ( rid , updates ) ;
347- enqueueFetch ( rid ) ;
343+ updatePaddings ( rid , updates ) ;
344+ enqueueFetch ( rid ) ;
348345
349- if ( ! pending . length ) {
350- adapter . calculateProperties ( ) ;
351- }
352- } ) ) ;
346+ if ( ! pending . length ) {
347+ adapter . calculateProperties ( ) ;
348+ }
353349 }
354350
355351 function adjustBufferAfterFetch ( rid ) {
356352 let updates = updateDOM ( ) ;
357353
358354 // We need the item bindings to be processed before we can do adjustment
359- $scope . $apply ( ( ) => $timeout ( ( ) => {
360- // show elements after data binging has been done
361- updates . inserted . forEach ( w => w . element . removeClass ( 'ng-hide' ) ) ;
362- updates . prepended . forEach ( w => w . element . removeClass ( 'ng-hide' ) ) ;
355+ ! $scope . $$phase && $scope . $digest ( ) ;
363356
364- viewport . adjustScrollTopAfterPrepend ( updates ) ;
357+ updates . inserted . forEach ( w => w . element . removeClass ( 'ng-hide' ) ) ;
358+ updates . prepended . forEach ( w => w . element . removeClass ( 'ng-hide' ) ) ;
365359
366- if ( isInvalid ( rid ) ) {
367- return ;
368- }
360+ viewport . adjustScrollTopAfterPrepend ( updates ) ;
369361
370- updatePaddings ( rid , updates ) ;
371- enqueueFetch ( rid , updates ) ;
372- pending . shift ( ) ;
362+ if ( isInvalid ( rid ) ) {
363+ return ;
364+ }
373365
374- if ( pending . length )
375- fetch ( rid ) ;
376- else {
377- adapter . loading ( false ) ;
378- bindEvents ( ) ;
379- adapter . calculateProperties ( ) ;
380- }
381- } ) ) ;
366+ updatePaddings ( rid , updates ) ;
367+ enqueueFetch ( rid , updates ) ;
368+ pending . shift ( ) ;
369+
370+ if ( pending . length )
371+ fetch ( rid ) ;
372+ else {
373+ adapter . loading ( false ) ;
374+ bindEvents ( ) ;
375+ adapter . calculateProperties ( ) ;
376+ }
382377 }
383378
384379 function fetch ( rid ) {
@@ -439,7 +434,7 @@ angular.module('ui.scroll', [])
439434 unbindEvents ( ) ;
440435 } else {
441436 adapter . calculateProperties ( ) ;
442- $scope . $apply ( ) ;
437+ ! $scope . $$phase && $scope . $digest ( ) ;
443438 }
444439 }
445440 }
0 commit comments