<br> window.onload=function()<br> {<br> var re=document.getElementById("mButton");<br> var hei="300";<br> var wid="300";<br> re.onclick=slideDown;<br> function slideDown()<br> {<br> elem=document.getElementById("container");<br> elem.style.height='0px';<br> elem.style.width='0px';<br> elem.style.display="";<br> for(var i=0;i<100;i+=5)<br> {<br> (function()<br> {<br> var pos=i;<br> //alert(pos+"\n"+(pos/100)*hei+"\n"+(pos+1)*10);<br> setTimeout(function(){elem.style.height=(pos/100)*hei+"px";elem.style.width=(pos/100)*wid+"px";},(pos+1)*100);<br> })();<br> }<br> }<br> alert(document.body.scrollWidth+'px');<br> alert(document.body.scrollLeft+"px");<br> };<br>
Slider
现在是有缓动效果的,可是把
setTimeout(function(){elem.style.height=(pos/100)*hei+"px";elem.style.width=(pos/100)*wid+"px";},(pos+1)*100);中的(pos+1)*10改成常数,比如50后,就没有缓动效果了,这是为什么啊?