fix(Calendar): does not show current month with larger screen sizes (#7355)

* fix(Calendar): does not show current month with larger screen sizes

* chore: fix demo snapshot
This commit is contained in:
neverland
2020-10-18 19:50:34 +08:00
committed by GitHub
parent 27d4cb7acf
commit 1b97315b54
2 changed files with 50 additions and 12 deletions
+16 -11
View File
@@ -266,28 +266,33 @@ export default createComponent({
let height = 0;
let currentMonth;
let visibleIndex;
const visibleRange = [-1, -1];
for (let i = 0; i < months.length; i++) {
const visible = height <= bottom && height + heights[i] >= top;
if (visible && !currentMonth) {
visibleIndex = i;
currentMonth = months[i];
}
if (visible) {
visibleRange[1] = i;
if (!months[i].visible && visible) {
this.$emit('month-show', {
date: months[i].date,
title: months[i].title,
});
if (!currentMonth) {
currentMonth = months[i];
visibleRange[0] = i;
}
if (!months[i].visible) {
this.$emit('month-show', {
date: months[i].date,
title: months[i].title,
});
}
}
height += heights[i];
}
months.forEach((month, index) => {
month.visible = index >= visibleIndex - 1 && index <= visibleIndex + 1;
month.visible =
index >= visibleRange[0] - 1 && index <= visibleRange[1] + 1;
});
/* istanbul ignore else */