Skip to content
Snippets Groups Projects
Commit 9a549e66 authored by Josh Borrow's avatar Josh Borrow
Browse files

Added initial scrollspy js

parent 96d63ddb
Branches
No related tags found
No related merge requests found
(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');
}
}
};
})();
\ No newline at end of file
......@@ -35,4 +35,6 @@
</div>
</div>
</div>
{% endblock %}
\ No newline at end of file
{% endblock %}
{% block js %}<script src="sidebar.js"></script>{% endblock %}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment