attr [i] === “opacity”)curVal = Tween [tween](t,beginAttr [i],count,i); //调用Tween,返回当前属性值,此时计算方法为移动到
写入位置else curVal = Tween [tween](t,beginAttr [i],count + beginAttr [i],i); //调用Tween,返回当前属性值,此时计算方法为移动了
写入距离if(attr [i] === “opacity”)target.style [attr [i]] = curVal; //给属性赋值
else target.style [attr [i]] = curVal + “px” ; //给属性赋值
}
if(t < Math .max(... time))requestAnimationFrame(animate); //判断函数是否运动完
其他回调&& callback(); //如果已经执行完时间最长的动画,则调查回调函数
return ;
}
}
//多段运动第2类 - 多属性,不同目标,同时间/不同时间
if(count instanceof Array){
//同时间
if(typeof time === “number”){
if(t> time)t = time; //判断是否超出目标值
for(let i in beginAttr){ //循环attr,count,分别赋值
//错误判断
if(!count [i] && count [i]!== 0){
throw new Error(
“输入值的长度不是等于属性的长度“);
}
if(flag
关键词:CSS+JS如何完成浪漫流星雨动画效果?(代码示例)