가이드 · 05

등장, 퇴장, 레이아웃

떠나는 자식을 모션이 끝날 때까지 남기고, 컴포넌트를 넘나드는 위치·크기 변화를 애니메이션합니다.

Animated.Keep

Animated.Keep은 key가 있는 직계 자식을 depart 포즈가 끝날 때까지 남깁니다. seed={false}는 첫 렌더에 있던 자식을 pose에서 시작하게 하고, wait는 퇴장이 끝날 때까지 새 자식을 미루며, onDeparted는 마지막 퇴장 뒤에 호출됩니다.

예제를 준비하는 중…

Animated.Scene과 move

Animated.Scene은 커밋된 레이아웃을 측정합니다. move가 있는 요소는 위치와 크기 변화를 애니메이션하고, move="pill" 같은 문자열은 한쪽이 언마운트되고 다른 쪽이 마운트되어도 Scene 안에서 같은 정체성의 요소를 이어 줍니다.

Scene은 그 요소들의 레이아웃 translate와 scale을 소유하므로 직접 쓰는 transform은 안쪽 요소에 두세요.

예제를 준비하는 중…

훅으로 쓰는 등장·퇴장

마운트를 직접 제어하고 싶다면 useAnimatedPresence(visible, { enter, exit })가 { mounted, animatedValue }를 돌려줍니다.

Toast.jsx
const { mounted, animatedValue } = useAnimatedPresence(open, {
  enter: (value) => spring(value, { toValue: 1 }),
  exit: (value) => timing(value, { toValue: 0, duration: 180 }),
});

return mounted ? <div style={{ opacity: animatedValue }}>Saved</div> : null;

React 밖에서

createLayoutScene은 같은 capture/commit 조율을 다른 렌더러나 직접 바꾸는 DOM에 제공합니다.

outside-react.js
const scene = createLayoutScene({ tempo: { spring: { stiffness: 320, damping: 30 } } });
const card = scene.attach(element, { key: 'card' });

scene.capture(); // before the DOM changes
list.prepend(element); // any renderer or manual DOM work
scene.commit(); // animates from the captured rectangles

검색

입력하면 문서를 검색합니다.