第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

一直報(bào)錯(cuò)Cannot read property 'timer' of undefined

//獲取obj的屬性(樣式)attr,如'height'、'width'等
function?getStyle(obj,?attr)?{?
	if(obj.currentStyle)?{?
	return?obj.currentStyle[attr];?
	}?
	else?{?
	return?getComputedStyle(obj,false)[attr];?
	}?
}
//完整運(yùn)動(dòng)動(dòng)畫框架
function?motionFrame(obj,json,fn)?{
	clearInterval(obj.timer);//只清除此obj的定時(shí)器,不影響其他物體運(yùn)動(dòng)
	obj.timer=setInterval(function?()?{
		var?flag=true;//是否json中所有運(yùn)動(dòng)都完成
		//每30ms所有屬性值都會(huì)運(yùn)動(dòng)一次,+speed
		//遍歷一遍,只要有沒達(dá)到的flag就為false,否則flag不變?nèi)詾閠rue
		for(var?attr?in?json){
			//獲得要改變的當(dāng)前屬性值
			var?curr=0;
			if?(attr=='opacity')?{
				curr=Math.round(parseFloat(getStyle(obj,attr))*100);
			}?else?{
				curr=parseInt(getStyle(obj,attr));
			}
????????????//改變速度處理
			var?speed=0;
			speed=(json[attr]-curr)/8;//根據(jù)目標(biāo)值與當(dāng)前值的差改變速度,緩沖,差距越大速度越快,差距越小速度越慢
			speed=speed>0?Math.ceil(speed):Math.floor(speed);//達(dá)到整數(shù)值
			//檢測是否達(dá)到目標(biāo)值
			if(curr!=json[attr]){
				flag=false;//沒到目標(biāo),需繼續(xù)執(zhí)行
			}
			//obj運(yùn)動(dòng)過程
			if(attr=='opacity'){
				obj.style.filter='alpha(opacity:'+(curr+speed)+')';
				obj.style.opacity=(curr+speed);
			}else{
				obj.style[attr]=curr+speed+'px';
			}
		}
		//多個(gè)屬性值已經(jīng)同時(shí)改變且達(dá)到目標(biāo)值
		if(flag){
			clearInterval(obj.timer);
			//檢測是否有回調(diào)函數(shù)
			if(fn){
				fn();
			}
		}
	},30);
}


window.onload=function?()?{
	var??list=document.getElementsByTagName('li');
	//var??timer=null;
	for?(var?i=0;i<list.length;i++)?{
		//list[i].timer=null;
		list[i].onmouseover=function?()?{
			motionFrame(list[i],{height:150,width:100,opacity:70});
		}
		list[i].onmouseout=function?()?{
			motionFrame(list[i],{height:100,width:150,opacity:30});
		}
	}
}


正在回答

1 回答

56-62行,如下

for(...){
???list[i].index=i???//保存i
???...=function(){
????motionFrame(list[this.index]...);//用this.index替換i
???}
???...=function(){
????motionFrame(list[this.index]...);//用this.index替換i


0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

lorogy 提問者

已解決,非常感謝!
2017-02-06 回復(fù) 有任何疑惑可以回復(fù)我~
#2

qq_美麗的曲線_03762593 回復(fù) lorogy 提問者

我的也一直報(bào)錯(cuò) 咋整
2017-03-29 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

一直報(bào)錯(cuò)Cannot read property 'timer' of undefined

我要回答 關(guān)注問題
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)