[improvement] Tab: use transform to improve animation performance

This commit is contained in:
陈嘉涵 2019-05-11 11:43:30 +08:00
parent 1158a31cb1
commit 2bf84cd790
3 changed files with 3 additions and 2 deletions

View File

@ -134,6 +134,7 @@
### Tab ### Tab
- 优化`animated`动画性能
- 修复开启`animated`后高度错误的问题 - 修复开启`animated`后高度错误的问题
### Tabbar ### Tabbar

View File

@ -206,7 +206,7 @@ exports[`renders demo correctly 1`] = `
</div> </div>
</div> </div>
<div class="van-tabs__content"> <div class="van-tabs__content">
<div class="van-tabs__track" style="left: 0%; transition-duration: 0.3s;"> <div class="van-tabs__track" style="transform: translate3d(0%, 0, 0); transition-duration: 0.3s;">
<div class="van-tab__pane-wrapper"> <div class="van-tab__pane-wrapper">
<div class="van-tab__pane"> <div class="van-tab__pane">
内容 1 内容 1

View File

@ -111,7 +111,7 @@ export default sfc({
trackStyle() { trackStyle() {
if (this.animated) { if (this.animated) {
return { return {
left: `${-1 * this.curActive * 100}%`, transform: `translate3d(${-1 * this.curActive * 100}%, 0, 0)`,
transitionDuration: `${this.duration}s` transitionDuration: `${this.duration}s`
}; };
} }