From 347e980da9ca177d3d2d08527e82c274c3d35ae8 Mon Sep 17 00:00:00 2001 From: neverland Date: Sun, 16 Dec 2018 15:18:14 +0800 Subject: [PATCH] [improvement] Tab: optimize animated tab (#2302) --- packages/tab/demo/index.vue | 14 +- packages/tab/index.vue | 6 +- .../tab/test/__snapshots__/demo.spec.js.snap | 262 ++++++++---------- .../tab/test/__snapshots__/index.spec.js.snap | 168 +++++------ packages/tabs/index.less | 12 +- packages/tabs/index.vue | 20 +- 6 files changed, 211 insertions(+), 271 deletions(-) diff --git a/packages/tab/demo/index.vue b/packages/tab/demo/index.vue index e1f029b7b..36ab3d273 100644 --- a/packages/tab/demo/index.vue +++ b/packages/tab/demo/index.vue @@ -93,14 +93,13 @@ -
{{ $t('content') }} {{ index }}
+ {{ $t('content') }} {{ index }}
@@ -214,16 +213,5 @@ export default { padding: 50px 20px; } } - - .animated-tabs { - .van-tab__pane { - padding: 0 20px; - } - } - - .custom-content-wrap { - height: 60px; - line-height: 60px; - } } diff --git a/packages/tab/index.vue b/packages/tab/index.vue index 1423f9c79..40234a810 100644 --- a/packages/tab/index.vue +++ b/packages/tab/index.vue @@ -1,6 +1,7 @@ @@ -145,20 +147,12 @@ export default create({ }, trackStyle() { - const { - curActive, - animated - } = this; - - const trackStyle = { - left: `${-1 * curActive * 100}%` - }; - - if (animated) { - trackStyle.transitionDuration = `${this.duration}s`; + if (this.animated) { + return { + left: `${-1 * this.curActive * 100}%`, + transitionDuration: `${this.duration}s` + }; } - - return trackStyle; } },