Skip to content

Commit 91fce9f

Browse files
authored
Merge pull request angular-ui#166 from angular-ui/sync
Sync
2 parents 3fa28da + e8055ac commit 91fce9f

17 files changed

+327
-403
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,9 +467,13 @@ PR should include source code (./scr) changes, may include tests (./test) change
467467

468468
## Change log
469469

470+
### v1.7.0
471+
* Reduced dygest cycles amount.
472+
* Refactored tests (removed timeouts).
473+
470474
### v1.6.2
471475
* Added bottomVisible, bottomVisibleElement and bottomVisibleScope properties to the Adapter.
472-
* Fixed some issues [149](https://github.com/angular-ui/ui-scroll/issues/149), [150](https://github.com/angular-ui/ui-scroll/issues/150), [151](https://github.com/angular-ui/ui-scroll/issues/151), [158](https://github.com/angular-ui/ui-scroll/issues/158), [159](https://github.com/angular-ui/ui-scroll/issues/159), [160](https://github.com/angular-ui/ui-scroll/issues/160), [163](https://github.com/angular-ui/ui-scroll/issues/163)
476+
* Fixed some issues [149](https://github.com/angular-ui/ui-scroll/issues/149), [150](https://github.com/angular-ui/ui-scroll/issues/150), [151](https://github.com/angular-ui/ui-scroll/issues/151), [158](https://github.com/angular-ui/ui-scroll/issues/158), [159](https://github.com/angular-ui/ui-scroll/issues/159), [160](https://github.com/angular-ui/ui-scroll/issues/160), [163](https://github.com/angular-ui/ui-scroll/issues/163).
473477

474478
### v1.6.1
475479
* Refactored Adapter assignments logic.

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "angular-ui-scroll",
33
"description": "AngularJS infinite scrolling module",
4-
"version": "1.6.2",
4+
"version": "1.7.0-rc.1",
55
"main": "./dist/ui-scroll.js",
66
"homepage": "https://github.com/angular-ui/ui-scroll.git",
77
"license": "MIT",

dist/ui-scroll-grid.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/ui-scroll-grid.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/ui-scroll-grid.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/ui-scroll-grid.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/ui-scroll.js

Lines changed: 46 additions & 55 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/ui-scroll.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/ui-scroll.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/ui-scroll.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "angular-ui-scroll",
33
"description": "AngularJS infinite scrolling module",
4-
"version": "1.6.2",
4+
"version": "1.7.0-rc.1",
55
"src": "./src/",
66
"public": "./dist/",
77
"main": "./dist/ui-scroll.js",

src/ui-scroll.js

Lines changed: 39 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -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
});
@@ -307,8 +305,8 @@ angular.module('ui.scroll', [])
307305
if (!updates || buffer.effectiveHeight(updates.inserted) > 0) {
308306
// this means that at least one item appended in the last batch has height > 0
309307
if (pending.push(true) === 1) {
310-
fetch(rid);
311308
adapter.loading(true);
309+
fetch(rid);
312310
}
313311
}
314312
} else if (viewport.shouldLoadTop()) {
@@ -317,8 +315,8 @@ angular.module('ui.scroll', [])
317315
// pending[0] = true means that previous fetch was appending. We need to force at least one prepend
318316
// BTW there will always be at least 1 element in the pending array because bottom is fetched first
319317
if (pending.push(false) === 1) {
320-
fetch(rid);
321318
adapter.loading(true);
319+
fetch(rid);
322320
}
323321
}
324322
}
@@ -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.$applyAsync(() => $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.$applyAsync(() => $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

Comments
 (0)