From f717a6dc4f3ffbc2624c38071079c64447c398ab Mon Sep 17 00:00:00 2001 From: Spythere Date: Sun, 25 Feb 2024 01:20:24 +0100 Subject: [PATCH] gsap animations demo --- package.json | 1 + src/components/Logo.tsx | 22 ++----------------- src/components/styles/Landing.styled.ts | 9 ++++++++ src/sections/LandingSection.tsx | 29 ++++++++++++++++++++----- 4 files changed, 36 insertions(+), 25 deletions(-) diff --git a/package.json b/package.json index 83bb9a5..590ba2b 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "preview": "vite preview" }, "dependencies": { + "@gsap/react": "^2.1.0", "i18next": "^23.4.6", "react": "^18.2.0", "react-dom": "^18.2.0", diff --git a/src/components/Logo.tsx b/src/components/Logo.tsx index de74e5d..1d21ce6 100644 --- a/src/components/Logo.tsx +++ b/src/components/Logo.tsx @@ -2,17 +2,7 @@ export default function Logo() { return ( - + diff --git a/src/components/styles/Landing.styled.ts b/src/components/styles/Landing.styled.ts index ed0a01c..8e2ac20 100644 --- a/src/components/styles/Landing.styled.ts +++ b/src/components/styles/Landing.styled.ts @@ -27,7 +27,13 @@ export const StyledLandingWrapper = styled.div` } } + .logo { + opacity: 0; + } + .landing_tech { + opacity: 0; + h3 { position: relative; margin: 0; @@ -93,10 +99,12 @@ export const StyledLandingRight = styled.div` .greeting { font-family: ${({ theme }) => theme.fonts.monospace}; display: block; + opacity: 0; } .description { margin-top: 1em; + opacity: 0; } `; @@ -104,6 +112,7 @@ export const StyledLinkIcons = styled.div` display: flex; gap: 1em; margin-top: 1em; + opacity: 0; `; export const StyledLinkIcon = styled.a` diff --git a/src/sections/LandingSection.tsx b/src/sections/LandingSection.tsx index 49ed9e2..4e74df8 100644 --- a/src/sections/LandingSection.tsx +++ b/src/sections/LandingSection.tsx @@ -9,13 +9,34 @@ import { StyledLinkIcons, StyledLandingRight, } from '../components/styles/Landing.styled'; +import { useEffect, useRef } from 'react'; +import { useGSAP } from '@gsap/react'; +import gsap from 'gsap'; export default function LandingSection() { + const container = useRef(null); + + useGSAP(() => { + gsap.to('.logo', { opacity: 1 }); + gsap.to('.greeting', { opacity: 1, delay: 0.75 }); + gsap.to('.description', { opacity: 1, delay: 1.25 }); + gsap.to('.icons', { opacity: 1, delay: 1.25 }); + gsap.to('.landing_tech', { opacity: 1, delay: 1.75 }); + }); + + useEffect(() => { + const splittedDesc = container.current!.querySelector('.description'); + + console.log(splittedDesc?.textContent); + }, []); + return ( - +
- +
+ +
Hello, I'm @@ -25,15 +46,13 @@ export default function LandingSection() {
an amatour and self-taught front-end and back-end developer from Poland!
- + - -