1+ import { useEffect , useState } from 'react' ;
2+ import { motion , useScroll , useTransform } from 'framer-motion' ;
3+ import { Carousel } from 'react-responsive-carousel' ;
4+
15import { PROJECT_NAME_ICON_MAP , StarIcon , StarTrekIcon } from '@assets' ;
26import {
37 HStack ,
@@ -11,8 +15,8 @@ import {
1115} from '@chakra-ui/react' ;
1216import { AnimatedModal , Chip , CardSpotlight } from '@components' ;
1317import { ProjectItemType } from '@data' ;
14- import { Carousel } from 'react-responsive-carousel' ;
1518import CustomIconButton from './CustomIconButton' ;
19+ import { useMoveToTop } from '@hooks' ;
1620
1721const ProjectItem = ( {
1822 title,
@@ -25,13 +29,29 @@ const ProjectItem = ({
2529 tags,
2630 demoVideo,
2731} : ProjectItemType & { index : number } ) => {
28- const handleClick = ( ) => {
29- const element = document . getElementById ( 'project-images' ) ;
30- element ?. scrollIntoView ( {
31- behavior : 'smooth' ,
32- block : 'end' ,
33- } ) ;
34- } ;
32+ const handleClick = useMoveToTop ( ) ;
33+ const { scrollY } = useScroll ( ) ;
34+ const top = useTransform ( scrollY , [ 300 , 1000 ] , [ 0 , 50 ] ) ;
35+ const [ blur , setBlur ] = useState < boolean > ( false ) ;
36+
37+ useEffect ( ( ) => {
38+ window . scrollTo ( { top : 700 } ) ;
39+ } , [ scrollY ] ) ;
40+
41+ useEffect ( ( ) => {
42+ // Add scroll event listener without using framer-motion
43+ const handleScroll = ( ) => {
44+ if ( window . scrollY > 300 ) {
45+ setBlur ( false ) ;
46+ } else {
47+ setBlur ( true ) ;
48+ }
49+ } ;
50+
51+ window . addEventListener ( 'scroll' , handleScroll ) ;
52+
53+ return ( ) => window . removeEventListener ( 'scroll' , handleScroll ) ;
54+ } , [ scrollY ] ) ;
3555
3656 return (
3757 < VStack
@@ -40,14 +60,76 @@ const ProjectItem = ({
4060 zIndex = { 1 }
4161 position = { 'sticky' }
4262 top = { '15vh' }
43- gap = { 20 }
4463 overflowX = { 'hidden' }
4564 >
65+ { image ? (
66+ < motion . div
67+ animate = { blur ? 'visible' : 'hidden' }
68+ variants = { {
69+ hidden : {
70+ filter : 'blur(5px)' ,
71+ opacity : 0.5 ,
72+ } ,
73+ visible : {
74+ filter : 'blur(0px)' ,
75+ opacity : 1 ,
76+ } ,
77+ } }
78+ transition = { { duration : 1 } }
79+ style = { {
80+ width : '100%' ,
81+ position : 'fixed' ,
82+ top : top ,
83+ } }
84+ id = "project-images"
85+ >
86+ < Carousel
87+ dynamicHeight = { false }
88+ axis = "horizontal"
89+ showStatus = { false }
90+ emulateTouch
91+ autoPlay
92+ showThumbs = { false }
93+ infiniteLoop
94+ interval = { 5000 }
95+ showArrows = { true }
96+ showIndicators = { false }
97+ // renderIndicator={(clickHandler, isSelected) => (
98+ // <Box
99+ // h={2}
100+ // w={2}
101+ // top={0}
102+ // marginX={1}
103+ // display={'inline-block'}
104+ // bg={isSelected ? 'violet' : 'white'}
105+ // borderRadius={'50%'}
106+ // _hover={{ bg: 'black' }}
107+ // onClick={clickHandler}
108+ // />
109+ // )}
110+ stopOnHover
111+ width = { '100%' }
112+ >
113+ { image . map ( ( img ) => (
114+ < Img
115+ width = { '80vh' }
116+ key = { img }
117+ src = { '../../' + img }
118+ alt = { title }
119+ loading = "lazy"
120+ />
121+ ) ) }
122+ </ Carousel >
123+ </ motion . div >
124+ ) : null }
46125 < Box
47126 style = { {
48127 width : '100%' ,
49128 overflowX : 'hidden' ,
129+ marginTop : '100vh' ,
50130 } }
131+ my = { 2 }
132+ shadow = { ' 0 0 10px 1px #FFFFFFfA' }
51133 >
52134 < CardSpotlight >
53135 < VStack
@@ -104,47 +186,6 @@ const ProjectItem = ({
104186 </ VStack >
105187 </ CardSpotlight >
106188 </ Box >
107- { image ? (
108- < Box width = { '100%' } id = "project-images" >
109- < Carousel
110- axis = "horizontal"
111- centerMode
112- dynamicHeight
113- showStatus = { false }
114- emulateTouch
115- autoPlay
116- showThumbs = { false }
117- infiniteLoop
118- interval = { 3000 }
119- showArrows = { false }
120- renderIndicator = { ( clickHandler , isSelected ) => (
121- < Box
122- h = { 2 }
123- w = { 2 }
124- top = { 0 }
125- marginX = { 1 }
126- display = { 'inline-block' }
127- bg = { isSelected ? 'violet' : 'white' }
128- borderRadius = { '50%' }
129- _hover = { { bg : 'black' } }
130- onClick = { clickHandler }
131- />
132- ) }
133- stopOnHover
134- width = { '100%' }
135- >
136- { image . map ( ( img ) => (
137- < Img
138- width = { '80vh' }
139- key = { img }
140- src = { '../../' + img }
141- alt = { title }
142- loading = "lazy"
143- />
144- ) ) }
145- </ Carousel >
146- </ Box >
147- ) : null }
148189 </ VStack >
149190 ) ;
150191} ;
0 commit comments