From a06e2e436975de51bd4f72f5fcbc082f18d9a2ce Mon Sep 17 00:00:00 2001 From: Maximilian Leo Huber <maximilian.huber@uni-bielefeld.de> Date: Wed, 18 Sep 2024 16:06:08 +0000 Subject: [PATCH] fixed 'Problems' images with seperate text --- src/components/FadeIn.tsx | 4 +- src/components/Problems.tsx | 160 ++++++++++++++++++++++++++++++++++++ src/contents/Home.tsx | 3 + 3 files changed, 164 insertions(+), 3 deletions(-) create mode 100644 src/components/Problems.tsx diff --git a/src/components/FadeIn.tsx b/src/components/FadeIn.tsx index 985df75e..cf498afe 100644 --- a/src/components/FadeIn.tsx +++ b/src/components/FadeIn.tsx @@ -6,8 +6,6 @@ export function FadeIn({filepath, bg}:{filepath: string, bg: string}){ useEffect(() => { const observer = new IntersectionObserver(entries => { entries.forEach(entry => setVisible(entry.isIntersecting)); - {/* debug */} - entries.forEach(entry => console.log(entry.isIntersecting)); }); observer.observe(domRef.current!); }, []); @@ -46,7 +44,7 @@ export function FadeIn({filepath, bg}:{filepath: string, bg: string}){ </img> </div> {/* Spacing Block */} - <div className='col' style={{ 'height': '90vh' }}></div> + <div className='col' style={{ 'height': '95vh' }}></div> </> ); } \ No newline at end of file diff --git a/src/components/Problems.tsx b/src/components/Problems.tsx new file mode 100644 index 00000000..cdd79468 --- /dev/null +++ b/src/components/Problems.tsx @@ -0,0 +1,160 @@ +import { useEffect, useRef, useState } from "react"; + +export function Problems(){ + const [isVisible, setVisible] = useState(false); + const domRef = useRef(null)!; + useEffect(() => { + const observer = new IntersectionObserver(entries => { + entries.forEach(entry => setVisible(entry.isIntersecting)); + }); + observer.observe(domRef.current!); + }, []); + + const [isVisible2, setVisible2] = useState(false); + const domRef2 = useRef(null)!; + useEffect(() => { + const observer = new IntersectionObserver(entries => { + entries.forEach(entry => setVisible2(entry.isIntersecting)); + }); + observer.observe(domRef2.current!); + }, []); + + const [isVisible3, setVisible3] = useState(false); + const domRef3 = useRef(null)!; + useEffect(() => { + const observer = new IntersectionObserver(entries => { + entries.forEach(entry => setVisible3(entry.isIntersecting)); + }); + observer.observe(domRef3.current!); + }, []); + + const [isVisible4, setVisible4] = useState(false); + const domRef4 = useRef(null)!; + useEffect(() => { + const observer = new IntersectionObserver(entries => { + entries.forEach(entry => setVisible4(entry.isIntersecting)); + }); + observer.observe(domRef4.current!); + }, []); + + + const [isVisible5, setVisible5] = useState(false); + const domRef5 = useRef(null)!; + useEffect(() => { + const observer = new IntersectionObserver(entries => { + entries.forEach(entry => setVisible5(entry.isIntersecting)); + }); + observer.observe(domRef5.current!); + }, []); + + return ( + <> + {/* One */} + <div + className='col' + style={{ + 'height': '100vh', + 'transition': 'opacity 0.6s ease-out', + 'opacity': `${isVisible ? '1' : '0'}`, + 'visibility': `${isVisible ? 'visible' : 'hidden'}`}} + ref={domRef}> + <img + style={{ + 'position': 'fixed', + 'top': '20vh', + 'left': '20vw', + 'width': '60vw', + 'height': '60vh', + }} + src="https://static.igem.wiki/teams/5247/landing/problems/cyfib-1.webp"> + </img> + <p style={{'position': 'fixed','top': '20vh', 'left': '20vw', 'zIndex': '1'}}>Text Here</p> + </div> + {/* Two */} + <div + className='col' + style={{ + 'height': '100vh', + 'transition': 'opacity 0.6s ease-out', + 'opacity': `${isVisible2 ? '1' : '0'}`, + 'visibility': `${isVisible2 ? 'visible' : 'hidden'}`}} + ref={domRef2}> + <img + style={{ + 'position': 'fixed', + 'top': '20vh', + 'left': '20vw', + 'width': '60vw', + 'height': '60vh', + }} + src="https://static.igem.wiki/teams/5247/landing/problems/cyfib-2.webp"> + </img> + <p style={{'position': 'fixed','top': '20vh', 'left': '20vw', 'zIndex': '1'}}>Text Here</p> + </div> + {/* Three */} + <div + className='col' + style={{ + 'height': '100vh', + 'transition': 'opacity 0.6s ease-out', + 'opacity': `${isVisible3 ? '1' : '0'}`, + 'visibility': `${isVisible3 ? 'visible' : 'hidden'}`}} + ref={domRef3}> + <img + style={{ + 'position': 'fixed', + 'top': '20vh', + 'left': '20vw', + 'width': '60vw', + 'height': '60vh', + }} + src="https://static.igem.wiki/teams/5247/landing/problems/cyfib-3.webp"> + </img> + <p style={{'position': 'fixed','top': '20vh', 'left': '20vw', 'zIndex': '1'}}>Text Here</p> + </div> + {/* Four */} + <div + className='col' + style={{ + 'height': '100vh', + 'transition': 'opacity 0.6s ease-out', + 'opacity': `${isVisible4 ? '1' : '0'}`, + 'visibility': `${isVisible4 ? 'visible' : 'hidden'}`}} + ref={domRef4}> + <img + style={{ + 'position': 'fixed', + 'top': '20vh', + 'left': '20vw', + 'width': '60vw', + 'height': '60vh', + }} + src="https://static.igem.wiki/teams/5247/landing/problems/cyfib-4.webp"> + </img> + <p style={{'position': 'fixed','top': '20vh', 'left': '20vw', 'zIndex': '1'}}>Text Here</p> + </div> + {/* Five */} + <div + className='col' + style={{ + 'height': '100vh', + 'transition': 'opacity 0.6s ease-out', + 'opacity': `${isVisible5 ? '1' : '0'}`, + 'visibility': `${isVisible5 ? 'visible' : 'hidden'}`}} + ref={domRef5}> + <img + style={{ + 'position': 'fixed', + 'top': '20vh', + 'left': '20vw', + 'width': '60vw', + 'height': '60vh', + }} + src="https://static.igem.wiki/teams/5247/landing/problems/cyfib-5.webp"> + </img> + <p style={{'position': 'fixed','top': '20vh', 'left': '20vw', 'zIndex': '1'}}>Text Here</p> + </div> + + </> + ); +} \ No newline at end of file diff --git a/src/contents/Home.tsx b/src/contents/Home.tsx index e0fd2a0d..9794192c 100644 --- a/src/contents/Home.tsx +++ b/src/contents/Home.tsx @@ -1,5 +1,6 @@ import { FadeIn } from "../components/FadeIn"; import { Breathe } from "../components/Breathe"; +import { Problems } from "../components/Problems"; export function Home() { return ( @@ -10,6 +11,8 @@ export function Home() { <div className='col' style={{ 'height': '70vh' }}></div> <Breathe></Breathe> + + <Problems></Problems> <FadeIn filepath="https://static.igem.wiki/teams/5247/landing/problems/problems-1.webp" bg=''></FadeIn> <FadeIn filepath="https://static.igem.wiki/teams/5247/landing/problems/problems-2.webp" bg=''></FadeIn> -- GitLab