import { RecoilRoot } from 'recoil' import Mutuals from "./components/Mutuals" import Card from "./components/Card" import Menu from "./components/Menu" import ContentRenderer from "./components/ContentRenderer" import Footer from "./components/Footer" import { useState, useEffect } from 'react'; export default function App() { const [cardY, setCardY] = useState(0); const [contentY, setContentY] = useState(0); const [cardOpacity, setCardOpacity] = useState(1.0); const handleScroll = () => { const card = Math.max((window.innerHeight / 2) - window.scrollY, 100); setCardY(card); const mutualsElm = document.getElementById("mutuals"); let mutualsY = 0; if (mutualsElm) { mutualsY += mutualsElm.scrollHeight; } setContentY(card + (window.innerHeight / 2) + mutualsY * 2); const cardElm = document.getElementById("card"); const contentElm = document.getElementById("content"); const a = cardElm?.getBoundingClientRect().bottom const b = contentElm?.getBoundingClientRect().top if (a && b) { if (a - b > 0 && a - b < 100) { setCardOpacity((100 - (a - b)) / 100) } else if (a - b < 0) { setCardOpacity(100) } else { setCardOpacity(0) } } }; useEffect(() => { handleScroll(); const mutualElm = document.getElementById("mutuals"); if (mutualElm) { window.scrollTo(0, mutualElm.scrollHeight) } window.addEventListener('scroll', handleScroll); return () => { window.removeEventListener('scroll', handleScroll); }; }, []); return (
) }