import React, {useState, useEffect} from 'react'; import Shader from './Shader'; import WhoAmIMobile from './WhoAmIMobile'; import GitMobile from './GitMobile'; import DownloadCVMobile from './DownloadCVMobile'; import ClickMe from './ClickMe'; import Player from './Player'; interface MobileRootProps { windowSize: number; } /** * @return {jsx} The root component */ export default function MobileRoot({windowSize}: MobileRootProps) { const [trigger, setTrigger] = useState(0); const [content, setContent]: any = useState([]); const [busy, setBusy]: any = useState(true); const loader: Array = []; for (let i = 0; i < 2; i++) { loader.push(
); } loader.push(
); loader.push(
); loader.push(
); loader.push(
); for (let i = 0; i < 2; i++) { loader.push(
); } const Shaders = [ 'BaseRaymarching', 'Droplets', 'Inception', 'Menstom', 'Torus', 'Triangle', 'BaseLattice', ]; const Sounds = [ 'Collapse.mp3', 'Droplets.mp3', 'Heavy Ropes.mp3', 'Inception.mp3', 'Menstom.mp3', 'Speechless.mp3', 'Triangle.mp3', ]; useEffect(() => { const newContent = []; const shadersRandom: Array = []; const imagesRandom: Array = []; const soundsRandom: Array = []; shadersRandom.push(
); for (let i = 0; i < 2; i++) { imagesRandom.push(Math.floor(Math.random() * 12) + 1); while (imagesRandom.indexOf( imagesRandom[imagesRandom.length - 1]) != imagesRandom.length - 1) { imagesRandom[imagesRandom.length - 1] += 1; if (imagesRandom[imagesRandom.length - 1] == 13) { imagesRandom[imagesRandom.length - 1] = 1; } } } for (let i = 0; i < 2; i++) { imagesRandom[i] =
; } soundsRandom.push(
); newContent.push(shadersRandom[0]); newContent.push(soundsRandom[0]); newContent.push(
); newContent.push(
); newContent.push(
); newContent.push(
); newContent.push(imagesRandom[0]); newContent.push(imagesRandom[1]); setContent(newContent); setBusy(false); }, [trigger]); return (
{busy ? loader : content}
); }