<div>
。说明过去/剩余的时间问题在于,每当时钟更新时,动画都会重新启动。因此,动画不会超过用户设置的持续时间。 我不知道将代码放在哪里?
runTimer = (timerType) => {
const node = this.myRef.current; // references a div in the html
let animation;
const keyFrames = [{ height: '0' }, { height: '100%' }];
const timing = {
easing: 'cubic-bezier(.2,.6,.8,.4)',
duration: 25 * 1000,
delay: 1000
}
if (timerType === "session") {
timing.duration = this.props.state.userSetSession; // for example 1200 (20 mins)
animation = node.animate(keyFrames, timing);
this.props.run(sType) // calls redux function to reduce session by 1
...