@@ -104,16 +104,14 @@ angular.module('ui.scroll', [])
104
104
Object . defineProperty ( datasource , propName , {
105
105
set : ( value ) => {
106
106
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 ) ;
115
113
}
116
- } ) ;
114
+ }
117
115
} ,
118
116
get : ( ) => indexStore [ propName ]
119
117
} ) ;
@@ -333,52 +331,49 @@ angular.module('ui.scroll', [])
333
331
let updates = updateDOM ( ) ;
334
332
335
333
// We need the item bindings to be processed before we can do adjustment
336
- $scope . $apply ( ( ) => $timeout ( ( ) => {
334
+ ! $scope . $$phase && $scope . $digest ( ) ;
337
335
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' ) ) ;
341
338
342
- if ( isInvalid ( rid ) ) {
343
- return ;
344
- }
339
+ if ( isInvalid ( rid ) ) {
340
+ return ;
341
+ }
345
342
346
- updatePaddings ( rid , updates ) ;
347
- enqueueFetch ( rid ) ;
343
+ updatePaddings ( rid , updates ) ;
344
+ enqueueFetch ( rid ) ;
348
345
349
- if ( ! pending . length ) {
350
- adapter . calculateProperties ( ) ;
351
- }
352
- } ) ) ;
346
+ if ( ! pending . length ) {
347
+ adapter . calculateProperties ( ) ;
348
+ }
353
349
}
354
350
355
351
function adjustBufferAfterFetch ( rid ) {
356
352
let updates = updateDOM ( ) ;
357
353
358
354
// 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 ( ) ;
363
356
364
- viewport . adjustScrollTopAfterPrepend ( updates ) ;
357
+ updates . inserted . forEach ( w => w . element . removeClass ( 'ng-hide' ) ) ;
358
+ updates . prepended . forEach ( w => w . element . removeClass ( 'ng-hide' ) ) ;
365
359
366
- if ( isInvalid ( rid ) ) {
367
- return ;
368
- }
360
+ viewport . adjustScrollTopAfterPrepend ( updates ) ;
369
361
370
- updatePaddings ( rid , updates ) ;
371
- enqueueFetch ( rid , updates ) ;
372
- pending . shift ( ) ;
362
+ if ( isInvalid ( rid ) ) {
363
+ return ;
364
+ }
373
365
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
+ }
382
377
}
383
378
384
379
function fetch ( rid ) {
@@ -439,7 +434,7 @@ angular.module('ui.scroll', [])
439
434
unbindEvents ( ) ;
440
435
} else {
441
436
adapter . calculateProperties ( ) ;
442
- $scope . $apply ( ) ;
437
+ ! $scope . $$phase && $scope . $digest ( ) ;
443
438
}
444
439
}
445
440
}
0 commit comments