From 14b2f343e2f81c98537d3884dcf7a243778084aa Mon Sep 17 00:00:00 2001 From: neverland Date: Wed, 9 Sep 2020 18:00:15 +0800 Subject: [PATCH] fix(Tabs): incorrect scroll position when offset-top has unit (#7143) --- src/tabs/index.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/tabs/index.js b/src/tabs/index.js index 86ea14c26..8d147a3ce 100644 --- a/src/tabs/index.js +++ b/src/tabs/index.js @@ -4,6 +4,7 @@ import { scrollLeftTo, scrollTopTo } from './utils'; import { route } from '../utils/router'; import { isHidden } from '../utils/dom/style'; import { on, off } from '../utils/dom/event'; +import { unitToPx } from '../utils/format/unit'; import { BORDER_TOP_BOTTOM } from '../utils/constant'; import { callInterceptor } from '../utils/interceptor'; import { @@ -119,9 +120,13 @@ export default createComponent({ } }, + offsetTopPx() { + return unitToPx(this.offsetTop); + }, + scrollOffset() { if (this.sticky) { - return +this.offsetTop + this.tabHeight; + return this.offsetTopPx + this.tabHeight; } return 0; }, @@ -151,7 +156,7 @@ export default createComponent({ // scroll to correct position if (this.stickyFixed && !this.scrollspy) { - setRootScrollTop(Math.ceil(getElementTop(this.$el) - this.offsetTop)); + setRootScrollTop(Math.ceil(getElementTop(this.$el) - this.offsetTopPx)); } },