課程
/前端開發(fā)
/JavaScript
/JS動(dòng)畫效果
我寫的鼠標(biāo)移入,就不能回來了!加了直接定值30px,也沒有出現(xiàn),感覺亂了!能看看代碼嗎?
2015-11-15
源自:JS動(dòng)畫效果 7-1
正在回答
function startMove(obj,json,fn){
var frag=true;
clearInterval(obj.timer);
obj.timer=setInterval(function(){
for(var att in json){
var wid=0;
//判斷是否為設(shè)置透明度屬性
if (att=='opacity') {
wid=Math.round(parseFloat(getStyle(obj,att))*100);
}else{
wid=parseInt(getStyle(obj,att));
} ?
var speed=(json[att]-wid)/8;
speed=speed>0?Math.ceil(speed):Math.floor(speed);
if (json[att]!=wid) {
frag=false;
}
obj.style.filter='alpha(opacity:'+(wid+speed)+')';
obj.style.opacity=(wid+speed)/100;
} else {
obj.style[att]=wid+speed+'px';
if (frag) {
if (fn) {
fn();
},30);
//獲取obj的屬性方法,兼容瀏覽器
function getStyle(obj,att){
if (obj.currentStyle) {
return obj.currentStyle[att];
return getComputedStyle(obj,false)[att];
舉報(bào)
通過本課程JS動(dòng)畫的學(xué)習(xí),從簡(jiǎn)單動(dòng)畫開始,逐步深入各種動(dòng)畫框架封裝
1 回答動(dòng)畫案例中
5 回答js動(dòng)畫效果顯示不出來
2 回答js動(dòng)畫改動(dòng)怎么不出效果呢?
6 回答動(dòng)畫案例那一節(jié)的問題
1 回答請(qǐng)問有沒有人有JS這個(gè)動(dòng)畫案例的圖標(biāo)和代碼
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號(hào)-11 京公網(wǎng)安備11010802030151號(hào)
購(gòu)課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動(dòng)學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號(hào)
2015-11-27
function startMove(obj,json,fn){
var frag=true;
clearInterval(obj.timer);
obj.timer=setInterval(function(){
for(var att in json){
var wid=0;
//判斷是否為設(shè)置透明度屬性
if (att=='opacity') {
wid=Math.round(parseFloat(getStyle(obj,att))*100);
}else{
wid=parseInt(getStyle(obj,att));
} ?
var speed=(json[att]-wid)/8;
speed=speed>0?Math.ceil(speed):Math.floor(speed);
if (json[att]!=wid) {
frag=false;
}
if (att=='opacity') {
obj.style.filter='alpha(opacity:'+(wid+speed)+')';
obj.style.opacity=(wid+speed)/100;
} else {
obj.style[att]=wid+speed+'px';
}
}
if (frag) {
clearInterval(obj.timer);
if (fn) {
fn();
}
}
},30);
}
//獲取obj的屬性方法,兼容瀏覽器
function getStyle(obj,att){
if (obj.currentStyle) {
return obj.currentStyle[att];
}else{
return getComputedStyle(obj,false)[att];
}
}