【发布时间】:2018-03-19 07:36:37
【问题描述】:
在 React 中,如果我有一个基于按钮单击开始的动画,我如何重新启动该动画?
jsx
const animationStyle = `countdown ${this.props.duration}s linear infinite forwards`;
<svg id="svg1">
<circle
id="c1"
style={{animation: animationStyle }}
cx="100"
cy="100"
r="80"
></circle>
</svg>
.css 文件
@keyframes countdown {
from {
stroke-dashoffset: 0px;
}
to {
stroke-dashoffset: 500px;
}
}
如果我传递一个新的持续时间,它不会立即开始新的动画。
【问题讨论】: