1
0
Fork 0
MastodonStartpage/web/js/scrolltrack.js
2019-12-02 20:16:26 +01:00

25 Zeilen
812 B
JavaScript

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='#97C3E9';
} else {
while (i>=0) {
if (document.getElementById(anchors[i]).getBoundingClientRect().top<=ruler) {
document.getElementById(anchors[i]+'L').style.color='#97C3E9';
break;
} else {
document.getElementById(anchors[i]+'L').style.color='#3088D4';
}
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='#3088D4';
}
}