fix(Tabs): incorrect scroll position when offset-top has unit (#7143)

This commit is contained in:
neverland 2020-09-09 18:00:15 +08:00 committed by GitHub
parent 3dddeaa7a3
commit 14b2f343e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,6 +4,7 @@ import { scrollLeftTo, scrollTopTo } from './utils';
import { route } from '../utils/router'; import { route } from '../utils/router';
import { isHidden } from '../utils/dom/style'; import { isHidden } from '../utils/dom/style';
import { on, off } from '../utils/dom/event'; import { on, off } from '../utils/dom/event';
import { unitToPx } from '../utils/format/unit';
import { BORDER_TOP_BOTTOM } from '../utils/constant'; import { BORDER_TOP_BOTTOM } from '../utils/constant';
import { callInterceptor } from '../utils/interceptor'; import { callInterceptor } from '../utils/interceptor';
import { import {
@ -119,9 +120,13 @@ export default createComponent({
} }
}, },
offsetTopPx() {
return unitToPx(this.offsetTop);
},
scrollOffset() { scrollOffset() {
if (this.sticky) { if (this.sticky) {
return +this.offsetTop + this.tabHeight; return this.offsetTopPx + this.tabHeight;
} }
return 0; return 0;
}, },
@ -151,7 +156,7 @@ export default createComponent({
// scroll to correct position // scroll to correct position
if (this.stickyFixed && !this.scrollspy) { if (this.stickyFixed && !this.scrollspy) {
setRootScrollTop(Math.ceil(getElementTop(this.$el) - this.offsetTop)); setRootScrollTop(Math.ceil(getElementTop(this.$el) - this.offsetTopPx));
} }
}, },