Line 26: | Line 26: | ||
var as = document.getElementById('toc').getElementsByTagName('a'); | var as = document.getElementById('toc').getElementsByTagName('a'); | ||
document.addEventListener('scroll', function () { | document.addEventListener('scroll', function () { | ||
− | |||
− | |||
for (var a of as) { | for (var a of as) { | ||
var id = a.href.replace(/.+?#/, ''); | var id = a.href.replace(/.+?#/, ''); | ||
Line 37: | Line 35: | ||
var y = element.getBoundingClientRect().top; | var y = element.getBoundingClientRect().top; | ||
− | + | var active = y < 50; | |
− | var active = y < | + | |
if (active) { | if (active) { | ||
console.log(id); | console.log(id); |
Revision as of 15:45, 6 October 2018