Skip to content

Commit 6ae65a7

Browse files
committed
new user indicies reload test and fix for it
1 parent b98ab04 commit 6ae65a7

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

src/ui-scroll.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@ angular.module('ui.scroll', [])
111111
// need to postpone min/maxIndexUser processing if the view is empty
112112
if(datasource.hasOwnProperty(propName) && !buffer.length) {
113113
getter = datasource[propName];
114-
onRenderHandlers.push(() => datasource[propName] = getter);
114+
if(Number.isInteger(getter)) {
115+
onRenderHandlers.push(() => datasource[propName] = getter);
116+
}
115117
}
116118
}
117119

test/UserIndiciesSpec.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -110,20 +110,20 @@ describe('uiScroll user min/max indicies.', () => {
110110
);
111111
});
112112

113-
// it('should persist user minIndex after reload', () => {
114-
// inject(function(myInfiniteDatasource) {
115-
// myInfiniteDatasource.minIndex = userMinIndex;
116-
// });
117-
// runTest(scrollSettings,
118-
// (viewport, scope) => {
119-
// scope.adapter.reload();
120-
// const topPaddingElement = angular.element(viewport.children()[0]);
121-
// const virtualItemsAmount = (-1) * userMinIndex - bufferSize + 1;
122-
// expect(topPaddingElement.height()).toBe(itemHeight * virtualItemsAmount);
123-
// expect(viewport.scrollTop()).toBe(itemHeight * ((-1) * userMinIndex + 1));
124-
// }
125-
// );
126-
// });
113+
it('should persist user minIndex after reload', () => {
114+
inject(function(myInfiniteDatasource) {
115+
myInfiniteDatasource.minIndex = userMinIndex;
116+
});
117+
runTest(scrollSettings,
118+
(viewport, scope) => {
119+
scope.adapter.reload();
120+
const topPaddingElement = angular.element(viewport.children()[0]);
121+
const virtualItemsAmount = (-1) * userMinIndex - bufferSize + 1;
122+
expect(topPaddingElement.height()).toBe(itemHeight * virtualItemsAmount);
123+
expect(viewport.scrollTop()).toBe(itemHeight * ((-1) * userMinIndex + 1));
124+
}
125+
);
126+
});
127127

128128
});
129129

0 commit comments

Comments
 (0)