12345678910111213141516171819202122232425 |
- function scrolltrack() {
- var i=anchors.length-1;
- var ruler=(window.innerHeight || document.documentElement.clientHeight) / 8;
- if ((window.innerHeight + window.pageYOffset) >= document.body.offsetHeight - 20) {
- document.getElementById(anchors[i]+'L').style.color='#C0D9F2';
- } else {
- while (i>=0) {
- if (document.getElementById(anchors[i]).getBoundingClientRect().top<=ruler) {
- document.getElementById(anchors[i]+'L').style.color='#C0D9F2';
- break;
- } else {
- document.getElementById(anchors[i]+'L').style.color='#539CDD';
- }
- i--;
- }
- }
- if (i>=0) {
- // console.log('Arrivati a: '+anchors[i]);
- document.getElementById(anchors[i]+'L').scrollIntoView({behavior: "smooth", block: "center"});
- }
- while (i>0) {
- i--;
- document.getElementById(anchors[i]+'L').style.color='#539CDD';
- }
- }
|