From 5da82cc579a69b5a53f9c15dfce28e37917d1579 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Fri, 22 Oct 2021 22:30:08 -0400 Subject: refactor(html): a one-header sticky header --- coverage/htmlfiles/coverage_html.js | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'coverage/htmlfiles/coverage_html.js') diff --git a/coverage/htmlfiles/coverage_html.js b/coverage/htmlfiles/coverage_html.js index 182e518c..cba668a8 100644 --- a/coverage/htmlfiles/coverage_html.js +++ b/coverage/htmlfiles/coverage_html.js @@ -611,24 +611,20 @@ coverage.build_scroll_markers = function () { }; coverage.wire_up_sticky_header = function () { - const body = document.querySelector('body'); + const header = document.querySelector('header'); const header_bottom = ( - document.querySelector('header .content .stats').getBoundingClientRect().top - - document.querySelector('header').getBoundingClientRect().top + header.querySelector('.content h2').getBoundingClientRect().top - + header.getBoundingClientRect().top ); function updateHeader() { if (window.scrollY > header_bottom) { - body.classList.remove('bighead'); - body.classList.add('littlehead'); + header.classList.add('sticky'); } else { - body.classList.add('bighead'); - body.classList.remove('littlehead'); + header.classList.remove('sticky'); } } + window.addEventListener('scroll', updateHeader); updateHeader(); - window.addEventListener('scroll', function() { - updateHeader(); - }); }; -- cgit v1.2.1