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

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

幫忙找bug, 參考老師的思路寫的單線程鏈?zhǔn)酵絼赢嫼孟裼行﹩栴}, 大家來找找.

<!DOCTYPE?html>
<html>
	<head>
		<meta?charset="UTF-8">
		<title>鏈?zhǔn)酵竭\(yùn)動</title>
		<style?type="text/css">
			#div1?{
				margin:0?auto;
				width:200px;
				height:200px;
				background:red;
				filter:alpha(opacity=100);
				opacity:1;
			}
			#div2?{
				margin:20px?auto;
				width:200px;
				height:200px;
				background:green;
				filter:alpha(opacity=100);
				opacity:1;
			}
		</style>
	</head>
	<body>
		<div?id="div1"></div>
		<div?id="div2"></div>
		<script?type="text/javascript">
			var?div1?=?document.getElementById("div1");
			var?div2?=?document.getElementById("div2");
			div1.onmouseover?=?function()?{
				change(this,{"width":400,"height":300,"opacity":20},function()?{
					change(this,{"width":200,"height":200,"opacity":100},function()?{
						change(this,{"width":400,"height":400,"opacity":10});
					})
				})
			}
			div1.onmouseout?=?function()?{
				change(this,{"width":400,"height":300,"opacity":20},function()?{
					change(this,{"width":300,"height":300,"opacity":60},function()?{
						change(this,{"width":200,"height":200,"opacity":100});
					})
				})
			}
			div2.onmouseover?=?function()?{
				change(this,{"width":400,"height":300,"opacity":10},function()?{
					change(this,{"width":200,"height":200,"opacity":100},function()?{
						change(this,{"width":400,"height":400,"opacity":10});
					})
				})
			}
			div2.onmouseout?=?function()?{
				change(this,{"width":400,"height":300,"opacity":20},function()?{
					change(this,{"width":300,"height":300,"opacity":60},function()?{
						change(this,{"width":200,"height":200,"opacity":100});
					})
				})
			}
			function?change(obj,target,callback)?{
				//首先清除上一個定時器
				clearInterval(obj.timer);
				//定義變量
				var?origin={};
				var?speed?=?0;
				var?flag?=?true;
				//遍歷獲取初始屬性
				for(attr?in?target)?{
					if(?attr?===?"opacity"?)?{
						origin[attr]?=?Math.round(getStyle(obj,attr)*100);		
					}?else?{
						origin[attr]?=?parseInt(getStyle(obj,attr));		
					}
				}
				//設(shè)置定時器
				obj.timer?=?setInterval(function()?{
					
					//初始化標(biāo)記true
					flag?=?true;
					
					//遍歷目標(biāo)值
					for(?attr?in?target)?{
						
						//計算速度
						speed?=?(target[attr]-origin[attr])/10;
						speed?=?speed>0?Math.ceil(speed):Math.floor(speed);
						
						//改變初始數(shù)值
						origin[attr]?+=?speed;
						if(attr?===?"opacity")?{
							obj.style.opacity?=?origin[attr]/100;
							obj.style.filter?=?'alpha(opacity='+origin[attr]+')';
						}?else?{
							obj.style[attr]?=?origin[attr]?+?"px";
						}
						
						//若有一個不等則將標(biāo)記設(shè)為false
						if(target[attr]?!=?origin[attr])?{
							flag?=?false;
						}
					}
					console.log("定時器清除了沒?");
					//如果標(biāo)記值為true清除定時器
					if(flag)?{
						clearInterval(obj.timer);
						//設(shè)置回調(diào)函數(shù)
						if(callback)?{
							callback.call(obj);
						}
					}	
				},30);
			}
			
			//獲取元素外聯(lián)和內(nèi)聯(lián)樣式
			function?getStyle(obj,attr)?{
				return?obj.currentStyle???obj.currentStyle[attr]?:?getComputedStyle(obj,false)[attr];
			}
		</script>
	</body>
</html>


正在回答

2 回答

題主的程序測著沒問題啊。。

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

<!DOCTYPE html>

<html>

? ? <head>

? ? ? ? <meta charset="UTF-8">

? ? ? ? <title>鏈?zhǔn)酵竭\(yùn)動</title>

? ? ? ? <style type="text/css">

? ? ? ? ? ? #div1 {

? ? ? ? ? ? ? ? margin:0 auto;

? ? ? ? ? ? ? ? width:100px;

? ? ? ? ? ? ? ? height:100px;

? ? ? ? ? ? ? ? background:red;

? ? ? ? ? ? ? ? filter:alpha(opacity=100);

? ? ? ? ? ? ? ? opacity:1;

? ? ? ? ? ? }

? ? ? ? ? ? #div2 {

? ? ? ? ? ? ? ? margin:20px auto;

? ? ? ? ? ? ? ? width:100px;

? ? ? ? ? ? ? ? height:100px;

? ? ? ? ? ? ? ? background:green;

? ? ? ? ? ? ? ? filter:alpha(opacity=100);

? ? ? ? ? ? ? ? opacity:1;

? ? ? ? ? ? }

? ? ? ? </style>

? ? </head>

? ? <body>

? ? ? ? <div id="div1"></div>

? ? ? ? <div id="div2"></div>

? ? ? ? <script type="text/javascript">

? ? ? ? ? ? var div1 = document.getElementById("div1");

? ? ? ? ? ? var div2 = document.getElementById("div2");

? ? ? ? ? ? div1.onmouseover = function() {

? ? ? ? ? ? ? ? change(this,{"width":200,"height":200,"opacity":20})

? ? ? ? ? ? }

? ? ? ? ? ? div1.onmouseout = function() {

? ? ? ? ? ? ? ? change(this,{"width":100,"height":100,"opacity":100})

? ? ? ? ? ? }

? ? ? ? ? ? div2.onmouseover = function() {

? ? ? ? ? ? ? ? change(this,{"width":200,"height":200,"opacity":10})

? ? ? ? ? ? }

? ? ? ? ? ? div2.onmouseout = function() {

? ? ? ? ? ? ? ? change(this,{"width":100,"height":100,"opacity":100})

? ? ? ? ? ? }

? ? ? ? ? ? function change(obj,target,callback) {

? ? ? ? ? ? ? ? //首先清除上一個定時器

? ? ? ? ? ? ? ? clearInterval(obj.timer);

? ? ? ? ? ? ? ? //定義變量

? ? ? ? ? ? ? ? var origin={};

? ? ? ? ? ? ? ? var speed = 0;

? ? ? ? ? ? ? ? var flag = true;

? ? ? ? ? ? ? ? //遍歷獲取初始屬性

? ? ? ? ? ? ? ? for(attr in target) {

? ? ? ? ? ? ? ? ? ? if( attr === "opacity" ) {

? ? ? ? ? ? ? ? ? ? ? ? origin[attr] = Math.round(getStyle(obj,attr)*100); ? ? ??

? ? ? ? ? ? ? ? ? ? } else {

? ? ? ? ? ? ? ? ? ? ? ? origin[attr] = parseInt(getStyle(obj,attr)); ? ??

? ? ? ? ? ? ? ? ? ? }

? ? ? ? ? ? ? ? }

? ? ? ? ? ? ? ? //設(shè)置定時器

? ? ? ? ? ? ? ? obj.timer = setInterval(function() {

? ? ? ? ? ? ? ? ? ? ?

? ? ? ? ? ? ? ? ? ? //初始化標(biāo)記true

? ? ? ? ? ? ? ? ? ? flag = true;

? ? ? ? ? ? ? ? ? ? ?

? ? ? ? ? ? ? ? ? ? //遍歷目標(biāo)值

? ? ? ? ? ? ? ? ? ? for( attr in target) {

? ? ? ? ? ? ? ? ? ? ? ? ?

? ? ? ? ? ? ? ? ? ? ? ? //計算速度

? ? ? ? ? ? ? ? ? ? ? ? speed = (target[attr]-origin[attr])/10;

? ? ? ? ? ? ? ? ? ? ? ? speed = speed>0?Math.ceil(speed):Math.floor(speed);

? ? ? ? ? ? ? ? ? ? ? ? ?

? ? ? ? ? ? ? ? ? ? ? ? //改變初始數(shù)值

? ? ? ? ? ? ? ? ? ? ? ? origin[attr] += speed;

? ? ? ? ? ? ? ? ? ? ? ? if(attr === "opacity") {

? ? ? ? ? ? ? ? ? ? ? ? ? ? obj.style.opacity = origin[attr]/100;

? ? ? ? ? ? ? ? ? ? ? ? ? ? obj.style.filter = 'alpha(opacity='+origin[attr]+')';

? ? ? ? ? ? ? ? ? ? ? ? } else {

? ? ? ? ? ? ? ? ? ? ? ? ? ? obj.style[attr] = origin[attr] + "px";

? ? ? ? ? ? ? ? ? ? ? ? }

? ? ? ? ? ? ? ? ? ? ? ? ?

? ? ? ? ? ? ? ? ? ? ? ? //若有一個不等則將標(biāo)記設(shè)為false

? ? ? ? ? ? ? ? ? ? ? ? if(target[attr] != origin[attr]) {

? ? ? ? ? ? ? ? ? ? ? ? ? ? flag = false;

? ? ? ? ? ? ? ? ? ? ? ? }

? ? ? ? ? ? ? ? ? ? }

? ? ? ? ? ? ? ? ? ? console.log("定時器清除了沒?");

? ? ? ? ? ? ? ? ? ? //如果標(biāo)記值為true清除定時器

? ? ? ? ? ? ? ? ? ? if(flag) {

? ? ? ? ? ? ? ? ? ? ? ? clearInterval(obj.timer);

? ? ? ? ? ? ? ? ? ? ? ? //設(shè)置回調(diào)函數(shù)

? ? ? ? ? ? ? ? ? ? ? ? if(callback) {

? ? ? ? ? ? ? ? ? ? ? ? ? ? callback.call(obj);

? ? ? ? ? ? ? ? ? ? ? ? }

? ? ? ? ? ? ? ? ? ? } ?

? ? ? ? ? ? ? ? },30);

? ? ? ? ? ? }

? ? ? ? ? ? ?

? ? ? ? ? ? //獲取元素外聯(lián)和內(nèi)聯(lián)樣式

? ? ? ? ? ? function getStyle(obj,attr) {

? ? ? ? ? ? ? ? return obj.currentStyle ? obj.currentStyle[attr] : getComputedStyle(obj,false)[attr];

? ? ? ? ? ? }

? ? ? ? </script>

? ? </body>

</html>


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

mwm喵 提問者

????沒有改動額
2016-11-06 回復(fù) 有任何疑惑可以回復(fù)我~
#2

前端_小小白 回復(fù) mwm喵 提問者

鼠標(biāo)移入移出事件那邊改了
2016-11-06 回復(fù) 有任何疑惑可以回復(fù)我~
#3

mwm喵 提問者 回復(fù) 前端_小小白

bug應(yīng)該不是在函數(shù)調(diào)用那塊 鼠標(biāo)移入移出事件后面加的是鏈?zhǔn)讲僮鞯幕卣{(diào)函數(shù),沒問題的. 其實(shí)我想你們找的bug是在我寫的change函數(shù)里面 在透明度變化的時候會有極小的幾率卡在0.19和0.2之間這是其一(我測試幾十次好像出現(xiàn)了一次)(幫我解決下) 還有一些bug就需要你們測試了
2016-11-06 回復(fù) 有任何疑惑可以回復(fù)我~
#4

常班長 回復(fù) mwm喵 提問者

33行和34行里的回調(diào)函數(shù)里不能引用this吧,此處的this應(yīng)該不是指向的當(dāng)前<div>標(biāo)簽,而是指向的window
2016-11-08 回復(fù) 有任何疑惑可以回復(fù)我~
#5

mwm喵 提問者 回復(fù) 常班長

我change的回調(diào)函數(shù)用call改變了this指向了(指向的就是當(dāng)前的div哦) (仔細(xì)看代碼)
2016-11-08 回復(fù) 有任何疑惑可以回復(fù)我~
查看2條回復(fù)

舉報

0/150
提交
取消

幫忙找bug, 參考老師的思路寫的單線程鏈?zhǔn)酵絼赢嫼孟裼行﹩栴}, 大家來找找.

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

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

幫助反饋 APP下載

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

公眾號

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