script.js 689 B

1234567891011121314151617181920
  1. var headerBackground = true;
  2. function updateScroll(checkHeight) {
  3. if (checkHeight) {
  4. if (headerBackground)
  5. document.querySelector("header").style.background = "black";
  6. headerBackground = false;
  7. } else {
  8. if (!headerBackground)
  9. document.querySelector("header").style.background = "";
  10. headerBackground = true;
  11. }
  12. }
  13. window.addEventListener("scroll", function() { updateScroll(window.scrollY > this.innerHeight * 0.27); });
  14. var fixedContent = document.querySelector(".body.body-fixed");
  15. if (fixedContent)
  16. fixedContent.addEventListener("scroll", function() { updateScroll(this.scrollTop > this.clientHeight * 0.27); });