Visualizzazione dei risultati da 1 a 5 su 5

Discussione: Scope intervallo

  1. #1

    Scope intervallo

    Codice PHP:
    function prova(id_oggetto,c_corrente,to_c) {
        var 
    obj document.getElementById(id_oggetto);
        var 
    c;
        if (
    c_corrente to_c) {
            
    c_corrente+1;
        } else {
            
    c_corrente-1;
        }
        if (
    to_c || to_c) {
            
    obj.innerHTML=(c+' '+to_c);
            
    intervallo setInterval("prova('"+id_oggetto+"',"+c+','+to_c+')',1000);
        } else if (
    == to_c) {
            
    clearInterval(intervallo);
            
    alert('ok');
            return 
    true;
        }

    possibile che continui a darmi un ciclo infinito???

    la funzione dovrebbe solamente richiamarsi ogni tot aumentando c_corrente sino a to_c, una volta arrivata si deve fermare

  2. #2

  3. #3
    ho modificato la funzione x quello che deve realmente fare..il problema è che lo fà ma poi và in loop...datemi una mano please...
    Codice PHP:
    intervallo_allunga_x null;
    intervallo_allunga_y null;
    function 
    resize_obj(id_oggetto,to_x,to_y,tipo) {
        
    //tipo è 'y' o 'x' rappresenta la prima coordinata da modificare
        
    var obj document.getElementById(id_oggetto);
        var 
    tempo 1;
        if (
    tipo == 'y') {
            var 
    c_corrente obj.clientHeight;
        } else if (
    tipo == 'x') {
            var 
    c_corrente obj.clientWidth;
        }
        
        if (
    tipo == 'y') {
            
    to_c to_y;
        } else if (
    tipo == 'x') {
            
    to_c to_x;
        }
        
        if (
    c_corrente to_c) {
            var 
    c_corrente+1;
        } else if (
    c_corrente to_c) {
            var 
    c_corrente-1;
        }
        
        if (
    == to_c) {
            if (
    tipo == 'y') {
                
    clearInterval(intervallo_allunga_y);
                
    intervallo_allunga_y null;
                
    intervallo_allunga_x setInterval("resize_obj('"+id_oggetto+"',"+to_x+","+to_y+",'x')",tempo);
                return;
            } else if (
    tipo == 'x') {
                
    clearInterval(intervallo_allunga_x);
                
    intervallo_allunga_x null;
                
    itervallo_allunga_y setInterval("resize_obj('"+id_oggetto+"',"+to_x+","+to_y+",'y')",tempo);
                return;
            }
                
        } else {
            if (
    tipo == 'y') {
                
    obj.style.height c+'px';
                if (
    intervallo_allunga_y == null) {
                    
    intervallo_allunga_y setInterval("resize_obj('"+id_oggetto+"',"+to_x+","+to_y+",'y')",tempo);
                return;
                }
            } else if (
    tipo == 'x') {
                
    obj.style.width c+'px';
                if (
    intervallo_allunga_x == null) {
                    
    intervallo_allunga_x setInterval("resize_obj('"+id_oggetto+"',"+to_x+","+to_y+",'x')",tempo);
                }
                return;
            }
        }



  4. #4
    nulla da fare...looop looop looop... 2 giorni che ci vado dietro...

  5. #5
    visto che non ne andavo fuori ho ricreato sta funz....solo che mi allerta con finito all'infinito...(scusate il gioco di parole)...
    Codice PHP:
    var is_started;
    function 
    resize_obj(id_oggetto,to_x,to_y) {
        var 
    obj document.getElementById(id_oggetto);
        var 
    now_x = new Number(obj.clientWidth);
        var 
    now_y = new Number(obj.clientHeight);
        var 
    intervallo_resize;

        if (
    now_x to_x) {
            
    obj.style.width Number(now_x-1)+'px';
        } else if (
    now_x to_x) {
            
    obj.style.width Number(now_x+1)+'px';
        }
        
        if (
    now_y to_y) {
            
    obj.style.height now_y-1+'px';
        } else if (
    now_y to_y) {
            
    obj.style.height now_y+1+'px';
        }
        
        
    //obj.innerHTML = obj.clientWidth+"  "+obj.clientHeight;
        
        
    if (obj.clientWidth == to_x obj.clientHeight == to_y) {
            try {
                
    clearInterval(intervallo_resize);
            } catch (
    e) {alert(e);
            }
            
    alert('finito');
            return;
        } else {
            if (
    is_started === true) {} else {
                
    is_started true;
                
    intervallo_resize setInterval("resize_obj('"+id_oggetto+"',"+to_x+","+to_y+")",1);
            }
        }


Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.