亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

沒有源碼哦

沒有源碼參考哦,老師,麻煩提供一下源碼把。謝謝

正在回答

1 回答

startMove,去聽下DOM基本事件那屆!
function?startMove(obj,json,?fun)
	{
		clearInterval(obj.timer);
		obj.timer=setInterval
		(
			function()
			{
				for(var?attr?in?json)		//得到屬性
				{
					//取當前的值
					var?cur=0;
					if(attr?==?'opacity')		//如果屬性為透明度
					{
						cur?=?Math.round(parseFloat(getStyle(obj,?attr))*100);
					}
					else
					{
						var?cur=parseInt(getStyle(obj,?attr));
					}
					//算速度
					//var?speed=(target-obj.offsetWidth)/8;
					var?speed=(json[attr]-cur)/8;
					speed=?(speed>0)???Math.ceil(speed)?:?Math.floor(speed);
					//檢測停止
					//if(obj.offsetWidth?==?target)
					if(cur?==?json[attr])
					{
						clearInterval(obj.timer);
						if(fun)
						{
							fun();
						}
					}
					else
					{
						if(attr?==?'opacity')
						{
							obj.style.filter?=?'alpha(opacity:'+(cur+speed)+')';
							obj.style.opacity=(cur+speed)/100;
						}
						else
						{
							//divs.style.width=divs.offsetWidth-1+'px';	//offsetWidth=208px(整個div的寬度margin?padding?border)	width=208-1px	207+8-1......
							//divs.style.width=parseInt(divs.style.width)-1+'px';		//width寫在行
							obj.style[attr]=cur+speed+'px';
						}
					}
				}
			},30
		);
	}
function?getStyle(obj,?attr)		//獲取CSS樣式
{
	if(obj.currentStyle)		//IE
	{
		return?obj.currentStyle[attr];
	}
	else
	{
		return?getComputedStyle(obj,?false)[attr];
	}
}//?JavaScript?Document	


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

舉報

0/150
提交
取消
網頁廣告特效
  • 參與學習       40172    人
  • 解答問題       132    個

原來這么EASY,從淺到深,逐步優化代碼,讓你深入理解

進入課程

沒有源碼哦

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號