Difference between revisions of "Template:TU Darmstadt/JS"

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 () {
    var scrollY = window.scrollY;
 
 
 
     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;
      console.log(id, y, scrollY, y < scrollY);
+
       var active = y < 50;
       var active = y < scrollY;
+
 
       if (active) {
 
       if (active) {
 
           console.log(id);
 
           console.log(id);

Revision as of 15:45, 6 October 2018