@@ -8,13 +8,15 @@ import { Element } from "hast";
8
8
import CodeBlock from "./code-block" ;
9
9
import { motion } from "framer-motion" ;
10
10
import remarkCallout from "@r4ai/remark-callout" ;
11
+ import { useIsMobile } from "@/hooks/use-mobile" ;
11
12
12
13
export interface MarkdownRendererProps {
13
14
content : string ;
14
15
publish ?: string ;
15
16
tags ?: string [ ] ;
16
17
published ?: string ;
17
18
modified ?: string ;
19
+ disableAnimation ?: boolean ; // 애니메이션 비활성화 옵션 추가
18
20
}
19
21
20
22
interface LinkMap {
@@ -37,7 +39,11 @@ export default function MarkdownRenderer({
37
39
tags,
38
40
published,
39
41
modified,
42
+ disableAnimation = false ,
40
43
} : MarkdownRendererProps ) {
44
+ // 기본적으로 모바일에서는 애니메이션 비활성화
45
+ const isMobile = useIsMobile ( ) ;
46
+ const shouldDisableAnimation = disableAnimation || isMobile ;
41
47
const [ linkMap , setLinkMap ] = useState < LinkMap > ( { } ) ;
42
48
const [ isMapLoaded , setIsMapLoaded ] = useState ( false ) ;
43
49
useEffect ( ( ) => {
@@ -291,10 +297,10 @@ export default function MarkdownRenderer({
291
297
} ,
292
298
img : ( { src, alt } : { src ?: string ; alt ?: string } ) => (
293
299
< motion . div
294
- className = "spacing-section relative group"
295
- initial = { { opacity : 0 , scale : 0.95 } }
300
+ className = "spacing-section relative group motion-gpu "
301
+ initial = { shouldDisableAnimation ? false : { opacity : 0 , scale : 0.95 } }
296
302
animate = { { opacity : 1 , scale : 1 } }
297
- transition = { { duration : 0.2 } }
303
+ transition = { { duration : shouldDisableAnimation ? 0 : 0.2 } }
298
304
>
299
305
< div className = "flex flex-col w-full items-center justify-center" >
300
306
< div
@@ -396,10 +402,10 @@ export default function MarkdownRenderer({
396
402
blockquote : ( { children } : { children ?: React . ReactNode } ) => (
397
403
< motion . blockquote
398
404
className = "spacing-paragraph border-l-4 border-primary pl-4 sm:pl-5 md:pl-6 py-2 sm:py-3
399
- bg-primary/5 rounded-r-lg shadow-sm"
400
- initial = { { opacity : 0 , x : - 5 } }
405
+ bg-primary/5 rounded-r-lg shadow-sm motion-gpu "
406
+ initial = { shouldDisableAnimation ? false : { opacity : 0 , x : - 5 } }
401
407
animate = { { opacity : 1 , x : 0 } }
402
- transition = { { duration : 0.15 } }
408
+ transition = { { duration : shouldDisableAnimation ? 0 : 0.15 } }
403
409
>
404
410
< div className = "text-foreground/80 italic font-medium" > { children } </ div >
405
411
</ motion . blockquote >
@@ -419,10 +425,10 @@ export default function MarkdownRenderer({
419
425
) ,
420
426
table : ( { children } : { children ?: React . ReactNode } ) => (
421
427
< motion . div
422
- className = "spacing-section overflow-x-auto rounded-md sm:rounded-lg border border-primary/10 shadow-sm"
423
- initial = { { opacity : 0 } }
428
+ className = "spacing-section overflow-x-auto rounded-md sm:rounded-lg border border-primary/10 shadow-sm motion-gpu "
429
+ initial = { shouldDisableAnimation ? false : { opacity : 0 } }
424
430
animate = { { opacity : 1 } }
425
- transition = { { duration : 0.15 } }
431
+ transition = { { duration : shouldDisableAnimation ? 0 : 0.15 } }
426
432
>
427
433
< table className = "w-full border-collapse text-hierarchy-body" >
428
434
{ children }
@@ -446,10 +452,10 @@ export default function MarkdownRenderer({
446
452
) ,
447
453
hr : ( ) => (
448
454
< motion . hr
449
- className = "spacing-section border-none h-px bg-gradient-to-r from-transparent via-primary/30 to-transparent"
450
- initial = { { width : 0 } }
455
+ className = "spacing-section border-none h-px bg-gradient-to-r from-transparent via-primary/30 to-transparent motion-gpu "
456
+ initial = { shouldDisableAnimation ? false : { width : 0 } }
451
457
animate = { { width : "100%" } }
452
- transition = { { duration : 0.2 } }
458
+ transition = { { duration : shouldDisableAnimation ? 0 : 0.2 } }
453
459
/>
454
460
) ,
455
461
input : ( { checked } : { checked ?: boolean } ) => (
0 commit comments