diff --git a/src/calendar/index.js b/src/calendar/index.js index 7f88475c5..857f08754 100644 --- a/src/calendar/index.js +++ b/src/calendar/index.js @@ -258,8 +258,15 @@ export default createComponent({ let height = 0; let currentMonth; + // add offset to avoid rem accuracy issues + // see: https://github.com/youzan/vant/issues/6929 + const viewportOffset = 50; + const viewportTop = top - viewportOffset; + const viewportBottom = bottom + viewportOffset; + for (let i = 0; i < months.length; i++) { - const visible = height <= bottom && height + heights[i] >= top; + const visible = + height <= viewportBottom && height + heights[i] >= viewportTop; if (visible && !currentMonth) { currentMonth = months[i];