Skip to content

Commit 174b420

Browse files
authored
refactor(v2): use transform instead of top position for hideable navbar (#4194)
* refactor(v2): use translateY instead of top to hide navbar * Use translate3d instead of translateY
1 parent d6510b6 commit 174b420

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

packages/docusaurus-theme-classic/src/theme/Navbar/styles.module.css

+3-2
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@
1818
}
1919

2020
.navbarHideable {
21-
transition: top 0.2s ease-in-out;
21+
transform: translate3d(0, 0, 0);
22+
transition: transform var(--ifm-transition-fast) ease;
2223
}
2324

2425
.navbarHidden {
25-
top: calc(var(--ifm-navbar-height) * -1) !important;
26+
transform: translate3d(0, calc(var(--ifm-navbar-height) * -1), 0);
2627
}

packages/docusaurus-theme-classic/src/theme/hooks/useHideableNavbar.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import type {useHideableNavbarReturns} from '@theme/hooks/useHideableNavbar';
1212

1313
const useHideableNavbar = (hideOnScroll: boolean): useHideableNavbarReturns => {
1414
const location = useLocation();
15-
const [isNavbarVisible, setIsNavbarVisible] = useState(!hideOnScroll);
15+
const [isNavbarVisible, setIsNavbarVisible] = useState(hideOnScroll);
1616
const isFocusedAnchor = useRef(false);
1717
const [lastScrollTop, setLastScrollTop] = useState(0);
1818
const [navbarHeight, setNavbarHeight] = useState(0);

0 commit comments

Comments
 (0)