|
1 | 1 | /*! |
2 | 2 | * angular-ui-scroll |
3 | 3 | * https://github.com/angular-ui/ui-scroll.git |
4 | | - * Version: 1.5.0 -- 2016-06-15T12:17:35.738Z |
| 4 | + * Version: 1.5.0 -- 2016-06-19T00:14:16.223Z |
5 | 5 | * License: MIT |
6 | 6 | */ |
7 | 7 |
|
@@ -377,18 +377,24 @@ angular.module('ui.scroll', []).directive('uiScrollViewport', function () { |
377 | 377 | var averageItemHeight = (visibleItemsHeight + topPaddingHeight + bottomPaddingHeight) / (buffer.maxIndex - buffer.minIndex + 1); |
378 | 378 |
|
379 | 379 | // average heights calculation, items that have never been reached |
380 | | - var adjustTopPadding = buffer.minIndexUser && buffer.minIndex > buffer.minIndexUser; |
381 | | - var adjustBottomPadding = buffer.maxIndexUser && buffer.maxIndex < buffer.maxIndexUser; |
| 380 | + var adjustTopPadding = buffer.minIndexUser !== null && buffer.minIndex > buffer.minIndexUser; |
| 381 | + var adjustBottomPadding = buffer.maxIndexUser !== null && buffer.maxIndex < buffer.maxIndexUser; |
382 | 382 | var topPaddingHeightAdd = adjustTopPadding ? (buffer.minIndex - buffer.minIndexUser) * averageItemHeight : 0; |
383 | 383 | var bottomPaddingHeightAdd = adjustBottomPadding ? (buffer.maxIndexUser - buffer.maxIndex) * averageItemHeight : 0; |
384 | 384 |
|
385 | 385 | // paddings combine adjustment |
386 | 386 | topPadding.height(topPaddingHeight + topPaddingHeightAdd); |
387 | 387 | bottomPadding.height(bottomPaddingHeight + bottomPaddingHeightAdd); |
388 | 388 | }, |
| 389 | + adjustPaddingUnbound: function adjustPaddingUnbound(updates) { |
| 390 | + if (updates.prepended && updates.prepended.length) topPadding.height(topPadding.height() + updates.estimatedPaddingIncrement);else viewport.adjustPadding(); |
| 391 | + }, |
| 392 | + adjustPaddingBound: function adjustPaddingBound(updates) { |
| 393 | + if (updates.prepended && updates.prepended.length) topPadding.height(topPadding.height() - updates.estimatedPaddingIncrement); |
| 394 | + }, |
389 | 395 | adjustScrollTopAfterMinIndexSet: function adjustScrollTopAfterMinIndexSet(topPaddingHeightOld) { |
390 | 396 | // additional scrollTop adjustment in case of datasource.minIndex external set |
391 | | - if (buffer.minIndexUser && buffer.minIndex > buffer.minIndexUser) { |
| 397 | + if (buffer.minIndexUser !== null && buffer.minIndex > buffer.minIndexUser) { |
392 | 398 | var diff = topPadding.height() - topPaddingHeightOld; |
393 | 399 | viewport.scrollTop(viewport.scrollTop() + diff); |
394 | 400 | } |
@@ -854,10 +860,13 @@ angular.module('ui.scroll', []).directive('uiScrollViewport', function () { |
854 | 860 | function adjustBufferAfterFetch(rid) { |
855 | 861 | var updates = updateDOM(); |
856 | 862 |
|
857 | | - viewport.adjustPadding(); |
| 863 | + viewport.adjustPaddingUnbound(updates); |
858 | 864 |
|
859 | 865 | // We need the item bindings to be processed before we can do adjustment |
860 | 866 | $timeout(function () { |
| 867 | + |
| 868 | + viewport.adjustPaddingBound(updates); |
| 869 | + |
861 | 870 | if (isInvalid(rid)) { |
862 | 871 | return; |
863 | 872 | } |
|
0 commit comments