mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-23 18:00:27 +08:00
fix(Calendar): incorrect header month title
This commit is contained in:
parent
c1e8cb9146
commit
6d85fc0aac
@ -7,8 +7,7 @@ import {
|
|||||||
compareDay,
|
compareDay,
|
||||||
compareMonth,
|
compareMonth,
|
||||||
createComponent,
|
createComponent,
|
||||||
ROW_HEIGHT,
|
ROW_HEIGHT
|
||||||
RENDER_OFFSET
|
|
||||||
} from './utils';
|
} from './utils';
|
||||||
|
|
||||||
import Popup from '../popup';
|
import Popup from '../popup';
|
||||||
@ -135,10 +134,15 @@ export default createComponent({
|
|||||||
// and find the elements that needs to be rendered
|
// and find the elements that needs to be rendered
|
||||||
onScroll() {
|
onScroll() {
|
||||||
const { body, months } = this.$refs;
|
const { body, months } = this.$refs;
|
||||||
const scrollTop = getScrollTop(body);
|
const top = getScrollTop(body);
|
||||||
const top = scrollTop - RENDER_OFFSET;
|
const bottom = top + this.bodyHeight;
|
||||||
const bottom = scrollTop + this.bodyHeight + RENDER_OFFSET;
|
|
||||||
const heights = months.map(item => item.height);
|
const heights = months.map(item => item.height);
|
||||||
|
const heightSum = heights.reduce((a, b) => a + b, 0);
|
||||||
|
|
||||||
|
// iOS scroll bounce may exceed the range
|
||||||
|
if (top < 0 || bottom > heightSum) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let height = 0;
|
let height = 0;
|
||||||
let firstMonth;
|
let firstMonth;
|
||||||
|
@ -6,7 +6,6 @@ const [createComponent, bem, t] = createNamespace('calendar');
|
|||||||
export { createComponent, bem, t };
|
export { createComponent, bem, t };
|
||||||
|
|
||||||
export const ROW_HEIGHT = 64;
|
export const ROW_HEIGHT = 64;
|
||||||
export const RENDER_OFFSET = 150;
|
|
||||||
|
|
||||||
export function formatMonthTitle(date: Date) {
|
export function formatMonthTitle(date: Date) {
|
||||||
return t('monthTitle', date.getFullYear(), padZero(date.getMonth() + 1));
|
return t('monthTitle', date.getFullYear(), padZero(date.getMonth() + 1));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user