mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-24 20:36:40 +07:00
fixed some scroll issues
This commit is contained in:
parent
58676ac1d5
commit
677dce9721
3 changed files with 25 additions and 10 deletions
|
@ -36,6 +36,8 @@ const FlowLayoutUnconnected: FC<IProps> = ({
|
|||
flowLoadMoreSearch,
|
||||
}) => {
|
||||
const onLoadMore = useCallback(() => {
|
||||
(window as any).flowScrollPos = window.scrollY;
|
||||
|
||||
const pos = window.scrollY + window.innerHeight - document.body.scrollHeight;
|
||||
|
||||
if (is_loading || pos < -600) return;
|
||||
|
@ -54,6 +56,10 @@ const FlowLayoutUnconnected: FC<IProps> = ({
|
|||
return () => window.removeEventListener('scroll', onLoadMore);
|
||||
}, [onLoadMore]);
|
||||
|
||||
useEffect(() => {
|
||||
window.scrollTo(0, (window as any).flowScrollPos || 0);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className={styles.grid}>
|
||||
<div className={styles.hero}>
|
||||
|
|
|
@ -15,17 +15,22 @@ const MainRouter: FC<IProps> = () => {
|
|||
|
||||
return (
|
||||
<TransitionGroup>
|
||||
<CSSTransition key={location.key} classNames="fade" timeout={500}>
|
||||
<Switch location={location}>
|
||||
<Route exact path={URLS.BASE} component={FlowLayout} />
|
||||
<Route path={URLS.NODE_URL(':id')} component={NodeLayout} />
|
||||
<Route path={URLS.BORIS} component={BorisLayout} />
|
||||
<Route path={URLS.ERRORS.NOT_FOUND} component={ErrorNotFound} />
|
||||
<Route path={URLS.PROFILE_PAGE(':username')} component={ProfilePage} />
|
||||
{
|
||||
// disabled for scroll restoration
|
||||
// <CSSTransition key={location.key} classNames="fade" timeout={500}>
|
||||
}
|
||||
<Switch location={location}>
|
||||
<Route exact path={URLS.BASE} component={FlowLayout} />
|
||||
<Route path={URLS.NODE_URL(':id')} component={NodeLayout} />
|
||||
<Route path={URLS.BORIS} component={BorisLayout} />
|
||||
<Route path={URLS.ERRORS.NOT_FOUND} component={ErrorNotFound} />
|
||||
<Route path={URLS.PROFILE_PAGE(':username')} component={ProfilePage} />
|
||||
|
||||
<Redirect to="/" />
|
||||
</Switch>
|
||||
</CSSTransition>
|
||||
<Redirect to="/" />
|
||||
</Switch>
|
||||
{
|
||||
// </CSSTransition>
|
||||
}
|
||||
</TransitionGroup>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -134,6 +134,10 @@ const NodeLayoutUnconnected: FC<IProps> = memo(
|
|||
return () => nodeSetCoverImage(null);
|
||||
}, [nodeSetCoverImage, node.cover]);
|
||||
|
||||
useEffect(() => {
|
||||
window.scrollTo(0, 0);
|
||||
}, [id]);
|
||||
|
||||
return (
|
||||
<>
|
||||
{createNodeBlock(head)}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue