mirror of
https://github.com/youzan/vant.git
synced 2025-10-20 18:54:24 +00:00
[bugfix] compatible <body />
is the scene of the scrolling container (#3844)
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
||||
getScrollTop,
|
||||
getElementTop,
|
||||
getRootScrollTop,
|
||||
setRootScrollTop,
|
||||
getScrollEventTarget
|
||||
} from '../utils/dom/scroll';
|
||||
|
||||
@@ -77,9 +78,13 @@ export default createComponent({
|
||||
|
||||
methods: {
|
||||
onScroll() {
|
||||
const scrollTop = this.scroller === window
|
||||
? getScrollTop(this.scroller)
|
||||
: 0;
|
||||
let scrollTop;
|
||||
if (this.scroller === window || this.scroller === document.body) {
|
||||
scrollTop = getScrollTop(this.scroller);
|
||||
} else {
|
||||
// see: https://github.com/youzan/vant/issues/3774
|
||||
scrollTop = 0;
|
||||
}
|
||||
const rects = this.children.map(item => ({
|
||||
height: item.height,
|
||||
top: getElementTop(item.$el)
|
||||
@@ -154,7 +159,7 @@ export default createComponent({
|
||||
match[0].scrollIntoView();
|
||||
|
||||
if (this.stickyOffsetTop) {
|
||||
window.scrollTo(0, getRootScrollTop() - this.stickyOffsetTop);
|
||||
setRootScrollTop(getRootScrollTop() - this.stickyOffsetTop);
|
||||
}
|
||||
|
||||
this.$emit('select', match[0].index);
|
||||
|
Reference in New Issue
Block a user