Skip to content

Commit 19e13c7

Browse files
committed
bottomVisible: the edge case of the viewport's extra height
1 parent 6aaee08 commit 19e13c7

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/modules/adapter.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,9 @@ class Adapter {
149149
calculateProperties() {
150150
let rowTop = null, topHeight = 0;
151151
let topDone = false, bottomDone = false;
152+
const length = this.buffer.length;
152153

153-
for (let i = 0; i < this.buffer.length; i++) {
154+
for (let i = 0; i < length; i++) {
154155
const item = this.buffer[i];
155156
const itemTop = item.element.offset().top;
156157

@@ -165,7 +166,7 @@ class Adapter {
165166
this['topVisibleScope'] = item.scope;
166167
}
167168

168-
if(!bottomDone && top > this.viewport.bottomVisiblePos()) {
169+
if (!bottomDone && (top >= this.viewport.bottomVisiblePos() || (i === length - 1 && this.isEOF()))) {
169170
bottomDone = true;
170171
this['bottomVisible'] = item.item;
171172
this['bottomVisibleElement'] = item.element;

test/AdapterTestsSpec.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ describe('uiScroll', function () {
2727

2828
expect(scope.adapter).toBeTruthy();
2929
expect(scope.adapter.topVisibleElement[0].innerHTML).toBe('1: one');
30+
expect(scope.adapter.bottomVisibleElement[0].innerHTML).toBe('3: three');
3031
}
3132
);
3233
});

0 commit comments

Comments
 (0)