mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-11-19 20:03:51 +01:00
navbar compat for compare
This commit is contained in:
5 files changed
+25
-19
No files matched your search
@@ -175,19 +175,26 @@ const strings = await api.strings(locale);
|
|||||||
const navbar = document.getElementById("navbar-mobile")!;
|
const navbar = document.getElementById("navbar-mobile")!;
|
||||||
const tool = document.getElementById("current-tool")!;
|
const tool = document.getElementById("current-tool")!;
|
||||||
const overlay = document.getElementById("navbar-mobile-overlay")!;
|
const overlay = document.getElementById("navbar-mobile-overlay")!;
|
||||||
let lastScrollY = window.scrollY;
|
const lastScrollTops = new WeakMap<Element, number>();
|
||||||
|
|
||||||
window.addEventListener(
|
// Scroll doesn't bubble, so capturing also catches nested scrollers like tables
|
||||||
|
document.addEventListener(
|
||||||
"scroll",
|
"scroll",
|
||||||
() => {
|
(event) => {
|
||||||
const scrollY = window.scrollY;
|
const target =
|
||||||
|
event.target instanceof Element
|
||||||
|
? event.target
|
||||||
|
: document.scrollingElement!;
|
||||||
|
const scrollTop = target.scrollTop;
|
||||||
|
const lastScrollTop = lastScrollTops.get(target) ?? 0;
|
||||||
|
|
||||||
if (scrollY === lastScrollY) return;
|
// Horizontal scrolling leaves scrollTop unchanged, so it's ignored
|
||||||
|
if (scrollTop === lastScrollTop) return;
|
||||||
|
|
||||||
navbar.dataset.visible = `${scrollY < lastScrollY}`;
|
navbar.dataset.visible = `${scrollTop < lastScrollTop}`;
|
||||||
lastScrollY = scrollY;
|
lastScrollTops.set(target, scrollTop);
|
||||||
},
|
},
|
||||||
{ passive: true },
|
{ capture: true, passive: true },
|
||||||
);
|
);
|
||||||
|
|
||||||
tool.addEventListener("click", () => {
|
tool.addEventListener("click", () => {
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
<script>
|
<script>
|
||||||
const root = document.documentElement;
|
// TODO: implement light mode here
|
||||||
const media = window.matchMedia("(prefers-color-scheme: dark)");
|
// const root = document.documentElement;
|
||||||
|
// const media = window.matchMedia("(prefers-color-scheme: dark)");
|
||||||
|
|
||||||
function applyTheme(e: MediaQueryList | MediaQueryListEvent) {
|
// function applyTheme(e: MediaQueryList | MediaQueryListEvent) {
|
||||||
root.classList.toggle("dark", e.matches);
|
// root.classList.toggle("dark", e.matches);
|
||||||
root.classList.toggle("light", !e.matches);
|
// root.classList.toggle("light", !e.matches);
|
||||||
}
|
// }
|
||||||
|
|
||||||
applyTheme(media);
|
// applyTheme(media);
|
||||||
media.addEventListener("change", applyTheme);
|
// media.addEventListener("change", applyTheme);
|
||||||
</script>
|
</script>
|
||||||
@@ -42,7 +42,6 @@ function Root({ children, className, scrollable, ...props }: RootProps) {
|
|||||||
|
|
||||||
return () => observer.disconnect();
|
return () => observer.disconnect();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const content = (
|
const content = (
|
||||||
<table ref={table} className={styles.table}>
|
<table ref={table} className={styles.table}>
|
||||||
{children}
|
{children}
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ const tool = tools.tanks;
|
|||||||
|
|
||||||
.main {
|
.main {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media screen and (max-width: 80rem) {
|
@media screen and (max-width: 80rem) {
|
||||||
|
|||||||
@@ -17,8 +17,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.table {
|
.table {
|
||||||
flex: 1;
|
|
||||||
min-height: 0;
|
|
||||||
align-self: stretch;
|
align-self: stretch;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user