Merge branch 'dev' of https://github.com/youzan/vant into dev

This commit is contained in:
陈嘉涵 2020-02-08 20:18:05 +08:00
commit 06513a985f

View File

@ -6,10 +6,11 @@ import { isHidden } from '../utils/dom/style';
import { on, off } from '../utils/dom/event'; import { on, off } from '../utils/dom/event';
import { BORDER_TOP_BOTTOM } from '../utils/constant'; import { BORDER_TOP_BOTTOM } from '../utils/constant';
import { import {
setRootScrollTop, getScroller,
getVisibleTop,
getElementTop, getElementTop,
getVisibleHeight, getVisibleHeight,
getVisibleTop, setRootScrollTop,
} from '../utils/dom/scroll'; } from '../utils/dom/scroll';
// Mixins // Mixins
@ -27,9 +28,14 @@ export default createComponent({
mixins: [ mixins: [
ParentMixin('vanTabs'), ParentMixin('vanTabs'),
BindEventMixin(function(bind) { BindEventMixin(function(bind) {
if (!this.scroller) {
this.scroller = getScroller(this.$el);
}
bind(window, 'resize', this.resize, true); bind(window, 'resize', this.resize, true);
if (this.scrollspy) { if (this.scrollspy) {
bind(window, 'scroll', this.onScroll, true); bind(this.scroller, 'scroll', this.onScroll, true);
} }
}), }),
], ],
@ -152,9 +158,9 @@ export default createComponent({
scrollspy(val) { scrollspy(val) {
if (val) { if (val) {
on(window, 'scroll', this.onScroll, true); on(this.scroller, 'scroll', this.onScroll, true);
} else { } else {
off(window, 'scroll', this.onScroll); off(this.scroller, 'scroll', this.onScroll);
} }
}, },
}, },