mirror of
https://github.com/mastermindzh/rickvanlieshout.com
synced 2025-01-13 07:18:57 +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';
|
||||
|
||||
const Page = ({ title, children }) => (
|
||||
<div className={styles['page']}>
|
||||
<div className={styles['page__inner']}>
|
||||
{ title && <h1 className={styles['page__title']}>{title}</h1>}
|
||||
<div className={styles['page__body']}>
|
||||
{children}
|
||||
const Page = ({ title, children }) => {
|
||||
const pageRef = useRef();
|
||||
|
||||
useEffect(() => {
|
||||
pageRef.current.scrollIntoView();
|
||||
});
|
||||
|
||||
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>
|
||||
);
|
||||
);
|
||||
};
|
||||
|
||||
export default Page;
|
||||
export default Page;
|
Loading…
Reference in New Issue
Block a user