diff --git a/packages/date-picker/src/vaadin-infinite-scroller.js b/packages/date-picker/src/vaadin-infinite-scroller.js index 30f2a238ca5..71ffea35521 100644 --- a/packages/date-picker/src/vaadin-infinite-scroller.js +++ b/packages/date-picker/src/vaadin-infinite-scroller.js @@ -391,7 +391,8 @@ export class InfiniteScroller extends HTMLElement { /** @private */ _updateClones(viewPortOnly) { - this._firstIndex = ~~((this._buffers[0].translateY - this._initialScroll) / this.itemHeight) + this._initialIndex; + this._firstIndex = + Math.round((this._buffers[0].translateY - this._initialScroll) / this.itemHeight) + this._initialIndex; const scrollerRect = viewPortOnly ? this.$.scroller.getBoundingClientRect() : undefined; this._buffers.forEach((buffer, bufferIndex) => { diff --git a/packages/date-picker/test/scroller.test.js b/packages/date-picker/test/scroller.test.js index 3d5db0122e6..e821d3d2ae7 100644 --- a/packages/date-picker/test/scroller.test.js +++ b/packages/date-picker/test/scroller.test.js @@ -125,3 +125,18 @@ describe('vaadin-infinite-scroller', () => { }); }); }); + +describe('fractional item size', () => { + let scroller; + + beforeEach(async () => { + scroller = fixtureSync(''); + scroller.bufferSize = 80; + scroller.style.setProperty('--vaadin-infinite-scroller-item-height', '30.0001px'); + await activateScroller(scroller); + }); + + it('should be at the position 0', () => { + expect(scroller.position).to.be.closeTo(0, 0.001); + }); +});