1/* Tiny Scrolling - a smooth navigation between internal links and their destinations 2by Marco Rosella - http://www.centralscrutinizer.it/en/design/js-php/tiny-scrolling 3based on the works by Travis Beckham and Brian McAllister. 4 v0.3 - March 27, 2006 5*/ 6window.onload = function() { 7 tinyScrolling.init(); 8 } 9 10var tinyScrolling = { 11 speed : 30, //set here the scroll speed: when this value increase, the speed decrease. 12 maxStep: 80, //set here the "uniform motion" step for long distances 13 brakeK: 3, //set here the coefficient of slowing down 14 hash:null, 15 currentBlock:null, 16 requestedY:0, 17 init: function() { 18 var lnks = document.getElementsByTagName('a'); 19 for(var i = 0, lnk; lnk = lnks[i]; i++) { 20 if ((lnk.href && lnk.href.indexOf('#') != -1) && ( (lnk.pathname == location.pathname) || 21 ('/'+lnk.pathname == location.pathname) ) && (lnk.search == location.search)) { 22 lnk.onclick = tinyScrolling.initScroll; 23 } 24 } 25 }, 26 getElementYpos: function(el){ 27 var y = 0; 28 while(el.offsetParent){ 29 y += el.offsetTop 30 el = el.offsetParent; 31 } return y; 32 }, 33 getScrollTop: function(){ 34 if(document.all) return (document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop; 35 else return window.pageYOffset; 36 }, 37 getWindowHeight: function(){ 38 if (window.innerHeight) return window.innerHeight; 39 if(document.documentElement && document.documentElement.clientHeight) return document.documentElement.clientHeight; 40 }, 41 getDocumentHeight: function(){ 42 if (document.height) return document.height; 43 if(document.body.offsetHeight) return document.body.offsetHeight; 44 }, 45 initScroll: function(e){ 46 var targ; 47 if (!e) var e = window.event; 48 if (e.target) targ = e.target; 49 else if (e.srcElement) targ = e.srcElement; 50 51 //C[WZbgÌÎ 52 do 53 { 54 if (typeof(targ.tagName) != "undefined") 55 { 56 //NÅÈ©Á½êÌÎ 57 if (targ.tagName.toLowerCase() == "a") 58 { 59 break; 60 } 61 } 62 targ = targ.parentNode; 63 } while(targ != null) 64 65 if (targ == null) 66 { 67 return ; 68 } 69 70 tinyScrolling.hash = targ.href.substr(targ.href.indexOf('#')+1,targ.href.length); 71 tinyScrolling.currentBlock = document.getElementById(tinyScrolling.hash); 72 if(!tinyScrolling.currentBlock) return; 73 tinyScrolling.requestedY = tinyScrolling.getElementYpos(tinyScrolling.currentBlock); 74 tinyScrolling.scroll(); 75 return false; 76 }, 77 scroll: function(){ 78 var top = tinyScrolling.getScrollTop(); 79 if(tinyScrolling.requestedY > top) { 80 var endDistance = Math.round((tinyScrolling.getDocumentHeight() - (top + tinyScrolling.getWindowHeight())) / tinyScrolling.brakeK); 81 endDistance = Math.max(Math.round((tinyScrolling.requestedY-top)/ tinyScrolling.brakeK), endDistance); 82 var offset = Math.max(2, Math.min(endDistance, tinyScrolling.maxStep)); 83 } else { var offset = - Math.min(Math.abs(Math.round((tinyScrolling.requestedY-top)/ tinyScrolling.brakeK)), tinyScrolling.maxStep); 84 } window.scrollTo(0, top + offset); 85 if(Math.abs(top-tinyScrolling.requestedY) <= 1 || tinyScrolling.getScrollTop() == top) { 86 window.scrollTo(0, tinyScrolling.requestedY); 87 if(!document.all || window.opera) location.hash = tinyScrolling.hash; 88 tinyScrolling.hash = null; 89 } else setTimeout(tinyScrolling.scroll,tinyScrolling.speed); 90 } 91}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.