From d6c6e9d742d39aac1a607c5de6be37fe4c2bb978 Mon Sep 17 00:00:00 2001 From: neverland Date: Thu, 7 Dec 2017 15:28:27 +0800 Subject: [PATCH] [Improvement] Tab: scroll to corrent position when sticky & tab change (#389) --- docs/markdown/zh-CN/changelog.md | 6 +++--- packages/tabs/index.vue | 14 +++++++++++--- packages/vant-css/src/tab.css | 3 ++- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/docs/markdown/zh-CN/changelog.md b/docs/markdown/zh-CN/changelog.md index 2a2b769df..4a74f4002 100644 --- a/docs/markdown/zh-CN/changelog.md +++ b/docs/markdown/zh-CN/changelog.md @@ -11,16 +11,16 @@ **Bug Fixes** - 修复 Popup overlayClass 类型错误 [\#374](https://github.com/youzan/vant/pull/374) [@chenjiahan](https://github.com/chenjiahan) - 修复 Filed number 类型输入值过滤 [\#386](https://github.com/youzan/vant/pull/386) [@chenjiahan](https://github.com/chenjiahan) -- 修复 Icon 'new' 显示问题 [\#381](https://github.com/youzan/vant/pull/381) ([@pangxie1991](https://github.com/pangxie1991)) +- 修复 Icon 'new' 显示问题 [\#381](https://github.com/youzan/vant/pull/381) [@pangxie1991](https://github.com/pangxie1991) - 修复 Sku 按钮圆角问题 [\#378](https://github.com/youzan/vant/pull/378) [@chenjiahan](https://github.com/chenjiahan) - 修复 Radio & Checkbox 禁用态样式 [\#383](https://github.com/youzan/vant/pull/383) [@chenjiahan](https://github.com/chenjiahan) - +- 修复 Filed disabled 在安卓下的显示问题 [\#388](https://github.com/youzan/vant/pull/388) [@chenjiahan](https://github.com/chenjiahan) ### [0.11.5](https://github.com/youzan/vant/tree/v0.11.5) `2017-12-04` **Improvements** -- Coupon:调增 Cell 右侧文案 [\#371](https://github.com/youzan/vant/pull/371) [@chenjiahan](https://github.com/chenjiahan) +- Coupon:调整 Cell 右侧文案 [\#371](https://github.com/youzan/vant/pull/371) [@chenjiahan](https://github.com/chenjiahan) - GoodsAction: 支持国际化 [\#367](https://github.com/youzan/vant/pull/367) [@chenjiahan](https://github.com/chenjiahan) - 增加 Props 命名规范相关文档 [\#366](https://github.com/youzan/vant/pull/366) [@chenjiahan](https://github.com/chenjiahan) diff --git a/packages/tabs/index.vue b/packages/tabs/index.vue index fd8911ff5..bc62c1106 100644 --- a/packages/tabs/index.vue +++ b/packages/tabs/index.vue @@ -79,6 +79,11 @@ export default { curActive() { this.scrollIntoView(); this.setNavBar(); + + // scroll to correct position + if (this.position === 'page-top' || this.position === 'content-bottom') { + scrollUtils.setScrollTop(this.scrollEl, scrollUtils.getElementTop(this.$el)); + } }, sticky(isSticky) { @@ -90,9 +95,12 @@ export default { this.correctActive(this.active); this.setNavBar(); - if (this.sticky) { - this.scrollHandler(true); - } + this.$nextTick(() => { + if (this.sticky) { + this.scrollHandler(true); + } + this.scrollIntoView(); + }); }, beforeDestroy() { diff --git a/packages/vant-css/src/tab.css b/packages/vant-css/src/tab.css index 323c14d4b..237af0d16 100644 --- a/packages/vant-css/src/tab.css +++ b/packages/vant-css/src/tab.css @@ -73,11 +73,12 @@ $van-tabs-card-height: 28px; .van-tabs__nav { overflow-x: auto; + overflow-y: hidden; -webkit-overflow-scrolling: touch; &::-webkit-scrollbar { display: none; - background-color: transparent; + background: transparent; } } }