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:
Alexey Pyltsyn 2020-11-18 18:17:04 +03:00 committed by GitHub
parent abcd8cefd6
commit 61fd53f7c0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 28 deletions

View file

@ -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;