Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [js] Problem z animacją setInterval
propage
post
Post #1





Grupa: Zarejestrowani
Postów: 330
Pomógł: 0
Dołączył: 25.01.2008

Ostrzeżenie: (0%)
-----


poniżej wklejam kompletny kod animacji;

Kod
var hoverInterval;

function doStuff_plus(){ doStuff(1); }
function doStuff_minus(){ doStuff(-1); }

function doStuff(hm) {
    
    var h = $('.thumb_slider div').height();
    //alert(h);
    var top = $('.thumb_slider div').css('top');
        
        top = top.replace('px', '');
        top = parseInt(top);        
    
    
        top += hm;
        
    var r =    h + top - 405;
    
    if(top<0 && r > 0)
    {
        $('.thumb_slider div').css({'top':top+'px'});
    }
}

$(function() {
           hoverInterval = setInterval(doStuff_minus,1);

    );
});



problem jest taki, że pod FireFoxem, animacja jest bardzo powodlna, mniejwięcej 10 razy wolniej element przesuwa się niż pod chrome lub ie.
Wydaje mi się że funkcja doStuff jest wywoaływana tyle samo razy wciagu 1 sekundy na wszystkich 3 przeglądarkach, a problem leży w samej funkcji ".css(" w jaki sposób to można poprawić?
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 22.08.2025 - 20:33