Skip to content

Commit

Permalink
fix(collapse): avoid use animation when height is 0 (#3562)
Browse files Browse the repository at this point in the history
fix #3449
  • Loading branch information
rex-zsd authored Aug 26, 2020
1 parent 13e82ea commit b7e184a
Showing 1 changed file with 25 additions and 26 deletions.
51 changes: 25 additions & 26 deletions packages/collapse-item/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ VantComponent({
relation: {
name: 'collapse',
type: 'ancestor',
current: 'collapse-item'
current: 'collapse-item',
},

props: {
Expand All @@ -19,22 +19,22 @@ VantComponent({
clickable: Boolean,
border: {
type: Boolean,
value: true
value: true,
},
isLink: {
type: Boolean,
value: true
}
value: true,
},
},

data: {
expanded: false
expanded: false,
},

created() {
this.animation = wx.createAnimation({
duration: 0,
timingFunction: 'ease-in-out'
timingFunction: 'ease-in-out',
});
},

Expand Down Expand Up @@ -79,32 +79,31 @@ VantComponent({
const { animation } = this;

if (expanded) {
animation
.height(height)
.top(1)
.step({
duration: inited ? 300 : 1
})
.height('auto')
.step();
if (height === 0) {
animation.height('auto').top(1).step();
} else {
animation
.height(height)
.top(1)
.step({
duration: inited ? 300 : 1,
})
.height('auto')
.step();
}

this.setData({
animation: animation.export()
animation: animation.export(),
});
return;
}

animation
.height(height)
.top(0)
.step({ duration: 1 })
.height(0)
.step({
duration: 300
});
animation.height(height).top(0).step({ duration: 1 }).height(0).step({
duration: 300,
});

this.setData({
animation: animation.export()
animation: animation.export(),
});
});
},
Expand All @@ -119,6 +118,6 @@ VantComponent({
const currentName = name == null ? index : name;

this.parent.switch(currentName, !expanded);
}
}
},
},
});

0 comments on commit b7e184a

Please sign in to comment.