diff --git a/src/calendar/index.js b/src/calendar/index.js index 591e64a2c..7b70a65c1 100644 --- a/src/calendar/index.js +++ b/src/calendar/index.js @@ -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; diff --git a/src/utils/dom/scroll.ts b/src/utils/dom/scroll.ts index aa3f7f571..6d7457f74 100644 --- a/src/utils/dom/scroll.ts +++ b/src/utils/dom/scroll.ts @@ -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) {