[英]delay css animation styled-component
How to delay opacity to zero when certain condition is met? 满足特定条件时如何将不透明度延迟为零? The loader bar is controlled using js, is the delay doable using just css?
加载程序栏是使用js控制的,是否仅使用CSS即可执行延迟?
const Wrap = styled.div`
background: #ddd;
width: 100px;
height: 10px;
border-radius: 3px;
opacity: ${props => (props.currentStep === props.steps ? 0 : 1)};
`;
demo (click on the add button) 演示(单击添加按钮)
https://codesandbox.io/s/7k20zw5z10 https://codesandbox.io/s/7k20zw5z10
What I want to achieve: the progress bar load till 100%, delay 1 second before the whole thing got fade away. 我要实现的目标是:进度条负载达到100%,在整个过程消失之前延迟1秒。
Yes it is with CSS transitions : 是的,它与CSS转换有关 :
div { background: #ddd; width: 100px; height: 10px; border-radius: 3px; opacity: 1; transition: opacity 1s 2s; } div:hover { opacity: 0; }
<div></div>
The transition will take 1s after a 2s delay. 转换将在2s延迟后花费1s。
You can use transition-delay : 您可以使用transition-delay :
const Wrap = styled.div`
background: #ddd;
width: 100px;
height: 10px;
border-radius: 3px;
opacity: ${props => (props.currentStep === props.steps ? 0 : 1)};
transition-delay: 2s;
`;
Demo: https://codesandbox.io/s/mq51n0jmrp 演示: https : //codesandbox.io/s/mq51n0jmrp
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.