mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 12:54:38 +03:00
* Move loadStickyHeader to src/hooks * intl stashIDs * Scroll to top on component mount * Add id to gallery cover image and tweak merge functions * Add useTitleProps hook * Also scroll to top on list pages * Refactor loaders and tabs * Use classnames * Add DetailImage
23 lines
493 B
TypeScript
23 lines
493 B
TypeScript
import { useEffect, useState } from "react";
|
|
|
|
function shouldLoadStickyHeader() {
|
|
return document.documentElement.scrollTop > 50;
|
|
}
|
|
|
|
export function useLoadStickyHeader() {
|
|
const [load, setLoad] = useState(shouldLoadStickyHeader());
|
|
|
|
useEffect(() => {
|
|
const onScroll = () => {
|
|
setLoad(shouldLoadStickyHeader());
|
|
};
|
|
|
|
window.addEventListener("scroll", onScroll);
|
|
return () => {
|
|
window.removeEventListener("scroll", onScroll);
|
|
};
|
|
}, []);
|
|
|
|
return load;
|
|
}
|