Nomadic Functions
Where selfishness is good™
blog
code
code
/
text scroller
The further from the center of the scroll bar, the faster the text will scroll. The closer to the center, the slower it will scroll. When you move over the center it pauses.
Example:
Internal Link
JAVASCRIPT
function $(v) { return(document.getElementById(v)); } function $S(v) { return($(v).style); } function xy(e,v) { return(v?(browser('msie')?event.clientY+document.body.scrollTop:e.pageY):(browser('msie')?event.clientX+document.body.scrollTop:e.pageX)); } function browser(v) { return(Math.max(navigator.userAgent.toLowerCase().indexOf(v),0)); } function box() { IE=navigator.userAgent.indexOf('MSIE')!=-1?true:false; h=$('data').offsetHeight; o=parseInt($S('data').top); s=1; ratio=(h/(o+h))*(154/h); hover=false; scroll(); } function scroll() { $S('data').top=(t=(parseInt($S('data').top)-s))+"px"; $S('slide').marginTop=((154-((t+h)*ratio))+5)+'px'; $S('slide').backgroundPosition=hover?'0 9px':''; if(t<-h) $S('data').top=o+"px"; else if(t>o) $S('data').top=-h+"px"; setTimeout("scroll()",42); } function slip() { function XY(e) { var X=xy(e),Y=xy(e,1); if(X>=185 && X<=200 && Y>=13 && Y<=190) { $S('slider').backgroundPosition='0px 173px'; $('data2').firstChild.nodeValue='pause'; hover=true; s=(Y-98)/5; } else { $S('slider').backgroundPosition=''; document.onmousemove=function(){}; hover=false; s=(Y>98)?1:-1; } } document.onmousemove=XY; } function flip(sp) { $('data2').firstChild.nodeValue=(sp==0)?'play':'pause'; s=sp; } function display(v) { for(i=0; i<(r=Array("data","search","about")).length; i++) { $S(r[i]+"2").color=(r[i]==v)?'#ddd':'#999'; $S(r[i]).display=(r[i]==v)?'block':'none'; } if(v!='data') { flip(0); $S('slider').display='none'; } else { flip(s==0?1:0); $S('slider').display='block'; } } function search(v) { for(i=0; i<(t=$('search').getElementsByTagName('a')).length; i++) t[i].className=(t[i].firstChild.firstChild.nodeValue.toLowerCase()==v)?"s0":"s1"; document.form.type.value=v; } function clearQ(v) { if(v.defaultValue==v.value) v.value=''; } window.onload=box;
Have ideas for code changes?
CC
·
GPL
·
NoFunc.com