Skip to content

Commit a4b745c

Browse files
committed
extract processUpdates method
1 parent 3c29747 commit a4b745c

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

src/ui-scroll.js

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -340,19 +340,24 @@ angular.module('ui.scroll', [])
340340
}
341341
}
342342

343+
function processUpdates() {
344+
const updates = updateDOM();
345+
346+
// We need the item bindings to be processed before we can do adjustments
347+
!$scope.$$phase && $scope.$digest();
348+
349+
updates.inserted.forEach(w => elementRoutines.showElement(w));
350+
updates.prepended.forEach(w => elementRoutines.showElement(w));
351+
return updates;
352+
}
353+
343354
function adjustBuffer(rid) {
344355
if (!rid) { // dismiss pending requests
345356
pending = [];
346357
rid = ++ridActual;
347358
}
348359

349-
let updates = updateDOM();
350-
351-
// We need the item bindings to be processed before we can do adjustment
352-
!$scope.$$phase && $scope.$digest();
353-
354-
updates.inserted.forEach(w => elementRoutines.showElement(w));
355-
updates.prepended.forEach(w => elementRoutines.showElement(w));
360+
const updates = processUpdates();
356361

357362
if (isInvalid(rid)) {
358363
return;
@@ -367,13 +372,7 @@ angular.module('ui.scroll', [])
367372
}
368373

369374
function adjustBufferAfterFetch(rid) {
370-
let updates = updateDOM();
371-
372-
// We need the item bindings to be processed before we can do adjustment
373-
!$scope.$$phase && $scope.$digest();
374-
375-
updates.inserted.forEach(w => elementRoutines.showElement(w));
376-
updates.prepended.forEach(w => elementRoutines.showElement(w));
375+
const updates = processUpdates();
377376

378377
viewport.onAfterPrepend(updates);
379378

0 commit comments

Comments
 (0)