fix(Calendar): rendering fails in some cases (#6812)

This commit is contained in:
neverland 2020-07-18 18:53:40 +08:00 committed by GitHub
parent 3c223ba7f7
commit e541260ef3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 5 deletions

View File

@ -244,14 +244,13 @@ export default createComponent({
onScroll() {
const { body, months } = this.$refs;
const top = getScrollTop(body);
const bottom = top + this.bodyHeight;
const heights = months.map((item) => item.getHeight());
const heightSum = heights.reduce((a, b) => a + b, 0);
// iOS scroll bounce may exceed the range
/* istanbul ignore next */
if (top < 0 || (bottom > heightSum && top > 0)) {
return;
let bottom = top + this.bodyHeight;
if (bottom > heightSum && top > 0) {
bottom = heightSum;
}
let height = 0;

View File

@ -40,7 +40,10 @@ export function getScroller(el: HTMLElement, root: ScrollElement = window) {
}
export function getScrollTop(el: ScrollElement): number {
return 'scrollTop' in el ? el.scrollTop : el.pageYOffset;
const top = 'scrollTop' in el ? el.scrollTop : el.pageYOffset;
// iOS scroll bounce cause minus scrollTop
return Math.max(top, 0);
}
export function setScrollTop(el: ScrollElement, value: number) {