mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
fix(Calendar): rendering fails in some cases (#6812)
This commit is contained in:
parent
3c223ba7f7
commit
e541260ef3
@ -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;
|
||||
|
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user