[bugfix] Tab: should not have line animation when inited (#2459)

This commit is contained in:
neverland 2019-01-07 19:22:40 +08:00 committed by GitHub
parent 2c3458587e
commit dd20a170ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 11 deletions

View File

@ -28,20 +28,20 @@ exports[`change tabs data 2`] = `
<div class="van-tabs van-tabs--line">
<div class="van-tabs__wrap van-hairline--top-bottom">
<div class="van-tabs__nav van-tabs__nav--line" style="border-color: #f44;">
<div class="van-tabs__line" style="background-color: rgb(255, 68, 68);"></div>
<div class="van-tabs__line" style="background-color: rgb(255, 68, 68); width: 2px; transform: translateX(-1px);"></div>
<div class="van-tab van-tab--active"><span class="van-ellipsis">title1</span></div>
<div class="van-tab"><span class="van-ellipsis"></span></div>
<div class="van-tab">
<div><span>title2</span></div>
</div>
<div class="van-tab van-tab--disabled"><span class="van-ellipsis">title3</span></div>
</div>
</div>
<div class="van-tabs__content">
<div class="van-tab__pane" style="">
<!---->
<div class="van-tab__pane" style="">Text
<!---->
</div>
<div class="van-tab__pane" style="display: none;">
<!---->
<div><span>title2</span></div>
</div>
<div class="van-tab__pane" style="display: none;">
<!---->

View File

@ -93,5 +93,7 @@ test('change tabs data', async () => {
color: 'blue',
title1: 'new title1'
});
await later();
expect(wrapper).toMatchSnapshot();
});

View File

@ -198,12 +198,9 @@ export default create({
},
mounted() {
this.correctActive(this.active);
this.setLine();
this.$nextTick(() => {
this.inited = true;
this.handlers(true);
this.scrollIntoView(true);
});
},
@ -293,6 +290,8 @@ export default create({
// update nav bar style
setLine() {
const shouldAnimate = this.inited;
this.$nextTick(() => {
const { tabs } = this.$refs;
@ -308,10 +307,13 @@ export default create({
const lineStyle = {
width: `${width}px`,
backgroundColor: this.color,
transform: `translateX(${left}px)`,
transitionDuration: `${this.duration}s`
transform: `translateX(${left}px)`
};
if (shouldAnimate) {
lineStyle.transitionDuration = `${this.duration}s`;
}
if (this.isDef(lineHeight)) {
const height = `${lineHeight}px`;
lineStyle.height = height;