-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/CDP-185-LandingAnimation #55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
7de2e92
CDP-185 refactorπ¨ (landing): μ€λ³΅ μ½λ μ κ±°
leeunduck 6e149c3
CDP-186 featβ¨ (landing): hero μΉμ
cta desktop λ²νΌ bounce μ λλ©μ΄μ
μΆκ°
leeunduck be1e244
CDP-187 featβ¨ (landing): feature section 1 μ λλ©μ΄μ
μΆκ° & 컀μ€ν
use in vieβ¦
leeunduck 68354eb
CDP-187 featβ¨ (landing): feature section 12 μ λλ©μ΄μ
μΆκ° & 컀μ€ν
use in vieβ¦
leeunduck ce2b4dd
CDP-189 featβ¨ (landing): special section μ λλ©μ΄μ
μΆκ°
leeunduck 0cfa03e
CDP-189 refactorπ¨ (landing): μ£Όμ μ κ±°
leeunduck ce3c017
CDP-186 refactorπ¨ (landing): hero μΉμ
μ€λ³΅ μ½λ μ κ±°
leeunduck 1f39fa8
CDP-190 featβ¨ (landing): full page μ λλ©μ΄μ
μΆκ°
leeunduck b98116c
CDP-190 featβ¨ (landing): full page μ λλ©μ΄μ
μΆκ°
leeunduck c306e9a
CDP-190 featβ¨ (landing): main section κ°κ²© μ‘°μ
leeunduck a086594
CDP-189 refactorπ¨ (landing): μ λλ©μ΄μ
κ³μ λμ€κ² 리ν©ν λ§
leeunduck File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,21 @@ | ||
| import { LandingFeaturesSection2 } from "@/components/landing/LandingFeatureSection2"; | ||
| import { LandingFeaturesSection1 } from "@/components/landing/LandingFeaturesSection1"; | ||
| import { LandingFullPageWrapper } from "@/components/landing/LandingFullPageWrapper"; | ||
| import { LandingHeroSection } from "@/components/landing/LandingHeroSection"; | ||
| import { LandingSpecialFeaturesSection } from "@/components/landing/LandingSpecialFeaturesSection"; | ||
|
|
||
| export const revalidate = 21600; | ||
|
|
||
| export default function Home() { | ||
| return ( | ||
| <> | ||
| <LandingHeroSection /> | ||
| <LandingFeaturesSection1 /> | ||
| <LandingFeaturesSection2 /> | ||
| <LandingSpecialFeaturesSection /> | ||
| </> | ||
| <LandingFullPageWrapper> | ||
| <LandingHeroSection className="scroll-section" /> | ||
|
|
||
| <LandingFeaturesSection1 className="scroll-section" /> | ||
|
|
||
| <LandingFeaturesSection2 className="scroll-section" /> | ||
|
|
||
| <LandingSpecialFeaturesSection className="scroll-section" /> | ||
| </LandingFullPageWrapper> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| "use client"; | ||
|
|
||
| import { useFullPageScroll } from "@/hooks/useFullPageScroll"; | ||
| import type { LandingFullPageWrapperProps } from "@/types/landing"; | ||
|
|
||
| export function LandingFullPageWrapper({ children }: LandingFullPageWrapperProps) { | ||
| useFullPageScroll(); | ||
| return <>{children}</>; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| "use client"; | ||
|
|
||
| import { useEffect } from "react"; | ||
|
|
||
| export function useFullPageScroll() { | ||
| useEffect(() => { | ||
| const sections = document.querySelectorAll<HTMLElement>(".scroll-section"); | ||
| if (!sections.length) return; | ||
|
|
||
| let isScrolling = false; | ||
| let startY = 0; | ||
|
|
||
| const getClosestSectionIndex = () => { | ||
| const scrollY = window.scrollY; | ||
| let closestIndex = 0; | ||
| let smallestDiff = Number.POSITIVE_INFINITY; | ||
|
|
||
| sections.forEach((section, index) => { | ||
| const diff = Math.abs(section.offsetTop - scrollY); | ||
| if (diff < smallestDiff) { | ||
| smallestDiff = diff; | ||
| closestIndex = index; | ||
| } | ||
| }); | ||
| return closestIndex; | ||
| }; | ||
|
|
||
| const scrollToSection = (index: number) => { | ||
| const target = sections[index]; | ||
| if (!target) return; | ||
|
|
||
| const sectionTop = target.offsetTop; | ||
| const sectionHeight = target.offsetHeight; | ||
| const viewportHeight = window.innerHeight; | ||
|
|
||
| const lastIndex = sections.length - 1; | ||
| const isLast = index === lastIndex; | ||
|
|
||
| // λ§μ§λ§ μΉμ λ§ μ μ λ ¬, λλ¨Έμ§λ μ€μ μ λ ¬ | ||
| const targetY = isLast ? sectionTop : sectionTop - (viewportHeight - sectionHeight) / 2; | ||
|
|
||
| window.scrollTo({ | ||
| top: targetY, | ||
| behavior: "smooth", | ||
| }); | ||
| }; | ||
|
|
||
| const moveOneSection = (direction: 1 | -1) => { | ||
| if (isScrolling) return; | ||
| isScrolling = true; | ||
|
|
||
| const currentIndex = getClosestSectionIndex(); | ||
| const nextIndex = Math.min(Math.max(currentIndex + direction, 0), sections.length - 1); | ||
|
|
||
| scrollToSection(nextIndex); | ||
|
|
||
| setTimeout(() => { | ||
| isScrolling = false; | ||
| }, 900); | ||
| }; | ||
|
|
||
| const handleWheel = (event: WheelEvent) => { | ||
| event.preventDefault(); | ||
| const deltaY = event.deltaY; | ||
| if (Math.abs(deltaY) < 10) return; | ||
|
|
||
| const direction: 1 | -1 = deltaY > 0 ? 1 : -1; | ||
| moveOneSection(direction); | ||
| }; | ||
|
|
||
| const handleTouchStart = (e: TouchEvent) => { | ||
| startY = e.touches[0].clientY; | ||
| }; | ||
|
|
||
| const handleTouchEnd = (e: TouchEvent) => { | ||
| const endY = e.changedTouches[0].clientY; | ||
| const deltaY = startY - endY; | ||
| if (Math.abs(deltaY) < 50) return; | ||
|
|
||
| const direction: 1 | -1 = deltaY > 0 ? 1 : -1; | ||
| moveOneSection(direction); | ||
| }; | ||
|
|
||
| window.addEventListener("wheel", handleWheel, { passive: false }); | ||
| window.addEventListener("touchstart", handleTouchStart, { passive: true }); | ||
| window.addEventListener("touchend", handleTouchEnd, { passive: true }); | ||
|
|
||
| // 첫 μ§μ μ Hero μΉμ μΌλ‘ μ€λ | ||
| scrollToSection(0); | ||
|
|
||
| return () => { | ||
| window.removeEventListener("wheel", handleWheel); | ||
| window.removeEventListener("touchstart", handleTouchStart); | ||
| window.removeEventListener("touchend", handleTouchEnd); | ||
| }; | ||
| }, []); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| import { UseInViewOptions, UseInViewResult } from "@/types/inView"; | ||
| import { useEffect, useRef, useState } from "react"; | ||
|
|
||
| export function useInView(options: UseInViewOptions = {}): UseInViewResult { | ||
| const { threshold = 0.2, rootMargin = "0px", once = true } = options; | ||
|
|
||
| const ref = useRef<HTMLDivElement | null>(null); | ||
| const [isInView, setIsInView] = useState(false); | ||
|
|
||
| useEffect(() => { | ||
| const node = ref.current; | ||
| if (!node) return; | ||
|
|
||
| const observer = new IntersectionObserver( | ||
| (entries) => { | ||
| entries.forEach((entry) => { | ||
| if (entry.isIntersecting) { | ||
| setIsInView(true); | ||
| if (once) { | ||
| observer.unobserve(entry.target); | ||
| } | ||
| } else if (!once) { | ||
| setIsInView(false); | ||
| } | ||
| }); | ||
| }, | ||
| { threshold, rootMargin }, | ||
| ); | ||
|
|
||
| observer.observe(node); | ||
|
|
||
| return () => observer.disconnect(); | ||
| }, [threshold, rootMargin, once]); | ||
|
|
||
| return { ref, isInView }; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import { RefObject } from "react"; | ||
|
|
||
| export interface UseInViewOptions { | ||
| threshold?: number; | ||
| rootMargin?: string; | ||
| once?: boolean; | ||
| } | ||
|
|
||
| export interface UseInViewResult { | ||
| ref: RefObject<HTMLDivElement | null>; | ||
| isInView: boolean; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The hook currently creates
refwithuseRef<HTMLDivElement | null>and exposes that type. In this commit the hook is attached to<section>elements inLandingFeaturesSection1andLandingFeaturesSection2, but under the repoβs strict TypeScript configuration aRefObject<HTMLDivElement>cannot be assigned to asection(RefObject<HTMLElement>is required). As a result the new components fail to compile. Consider widening the element type toHTMLElementor making the hook generic so it can be used with nonβdiv root elements.Useful? React with πΒ / π.