From fd56acd852c90efc3e60be7dfad7031be7cce41b Mon Sep 17 00:00:00 2001 From: epenflow Date: Tue, 6 Feb 2024 02:11:03 +0800 Subject: [PATCH] refactoring --- src/app/globals.css | 22 +++++++++++++ src/components/Section/Hero.tsx | 26 +++++++++++++--- src/components/Section/Home/Home.tsx | 46 +++++++++++++++++++++++++--- src/lib/context/LenisScroll.tsx | 2 ++ 4 files changed, 86 insertions(+), 10 deletions(-) diff --git a/src/app/globals.css b/src/app/globals.css index 5cf6797..4a0f1f6 100644 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -84,9 +84,31 @@ scrollbar-width: none; } } +html.lenis { + height: auto; +} + +.lenis.lenis-smooth { + scroll-behavior: auto !important; +} + +.lenis.lenis-smooth [data-lenis-prevent] { + overscroll-behavior: contain; +} + +.lenis.lenis-stopped { + overflow: hidden; +} + +.lenis.lenis-scrolling iframe { + pointer-events: none; +} .circle__clip-path { clip-path: circle(100% at 50% 50%); } +.square__clip-path { + clip-path: polygon(0 0, 100% 0, 100% 100%, 0% 100%); +} .markers__text { background-image: linear-gradient(#00ff00, #00ff00); background-size: 0 100%; diff --git a/src/components/Section/Hero.tsx b/src/components/Section/Hero.tsx index a4c4dab..cf277ae 100644 --- a/src/components/Section/Hero.tsx +++ b/src/components/Section/Hero.tsx @@ -24,21 +24,37 @@ const Hero = () => { backgroundColor: 'black', color: '#00ff00', }); + gsap.to('#hero__text', { + scrollTrigger: { + trigger: '#hero__text', + start: 'top top', + end: 'bottom top', + pin: true, + scrub: true, + pinSpacing: false, + invalidateOnRefresh: true, + pinType: 'transform', + }, + yPercent: -100, + duration: 1.5, + }); }, []); return (
-
+ className='-z-20 h-screen w-screen flex flex-col items-center'> +

Prologue

{date.toUTCString()}

-

- Bangli +

+ <--!Bangli - Skatepark + Skatepark-->

); diff --git a/src/components/Section/Home/Home.tsx b/src/components/Section/Home/Home.tsx index 9e22650..fff4fc4 100644 --- a/src/components/Section/Home/Home.tsx +++ b/src/components/Section/Home/Home.tsx @@ -19,16 +19,48 @@ const Home = () => { end: 'bottom top', invalidateOnRefresh: true, }; + const sectionTwoTrigger = { + trigger: '#home__section-two', + pin: true, + scrub: true, + start: 'top+=25% top', + end: 'bottom+=25% top', + invalidateOnRefresh: true, + markers: true, + }; React.useLayoutEffect(() => { const tl = gsap.timeline(); const markersText = gsap.utils.toArray('.markers__text'); - + const homeText = gsap.utils.toArray('#home__section-text'); const ctx = gsap.context(() => { tl.to('#home__section-one', { scrollTrigger: sectionOneTrigger, duration: 0.5, clipPath: 'circle(0% at 50% 50%)', }); + homeText.forEach((text, index) => { + tl.to( + '#home__section-text', + { + clipPath: + 'polygon(0 100%, 100% 100%, 100% 100%, 0% 100%)', + stagger: 1.5, + duration: 2.5, + scrollTrigger: { + trigger: text as HTMLParagraphElement, + pin: true, + scrub: 0.2, + start: 'top+=15% top', + end: 'bottom+=50% top', + invalidateOnRefresh: true, + markers: true, + pinSpacing: false, + pinType: 'fixed', + }, + }, + index + 2 + ); + }); markersText.forEach((text, index) => { gsap.to(text as HTMLSpanElement, { backgroundSize: '100% 100%', @@ -51,7 +83,7 @@ const Home = () => { className='w-screen lg:max-h-screen lg:h-screen flex flex-col lg:flex-row border-y border-solid border-black z-10 bg-black'>
+ className='flex items-center justify-center h-screen lg:h-full flex-col w-full lg:w-1/2 relative overflow-hidden lg:border-none gap-2 circle__clip-path bg-[#00ff00]'>

Bupati Cup Skateboard Competition
@@ -74,12 +106,14 @@ const Home = () => {

+ className='flex flex-col h-full w-full lg:w-1/2 items-center justify-center border-t border-l border-solid border-black gap-2 box-border overflow-hidden relative bg-[#f2f2f2] '>

background

-

+

We are part of the PSB (Persatuan Skateboarders Bali), an official organization that accommodates the skateboard community in the Bangli area (PSB Bangli) @@ -97,7 +131,9 @@ const Home = () => { sports.

-

+

With the success of the Bupati Cup Competition I event last year, we want to continue this positive diff --git a/src/lib/context/LenisScroll.tsx b/src/lib/context/LenisScroll.tsx index 7a67e67..a47a45d 100644 --- a/src/lib/context/LenisScroll.tsx +++ b/src/lib/context/LenisScroll.tsx @@ -14,6 +14,8 @@ const LenisScroll = ({ children }: Props) => { duration: 5000, smoothTouch: true, syncTouch: true, + syncTouchLerp: 0.1, + autoResize: true, }}> {children}