[bugfix] Tabs:修复开启animated时导致的滚动问题 (#1030)

This commit is contained in:
张敏 2018-12-20 17:37:37 +08:00 committed by rex
parent 148938f039
commit 7a77aa69a7
6 changed files with 18 additions and 7 deletions

View File

@ -104,7 +104,7 @@
wx:key="index" wx:key="index"
title="{{ '标签' + item }}" title="{{ '标签' + item }}"
> >
<view class="content" style="height: 1000px;"> <view class="content">
{{ '内容' + item }} {{ '内容' + item }}
</view> </view>
</van-tab> </van-tab>

View File

@ -58,7 +58,7 @@
| scrollable | 是否在长度溢出时滚动播放 | `Boolean` | `true` | | scrollable | 是否在长度溢出时滚动播放 | `Boolean` | `true` |
| left-icon | 左侧图标图片 URL | `String` | - | | left-icon | 左侧图标图片 URL | `String` | - |
| color | 文本颜色 | `String` | `#ed6a0c` | | color | 文本颜色 | `String` | `#ed6a0c` |
| background | 滚动条背景 | `String` | `#fffbe8` | | backgroundColor | 滚动条背景 | `String` | `#fffbe8` |
| open-type | 微信开放能力 | `String` | `navigate` | | open-type | 微信开放能力 | `String` | `navigate` |
### Event ### Event

View File

@ -1,7 +1,13 @@
.van-tab__pane { .van-tab__pane {
box-sizing: border-box; box-sizing: border-box;
overflow-y: auto;
&--float { &--active {
float: left; height: auto;
}
&--inactive {
height: 0px;
overflow: visible;
} }
} }

View File

@ -1,6 +1,6 @@
<view <view
wx:if="{{ animated || inited }}" wx:if="{{ animated || inited }}"
class="custom-class van-tab__pane {{ animated ? 'van-tab__pane--float' : '' }}" class="custom-class van-tab__pane {{ active ? 'van-tab__pane--active' : 'van-tab__pane--inactive' }}"
style="{{ animated || active ? '' : 'display: none;' }} {{ width ? 'width:' + width + 'px;' : '' }}" style="{{ animated || active ? '' : 'display: none;' }} {{ width ? 'width:' + width + 'px;' : '' }}"
> >
<slot /> <slot />

View File

@ -94,6 +94,10 @@
&__content { &__content {
overflow: hidden; overflow: hidden;
} }
&__track {
position: relative;
}
} }
.van-tab { .van-tab {

View File

@ -189,8 +189,9 @@ VantComponent({
this.set({ this.set({
trackStyle: ` trackStyle: `
width: ${width * this.child.length}px; width: ${width * this.child.length}px;
transform: translateX(${-1 * active * width}px); left: ${-1 * active * width}px;
transition-duration: ${duration}s; transition: left ${duration}s;
display: flex;
` `
}); });
this.setTabsProps({ this.setTabsProps({