Skip to content

Commit

Permalink
fix: calculate vidxOffset correctly when clientHeight != offsetHeight (
Browse files Browse the repository at this point in the history
  • Loading branch information
vursen authored Mar 25, 2024
1 parent 4763444 commit 17fa7b2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ export class IronListAdapter {
this.__skipNextVirtualIndexAdjust = false;
} else if (Math.abs(delta) > 10000) {
// Process a large scroll position change
const scale = this._scrollTop / (this.scrollTarget.scrollHeight - this.scrollTarget.offsetHeight);
const scale = this._scrollTop / (this.scrollTarget.scrollHeight - this.scrollTarget.clientHeight);
this._vidxOffset = Math.round(scale * maxOffset);
} else {
// Make sure user can always swipe/wheel scroll to the start and end
Expand Down
10 changes: 10 additions & 0 deletions packages/component-base/test/virtualizer-unlimited-size.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,16 @@ describe('unlimited size', () => {
expect(item.getBoundingClientRect().top).to.equal(scrollTarget.getBoundingClientRect().top);
});

it('should manually scroll to end when the scroll target has a border', async () => {
scrollTarget.style.borderTop = '20px solid black';

scrollTarget.scrollTop = scrollTarget.scrollHeight;
await oneEvent(scrollTarget, 'scroll');

const item = elementsContainer.querySelector(`#item-${virtualizer.size - 1}`);
expect(item.getBoundingClientRect().bottom).to.be.closeTo(scrollTarget.getBoundingClientRect().bottom, 1);
});

it('should manually scroll to start after scroll to index', async () => {
virtualizer.scrollToIndex(virtualizer.size / 400);

Expand Down

0 comments on commit 17fa7b2

Please sign in to comment.