Skip to content

Commit 5102ab2

Browse files
committed
feat(): Fixing other things
1 parent ca39645 commit 5102ab2

4 files changed

Lines changed: 70 additions & 30 deletions

File tree

src/components/WavyBackground/WavyBackground.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const WavyBackground = ({
66
colors,
77
waveWidth,
88
backgroundFill,
9-
blur = 10,
9+
blur = 8,
1010
speed = 'fast',
1111
waveOpacity = 0.5,
1212
}: {
@@ -45,12 +45,12 @@ const WavyBackground = ({
4545
canvas = canvasRef.current;
4646
ctx = canvas.getContext('2d');
4747
w = ctx.canvas.width = window.innerWidth;
48-
h = ctx.canvas.height = window.innerHeight;
48+
h = ctx.canvas.height = window.innerHeight / 2;
4949
ctx.filter = `blur(${blur}px)`;
5050
nt = 0;
5151
window.onresize = function () {
5252
w = ctx.canvas.width = window.innerWidth;
53-
h = ctx.canvas.height = window.innerHeight;
53+
h = ctx.canvas.height = window.innerHeight / 2;
5454
ctx.filter = `blur(${blur}px)`;
5555
};
5656
render();
@@ -108,11 +108,10 @@ const WavyBackground = ({
108108

109109
return (
110110
<div
111-
className={'flex flex-col items-center justify-center mx-auto pb-20'}
111+
className={'flex flex-col items-center justify-center mx-auto'}
112112
style={{
113-
height: '20vh',
113+
height: '15vh',
114114
zIndex: 0,
115-
top: 0,
116115
overflowX: 'clip',
117116
mixBlendMode: 'lighten',
118117
}}
@@ -122,6 +121,8 @@ const WavyBackground = ({
122121
ref={canvasRef}
123122
id="canvas"
124123
style={{
124+
height: '100vh',
125+
width: '100%',
125126
...(isSafari ? { filter: `blur(${blur}px)` } : {}),
126127
}}
127128
></canvas>

src/screens/mainFlow/contents/Work.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ const Work = () => {
99
height={'100vh'}
1010
width={'100vw'}
1111
id="work"
12+
position={'sticky'}
13+
top={'15vh'}
1214
paddingX={32}
1315
paddingY={{ base: 16, md: 24 }}
1416
>

src/screens/mainFlow/contents/projects/HeroText.tsx

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
11
import { Box, Text } from '@chakra-ui/react';
2+
import { motion, MotionValue } from 'framer-motion';
23
import { useTranslation } from 'react-i18next';
34

4-
const HeroText = () => {
5+
const HeroText = ({ opacity }: { opacity: MotionValue<number> }) => {
56
const { t } = useTranslation();
67

78
return (
8-
<Box
9-
zIndex={100}
10-
position={'sticky'}
11-
top={'8vh'}
12-
overflowX={'hidden'}
13-
fontSize={{ base: '2xl', md: '3xl', lg: '5xl' }}
9+
<motion.div
10+
style={{
11+
opacity,
12+
zIndex: 100,
13+
position: 'sticky',
14+
top: '8vh',
15+
overflowX: 'hidden',
16+
fontSize: '5xl',
17+
}}
1418
>
15-
<Text className=" text-white font-bold inter-var text-center">
19+
<Text
20+
className=" text-white font-bold inter-var text-center"
21+
fontSize={{ base: '2xl', md: '3xl', lg: '5xl' }}
22+
>
1623
{t('about.quoteHeading')}
1724
</Text>
1825
<Text
@@ -21,7 +28,7 @@ const HeroText = () => {
2128
>
2229
{t('about.quoteSubheading')}
2330
</Text>
24-
</Box>
31+
</motion.div>
2532
);
2633
};
2734

src/screens/mainFlow/contents/projects/Projects.tsx

Lines changed: 45 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,59 @@
1-
import { motion } from 'framer-motion';
1+
import { motion, useScroll, useTransform } from 'framer-motion';
22
import { Box, VStack } from '@chakra-ui/react';
33
import { ProjectsData } from '@data';
44
import 'react-responsive-carousel/lib/styles/carousel.min.css';
55
import ProjectItem from './ProjectItem';
66
import { WavyBackground } from '@components';
77
import HeroText from './HeroText';
8+
import { useRef } from 'react';
89

910
const Projects = () => {
11+
const ref = useRef(null);
12+
const base = [400, 600, 1000, 1400];
13+
const project1Ref = useRef<HTMLDivElement>(null);
14+
const { scrollY } = useScroll({ target: ref });
15+
const opacity1 = useTransform(scrollY, base, [0, 1, 1, 0]);
16+
const height1 = project1Ref.current?.clientHeight;
17+
const opacity2 = useTransform(
18+
scrollY,
19+
base.map((i) => i + (height1 ?? 550)),
20+
[0, 1, 1, 0],
21+
);
22+
23+
const heroOpacity = useTransform(
24+
scrollY,
25+
base.map((i) => i + 550),
26+
[1, 1, 1, 0],
27+
);
28+
29+
const project1 = ProjectsData[0];
30+
const project2 = ProjectsData[1];
31+
1032
return (
11-
<VStack minH={'100vh'} width={'100vw'} id="projects" rowGap={20}>
12-
<HeroText />
13-
<Box position={'sticky'} top={'0'}>
33+
<VStack minH={'100vh'} width={'99vw'} id="projects" rowGap={20} ref={ref}>
34+
<HeroText opacity={heroOpacity} />
35+
<Box position={'sticky'} top={'15vh'} transform={'translateY(-120px)'}>
1436
<WavyBackground />
1537
</Box>
16-
{ProjectsData.map((project) => (
17-
<motion.div
18-
style={{
19-
position: 'sticky',
20-
top: '25vh',
21-
}}
22-
key={project.title}
23-
>
24-
<ProjectItem {...project} />
25-
</motion.div>
26-
))}
38+
<motion.div
39+
style={{
40+
opacity: opacity1,
41+
position: 'sticky',
42+
top: '25vh',
43+
}}
44+
>
45+
<ProjectItem {...project1} />
46+
</motion.div>
47+
<motion.div
48+
style={{
49+
opacity: opacity2,
50+
position: 'sticky',
51+
top: '25vh',
52+
}}
53+
>
54+
<ProjectItem {...project2} />
55+
</motion.div>
56+
);
2757
</VStack>
2858
);
2959
};

0 commit comments

Comments
 (0)