diff --git a/packages/date-picker/src/vaadin-infinite-scroller.js b/packages/date-picker/src/vaadin-infinite-scroller.js index 0dc62272cc..589ba7aca3 100644 --- a/packages/date-picker/src/vaadin-infinite-scroller.js +++ b/packages/date-picker/src/vaadin-infinite-scroller.js @@ -376,7 +376,11 @@ class InfiniteScroller extends PolymerElement { /** @private */ _updateClones(viewPortOnly) { - this._firstIndex = ~~((this._buffers[0].translateY - this._initialScroll) / this.itemHeight) + this._initialIndex; + const itemCount = (this._buffers[0].translateY - this._initialScroll) / this.itemHeight; + if (isNaN(itemCount)) { + return; + } + this._firstIndex = Math.round(itemCount) + 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 d808674aa1..c00d19a050 100644 --- a/packages/date-picker/test/scroller.test.js +++ b/packages/date-picker/test/scroller.test.js @@ -118,3 +118,23 @@ describe('vaadin-infinite-scroller', () => { }); }); }); + +describe('fractional item size', () => { + let scroller; + + beforeEach(async () => { + scroller = fixtureSync(` + + + + `); + 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); + }); +});