mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 04:46: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,
|
flowLoadMoreSearch,
|
||||||
}) => {
|
}) => {
|
||||||
const onLoadMore = useCallback(() => {
|
const onLoadMore = useCallback(() => {
|
||||||
|
(window as any).flowScrollPos = window.scrollY;
|
||||||
|
|
||||||
const pos = window.scrollY + window.innerHeight - document.body.scrollHeight;
|
const pos = window.scrollY + window.innerHeight - document.body.scrollHeight;
|
||||||
|
|
||||||
if (is_loading || pos < -600) return;
|
if (is_loading || pos < -600) return;
|
||||||
|
@ -54,6 +56,10 @@ const FlowLayoutUnconnected: FC<IProps> = ({
|
||||||
return () => window.removeEventListener('scroll', onLoadMore);
|
return () => window.removeEventListener('scroll', onLoadMore);
|
||||||
}, [onLoadMore]);
|
}, [onLoadMore]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
window.scrollTo(0, (window as any).flowScrollPos || 0);
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.grid}>
|
<div className={styles.grid}>
|
||||||
<div className={styles.hero}>
|
<div className={styles.hero}>
|
||||||
|
|
|
@ -15,17 +15,22 @@ const MainRouter: FC<IProps> = () => {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TransitionGroup>
|
<TransitionGroup>
|
||||||
<CSSTransition key={location.key} classNames="fade" timeout={500}>
|
{
|
||||||
<Switch location={location}>
|
// disabled for scroll restoration
|
||||||
<Route exact path={URLS.BASE} component={FlowLayout} />
|
// <CSSTransition key={location.key} classNames="fade" timeout={500}>
|
||||||
<Route path={URLS.NODE_URL(':id')} component={NodeLayout} />
|
}
|
||||||
<Route path={URLS.BORIS} component={BorisLayout} />
|
<Switch location={location}>
|
||||||
<Route path={URLS.ERRORS.NOT_FOUND} component={ErrorNotFound} />
|
<Route exact path={URLS.BASE} component={FlowLayout} />
|
||||||
<Route path={URLS.PROFILE_PAGE(':username')} component={ProfilePage} />
|
<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="/" />
|
<Redirect to="/" />
|
||||||
</Switch>
|
</Switch>
|
||||||
</CSSTransition>
|
{
|
||||||
|
// </CSSTransition>
|
||||||
|
}
|
||||||
</TransitionGroup>
|
</TransitionGroup>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -134,6 +134,10 @@ const NodeLayoutUnconnected: FC<IProps> = memo(
|
||||||
return () => nodeSetCoverImage(null);
|
return () => nodeSetCoverImage(null);
|
||||||
}, [nodeSetCoverImage, node.cover]);
|
}, [nodeSetCoverImage, node.cover]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
window.scrollTo(0, 0);
|
||||||
|
}, [id]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{createNodeBlock(head)}
|
{createNodeBlock(head)}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue