@@ -7,70 +7,67 @@ import { useEffect, useRef } from 'react';
77import gsap from 'gsap' ;
88
99function StarMain ( ) {
10- const background = useRef < HTMLDivElement > ( null ) ;
11- const foreground = useRef < HTMLDivElement > ( null ) ;
12- const mouse = useRef ( { x : 0 , y : 0 } ) ;
13- const rafId = useRef < number | null > ( null ) ;
10+ // const background = useRef<HTMLDivElement>(null);
11+ // const foreground = useRef<HTMLDivElement>(null);
12+ // const mouse = useRef({ x: 0, y: 0 });
13+ // const rafId = useRef<number | null>(null);
1414
15- useEffect ( ( ) => {
16- if ( ! background . current || ! foreground . current ) return ;
15+ // useEffect(() => {
16+ // if (!background.current || !foreground.current) return;
1717
18- const bgX = gsap . quickSetter ( background . current , 'x' , 'px' ) ;
19- const bgY = gsap . quickSetter ( background . current , 'y' , 'px' ) ;
20- const bgRotate = gsap . quickSetter ( background . current , 'rotate' , 'deg' ) ;
18+ // const bgX = gsap.quickSetter(background.current, 'x', 'px');
19+ // const bgY = gsap.quickSetter(background.current, 'y', 'px');
20+ // const bgRotate = gsap.quickSetter(background.current, 'rotate', 'deg');
2121
22- const fgX = gsap . quickSetter ( foreground . current , 'x' , 'px' ) ;
23- const fgY = gsap . quickSetter ( foreground . current , 'y' , 'px' ) ;
24- const fgRotate = gsap . quickSetter ( foreground . current , 'rotate' , 'deg' ) ;
22+ // const fgX = gsap.quickSetter(foreground.current, 'x', 'px');
23+ // const fgY = gsap.quickSetter(foreground.current, 'y', 'px');
24+ // const fgRotate = gsap.quickSetter(foreground.current, 'rotate', 'deg');
2525
26- const update = ( ) => {
27- const { x, y } = mouse . current ;
26+ // const update = () => {
27+ // const { x, y } = mouse.current;
2828
29- bgX ( x * - 2 ) ;
30- bgY ( y * - 2 ) ;
31- bgRotate ( x * - 0.2 ) ;
29+ // bgX(x * -2);
30+ // bgY(y * -2);
31+ // bgRotate(x * -0.2);
3232
33- fgX ( x * 3 ) ;
34- fgY ( y * 3 ) ;
35- fgRotate ( y * 0.2 ) ;
33+ // fgX(x * 3);
34+ // fgY(y * 3);
35+ // fgRotate(y * 0.2);
3636
37- rafId . current = requestAnimationFrame ( update ) ;
38- } ;
37+ // rafId.current = requestAnimationFrame(update);
38+ // };
3939
40- const handleMouseMove = ( e : MouseEvent ) => {
41- // 화면 중앙 기준으로 얼마나 벗어났는지 (-1 ~ 1 범위)
42- const x = ( e . clientX / window . innerWidth - 0.5 ) * 2 ;
43- const y = ( e . clientY / window . innerHeight - 0.5 ) * 2 ;
44- mouse . current = { x, y } ;
45- } ;
40+ // const handleMouseMove = (e: MouseEvent) => {
41+ // // 화면 중앙 기준으로 얼마나 벗어났는지 (-1 ~ 1 범위)
42+ // const x = (e.clientX / window.innerWidth - 0.5) * 2;
43+ // const y = (e.clientY / window.innerHeight - 0.5) * 2;
44+ // mouse.current = { x, y };
45+ // };
4646
47- const handleTouchMove = ( e : TouchEvent ) => {
48- const touch = e . touches [ 0 ] ;
49- const x = ( touch . clientX / window . innerWidth - 0.5 ) * 2 ;
50- const y = ( touch . clientY / window . innerHeight - 0.5 ) * 2 ;
51- mouse . current = { x, y } ;
52- } ;
47+ // const handleTouchMove = (e: TouchEvent) => {
48+ // const touch = e.touches[0];
49+ // const x = (touch.clientX / window.innerWidth - 0.5) * 2;
50+ // const y = (touch.clientY / window.innerHeight - 0.5) * 2;
51+ // mouse.current = { x, y };
52+ // };
5353
54- window . addEventListener ( 'mousemove' , handleMouseMove ) ;
55- window . addEventListener ( 'touchmove' , handleTouchMove ) ;
56- rafId . current = requestAnimationFrame ( update ) ;
54+ // window.addEventListener('mousemove', handleMouseMove);
55+ // window.addEventListener('touchmove', handleTouchMove);
56+ // rafId.current = requestAnimationFrame(update);
5757
58- return ( ) => {
59- window . removeEventListener ( 'mousemove' , handleMouseMove ) ;
60- window . removeEventListener ( 'touchmove' , handleTouchMove ) ;
61- if ( rafId . current ) cancelAnimationFrame ( rafId . current ) ;
62- } ;
63- } , [ ] ) ;
58+ // return () => {
59+ // window.removeEventListener('mousemove', handleMouseMove);
60+ // window.removeEventListener('touchmove', handleTouchMove);
61+ // if (rafId.current) cancelAnimationFrame(rafId.current);
62+ // };
63+ // }, []);
6464
6565 return (
6666 < >
6767 { /* <HomeBackground /> */ }
6868 < div >
6969 < div className = "fixed top-0 left-0 w-full h-full overflow-hidden" >
70- < div
71- ref = { background }
72- className = "absolute w-full h-full top-0 left-0 will-change-transform"
73- >
70+ < div className = "absolute w-full h-full top-0 left-0 will-change-transform" >
7471 < Image
7572 src = { foreStar }
7673 alt = "앞쪽 별"
@@ -80,7 +77,7 @@ function StarMain() {
8077 sizes = "100vw"
8178 />
8279 </ div >
83- < div ref = { foreground } className = "fixed w-full h-full top-0 left-0 will-change-transform" >
80+ < div className = "fixed w-full h-full top-0 left-0 will-change-transform" >
8481 < Image
8582 src = { backStar }
8683 alt = "뒤쪽 별"
0 commit comments