fix: 动画选择面板抖动

This commit is contained in:
pipipi-pikachu 2021-11-05 16:48:50 +08:00
parent 5d5f54951b
commit 0035923e3c

View File

@ -1,7 +1,12 @@
<template> <template>
<div class="element-animation-panel"> <div class="element-animation-panel">
<div class="element-animation" v-if="handleElement"> <div class="element-animation" v-if="handleElement">
<Popover trigger="click" v-model:visible="animationPoolVisible" v-if="!['chart', 'video'].includes(handleElement.type)"> <Popover
trigger="click"
v-model:visible="animationPoolVisible"
v-if="!['chart', 'video'].includes(handleElement.type)"
@visibleChange="visible => handlePopoverVisibleChange(visible)"
>
<template #content> <template #content>
<div class="animation-pool"> <div class="animation-pool">
<div class="pool-type" v-for="type in animations" :key="type.name"> <div class="pool-type" v-for="type in animations" :key="type.name">
@ -27,6 +32,7 @@
</div> </div>
</div> </div>
</div> </div>
<div class="mask" v-if="!popoverMaskHide"></div>
</div> </div>
</template> </template>
<Button class="element-animation-btn"> <Button class="element-animation-btn">
@ -239,6 +245,15 @@ export default defineComponent({
runAnimation(handleElement.value.id, type, defaultDuration) runAnimation(handleElement.value.id, type, defaultDuration)
} }
// 500ms
const popoverMaskHide = ref(false)
const handlePopoverVisibleChange = (visible: boolean) => {
if (visible) {
setTimeout(() => popoverMaskHide.value = true, 500)
}
else popoverMaskHide.value = false
}
return { return {
handleElement, handleElement,
animationPoolVisible, animationPoolVisible,
@ -247,11 +262,13 @@ export default defineComponent({
hoverPreviewAnimation, hoverPreviewAnimation,
handleElementAnimation, handleElementAnimation,
handleElementAnimationName, handleElementAnimationName,
popoverMaskHide,
addAnimation, addAnimation,
deleteAnimation, deleteAnimation,
handleDragEnd, handleDragEnd,
runAnimation, runAnimation,
updateElementAnimationDuration, updateElementAnimationDuration,
handlePopoverVisibleChange,
} }
}, },
}) })
@ -280,6 +297,15 @@ export default defineComponent({
font-size: 12px; font-size: 12px;
margin-right: -12px; margin-right: -12px;
padding-right: 12px; padding-right: 12px;
position: relative;
.mask {
width: 400px;
height: 500px;
position: absolute;
top: 0;
left: 0;
}
} }
.type-title { .type-title {
width: 100%; width: 100%;