伊人怎会持宠而骄
希望有人懂你的低头不语、小心翼翼守护你的孩子气
匀速运动
function startMove(target){
          clearInterval( timer );
          timer = setInterval( function(){
              var speed = target - oDiv.offsetLeft>0 ? 7  : -7;
              if( Math.abs( target - oDiv.offsetLeft ) <  7 ){
                   oDiv.style.left = target + "px";
                   clearInterval( timer );
              }else{
                   oDiv.style.left = oDiv.offsetLeft +  speed + "px";
              }
          },30 )
     }
 
匀速透明运动
var alpha = 30;// 操作透明度的变化
function startMove(target){
          clearInterval( timer );
          timer = setInterval( function(){
              var speed = target-alpha>0 ? 1 : -1;
              if( target == alpha ){
                   clearInterval( timer );
              }else{
                   alpha += speed;
                   oDiv.style.opacity =  alpha/100;
              }
          },30 )
     }
posted on 2019-01-21 10:24  伊人怎会持宠而骄  阅读(106)  评论(0编辑  收藏  举报