Computerhilfen.de Logo
Forum
Tipps
News
Frage stellen

setInterval funktionier nicht richtig

hallo Leute,

ich sitze am folgenden Code schon drei stunden, aber ich bekomme es einfach nicht raus, warum setTimeout sich so schnell aufruft.Ich hab da 10 sek angegeben. Der Code soll die Opacity ändern. Das passiert aber leider viel zu schnell. Ich hab alles ausprobiert, von 1 ms bis zu 10000 ms. Könnt ihr mir helfen.


Effect = function(){
   var _this   = this;

   this.setStyle = function(adds)
         {
            if(!adds) return false;
            if(!adds.objID) return false;
            if(!$(adds.objID)) return false;
            for(var st in adds.style)
            {
               if($(adds.objID).style.st){
                  $(adds.objID).style.st = adds.style[st];
               }
            }
         }

   this.appear = function(adds)
         {
            if(!adds) return false;
            if(!adds.objID) return false;
            if(!$(adds.objID)) return false;
            var copy      = adds;
            copy.end      = (!isNaN(copy.end)) ? copy.end : 1;
            copy.duration    = (!isNaN(copy.duration)) ? copy.duration : 10;
            copy.step       = (!isNaN(copy.step)) ? copy.step : 0.01;
            copy.dir      = copy.dir ? copy.dir : '+';
            copy.start      = (!isNaN(copy.start)) ? copy.start : 0;

            if(copy.dir == '+'){
               copy.start   += copy.step;
            }

            if(copy.dir == '-'){
               copy.start   -= copy.step;
            }

            if(window.document.documentElement.style.opacity == "")$(copy.objID).style.opacity = copy.start;
            if(window.document.documentElement.style.filter == "" ) $(copy.objID).style.filter = 'alpha(style=2,opacity=' + (copy.start * 100) + ')';

            if(Math.ceil($(copy.objID).style.opacity) > copy.end && window.document.documentElement.style.opacity != 'undefined')
               window.setTimeout('' + this.appear(copy) + '', 100000);

            if(Math.ceil($(copy.objID).style.filter) > copy.end && window.document.documentElement.style.filter != 'undefinde')
               window.setTimeout('' + this.appear(copy) + '',100000);

         }

}



mfg linksys


Antworten zu setInterval funktionier nicht richtig:

hey leute,

ich hab das Problem :D
man muss bei setTimeout einfach die Function in eine function()  {} container tun, damit es dann so aussieht:

setTimeout(function(){ meine Function }, zeitangabe);


trotzdem danke an alle die sich bemüht haben das Problem zu lösen  ;)


mfg
linksys


« Delphi 7 PE DownloadC++ GUI! »
 

Schnelle Hilfe: Hier nach ähnlichen Fragen und passenden Tipps suchen!

Fremdwörter? Erklärungen im Lexikon!
Quellcode
Ein Quellcode, auch als Quelltext bekannt, bezeichnet den unkompilierten Programm-Code einer Software. Quell- oder Programm-Code ist der auch für Menschen lesbare Co...

Unicode
Unicode ist ein international anerkannter Standard, der als universeller Zeichencode ("Universal Code") dient und durch das Unicode-Konsortium entwickelt und verwaltet wi...

QR-Code
QR-Codes, die Abkürzung für "Quick Response Codes", sind eine Form von zweidimensionalen Barcodes. Damit lassen sich Informationen schnell und effizient speiche...