Skip to content

Commit

Permalink
Add 2 second to timer
Browse files Browse the repository at this point in the history
  • Loading branch information
GabeDiniz committed Mar 28, 2024
1 parent 4880e0e commit 5ef7433
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/pages/Landing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,22 @@ import { HeroAboutDesktop } from '@assets';
const Landing: React.FC = () => {
const [isLoading, setIsLoading] = useState(true);
const [componentLoaded, setComponentLoaded] = useState(false);
const [timerFinished, setTimerFinished] = useState(false);

useEffect(() => {
const desktopImage = new Image();

desktopImage.src = HeroAboutDesktop;
desktopImage.onload = () => setComponentLoaded(true);

setTimeout(() => setTimerFinished(true), 2000);
}, []);

// Once the timer and component are finished -> display the page
useEffect(() => {
if (componentLoaded) {
if (componentLoaded && timerFinished) {
setIsLoading(false);
}
}, [componentLoaded]);
}, [componentLoaded, timerFinished]);

if (isLoading) {
return <LoadingAnimation />;
Expand Down

0 comments on commit 5ef7433

Please sign in to comment.