Add scroll, languages, settings

This commit is contained in:
obergodmar
2020-06-25 03:20:33 +03:00
parent 98a307f2cc
commit 8647adc66c
47 changed files with 946 additions and 120 deletions
@@ -1,7 +1,8 @@
import * as React from 'react'
import { useEffect, useMemo, useState } from 'react'
import { useEffect, useState } from 'react'
import { Background } from '../../assets'
import { ANIMATION_DURATION } from '../../utils'
import './view-component.scss'
@@ -11,25 +12,25 @@ interface Props {
export const ViewComponent = ({src}: Props) => {
const [imageSrc, setImageSrc] = useState(Background)
const isImage = useMemo(() => imageSrc !== Background, [imageSrc])
useEffect(() => {
setTimeout(() => {
const timer = setTimeout(() => {
const image = new Image()
image.src = src
image.onload = () => {
setImageSrc(src)
}
}, 500)
}, ANIMATION_DURATION)
return () => {
clearTimeout(timer)
}
}, [src])
return (
<div
className='view'
style={{
backgroundImage: `url(${imageSrc})`,
backgroundRepeat: `${isImage ? 'no-repeat' : 'repeat'}`,
backgroundSize: `${isImage ? 'cover' : '256px'}`
backgroundImage: `url(${imageSrc})`
}}
/>
)