zoukankan      html  css  js  c++  java
  • JS完美运动框架

    move.png

    // for in 循环 ---json
    function getStyle(obj, attr) {
    	return obj.currentStyle?obj.currentStyle[attr]:window.getComputedStyle(obj, false)[attr];
    }
    
    function getByClassName(parent, name) {
    	var aResult = [];
    	var arr = parent.getElementsByTagName('*');
    	for (var i=0,len=arr.length; i<len;i++) {
    		if (arr[i].className===name) {
    			aResult.push(arr[i]);
    		}
    	}
    	return aResult;
    }
    
    function startMove(obj, json, fn) {
    	clearInterval(obj.timer);
    	obj.timer = setInterval(function () {
    		var bStop = true;
    		for(var attr in json) {
    			var icur = 0;
    			if (attr==='opacity') {
    				icur = parseInt(parseFloat(getStyle(obj, attr))*100);
    			} else {
    				icur = parseInt(getStyle(obj, attr));
    			}
    			var speed = (json[attr] - icur)/8;
    			speed = speed>0?Math.ceil(speed):Math.floor(speed);
    
    			if (icur!==json[attr]) {
    				bStop = false;
    			}
    			if (attr==='opacity') {
    				obj.style.opacity = (icur + speed) /100;
    				obj.style.filter = "alpha(opacity="+(icur+speed)+")";
    			} else {
    				obj.style[attr] = icur + speed + 'px';
    			}
    		}
    		if (bStop) {
    			clearInterval(obj.timer);
    			if (fn) {
    				fn();
    			}
    		}
    	},30);
    }
    
    

    不是完美版,还有些待修改的地方

  • 相关阅读:
    Linux安装ntp同步时间
    Linux安装ntp同步时间
    Python的中文处理
    Python的中文处理
    Python的中文处理
    Sudo环境变量继承
    Sudo环境变量继承
    dataguard 日志传输服务
    Dataguard Content
    Oracle 10g DataGuard手记之基础配置
  • 原文地址:https://www.cnblogs.com/maczyt/p/4918606.html
Copyright © 2011-2022 走看看