优化细节

This commit is contained in:
icssoa
2025-09-10 18:53:14 +08:00
parent 20a0bf1f57
commit 713f6956cb

View File

@@ -6,6 +6,7 @@
<!-- #ifdef MP --> <!-- #ifdef MP -->
<root-portal :enable="enablePortal"> <root-portal :enable="enablePortal">
<!-- #endif --> <!-- #endif -->
<view <view
class="cl-popup-wrapper" class="cl-popup-wrapper"
:class="[`cl-popup-wrapper--${direction}`]" :class="[`cl-popup-wrapper--${direction}`]"
@@ -108,9 +109,11 @@
</view> </view>
</view> </view>
</view> </view>
<!-- #ifdef MP --> <!-- #ifdef MP -->
</root-portal> </root-portal>
<!-- #endif --> <!-- #endif -->
<!-- #ifdef H5 --> <!-- #ifdef H5 -->
</teleport> </teleport>
<!-- #endif --> <!-- #endif -->
@@ -118,7 +121,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import { computed, reactive, ref, watch, type PropType } from "vue"; import { computed, reactive, ref, watch, type PropType } from "vue";
import { getSafeAreaHeight, parsePt, parseRpx } from "@/cool"; import { getSafeAreaHeight, isAppIOS, parsePt, parseRpx } from "@/cool";
import type { ClPopupDirection, PassThroughProps } from "../../types"; import type { ClPopupDirection, PassThroughProps } from "../../types";
import { isDark, router } from "@/cool"; import { isDark, router } from "@/cool";
import { config } from "../../config"; import { config } from "../../config";
@@ -303,17 +306,20 @@ function open() {
emit("open"); emit("open");
// 等待DOM更新后开始动画 // 等待DOM更新后开始动画
setTimeout(() => { setTimeout(
// 设置打开状态 () => {
status.value = 1; // 设置打开状态
status.value = 1;
// 动画结束后触发opened事件 // 动画结束后触发opened事件
// @ts-ignore // @ts-ignore
timer = setTimeout(() => { timer = setTimeout(() => {
isOpened.value = true; isOpened.value = true;
emit("opened"); emit("opened");
}, 350); }, 350);
}, 50); },
isAppIOS() ? 100 : 50
);
} }
} }
@@ -502,7 +508,8 @@ defineExpose({
} }
.cl-popup { .cl-popup {
@apply absolute; @apply absolute duration-300;
transition-property: transform;
&__inner { &__inner {
@apply bg-white h-full w-full flex flex-col; @apply bg-white h-full w-full flex flex-col;
@@ -532,19 +539,8 @@ defineExpose({
flex: 1; flex: 1;
} }
&.is-open {
transform: translate(0, 0) scale(1);
opacity: 1;
}
&.is-open,
&.is-close {
transition-property: transform, opacity;
transition-duration: 0.3s;
}
&.stop-transition { &.stop-transition {
transition-property: none; @apply transition-none;
} }
} }
@@ -552,6 +548,10 @@ defineExpose({
.cl-popup { .cl-popup {
@apply left-0 top-0; @apply left-0 top-0;
transform: translateX(-100%); transform: translateX(-100%);
&.is-open {
transform: translateX(0);
}
} }
} }
@@ -559,18 +559,25 @@ defineExpose({
.cl-popup { .cl-popup {
@apply right-0 top-0; @apply right-0 top-0;
transform: translateX(100%); transform: translateX(100%);
&.is-open {
transform: translateX(0);
}
} }
} }
&--top { &--top {
.cl-popup { .cl-popup {
@apply left-0 top-0; @apply left-0 top-0;
transform: translateY(-100%);
.cl-popup__inner { .cl-popup__inner {
@apply rounded-b-2xl; @apply rounded-b-2xl;
} }
transform: translateY(-100%); &.is-open {
transform: translateY(0);
}
} }
} }
@@ -605,6 +612,14 @@ defineExpose({
.cl-popup__inner { .cl-popup__inner {
@apply rounded-t-2xl; @apply rounded-t-2xl;
} }
&.is-open {
transform: translateY(0);
}
&.is-close {
transform: translateY(100%);
}
} }
} }
@@ -614,10 +629,16 @@ defineExpose({
& > .cl-popup { & > .cl-popup {
transform: scale(1.3); transform: scale(1.3);
opacity: 0; opacity: 0;
transition-property: transform, opacity;
.cl-popup__inner { .cl-popup__inner {
@apply rounded-2xl; @apply rounded-2xl;
} }
&.is-open {
transform: translate(0, 0) scale(1);
opacity: 1;
}
} }
} }
} }