mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
[bugfix] Collapse: flick in safari (#3686)
This commit is contained in:
parent
e08bea7577
commit
fe87885d90
@ -60,15 +60,19 @@ export default createComponent({
|
|||||||
this.inited = true;
|
this.inited = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
raf(() => {
|
// Use raf: flick when opened in safari
|
||||||
|
// Use nextTick: closing animation failed when set `user-select: none`
|
||||||
|
const nextTick = expanded ? this.$nextTick : raf;
|
||||||
|
|
||||||
|
nextTick(() => {
|
||||||
const { content, wrapper } = this.$refs;
|
const { content, wrapper } = this.$refs;
|
||||||
if (!content || !wrapper) {
|
if (!content || !wrapper) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { clientHeight } = content;
|
const { offsetHeight } = content;
|
||||||
if (clientHeight) {
|
if (offsetHeight) {
|
||||||
const contentHeight = `${clientHeight}px`;
|
const contentHeight = `${offsetHeight}px`;
|
||||||
wrapper.style.height = expanded ? 0 : contentHeight;
|
wrapper.style.height = expanded ? 0 : contentHeight;
|
||||||
raf(() => {
|
raf(() => {
|
||||||
wrapper.style.height = expanded ? contentHeight : 0;
|
wrapper.style.height = expanded ? contentHeight : 0;
|
||||||
@ -96,7 +100,7 @@ export default createComponent({
|
|||||||
if (!this.expanded) {
|
if (!this.expanded) {
|
||||||
this.show = false;
|
this.show = false;
|
||||||
} else {
|
} else {
|
||||||
this.$refs.wrapper.style.height = null;
|
this.$refs.wrapper.style.height = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -127,8 +127,6 @@ test('lazy render collapse content', async () => {
|
|||||||
const titles = wrapper.findAll('.van-collapse-item__title');
|
const titles = wrapper.findAll('.van-collapse-item__title');
|
||||||
|
|
||||||
titles.at(1).trigger('click');
|
titles.at(1).trigger('click');
|
||||||
await later(50);
|
|
||||||
|
|
||||||
wrapper.vm.content = 'content';
|
wrapper.vm.content = 'content';
|
||||||
expect(wrapper).toMatchSnapshot();
|
expect(wrapper).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user