為什么只執(zhí)行第一個,后面的鏈式函數沒執(zhí)行
function startMove(obj,json,fn){//四個參數,作用的對象,對象的哪個屬性,作用的值是多少,回調函數,沒退出該函數再執(zhí)行里面的函數。
? ? ? ? // var obj=document.getElementsByTagName('ul')[1];
? ? ? ? clearInterval(obj.timer);
? ? ? ? obj.timer=setInterval(function(){
? ? ? ? ? ? var flag=true;
? ? ? ? ? ? for(var attr in json){ ? ? ? ? ? ?
? ? ? ? ? ? ? ? var icur=0;
? ? ? ? ? ? ? ? if (attr=="opacity") {
? ? ? ? ? ? ? ? ? ? icur=Math.round(parseFloat(getStyle(obj,attr))*100);
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? else{
? ? ? ? ? ? ? ? ? ? icur=parseInt(getStyle(obj,attr));
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? var speed=(json[attr]-icur)/8;
? ? ? ? ? ? ? ? ? ?speed=speed>0?Math.ceil(speed):Math.floor(speed);?
? ? ? ? ? ? ? ? if(icur!=json[attr]){
? ? ? ? ? ? ? ? ? ? flag=false;
? ? ? ? ? ? ? ??
? ? ? ? ? ? ? ? ? ? if(attr=="opacity"){
? ? ? ? ? ? ? ? ? ? ? ?obj.style.filter="Alpha(opacity="+(icur+speed)+")";
? ? ? ? ? ? ? ? ? ? ? ?obj.style.opacity=(icur+speed)/100; ??
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? else{
? ? ? ? ? ? ? ? ? ? obj.style[attr]=icur+speed+"px";
? ? ? ? ? ? ? ? ? ? // console.log(obj.style[attr]);
? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? if(flag){
? ? ? ? ? ? ? ? ? ? clearInterval(obj.timer);
? ? ? ? ? ? ? ? ? ? // console.log("down");
? ? ? ? ? ? ? ? ? ? if(fn){
? ? ? ? ? ? ? ? ? ? ? ? fn();
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? },30)
}
? //獲得非行內定義的樣式,封裝函數
function getStyle(obj,attr){
? ?if (obj.currentStyle){
? ? ? ?return obj.currentStyle[attr];//針對IE瀏覽器;
? ?}else{
? ? ? ?return getComputedStyle(obj,false)[attr];//針對大多數瀏覽器;
? ?}
}
2016-04-14
呵呵,但是寶寶想要全套的源碼,自己留著用,請問您方便分享嘛?
2016-04-10
求樓主分享一根move.js的源碼給我,好嗎?謝謝,思密達