Skip to content
Snippets Groups Projects
Select Git revision
  • e82d415fcda3d903b10f6acee4585aa8e5fb239c
  • master default protected
  • add_logger
  • spheric_talk
  • james_paper
  • ewass_talk
  • updated_contact_list
  • about-page-information
  • eurohack
  • updated_people_list
10 results

sidebar.js

Blame
  • user avatar
    Josh Borrow authored
    9a549e66
    History
    sidebar.js 635 B
    (function() {
        'use strict';
      
        var section = document.querySelectorAll(".section");
        var sections = {};
        var i = 0;
      
        Array.prototype.forEach.call(section, function(e) {
          sections[e.id] = e.offsetTop;
        });
      
        window.onscroll = function() {
          var scrollPosition = document.documentElement.scrollTop || document.body.scrollTop;
      
          for (i in sections) {
            if (sections[i] <= scrollPosition) {
              document.querySelector('.active').setAttribute('class', ' ');
              document.querySelector('a[href*=' + i + ']').setAttribute('class', 'active');
            }
          }
        };
      })();