Visualizzazione dei risultati da 1 a 5 su 5

Discussione: moshide in scroll area

  1. #1
    Utente di HTML.it
    Registrato dal
    May 2003
    Messaggi
    186

    moshide in scroll area

    Ciao ragazzi: ho questo script di un div con testo scrollabile; quando parte calcola l'area del content (in neretto) e fin qui ci siamo.


    //If you want it to move faster you can set this lower:
    var speed=5

    //Sets variables to keep track of what's happening
    var loop, timer

    //Object constructor
    function makeObj(obj,nest){
    nest=(!nest) ? '':'document.'+nest+'.'
    this.el=bw.dom?document.getElementById(obj):bw.ie4 ?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):0;
    this.css=bw.dom?document.getElementById(obj).style :bw.ie4?document.all[obj].style:bw.ns4?eval(nest+'document.'+obj):0;
    this.scrollHeight=bw.ns4?this.css.document.height: this.el.offsetHeight
    this.clipHeight=bw.ns4?this.css.clip.height:this.e l.offsetHeight

    this.up=goUp;this.down=goDown;
    this.moveIt=moveIt; this.x; this.y;
    this.obj = obj + "Object"
    eval(this.obj + "=this")
    return this
    }
    function moveIt(x,y){
    this.x=x;this.y=y
    this.css.left=this.x
    this.css.top=this.y
    }

    //Makes the object go up
    function goDown(move){
    if(this.y>-this.scrollHeight+oCont.clipHeight){
    this.moveIt(0,this.y-move)
    if(loop) setTimeout(this.obj+".down("+move+")",speed)
    }
    }
    //Makes the object go down
    function goUp(move){
    if(this.y<0){
    this.moveIt(0,this.y-move)
    if(loop) setTimeout(this.obj+".up("+move+")",speed)
    }
    }

    //Calls the scrolling functions. Also checks whether the page is loaded or not.
    function scroll(speed){
    if(loaded){
    loop=true;
    if(speed>0) oScroll.down(speed)
    else oScroll.up(speed)
    }
    }

    //Stops the scrolling (called on mouseout)
    function noScroll(){
    loop=false
    if(timer) clearTimeout(timer)
    }
    //Makes the object
    var loaded;
    function scrollInit(){
    oCont=new makeObj('divCont2')
    oScroll=new makeObj('divText2','divCont2')
    oScroll.moveIt(0,0)
    oCont.css.visibility='visible'
    loaded=true;
    }
    //Call the init on page load
    onload=scrollInit;
    // -->
    </SCRIPT>




    Se però voglio mettere dentro delle faq open-close stile moshide dovrei, all'apertura del div che contiene il testo nascosto, far ricalcolare l'area dello scrolling e lo faccio facendo ripartire da capo lo script (in neretto):


    <DIV id=divUp2>
    [img]chi_siamo_file/freccia-giu.gif[/img]
    </DIV>
    <DIV id=divDown2>
    [img]chi_siamo_file/freccia-su.gif[/img]
    </DIV>

    <DIV id=divCont2>
    <DIV id=divText2>
    apri</u> ' : ' chiudi [-] '; o.display = o.display!='none' ? 'none' : 'block'; scrollInit();"><u>apri</u>[/b]
    <div style="display: none; position:relative; left:10px;" id="moshide1">
    ...qui il testo nascosto...perj poi poweij poej reo jpweor weior kegpoe pwek eqpo qe oeqpoqkerpo keqrpogeqpoqeoprg pej oej goej oej opwej poewq goe g ...
    </div>
    </DIV>
    </DIV>


    ...e anche fin qui tutto bene ...ma...il problema è che, ovviamente ripartendo tutto lo script daccapo, il testo scrollabile mi si riposiziona dall'inizio, mentre io voglio farlo rimanere esattamente dove si trova nella continuazione della lettura.
    Non so se mi sono spiegato. Spero possiate aiutarmi. Grazie.

  2. #2
    Utente di HTML.it
    Registrato dal
    May 2003
    Messaggi
    186
    :master:

  3. #3
    Utente di HTML.it
    Registrato dal
    May 2003
    Messaggi
    186
    insomma so che dovrei creare una funzione solo per ricalcolare l'area aggiornata del testo e riportare la scrollbar dove l'ho la lasciata, invece di rilanciare Init() che mi ricrea tutto daccapo.

    ed il tutto sta qua...

    this.el=bw.dom?document.getElementById(obj):bw.ie4 ?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):0;
    this.css=bw.dom?document.getElementById(obj).style :bw.ie4?document.all[obj].style:bw.ns4?eval(nest+'document.'+obj):0;
    this.scrollHeight=bw.ns4?this.css.document.height: this.el.offsetHeight
    this.clipHeight=bw.ns4?this.css.clip.height:this.e l.offsetHeight
    ...

    ...più il codice per ricordare la posizione della scrollbar

    Qualcuno sa come aiutarmi? Grazie.

  4. #4
    Utente di HTML.it
    Registrato dal
    May 2003
    Messaggi
    186

  5. #5
    Utente di HTML.it
    Registrato dal
    May 2003
    Messaggi
    186

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.