mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-08 12:28:02 +02:00
fix(v2): increase stability of hideable navbar (#3733)
* fix * fix(v2): increase stability of hideable navbar * Fix bug after reload * Remove state for hash
This commit is contained in:
parent
abcd8cefd6
commit
61fd53f7c0
2 changed files with 24 additions and 28 deletions
|
@ -31,13 +31,13 @@ const useScrollPosition = (
|
|||
};
|
||||
|
||||
useEffect(() => {
|
||||
window.addEventListener('scroll', handleScroll);
|
||||
const opts: AddEventListenerOptions & EventListenerOptions = {
|
||||
passive: true,
|
||||
};
|
||||
|
||||
return () =>
|
||||
window.removeEventListener('scroll', handleScroll, {
|
||||
// @ts-expect-error: See https://github.com/microsoft/TypeScript/issues/32912
|
||||
passive: true,
|
||||
});
|
||||
window.addEventListener('scroll', handleScroll, opts);
|
||||
|
||||
return () => window.removeEventListener('scroll', handleScroll, opts);
|
||||
}, deps);
|
||||
|
||||
return scrollPosition;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue