Skip to content

Commit

Permalink
Add doc for header scroll, support prefers contrast
Browse files Browse the repository at this point in the history
  • Loading branch information
janfaracik committed Feb 8, 2025
1 parent 90dd49f commit c493a41
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/main/js/components/header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Utils from "@/components/dropdowns/utils";
import { createElementFromHtml } from "@/util/dom";

function init() {
// TODO
// Fade in the page header on scroll, increasing opacity and intensity of the backdrop blur
window.addEventListener("scroll", () => {
const navigation = document.querySelector("#page-header");
const scrollY = Math.max(0, window.scrollY);
Expand All @@ -18,9 +18,10 @@ function init() {
!document.querySelector(".jenkins-search--app-bar") &&
!document.querySelector(".app-page-body__sidebar--sticky")
) {
const prefersContrast = window.matchMedia('(prefers-contrast: more)').matches;
navigation.style.setProperty(
"--border-opacity",
Math.min(10, scrollY) + "%",
Math.min(prefersContrast ? 100 : 10, prefersContrast ? scrollY * 3 : scrollY) + "%",
);
}
});
Expand Down

0 comments on commit c493a41

Please sign in to comment.