function?startMove(obj,json,func){
????clearInterval(obj.timer);
????var?i?=?true;//假設(shè)所有運(yùn)動(dòng)都完成
????obj.timer?=?setInterval(function(){
????????//1.取值
????????for(var?arrt?in?json){
????????var?ice?=?0;
????????//判斷是否是透明度
????????if(arrt?==?'opacity'){
????????????ice?=?Math.round(parseFloat(getStyle(obj,arrt))*100);//當(dāng)前透明度數(shù)值
????????????}else{
????????????ice?=?parseInt(getStyle(obj,arrt));//當(dāng)前數(shù)值
????????????????}
????????//2.計(jì)算速度????????
????????var?speed?=?(json[arrt]-ice)/5;
????????//做緩沖運(yùn)動(dòng)的值的取整,如果大于0,向上取整;小于0,向下取整。
????????speed?=?(speed>0)?Math.ceil(speed):Math.floor(speed);
????????//3.檢查停止
????????if(ice?!=?json[arrt]){????????????????????????????????
????????????i?=?false;//假如當(dāng)前值不等于目標(biāo)值,繼續(xù)執(zhí)行以下操作。
????????????????}????????????????????????????????
??????????????if(arrt?==?'opacity'){
??????????????????//針對(duì)IE瀏覽器
??????????????????obj.style.filter?=?'alpha(opacity:'+(ice+speed)+')';
??????????????????//針對(duì)FireFox(火狐瀏覽器)/Chrom(谷歌瀏覽器)
??????????????????obj.style.opacity?=?(ice+speed)/100;?
??????????????????}else{
??????????????????obj.style[arrt]?=?ice?+?speed?+?'px';??
??????????????????????}????????????????
????????????}
????????if(i){//假如i成立(等于true),關(guān)閉計(jì)時(shí)器
????????????clearInterval(obj.timer);
????????????if(func){//判斷是否還有后調(diào)函數(shù)????
????????????????func();
????????????}????????????????
??????????}
????????},30);
????}
????
????
<script?type="text/javascript">
window.onload?=?function(){
????var?div?=?document.getElementById('id');
????
????div.onmouseover?=?function(){
????????startMove(div,{width:400,height:300},function(){
????????????startMove(div,{opacity:100});
????????????});
????????}
????div.onmouseout?=?function(){
????????startMove(div,{width:200,height:150},function(){
????????????startMove(div,{opacity:30});
????????????});
????????}
????}
</script>
在學(xué)習(xí)完美運(yùn)動(dòng)框架課程后,這個(gè)代碼為什么沒有執(zhí)行后調(diào)函數(shù)。
手刃情人
2016-04-20 15:33:00