mirror of
https://github.com/mastermindzh/rickvanlieshout.com
synced 2025-01-13 15:29:16 +01:00
Autoscrolling on mobile devices
This commit is contained in:
parent
d31e82a2f9
commit
1ac51111f7
@ -1,15 +1,23 @@
|
|||||||
import React from 'react';
|
import React, { useRef, useEffect } from 'react';
|
||||||
import styles from './Page.module.scss';
|
import styles from './Page.module.scss';
|
||||||
|
|
||||||
const Page = ({ title, children }) => (
|
const Page = ({ title, children }) => {
|
||||||
<div className={styles['page']}>
|
const pageRef = useRef();
|
||||||
<div className={styles['page__inner']}>
|
|
||||||
{ title && <h1 className={styles['page__title']}>{title}</h1>}
|
useEffect(() => {
|
||||||
<div className={styles['page__body']}>
|
pageRef.current.scrollIntoView();
|
||||||
{children}
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div ref={pageRef} className={styles['page']}>
|
||||||
|
<div className={styles['page__inner']}>
|
||||||
|
{ title && <h1 className={styles['page__title']}>{title}</h1>}
|
||||||
|
<div className={styles['page__body']}>
|
||||||
|
{children}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
);
|
||||||
);
|
};
|
||||||
|
|
||||||
export default Page;
|
export default Page;
|
Loading…
Reference in New Issue
Block a user