Skip to content

Commit a03263e

Browse files
committed
min/maxIndexUser explicit checking + distributives
1 parent 3e8d8c6 commit a03263e

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

dist/ui-scroll.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*!
22
* angular-ui-scroll
33
* 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
55
* License: MIT
66
*/
77

@@ -377,18 +377,24 @@ angular.module('ui.scroll', []).directive('uiScrollViewport', function () {
377377
var averageItemHeight = (visibleItemsHeight + topPaddingHeight + bottomPaddingHeight) / (buffer.maxIndex - buffer.minIndex + 1);
378378

379379
// 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;
382382
var topPaddingHeightAdd = adjustTopPadding ? (buffer.minIndex - buffer.minIndexUser) * averageItemHeight : 0;
383383
var bottomPaddingHeightAdd = adjustBottomPadding ? (buffer.maxIndexUser - buffer.maxIndex) * averageItemHeight : 0;
384384

385385
// paddings combine adjustment
386386
topPadding.height(topPaddingHeight + topPaddingHeightAdd);
387387
bottomPadding.height(bottomPaddingHeight + bottomPaddingHeightAdd);
388388
},
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+
},
389395
adjustScrollTopAfterMinIndexSet: function adjustScrollTopAfterMinIndexSet(topPaddingHeightOld) {
390396
// 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) {
392398
var diff = topPadding.height() - topPaddingHeightOld;
393399
viewport.scrollTop(viewport.scrollTop() + diff);
394400
}
@@ -854,10 +860,13 @@ angular.module('ui.scroll', []).directive('uiScrollViewport', function () {
854860
function adjustBufferAfterFetch(rid) {
855861
var updates = updateDOM();
856862

857-
viewport.adjustPadding();
863+
viewport.adjustPaddingUnbound(updates);
858864

859865
// We need the item bindings to be processed before we can do adjustment
860866
$timeout(function () {
867+
868+
viewport.adjustPaddingBound(updates);
869+
861870
if (isInvalid(rid)) {
862871
return;
863872
}

0 commit comments

Comments
 (0)