为了账号安全,请及时绑定邮箱和手机立即绑定

为什么添加了多个动画,后面的链式函数没执行啊??????

<script>
function getStyle(obj,attr) {
   if(obj.currentStyle){
       return obj.currentStyle[attr];
   }else{
       return getComputedStyle(obj,false)[attr];
   }
}//封装一个方法去获得任何一个属性值,同时方法要考虑兼容

function startMove(obj,arrt,iTarget,fn) {
   clearInterval(obj.timer);
   obj.timer=setInterval(function () {
       //1、判断属性值里是否有透明度,如有的话小数点和像素怎么处理
       var icur=0;
       if(arrt=='opacity'){
           icur=Math.round(parseFloat(getStyle(obj,arrt))*100);
       }else{
           icur=parseInt(getStyle(obj,arrt));
       }
       //2、算速度,速度=目标-参数m/h,并取整数
       var speed=(iTarget-icur)/8;
       speed=speed>0?Math.ceil(speed):Math.floor(speed);
       //检测停止、得出透明度、得出其他值
       if (icur==0){
           clearInterval(obj.timer);
           if(fn){
               fn();
           }
       }else{
           if (arrt=='opacity'){
               obj.style.filter='alpha:(opacity:'+icur+speed+')';
               obj.style.opacity=(icur+speed)/100;
           }else {
               obj.style[arrt]=icur+speed+'px';
           }
       }
   },30)
}

///////    以上是一个框架   ///////
window.onload=function () {
   var Li=document.getElementById('li1');
   Li.onmouseover=function () {
       startMove(Li,'height',200,function(){
           startMove(Li,'width',400,function(){
               startMove(Li,'opacity',100);
           })
       })
   }
}

正在回答

3 回答

attr 与 arrt  

0 回复 有任何疑惑可以回复我~

   if (icur==iTarget){   //判断条件是到达目标  而不是==0

           clearInterval(obj.timer);

           if(fn){

               fn();

           }


0 回复 有任何疑惑可以回复我~

你调用封装的框架没看看!

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

为什么添加了多个动画,后面的链式函数没执行啊??????

我要回答 关注问题
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号