100vh screen size fix for ios mobile, now dynamic

This commit is contained in:
cupcakearmy 2019-03-24 13:46:19 +01:00
parent 78ccbfa591
commit 7151deb316
2 changed files with 22 additions and 1 deletions

View File

@ -4,9 +4,13 @@ import AnimatedBackground from '../Components/AnimatedBackground'
import Cursor from '../Components/Cursor'
import Parallax from '../Components/Parallax'
import Letters from '../Screens/Letters'
import { useInnerWindowSize } from '../util'
const Home: React.FC = () => {
return <div id="home">
const {height, width} = useInnerWindowSize()
return <div id="home" style={{width: width + 'px', height: height + 'px'}}>
<Parallax>
<section id={'letters-container'}>
<h1>

View File

@ -1,5 +1,22 @@
import { useEffect, useState } from 'react'
type Size = { width: number, height: number }
export const useInnerWindowSize = (): Size => {
const getCurrentSize = (): Size => ({
height: window.innerHeight,
width: window.innerWidth,
})
let [size, setSize] = useState<Size>(getCurrentSize)
useEffect(() => {
const handle = () => setSize(getCurrentSize())
window.addEventListener('resize', handle)
return () => window.removeEventListener('resize', handle)
}, [])
return size
}
export const useIsMousePresent = () => {
let [present, setPresent] = useState<boolean>(false)