提交 18f200e2 编写于 作者: M mehaotian

fix: 修复折叠面板动画失效的问题

上级 38b3b2e1
<template> <template>
<view class="uni-collapse-item"> <view class="uni-collapse-item">
<view class="uni-collapse-item__title" @click="openCollapse(!is_open)"> <view class="uni-collapse-item__title" @click="openCollapse(!is_open)">
<text class="uni-collapse-item__title-text" <text class="uni-collapse-item__title-text" :class="{'is-disabled':disabled,'open--active':is_open}">{{title}}</text>
:class="{'is-disabled':disabled,'open--active':is_open}">{{title}}</text>
<view class="down_arrow" :class="{'down_arrow--active': is_open}"></view> <view class="down_arrow" :class="{'down_arrow--active': is_open}"></view>
</view> </view>
<view ref="boxRef" class="uni-collapse-item__content" :class="{'box-open--active':is_open}"> <view ref="boxRef" class="uni-collapse-item__content" :class="{'box-open--active':is_open}">
<view ref="contentRef" class="uni-collapse-item__content-box" :class="{'content-open--active':!box_is_open}"> <view ref="contentRef" class="uni-collapse-item__content-box" :class="{'content-open--active':box_is_open}">
<slot></slot> <slot></slot>
</view> </view>
</view> </view>
...@@ -36,7 +35,7 @@ ...@@ -36,7 +35,7 @@
return { return {
height: 0, height: 0,
is_open: this.open as boolean, is_open: this.open as boolean,
box_is_open:this.open as boolean, box_is_open: this.open as boolean,
boxNode: null as UniElement | null, boxNode: null as UniElement | null,
contentNode: null as UniElement | null, contentNode: null as UniElement | null,
}; };
...@@ -68,9 +67,9 @@ ...@@ -68,9 +67,9 @@
}, },
openOrClose(open : boolean) { openOrClose(open : boolean) {
// #ifdef MP-WEIXIN // #ifdef MP-WEIXIN
setTimeout(()=>{ setTimeout(() => {
this.box_is_open = !open this.box_is_open = open
},10) }, 10)
// #endif // #endif
// #ifndef MP-WEIXIN // #ifndef MP-WEIXIN
const boxNode = this.boxNode?.style!; const boxNode = this.boxNode?.style!;
...@@ -80,8 +79,10 @@ ...@@ -80,8 +79,10 @@
let ani_transform = open ? 'translateY(0)' : 'translateY(-100%)'; let ani_transform = open ? 'translateY(0)' : 'translateY(-100%)';
boxNode.setProperty('display', hide); boxNode.setProperty('display', hide);
this.$nextTick(() => { this.$nextTick(() => {
setTimeout(() => {
contentNode.setProperty('transform', ani_transform); contentNode.setProperty('transform', ani_transform);
contentNode.setProperty('opacity', opacity); contentNode.setProperty('opacity', opacity);
}, 10)
}) })
// #endif // #endif
} }
...@@ -138,6 +139,7 @@ ...@@ -138,6 +139,7 @@
position: relative; position: relative;
overflow: hidden; overflow: hidden;
} }
.uni-collapse-item .box-open--active { .uni-collapse-item .box-open--active {
display: flex; display: flex;
} }
...@@ -149,9 +151,10 @@ ...@@ -149,9 +151,10 @@
transform: translateY(-100%); transform: translateY(-100%);
opacity: 0; opacity: 0;
} }
/* #ifdef MP-WEIXIN */
.uni-collapse-item .content-open--active { .uni-collapse-item .content-open--active {
transform: translateY(0%); transform: translateY(0%);
opacity: 1; opacity: 1;
} }
/* #endif */
</style> </style>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册