mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-02 08:19:07 +02:00
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
This commit is contained in:
parent
d6510b63ae
commit
174b4200ee
2 changed files with 4 additions and 3 deletions
|
@ -18,9 +18,10 @@
|
|||
}
|
||||
|
||||
.navbarHideable {
|
||||
transition: top 0.2s ease-in-out;
|
||||
transform: translate3d(0, 0, 0);
|
||||
transition: transform var(--ifm-transition-fast) ease;
|
||||
}
|
||||
|
||||
.navbarHidden {
|
||||
top: calc(var(--ifm-navbar-height) * -1) !important;
|
||||
transform: translate3d(0, calc(var(--ifm-navbar-height) * -1), 0);
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import type {useHideableNavbarReturns} from '@theme/hooks/useHideableNavbar';
|
|||
|
||||
const useHideableNavbar = (hideOnScroll: boolean): useHideableNavbarReturns => {
|
||||
const location = useLocation();
|
||||
const [isNavbarVisible, setIsNavbarVisible] = useState(!hideOnScroll);
|
||||
const [isNavbarVisible, setIsNavbarVisible] = useState(hideOnScroll);
|
||||
const isFocusedAnchor = useRef(false);
|
||||
const [lastScrollTop, setLastScrollTop] = useState(0);
|
||||
const [navbarHeight, setNavbarHeight] = useState(0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue