課程
/前端開發(fā)
/JavaScript
/JS動(dòng)畫效果
求move.js的源碼
2016-08-03
源自:JS動(dòng)畫效果 6-1
正在回答
function startMove(obj,json,fn){
var flag=true;//假設(shè)所有都到達(dá)目標(biāo)值
clearInterval(obj.timer);
obj.timer=setInterval(function(){
for(var attr in json){
//1、取當(dāng)前值
var icur=0;
if(attr=='opacity'){
icur=Math.round(parseFloat(getStyle(obj,attr))*100);
}else{
icur=parseInt(getStyle(obj,attr));
}
//2、算速度
var speed=(json[attr]-icur)/8;
speed=speed>0?Math.ceil(speed):Math.floor(speed);
//3、檢測停止
if(icur!=json[attr]){
flag=false;
if(attr=='opacity')
{
obj.style.filter='alpha(opacity:'+attr+')';//針對iE
obj.style.opacity=(icur+speed)/100;
? ?obj.style[attr]=icur+speed+'px';
?if(flag)
?{
? ?if(fn)
fn();
} ?
? }
?
},30)
? ?
};
//獲取樣式
function getStyle(obj,attr){
//IE
if(obj.currentStyle){
obj.currentStyle[attr];
}else{ //FF
return getComputedStyle(obj,false)[attr];
慕九州0389596 提問者
舉報(bào)
通過本課程JS動(dòng)畫的學(xué)習(xí),從簡單動(dòng)畫開始,逐步深入各種動(dòng)畫框架封裝
3 回答老師,您好,能提供一些move.js的源碼么~~~~~
1 回答有沒有老師的move.js
1 回答求這節(jié)課的源碼
1 回答跪求源代碼
2 回答求整個(gè)練習(xí)源碼
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網(wǎng)安備11010802030151號
購課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動(dòng)學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號
2016-08-03
function startMove(obj,json,fn){
var flag=true;//假設(shè)所有都到達(dá)目標(biāo)值
clearInterval(obj.timer);
obj.timer=setInterval(function(){
for(var attr in json){
//1、取當(dāng)前值
var icur=0;
if(attr=='opacity'){
icur=Math.round(parseFloat(getStyle(obj,attr))*100);
}else{
icur=parseInt(getStyle(obj,attr));
}
//2、算速度
var speed=(json[attr]-icur)/8;
speed=speed>0?Math.ceil(speed):Math.floor(speed);
//3、檢測停止
if(icur!=json[attr]){
flag=false;
}
if(attr=='opacity')
{
obj.style.filter='alpha(opacity:'+attr+')';//針對iE
obj.style.opacity=(icur+speed)/100;
}else{
? ?obj.style[attr]=icur+speed+'px';
}
}
?if(flag)
?{
clearInterval(obj.timer);
? ?if(fn)
{
fn();
} ?
? }
?
},30)
? ?
};
//獲取樣式
function getStyle(obj,attr){
//IE
if(obj.currentStyle){
obj.currentStyle[attr];
}else{ //FF
return getComputedStyle(obj,false)[attr];
}
}