javascript - 如何使模态框的动画在模态框消失在屏幕上之前执行?反应
问题描述
我有一个在进入和退出屏幕时制作动画的模式,但是在退出时它在制作动画之前就消失了,我无法识别错误。任何人都可以帮忙吗?我的代码:
displayModal ? (
<Background>
<Backdrop onClick={closeModal} />
<Container closeModal={closeModal} displayModal={displayModal}>
{children}
</Container>
</Background>
) : null;
//animations
const animationIn = keyframes`
from {
transform: translateY(100vh);
}
to {
transform: translateY(0);
}
`;
const animationOut = keyframes`
from {
transform: translateY(0);
}
to {
transform: translateY(100vh);
}
`;
const Container = styled.div<ContainerProps>`
visibility: visible;
display: flex;
width: 100%;
flex-direction: column;
align-items: center;
background: #ffffff;
animation: ${({ displayModal }) =>
displayModal
? css`
${animationIn} 0.5s ease-out forwards;
`
: css`
${animationOut} 0.5s ease-out forwards;
`};
z-index: 600;
bottom: 0;
`;
基本上,在输入的动画中它工作正常,但是当我单击关闭模式时,它会迅速消失,而不是制作动画
解决方案
推荐阅读
- javascript - 如何防止 Node Typscript 的 Azure AppService Deployments (VSCode) 在 TsConfig 文件旁边创建 JsConfig 文件?
- node.js - 子进程的后代未在 ubuntu 上接收 SIGTERM 但在 mac 上接收
- javascript - node.js中倒计时的for循环问题
- django - Django模型方法测试
- ios - 如何更改不同国家 IOS 中的应用程序图标?
- laravel - Laravel Dompdf 附件无法对有效负载进行 JSON 编码。错误代码:5
- php - 我正在尝试通过 ajax 传递字母以获取 lastName 的第一个字母并将其链接到导航栏,错误代码?
- android - 如何在 Android Studio 上将 API REST Symfony 与我的 Ionic Capacitor 应用程序一起使用
- mysql - 当 DELETE 语句清空表时 SQL 重置 AUTO_INCREMENT
- xdebug - 在便携式驱动器上配置 xdebug