1
0
Fork 0
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:
Fedor Katurov 2020-10-26 11:47:22 +07:00
parent 58676ac1d5
commit 677dce9721
3 changed files with 25 additions and 10 deletions

View file

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

View file

@ -15,7 +15,10 @@ const MainRouter: FC<IProps> = () => {
return ( return (
<TransitionGroup> <TransitionGroup>
<CSSTransition key={location.key} classNames="fade" timeout={500}> {
// disabled for scroll restoration
// <CSSTransition key={location.key} classNames="fade" timeout={500}>
}
<Switch location={location}> <Switch location={location}>
<Route exact path={URLS.BASE} component={FlowLayout} /> <Route exact path={URLS.BASE} component={FlowLayout} />
<Route path={URLS.NODE_URL(':id')} component={NodeLayout} /> <Route path={URLS.NODE_URL(':id')} component={NodeLayout} />
@ -25,7 +28,9 @@ const MainRouter: FC<IProps> = () => {
<Redirect to="/" /> <Redirect to="/" />
</Switch> </Switch>
</CSSTransition> {
// </CSSTransition>
}
</TransitionGroup> </TransitionGroup>
); );
}; };

View file

@ -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)}