Skip to content

Commit 5948a61

Browse files
authored
Merge pull request #13 from JS-GitRepo/feature/LandingPageAnimations
Feature/landing page animations
2 parents bdac7d3 + d00d6b6 commit 5948a61

File tree

4 files changed

+17
-7
lines changed

4 files changed

+17
-7
lines changed

src/AppConfig.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"hueAnimDuration": 4000,
3+
"hueAnimDuration_Slow": 10000
4+
}

src/components/HomeView.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@ import { useContext, useEffect, useState } from "react";
44
import HomeViewHeader from "./HomeViewHeader";
55
import HomeViewFooter from "./HomeViewFooter";
66
import HomeViewContent from "./HomeViewContent";
7-
import { SpringValue } from "react-spring";
87
import StyleContext from "../contexts/StyleContext";
8+
import AppConfig from "../AppConfig.json";
99

1010
interface Props {}
1111

1212
const HomeView = ({}: Props) => {
1313
// - - - - GENERAL STATES - - - -
14-
const [firstRender, setFirstRender] = useState<boolean>(true);
1514
const { hueRotation, setHueDuration } = useContext(StyleContext);
1615
// - - - - - TITLES AND TEXT - - - - -
1716
const [currentProject, setCurrentProject] = useState<string>("Deerfall");
@@ -74,9 +73,10 @@ const HomeView = ({}: Props) => {
7473
} else if (currentPath.includes("/webdev/")) {
7574
setCurrentProject(webDevProjList[0]);
7675
}
77-
console.log(currentPath);
7876

79-
// setHueDuration(12000);
77+
if (hueRotation != AppConfig.hueAnimDuration_Slow) {
78+
setHueDuration(AppConfig.hueAnimDuration_Slow);
79+
}
8080
}, [currentPath]);
8181

8282
return (

src/components/LandingPage.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import pixelBG from "../img/pixelBG_LowRes.png";
99
import pixelFadeBG from "../img/animated-14fps.png";
1010
import PersonalIntro from "./PersonalIntro";
1111
import StyleContext from "../contexts/StyleContext";
12+
import AppConfig from "../AppConfig.json";
1213

1314
interface Props {}
1415

@@ -65,7 +66,7 @@ const LandingPage = ({}: Props) => {
6566
setIsActivePage(false);
6667
setHideHV("");
6768
setTimeout(() => setHideLP("hide"), 2000);
68-
setHueDuration(12000);
69+
setHueDuration(AppConfig.hueAnimDuration_Slow);
6970
}
7071

7172
if (currentPath === "/") {
@@ -81,19 +82,21 @@ const LandingPage = ({}: Props) => {
8182
setLink1Path("/landing/webdev");
8283
setLink2Text("Game Dev");
8384
setLink2Path("/landing/gamedev");
84-
setHueDuration(4000);
85+
setHueDuration(AppConfig.hueAnimDuration);
8586
} else if (currentPath === "/landing/webdev") {
8687
setCurrentDisplay("Web Development");
8788
setLink1Text("Portfolio");
8889
setLink1Path("/landing/webdev/portfolio");
8990
setLink2Text("Blog");
9091
setLink2Path("/landing/webdev/blog");
92+
setHueDuration(AppConfig.hueAnimDuration);
9193
} else if (currentPath === "/landing/gamedev") {
9294
setCurrentDisplay("Game Development");
9395
setLink1Text("Portfolio");
9496
setLink1Path("/landing/webdev/portfolio");
9597
setLink2Text("Blog");
9698
setLink2Path("/landing/gamedev/blog");
99+
setHueDuration(AppConfig.hueAnimDuration);
97100
}
98101
}, [currentPath]);
99102

src/contexts/StyleContextProvider.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import StyleContext from "./StyleContext";
22
import { ReactNode, useEffect, useState } from "react";
33
import { useSpring } from "react-spring";
4+
import AppConfig from "../AppConfig.json";
45

56
interface Props {
67
children: ReactNode;
@@ -12,7 +13,9 @@ const StyleContextProvider = ({ children }: Props) => {
1213

1314
// ANIMATIONS / REACT SPRING
1415
const [bgAnimOff, setBgAnimOff] = useState<boolean>(false);
15-
const [hueDuration, setHueDuration] = useState<number>(4000);
16+
const [hueDuration, setHueDuration] = useState<number>(
17+
AppConfig.hueAnimDuration
18+
);
1619
const hueRotation = useSpring({
1720
loop: { reverse: true, config: { duration: hueDuration } },
1821
delay: 1000,

0 commit comments

Comments
 (0)