zoukankan      html  css  js  c++  java
  • JS-完美运动框架(封装)

    function getStyle(obj, name)
    {
        if(obj.currentStyle)
        {
            return obj.currentStyle[name];
        }
        else
        {
            return getComputedStyle(obj, false)[name];
        }
    }
    
    
    //startMove(oDiv, { 400, height: 400})
    
    
    function startMove(obj, json, fnEnd)
    {
        clearInterval(obj.timer);
        obj.timer=setInterval(function (){
            var bStop=true;        //假设:所有值都已经到了
            
            for(var attr in json)
            {
                var cur=0;
                
                if(attr=='opacity')
                {
                    cur=Math.round(parseFloat(getStyle(obj, attr))*100);
                }
                else
                {
                    cur=parseInt(getStyle(obj, attr));
                }
                
                var speed=(json[attr]-cur)/6;
                speed=speed>0?Math.ceil(speed):Math.floor(speed);
                
                if(cur!=json[attr])
                    bStop=false;
                
                if(attr=='opacity')
                {
                    obj.style.filter='alpha(opacity:'+(cur+speed)+')';
                    obj.style.opacity=(cur+speed)/100;
                }
                else
                {
                    obj.style[attr]=cur+speed+'px';
                }
            }
            
            if(bStop)
            {
                clearInterval(obj.timer);
                            
                if(fnEnd)fnEnd();
            }
        }, 30);
    }

    智能社资源:https://ke.qq.com/webcourse/index.html#course_id=152997&term_id=100174752&taid=766913655494053&vid=v14127nxshc

  • 相关阅读:
    mysql索引类型 normal, unique, full text
    16.信号量互斥编程
    15.信号通信编程
    14.有名管道通信
    13.无名管道通讯编程
    12.多进程程序的操作
    11.进程控制理论
    10.时间编程
    9. 库函数方式文件编程
    8.Linux文件编程
  • 原文地址:https://www.cnblogs.com/padding1015/p/6403264.html
Copyright © 2011-2022 走看看