본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

모션 줄이기

원문 보기 위키 갱신

모션 줄이기 (Reduce Motion)

어떤 시나리오에서는 인터페이스에 복잡한 애니메이션 효과가 없기를 바랄 수 있어요. 그럴 때는 antd-mobile이 제공하는 reduceMotion과 restoreMotion 함수로 컴포넌트의 애니메이션 효과를 제어할 수 있어요.

출처: 문서

본문

reduceMotion()을 호출하면 antd-mobile 컴포넌트는 가능한 한 애니메이션을 건너뛰어요.

import { reduceMotion } from 'antd-mobile'

reduceMotion()

주의할 점은 reduceMotion()이 antd-mobile이 제공하는 컴포넌트만 제어한다는 거예요. 비즈니스 프로젝트에 속한 여러분 자신의 컴포넌트에는 영향을 주지 않아요.

애니메이션 효과를 원래대로 되돌리고 싶을 때는 restoreMotion()을 호출하면 돼요.

시스템 설정 따르기

어떤 경우에는 애니메이션 동작이 시스템 설정을 직접 따르길 바랄 수 있어요. 예를 들어 iOS의 "접근성 - 동작 줄이기" 설정 같은 경우예요:

reduce-motion-en

그럴 때는 react-reduce-motion과 함께 사용할 수 있어요:

import { useReducedMotion } from 'react-reduce-motion'
import { reduceMotion, restoreMotion } from 'antd-mobile'

const MyApp = () => {
  const prefersReducedMotion = useReducedMotion()
  React.useEffect(() => {
    if (prefersReducedMotion) {
      reduceMotion()
    } else {
      restoreMotion()
    }
  }, [prefersReducedMotion])
  // ...
}

더 알아보기

antd-mobile의 접근성과 스타일 이슈로는 다크 모드 문서도 참고해 보세요.