Skip to content
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

[SP2] 메인 상단 Introduce QA #292

Merged
merged 6 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 0 additions & 37 deletions src/views/MainPage/components/Introduce/MotionTitle/index.tsx

This file was deleted.

16 changes: 0 additions & 16 deletions src/views/MainPage/components/Introduce/MotionTitle/style.ts

This file was deleted.

24 changes: 20 additions & 4 deletions src/views/MainPage/components/Introduce/index.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,39 @@
import { useScroll, useTransform } from 'framer-motion';
import { useRef } from 'react';
import MotionTitle from './MotionTitle';
import { useEffect, useRef, useState } from 'react';
import { useIsMobile } from '@src/hooks/useDevice';
import * as S from './style';

export default function Introduce() {
const isMobileSize = useIsMobile('768px');
const contentRef = useRef<HTMLElement>(null);
const { scrollYProgress } = useScroll({
target: contentRef,
offset: ['end center', 'start start'],
offset: ['end center', 'start'],
});

const scaleValue = useTransform(scrollYProgress, [1, 0.4], [0.9, 1]);
const content = '전국 최대 규모의 대학생 IT 연합 동아리, SOPT를 소개합니다.';

const [style, setStyle] = useState<{ opacity?: number; clipPath?: string }>();
const scrollValue = useTransform(scrollYProgress, [1, 0.4], [100, 0]);

useEffect(() => {
const unsubscribe = scrollValue.on('change', (value) => {
const newStyle = isMobileSize
? { opacity: 1 - value / 100 }
: { clipPath: `inset(0% ${value}% 0% 0%)`, opacity: 1 };
setStyle(newStyle);
});

return () => {
unsubscribe();
};
}, [scrollValue, isMobileSize]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ㅜㅜ폴더를 나눴다가 문제가 생긴 거였군요 ..

return (
<S.Background ref={contentRef}>
<S.Wrapper>
<S.TextContainer style={{ scale: scaleValue }}>
<MotionTitle contentRef={contentRef} content={content} />
<S.MotionTitle style={style} data-text={content} />
<S.BackgroundTitle>{content}</S.BackgroundTitle>
</S.TextContainer>
</S.Wrapper>
Expand Down
16 changes: 15 additions & 1 deletion src/views/MainPage/components/Introduce/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { motion } from 'framer-motion';

export const Background = styled.section`
display: flex;
max-width: 1920px;
height: 200vh;
justify-content: center;
align-items: flex-start;
Expand Down Expand Up @@ -63,6 +62,21 @@ export const TextContainer = styled(motion.span)`
}
`;

export const MotionTitle = styled(motion.span)`
position: absolute;
left: 0;
opacity: 0;

::before {
content: attr(data-text);
display: inline-block;
background: linear-gradient(93deg, #c9d8dd 78.65%, #fff 128.82%, #c9d8dd 137.19%);
background-clip: text;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
`;

export const BackgroundTitle = styled.span`
background: linear-gradient(93deg, #c9d8dd -34.77%, #fff -14.77%, #636770 6.12%);
background-clip: text;
Expand Down
Loading