@@ -4,7 +4,7 @@ import { nativeBridge } from '@/utils/bridge';
44import * as S from './MemeDetailPage.styles' ;
55import { useTheme } from '@emotion/react' ;
66import { useRef } from 'react' ;
7- import { useScroll , useTransform , useSpring } from 'motion/react' ;
7+ import { useScroll , useTransform , useSpring , anticipate } from 'motion/react' ;
88
99const DUMMY_DATA = {
1010 resultType : 'SUCCESS' ,
@@ -28,22 +28,27 @@ const MemeDetailPage = () => {
2828 const containerRef = useRef < HTMLDivElement > ( null ) ;
2929 const { scrollY } = useScroll ( { container : containerRef } ) ;
3030
31- const height = useTransform ( scrollY , [ 0 , 100 ] , [ 400 , 10 ] ) ;
31+ const isMobile = window . innerWidth <= 768 ;
32+ const heightRange = isMobile ? [ 300 , 150 ] : [ 400 , 200 ] ;
33+ const scrollRange = isMobile ? [ 0 , 50 ] : [ 0 , 100 ] ;
34+
35+ const height = useTransform ( scrollY , scrollRange , heightRange ) ;
3236 const smoothHeight = useSpring ( height , {
33- stiffness : 150 ,
34- damping : 50 ,
37+ stiffness : 200 ,
38+ damping : 30 ,
3539 } ) ;
3640
37- const textWidth = useTransform ( scrollY , [ 0 , 10 ] , [ 100 , 0 ] ) ;
38- const smoothTextWidth = useSpring ( textWidth , {
39- stiffness : 150 ,
40- damping : 50 ,
41+ const threshold = isMobile ? 15 : 30 ;
42+
43+ const isTextVisible = useTransform ( scrollY , [ 0 , threshold ] , [ 1 , 0 ] , {
44+ clamp : true ,
45+ ease : anticipate ,
4146 } ) ;
4247
43- const padding = useTransform ( scrollY , [ 0 , 20 ] , [ 10 , 5 ] ) ;
48+ const padding = useTransform ( scrollY , [ 0 , threshold ] , [ 10 , 5 ] ) ;
4449 const smoothPadding = useSpring ( padding , {
45- stiffness : 150 ,
46- damping : 50 ,
50+ stiffness : 200 ,
51+ damping : 30 ,
4752 } ) ;
4853
4954 return (
@@ -68,9 +73,15 @@ const MemeDetailPage = () => {
6873 } }
6974 >
7075 < ShareIcon width = { 24 } height = { 24 } />
71- < S . ShareButtonText style = { { maxWidth : smoothTextWidth } } >
72- 공유하기
73- </ S . ShareButtonText >
76+ < S . ShareTextWrapper
77+ style = { {
78+ display : useTransform ( isTextVisible , ( v ) =>
79+ v > 0.01 ? 'flex' : 'none' ,
80+ ) ,
81+ } }
82+ >
83+ < S . ShareButtonText > 공유하기</ S . ShareButtonText >
84+ </ S . ShareTextWrapper >
7485 </ S . ShareButton >
7586 </ S . ImageContainer >
7687 < S . ContentContainer >
0 commit comments