Skip to content

Commit 91bfd69

Browse files
committed
fixed bug where link hover animations reset everytime the background hue reversed. Previously, it used onRest to reset, with spring parameters AND duration. Read docs further at react-spring.dev and realized I was using props / config parameters in a strange combination
1 parent 6da8e33 commit 91bfd69

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

src/App.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ import "./App.css";
22
import { BrowserRouter as Router, Route, Routes } from "react-router-dom";
33
import LandingPage from "./components/LandingPage";
44
import HomeView from "./components/HomeView";
5-
import { useSpring } from "react-spring";
6-
import { useState } from "react";
75
import WIPDisclaimer from "./components/WIPDisclaimer";
86

97
function App() {

src/components/LandingPage.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@ const LandingPage = ({}: Props) => {
2020
const [link1Path, setLink1Path] = useState<string>("");
2121
const [link2Text, setLink2Text] = useState<string>("");
2222
const [link2Path, setLink2Path] = useState<string>("");
23-
const { currentPathContext, setCurrentPathContext } = useContext(AuthContext);
24-
const { hueRotation, setHueDuration } = useContext(StyleContext);
2523
const currentPath = useLocation().pathname;
2624
const navigate = useNavigate();
2725

26+
// - - - - - CONTEXT - - - - -
27+
const { currentPathContext, setCurrentPathContext } = useContext(AuthContext);
28+
const { hueRotation, setHueDuration } = useContext(StyleContext);
29+
2830
// - - - - - BG TRANSITION - - - - -
2931
const [hideLP, setHideLP] = useState<string>("");
3032
const [hideHV, setHideHV] = useState<string>("hide");

src/contexts/StyleContextProvider.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { User } from "firebase/auth";
22
import StyleContext from "./StyleContext";
33
import { ReactNode, useEffect, useState } from "react";
4-
import { useSpring } from "react-spring";
4+
import { useSpring, config } from "react-spring";
55

66
interface Props {
77
children: ReactNode;
@@ -15,18 +15,17 @@ const StyleContextProvider = ({ children }: Props) => {
1515
const [bgAnimOff, setBgAnimOff] = useState<boolean>(false);
1616
const [hueDuration, setHueDuration] = useState<number>(4500);
1717
const hueRotation = useSpring({
18+
loop: { reverse: true },
19+
delay: 1000,
20+
reset: true,
1821
to: {
1922
filter: "hue-rotate(130deg) saturate(80%) sepia(30%)",
2023
},
2124
from: {
2225
filter: "hue-rotate(0deg) saturate(100%) sepia(0%)",
2326
},
24-
reset: false,
2527
cancel: bgAnimOff,
26-
reverse: hueFlip,
27-
delay: 1000,
28-
config: { duration: hueDuration, tension: 280, friction: 60 },
29-
onRest: () => setHueFlip(!hueFlip),
28+
config: { duration: hueDuration },
3029
});
3130

3231
const checkWindowSize = () => {

0 commit comments

Comments
 (0)