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