์ฝ˜ํ…์ธ  ๋Œ€ํ‘œ ์ด๋ฏธ์ง€ - ๐ŸŽจ ๋ฆฌ์•กํŠธ ๋„ค์ดํ‹ฐ๋ธŒ ์• ๋‹ˆ๋ฉ”์ด์…˜ ๊ตฌํ˜„: Animated API๋กœ ์•ฑ์— ์ƒ๋ช… ๋ถˆ์–ด๋„ฃ๊ธฐ

๐ŸŽจ ๋ฆฌ์•กํŠธ ๋„ค์ดํ‹ฐ๋ธŒ ์• ๋‹ˆ๋ฉ”์ด์…˜ ๊ตฌํ˜„: Animated API๋กœ ์•ฑ์— ์ƒ๋ช… ๋ถˆ์–ด๋„ฃ๊ธฐ

์นœ๊ตฌ์ฒ˜๋Ÿผ ์‰ฝ๊ฒŒ ๋ฐฐ์šฐ๋Š” ๋ชจ๋ฐ”์ผ ์•ฑ ์• ๋‹ˆ๋ฉ”์ด์…˜์˜ ๋ชจ๋“  ๊ฒƒ โœจ

๐Ÿš€ ์™œ ์• ๋‹ˆ๋ฉ”์ด์…˜์ด ์ค‘์š”ํ• ๊นŒ?

์•ผ, ์†”์งํžˆ ๋งํ•ด์„œ ์š”์ฆ˜ ์•ฑ๋“ค ๋ณด๋ฉด ๋‹ค๋“ค ์—„์ฒญ ๋ถ€๋“œ๋Ÿฝ๊ฒŒ ์›€์ง์ด์ž–์•„? ๐Ÿ˜Ž
๋ฒ„ํŠผ ๋ˆ„๋ฅด๋ฉด ์‚ด์ง ๋ˆŒ๋ฆฌ๋Š” ๋А๋‚Œ, ํ™”๋ฉด ์ „ํ™˜ํ•  ๋•Œ ์Šค์œฝ ๋„˜์–ด๊ฐ€๋Š” ๋А๋‚Œ...
์ด๋Ÿฐ ๊ฒŒ ๋‹ค ์• ๋‹ˆ๋ฉ”์ด์…˜์ด์•ผ!

๋ฆฌ์•กํŠธ ๋„ค์ดํ‹ฐ๋ธŒ๋กœ ์•ฑ ๋งŒ๋“ค ๋•Œ๋„ ๋งˆ์ฐฌ๊ฐ€์ง€์•ผ.
๊ทธ๋ƒฅ ๋”ฑ๋”ฑํ•˜๊ฒŒ ํ™”๋ฉด๋งŒ ๋ฐ”๋€Œ๋ฉด ๋ญ”๊ฐ€ 2000๋…„๋Œ€ ์•ฑ ์“ฐ๋Š” ๋А๋‚Œ์ด์ž–์•„? ๐Ÿค”
์‚ฌ์šฉ์ž๋“ค์€ ์ด์ œ ๋ถ€๋“œ๋Ÿฌ์šด ์ „ํ™˜, ์ž์—ฐ์Šค๋Ÿฌ์šด ์›€์ง์ž„์„ ๋‹น์—ฐํ•˜๊ฒŒ ์ƒ๊ฐํ•ด.

๊ทธ๋ž˜์„œ ์˜ค๋Š˜์€ ๋ฆฌ์•กํŠธ ๋„ค์ดํ‹ฐ๋ธŒ์˜ Animated API๋ฅผ ์™„์ „ ์ •๋ณตํ•ด๋ณผ ๊ฑฐ์•ผ!
์ฒ˜์Œ ๋ณด๋ฉด ์ข€ ์–ด๋ ค์›Œ ๋ณด์ผ ์ˆ˜ ์žˆ๋Š”๋ฐ, ์นœ๊ตฌํ•œํ…Œ ์„ค๋ช…ํ•˜๋“ฏ์ด ์‰ฝ๊ฒŒ ํ’€์–ด์„œ ์•Œ๋ ค์ค„๊ฒŒ! ๐Ÿ’ช

๐Ÿ’ก ์ด ๊ธ€์—์„œ ๋ฐฐ์šธ ๋‚ด์šฉ
  • โœ… Animated API์˜ ๊ธฐ๋ณธ ๊ฐœ๋…๊ณผ ์ž‘๋™ ์›๋ฆฌ
  • โœ… ๋‹ค์–‘ํ•œ ์• ๋‹ˆ๋ฉ”์ด์…˜ ํƒ€์ž… (Timing, Spring, Decay)
  • โœ… ์‹ค์ „ ์˜ˆ์ œ๋กœ ๋ฐฐ์šฐ๋Š” ์• ๋‹ˆ๋ฉ”์ด์…˜ ๊ตฌํ˜„
  • โœ… ์„ฑ๋Šฅ ์ตœ์ ํ™” ํŒ๊ณผ ์ฃผ์˜์‚ฌํ•ญ
  • โœ… ๊ณ ๊ธ‰ ํ…Œํฌ๋‹‰๊ณผ ์กฐํ•ฉ ํ™œ์šฉ๋ฒ•

๐ŸŽฏ Animated API๋ž€ ๋ฌด์—‡์ธ๊ฐ€?

๋ฆฌ์•กํŠธ ๋„ค์ดํ‹ฐ๋ธŒ์˜ Animated API๋Š” ๋ง ๊ทธ๋Œ€๋กœ ์• ๋‹ˆ๋ฉ”์ด์…˜์„ ๋งŒ๋“ค๊ธฐ ์œ„ํ•œ ๋„๊ตฌ์•ผ! ๐Ÿ› ๏ธ
๊ทผ๋ฐ ์ด๊ฒŒ ๊ทธ๋ƒฅ ๋‹จ์ˆœํ•œ ๋„๊ตฌ๊ฐ€ ์•„๋‹ˆ๋ผ, ์—„์ฒญ ๊ฐ•๋ ฅํ•˜๋ฉด์„œ๋„ ์„ฑ๋Šฅ์ด ์ข‹์€ ์นœ๊ตฌ์ง€.

์ผ๋ฐ˜์ ์œผ๋กœ ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ๋กœ ์• ๋‹ˆ๋ฉ”์ด์…˜์„ ๋งŒ๋“ค๋ฉด ์–ด๋–ป๊ฒŒ ๋ ๊นŒ?
๋งค ํ”„๋ ˆ์ž„๋งˆ๋‹ค ์ƒํƒœ๋ฅผ ์—…๋ฐ์ดํŠธํ•˜๊ณ , ๋ฆฌ๋ Œ๋”๋งํ•˜๊ณ ... ์ด๋Ÿฌ๋ฉด ์„ฑ๋Šฅ์ด ๋–จ์–ด์ ธ. ๐Ÿ˜ฐ
ํŠนํžˆ ๋ชจ๋ฐ”์ผ์—์„œ๋Š” 60fps๋ฅผ ์œ ์ง€ํ•˜๊ธฐ๊ฐ€ ์ •๋ง ์–ด๋ ค์›Œ.

ํ•˜์ง€๋งŒ Animated API๋Š” ๋‹ค๋ฅด๊ฒŒ ์ž‘๋™ํ•ด!
๋„ค์ดํ‹ฐ๋ธŒ ๋“œ๋ผ์ด๋ฒ„๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ ์Šค๋ ˆ๋“œ๋ฅผ ๊ฑฐ์น˜์ง€ ์•Š๊ณ 
์ง์ ‘ ๋„ค์ดํ‹ฐ๋ธŒ ๋ ˆ์ด์–ด์—์„œ ์• ๋‹ˆ๋ฉ”์ด์…˜์„ ์ฒ˜๋ฆฌํ•  ์ˆ˜ ์žˆ๊ฑฐ๋“ . ๐Ÿš„
๊ทธ๋ž˜์„œ ์—„์ฒญ ๋ถ€๋“œ๋Ÿฝ๊ณ  ๋น ๋ฅธ ์• ๋‹ˆ๋ฉ”์ด์…˜์„ ๋งŒ๋“ค ์ˆ˜ ์žˆ์–ด!

์ผ๋ฐ˜ ์• ๋‹ˆ๋ฉ”์ด์…˜ JS ์Šค๋ ˆ๋“œ ๋งค ํ”„๋ ˆ์ž„ ๋ฆฌ๋ Œ๋”๋ง ๋А๋ฆผ ๐Ÿ˜ฐ Animated API ๋„ค์ดํ‹ฐ๋ธŒ ๋“œ๋ผ์ด๋ฒ„ ์ง์ ‘ ๋„ค์ดํ‹ฐ๋ธŒ ์ฒ˜๋ฆฌ ๋น ๋ฆ„ ๐Ÿš€
๐ŸŽ“ ํ•ต์‹ฌ ํฌ์ธํŠธ Animated API์˜ ๊ฐ€์žฅ ํฐ ์žฅ์ ์€ ๋„ค์ดํ‹ฐ๋ธŒ ๋“œ๋ผ์ด๋ฒ„๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค๋Š” ๊ฑฐ์•ผ!
์ด๊ฑธ ํ™œ์„ฑํ™”ํ•˜๋ฉด ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ ๋ธŒ๋ฆฟ์ง€๋ฅผ ๊ฑฐ์น˜์ง€ ์•Š๊ณ  ๋„ค์ดํ‹ฐ๋ธŒ ๋ ˆ๋ฒจ์—์„œ ์• ๋‹ˆ๋ฉ”์ด์…˜์ด ์‹คํ–‰๋ผ์„œ
60fps๋ฅผ ์•ˆ์ •์ ์œผ๋กœ ์œ ์ง€ํ•  ์ˆ˜ ์žˆ์–ด. ์ง„์งœ ๊ฒŒ์ž„ ์ฒด์ธ์ €์•ผ! ๐ŸŽฎ

๐Ÿ“ฆ Animated API์˜ ํ•ต์‹ฌ ๊ตฌ์„ฑ ์š”์†Œ

์ž, ์ด์ œ ๋ณธ๊ฒฉ์ ์œผ๋กœ Animated API์˜ ๊ตฌ์กฐ๋ฅผ ํŒŒํ—ค์ณ๋ณด์ž! ๐Ÿ”
ํฌ๊ฒŒ ์„ธ ๊ฐ€์ง€ ํ•ต์‹ฌ ์š”์†Œ๋กœ ๋‚˜๋ˆŒ ์ˆ˜ ์žˆ์–ด.

1๏ธโƒฃ Animated Values (์• ๋‹ˆ๋ฉ”์ด์…˜ ๊ฐ’)

์• ๋‹ˆ๋ฉ”์ด์…˜์˜ ์‹œ์ž‘์ ์ด์•ผ!
๋ณ€ํ™”ํ•  ๊ฐ’์„ ๋‹ด๋Š” ํŠน๋ณ„ํ•œ ์ปจํ…Œ์ด๋„ˆ๋ผ๊ณ  ์ƒ๊ฐํ•˜๋ฉด ๋ผ. ๐Ÿ“Š

์ฃผ๋กœ ๋‘ ๊ฐ€์ง€ ํƒ€์ž…์„ ์‚ฌ์šฉํ•ด:

๐Ÿ”น Animated.Value
๋‹จ์ผ ์ˆซ์ž ๊ฐ’์„ ๋‹ค๋ฃฐ ๋•Œ ์‚ฌ์šฉํ•ด. ํˆฌ๋ช…๋„, ์œ„์น˜, ํฌ๊ธฐ ๊ฐ™์€ ๊ฑฐ!

const fadeAnim = new Animated.Value(0);  // 0๋ถ€ํ„ฐ ์‹œ์ž‘
const scaleAnim = new Animated.Value(1); // 1๋ถ€ํ„ฐ ์‹œ์ž‘

๐Ÿ”น Animated.ValueXY
X, Y ์ขŒํ‘œ์ฒ˜๋Ÿผ ๋‘ ๊ฐœ์˜ ๊ฐ’์„ ํ•จ๊ป˜ ๋‹ค๋ฃฐ ๋•Œ ์‚ฌ์šฉํ•ด!

const position = new Animated.ValueXY({ x: 0, y: 0 });

2๏ธโƒฃ Animated Components (์• ๋‹ˆ๋ฉ”์ด์…˜ ์ปดํฌ๋„ŒํŠธ)

์ผ๋ฐ˜ ์ปดํฌ๋„ŒํŠธ๋Š” ์• ๋‹ˆ๋ฉ”์ด์…˜ ๊ฐ’์„ ์ง์ ‘ ๋ฐ›์„ ์ˆ˜ ์—†์–ด. ๐Ÿ˜…
๊ทธ๋ž˜์„œ Animated API๊ฐ€ ์ œ๊ณตํ•˜๋Š” ํŠน๋ณ„ํ•œ ์ปดํฌ๋„ŒํŠธ๋ฅผ ์‚ฌ์šฉํ•ด์•ผ ํ•ด!

์ปดํฌ๋„ŒํŠธ ์„ค๋ช… ์ฃผ์š” ์šฉ๋„
Animated.View ์• ๋‹ˆ๋ฉ”์ด์…˜ ๊ฐ€๋Šฅํ•œ View ๋ ˆ์ด์•„์›ƒ, ์œ„์น˜, ํฌ๊ธฐ ๋ณ€๊ฒฝ
Animated.Text ์• ๋‹ˆ๋ฉ”์ด์…˜ ๊ฐ€๋Šฅํ•œ Text ํ…์ŠคํŠธ ํŽ˜์ด๋“œ, ์ƒ‰์ƒ ๋ณ€๊ฒฝ
Animated.Image ์• ๋‹ˆ๋ฉ”์ด์…˜ ๊ฐ€๋Šฅํ•œ Image ์ด๋ฏธ์ง€ ์ „ํ™˜, ํ™•๋Œ€/์ถ•์†Œ
Animated.ScrollView ์• ๋‹ˆ๋ฉ”์ด์…˜ ๊ฐ€๋Šฅํ•œ ScrollView ์Šคํฌ๋กค ๊ธฐ๋ฐ˜ ์• ๋‹ˆ๋ฉ”์ด์…˜

์ปค์Šคํ…€ ์ปดํฌ๋„ŒํŠธ๋ฅผ ์• ๋‹ˆ๋ฉ”์ด์…˜ ๊ฐ€๋Šฅํ•˜๊ฒŒ ๋งŒ๋“ค๊ณ  ์‹ถ๋‹ค๋ฉด?
Animated.createAnimatedComponent()๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ๋ผ! ๐ŸŽจ

const AnimatedTouchable = Animated.createAnimatedComponent(TouchableOpacity);

3๏ธโƒฃ Animation Types (์• ๋‹ˆ๋ฉ”์ด์…˜ ํƒ€์ž…)

๊ฐ’์„ ์–ด๋–ป๊ฒŒ ๋ณ€ํ™”์‹œํ‚ฌ์ง€ ์ •ํ•˜๋Š” ๊ฑฐ์•ผ!
๊ฐ๊ฐ ํŠน์ง•์ด ๋‹ค๋ฅด๋‹ˆ๊นŒ ์ƒํ™ฉ์— ๋งž๊ฒŒ ๊ณจ๋ผ ์“ฐ๋ฉด ๋ผ. ๐ŸŽฏ

โฑ๏ธ Animated.timing
์‹œ๊ฐ„์— ๋”ฐ๋ผ ์„ ํ˜•์ ์œผ๋กœ ๊ฐ’์„ ๋ณ€ํ™”์‹œ์ผœ.
๊ฐ€์žฅ ๊ธฐ๋ณธ์ ์ด๊ณ  ๋งŽ์ด ์“ฐ๋Š” ๋ฐฉ์‹์ด์•ผ!

Animated.timing(fadeAnim, {
  toValue: 1,           // ๋ชฉํ‘œ๊ฐ’
  duration: 1000,       // 1์ดˆ ๋™์•ˆ
  useNativeDriver: true // ๋„ค์ดํ‹ฐ๋ธŒ ๋“œ๋ผ์ด๋ฒ„ ์‚ฌ์šฉ!
}).start();

๐ŸŒŠ Animated.spring
๋ฌผ๋ฆฌ ๋ฒ•์น™์„ ์ ์šฉํ•œ ์Šคํ”„๋ง ํšจ๊ณผ!
ํ†ตํ†ต ํŠ€๋Š” ๋А๋‚Œ์„ ์ค„ ์ˆ˜ ์žˆ์–ด์„œ ์ž์—ฐ์Šค๋Ÿฌ์›Œ. ๐ŸŽช

Animated.spring(scaleAnim, {
  toValue: 1.2,
  friction: 3,          // ๋งˆ์ฐฐ๋ ฅ (๋‚ฎ์„์ˆ˜๋ก ๋” ํА)
  tension: 40,          // ์žฅ๋ ฅ (๋†’์„์ˆ˜๋ก ๋น ๋ฆ„)
  useNativeDriver: true
}).start();

๐ŸŽข Animated.decay
๊ฐ์† ํšจ๊ณผ! ์Šคํฌ๋กค์ด ์ ์  ๋А๋ ค์ง€๋Š” ๊ฒƒ์ฒ˜๋Ÿผ.
์ฃผ๋กœ ์ œ์Šค์ฒ˜์™€ ํ•จ๊ป˜ ์‚ฌ์šฉํ•ด.

Animated.decay(position, {
  velocity: { x: gestureState.vx, y: gestureState.vy },
  deceleration: 0.997,  // ๊ฐ์†๋ฅ 
  useNativeDriver: true
}).start();

๐ŸŽฌ ์‹ค์ „ ์˜ˆ์ œ: ํŽ˜์ด๋“œ ์ธ ์• ๋‹ˆ๋ฉ”์ด์…˜

์ด๋ก ๋งŒ ๋ณด๋ฉด ์žฌ๋ฏธ์—†์ž–์•„? ๐Ÿ˜ด
์‹ค์ œ๋กœ ์ฝ”๋“œ๋ฅผ ์งœ๋ฉด์„œ ๋ฐฐ์›Œ๋ณด์ž!
๊ฐ€์žฅ ๊ธฐ๋ณธ์ ์ธ ํŽ˜์ด๋“œ ์ธ ํšจ๊ณผ๋ถ€ํ„ฐ ์‹œ์ž‘ํ• ๊ฒŒ.

๐ŸŽจ ๊ธฐ๋ณธ ํŽ˜์ด๋“œ ์ธ ๊ตฌํ˜„

import React, { useEffect, useRef } from 'react';
import { Animated, View, Text, StyleSheet } from 'react-native';

const FadeInView = ({ children }) => {
  // 1. Animated.Value ์ƒ์„ฑ (์ดˆ๊ธฐ๊ฐ’ 0 = ํˆฌ๋ช…)
  const fadeAnim = useRef(new Animated.Value(0)).current;

  useEffect(() => {
    // 2. ์ปดํฌ๋„ŒํŠธ ๋งˆ์šดํŠธ ์‹œ ์• ๋‹ˆ๋ฉ”์ด์…˜ ์‹œ์ž‘
    Animated.timing(fadeAnim, {
      toValue: 1,              // ์™„์ „ ๋ถˆํˆฌ๋ช…
      duration: 2000,          // 2์ดˆ ๋™์•ˆ
      useNativeDriver: true    // ์„ฑ๋Šฅ ์ตœ์ ํ™”!
    }).start();
  }, [fadeAnim]);

  return (
    // 3. Animated.View์— opacity ์ ์šฉ
    <Animated.View style={{ opacity: fadeAnim }}>
      {children}
    </Animated.View>
  );
};

// ์‚ฌ์šฉ ์˜ˆ์‹œ
const App = () => {
  return (
    <View style={styles.container}>
      <FadeInView>
        <Text style={styles.text}>์•ˆ๋…•! ๋‚˜ ์„œ์„œํžˆ ๋‚˜ํƒ€๋‚ฌ์ง€? ๐Ÿ‘‹</Text>
      </FadeInView>
    </View>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#f0f0f0'
  },
  text: {
    fontSize: 20,
    fontWeight: 'bold'
  }
});

export default App;
๐Ÿ’ก ์ฝ”๋“œ ํ•ด์„ค 1. useRef๋กœ Animated.Value๋ฅผ ๊ฐ์‹ธ๋Š” ์ด์œ ?
๋ฆฌ๋ Œ๋”๋ง ์‹œ์—๋„ ๊ฐ™์€ ์ธ์Šคํ„ด์Šค๋ฅผ ์œ ์ง€ํ•˜๊ธฐ ์œ„ํ•ด์„œ์•ผ!

2. useNativeDriver: true๋Š” ํ•„์ˆ˜!
์ด๊ฒŒ ์žˆ์–ด์•ผ ๋„ค์ดํ‹ฐ๋ธŒ ๋ ˆ๋ฒจ์—์„œ ์• ๋‹ˆ๋ฉ”์ด์…˜์ด ์‹คํ–‰๋ผ.
๋‹จ, transform๊ณผ opacity๋งŒ ์ง€์›ํ•œ๋‹ค๋Š” ์  ๊ธฐ์–ตํ•ด! ๐ŸŽฏ

3. .start()๋ฅผ ํ˜ธ์ถœํ•ด์•ผ ์• ๋‹ˆ๋ฉ”์ด์…˜์ด ์‹œ์ž‘๋ผ.
์ฝœ๋ฐฑ ํ•จ์ˆ˜๋ฅผ ๋„ฃ์œผ๋ฉด ์™„๋ฃŒ ์‹œ์ ์„ ์•Œ ์ˆ˜ ์žˆ์–ด!

๐Ÿ”„ ์• ๋‹ˆ๋ฉ”์ด์…˜ ๋ฐ˜๋ณตํ•˜๊ธฐ

ํ•œ ๋ฒˆ๋งŒ ์‹คํ–‰ํ•˜๋Š” ๊ฒŒ ์•„๋‹ˆ๋ผ ๊ณ„์† ๋ฐ˜๋ณตํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด?
Animated.loop()๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ๋ผ! ๐Ÿ”

const PulseAnimation = () => {
  const pulseAnim = useRef(new Animated.Value(1)).current;

  useEffect(() => {
    // ๋ฌดํ•œ ๋ฐ˜๋ณต ์• ๋‹ˆ๋ฉ”์ด์…˜
    Animated.loop(
      Animated.sequence([
        Animated.timing(pulseAnim, {
          toValue: 1.2,
          duration: 500,
          useNativeDriver: true
        }),
        Animated.timing(pulseAnim, {
          toValue: 1,
          duration: 500,
          useNativeDriver: true
        })
      ])
    ).start();
  }, []);

  return (
    <Animated.View 
      style={{
        transform: [{ scale: pulseAnim }]
      }}
    >
      <Text style={{ fontSize: 50 }}>๐Ÿ’“</Text>
    </Animated.View>
  );
};

์ด๋ ‡๊ฒŒ ํ•˜๋ฉด ํ•˜ํŠธ๊ฐ€ ๊ณ„์† ๋‘๊ทผ๋‘๊ทผ ๋›ฐ๋Š” ํšจ๊ณผ๋ฅผ ๋งŒ๋“ค ์ˆ˜ ์žˆ์–ด! ๐Ÿ’—
Animated.sequence()๋Š” ์• ๋‹ˆ๋ฉ”์ด์…˜์„ ์ˆœ์ฐจ์ ์œผ๋กœ ์‹คํ–‰ํ•˜๋Š” ๊ฑฐ๊ณ ,
Animated.loop()๋กœ ๊ฐ์‹ธ๋ฉด ๋ฌดํ•œ ๋ฐ˜๋ณต์ด์•ผ!

๐ŸŽช ๊ณ ๊ธ‰ ์• ๋‹ˆ๋ฉ”์ด์…˜ ํ…Œํฌ๋‹‰

๊ธฐ๋ณธ์€ ๋งˆ์Šคํ„ฐํ–ˆ์ง€?
์ด์ œ ์ข€ ๋” ๋ฉ‹์ง„ ํšจ๊ณผ๋“ค์„ ๋งŒ๋“ค์–ด๋ณด์ž! ๐ŸŒŸ

๐ŸŽฏ ์—ฌ๋Ÿฌ ์• ๋‹ˆ๋ฉ”์ด์…˜ ์กฐํ•ฉํ•˜๊ธฐ

์‹ค์ œ ์•ฑ์—์„œ๋Š” ์—ฌ๋Ÿฌ ์• ๋‹ˆ๋ฉ”์ด์…˜์„ ๋™์‹œ์— ๋˜๋Š” ์ˆœ์ฐจ์ ์œผ๋กœ ์‹คํ–‰ํ•ด์•ผ ํ•  ๋•Œ๊ฐ€ ๋งŽ์•„.
Animated API๋Š” ์ด๋Ÿฐ ์กฐํ•ฉ์„ ์œ„ํ•œ ๊ฐ•๋ ฅํ•œ ๋„๊ตฌ๋“ค์„ ์ œ๊ณตํ•ด! ๐Ÿ› ๏ธ

๐Ÿ”น Animated.parallel()
์—ฌ๋Ÿฌ ์• ๋‹ˆ๋ฉ”์ด์…˜์„ ๋™์‹œ์— ์‹คํ–‰!

Animated.parallel([
  Animated.timing(fadeAnim, {
    toValue: 1,
    duration: 1000,
    useNativeDriver: true
  }),
  Animated.timing(slideAnim, {
    toValue: 0,
    duration: 1000,
    useNativeDriver: true
  })
]).start();

๐Ÿ”น Animated.sequence()
์• ๋‹ˆ๋ฉ”์ด์…˜์„ ์ˆœ์ฐจ์ ์œผ๋กœ ์‹คํ–‰!

Animated.sequence([
  Animated.timing(scaleAnim, {
    toValue: 1.2,
    duration: 300,
    useNativeDriver: true
  }),
  Animated.timing(scaleAnim, {
    toValue: 1,
    duration: 300,
    useNativeDriver: true
  })
]).start();

๐Ÿ”น Animated.stagger()
๊ฐ ์• ๋‹ˆ๋ฉ”์ด์…˜ ์‚ฌ์ด์— ๋”œ๋ ˆ์ด๋ฅผ ์ค˜์„œ ์ˆœ์ฐจ ์‹คํ–‰!

Animated.stagger(100, [
  Animated.timing(anim1, { ... }),
  Animated.timing(anim2, { ... }),
  Animated.timing(anim3, { ... })
]).start();

๐ŸŽจ ์‹ค์ „ ์˜ˆ์ œ: ์นด๋“œ ๋’ค์ง‘๊ธฐ ์• ๋‹ˆ๋ฉ”์ด์…˜

์ด์ œ ์ง„์งœ ๋ฉ‹์ง„ ๊ฑธ ๋งŒ๋“ค์–ด๋ณผ๊นŒ?
์นด๋“œ๊ฐ€ ๋’ค์ง‘ํžˆ๋Š” 3D ํšจ๊ณผ๋ฅผ ๊ตฌํ˜„ํ•ด๋ณด์ž! ๐Ÿƒ

import React, { useRef, useState } from 'react';
import { Animated, TouchableOpacity, StyleSheet, Text } from 'react-native';

const FlipCard = () => {
  const [isFlipped, setIsFlipped] = useState(false);
  const flipAnim = useRef(new Animated.Value(0)).current;

  const flipCard = () => {
    // ํ˜„์žฌ ์ƒํƒœ์— ๋”ฐ๋ผ ๋ชฉํ‘œ๊ฐ’ ์„ค์ •
    const toValue = isFlipped ? 0 : 1;
    
    Animated.spring(flipAnim, {
      toValue,
      friction: 8,
      tension: 10,
      useNativeDriver: true
    }).start();
    
    setIsFlipped(!isFlipped);
  };

  // ์•ž๋ฉด ํšŒ์ „ ๊ฐ๋„ (0deg โ†’ 90deg)
  const frontInterpolate = flipAnim.interpolate({
    inputRange: [0, 1],
    outputRange: ['0deg', '180deg']
  });

  // ๋’ท๋ฉด ํšŒ์ „ ๊ฐ๋„ (90deg โ†’ 180deg)
  const backInterpolate = flipAnim.interpolate({
    inputRange: [0, 1],
    outputRange: ['180deg', '360deg']
  });

  // ์•ž๋ฉด ํˆฌ๋ช…๋„
  const frontOpacity = flipAnim.interpolate({
    inputRange: [0, 0.5, 0.5, 1],
    outputRange: [1, 1, 0, 0]
  });

  // ๋’ท๋ฉด ํˆฌ๋ช…๋„
  const backOpacity = flipAnim.interpolate({
    inputRange: [0, 0.5, 0.5, 1],
    outputRange: [0, 0, 1, 1]
  });

  return (
    <TouchableOpacity onPress={flipCard} style={styles.container}>
      {/* ์•ž๋ฉด */}
      <Animated.View 
        style={[
          styles.card,
          styles.cardFront,
          {
            opacity: frontOpacity,
            transform: [{ rotateY: frontInterpolate }]
          }
        ]}
      >
        <Text style={styles.cardText}>์•ž๋ฉด ๐ŸŽด</Text>
      </Animated.View>

      {/* ๋’ท๋ฉด */}
      <Animated.View 
        style={[
          styles.card,
          styles.cardBack,
          {
            opacity: backOpacity,
            transform: [{ rotateY: backInterpolate }]
          }
        ]}
      >
        <Text style={styles.cardText}>๋’ท๋ฉด ๐ŸŽญ</Text>
      </Animated.View>
    </TouchableOpacity>
  );
};

const styles = StyleSheet.create({
  container: {
    width: 200,
    height: 300,
    alignItems: 'center',
    justifyContent: 'center'
  },
  card: {
    width: 200,
    height: 300,
    position: 'absolute',
    alignItems: 'center',
    justifyContent: 'center',
    backfaceVisibility: 'hidden',
    borderRadius: 20,
    shadowColor: '#000',
    shadowOffset: { width: 0, height: 2 },
    shadowOpacity: 0.3,
    shadowRadius: 4,
    elevation: 5
  },
  cardFront: {
    backgroundColor: '#667eea'
  },
  cardBack: {
    backgroundColor: '#764ba2'
  },
  cardText: {
    fontSize: 24,
    color: 'white',
    fontWeight: 'bold'
  }
});

export default FlipCard;
๐ŸŽ“ interpolate์˜ ๋งˆ๋ฒ• interpolate()๋Š” ์ •๋ง ๊ฐ•๋ ฅํ•œ ๊ธฐ๋Šฅ์ด์•ผ!
ํ•˜๋‚˜์˜ Animated.Value๋ฅผ ์—ฌ๋Ÿฌ ๊ฐ€์ง€ ๊ฐ’์œผ๋กœ ๋ณ€ํ™˜ํ•  ์ˆ˜ ์žˆ๊ฑฐ๋“ .

์˜ˆ๋ฅผ ๋“ค์–ด 0~1 ์‚ฌ์ด์˜ ๊ฐ’์„:
โ€ข ๊ฐ๋„๋กœ ๋ณ€ํ™˜ (0deg โ†’ 180deg)
โ€ข ์ƒ‰์ƒ์œผ๋กœ ๋ณ€ํ™˜ (rgb(0,0,0) โ†’ rgb(255,255,255))
โ€ข ํฌ๊ธฐ๋กœ ๋ณ€ํ™˜ (100 โ†’ 200)

์ด๋ ‡๊ฒŒ ํ•˜๋‚˜์˜ ์• ๋‹ˆ๋ฉ”์ด์…˜ ๊ฐ’์œผ๋กœ ์—ฌ๋Ÿฌ ์†์„ฑ์„ ๋™์‹œ์— ์ œ์–ดํ•  ์ˆ˜ ์žˆ์–ด! ๐ŸŽฏ

๐Ÿ“ฑ ์ œ์Šค์ฒ˜ ๊ธฐ๋ฐ˜ ์• ๋‹ˆ๋ฉ”์ด์…˜

์‚ฌ์šฉ์ž์˜ ํ„ฐ์น˜๋‚˜ ๋“œ๋ž˜๊ทธ์— ๋ฐ˜์‘ํ•˜๋Š” ์• ๋‹ˆ๋ฉ”์ด์…˜๋„ ๋งŒ๋“ค ์ˆ˜ ์žˆ์–ด!
PanResponder์™€ ํ•จ๊ป˜ ์‚ฌ์šฉํ•˜๋ฉด ์ง„์งœ ์ธํ„ฐ๋ž™ํ‹ฐ๋ธŒํ•œ UI๋ฅผ ๋งŒ๋“ค ์ˆ˜ ์žˆ์ง€. ๐Ÿ‘†

import React, { useRef } from 'react';
import { Animated, PanResponder, View, StyleSheet } from 'react-native';

const DraggableBox = () => {
  const pan = useRef(new Animated.ValueXY()).current;

  const panResponder = useRef(
    PanResponder.create({
      onStartShouldSetPanResponder: () => true,
      
      onPanResponderMove: Animated.event(
        [
          null,
          { dx: pan.x, dy: pan.y }
        ],
        { useNativeDriver: false } // ValueXY๋Š” ๋„ค์ดํ‹ฐ๋ธŒ ๋“œ๋ผ์ด๋ฒ„ ๋ฏธ์ง€์›
      ),
      
      onPanResponderRelease: () => {
        // ๋†“์œผ๋ฉด ์›๋ž˜ ์œ„์น˜๋กœ ๋Œ์•„๊ฐ€๊ธฐ
        Animated.spring(pan, {
          toValue: { x: 0, y: 0 },
          useNativeDriver: false
        }).start();
      }
    })
  ).current;

  return (
    <View style={styles.container}>
      <Animated.View
        style={[
          styles.box,
          {
            transform: [
              { translateX: pan.x },
              { translateY: pan.y }
            ]
          }
        ]}
        {...panResponder.panHandlers}
      >
        <Text style={styles.text}>๋“œ๋ž˜๊ทธํ•ด๋ด! ๐ŸŽฏ</Text>
      </Animated.View>
    </View>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center'
  },
  box: {
    width: 150,
    height: 150,
    backgroundColor: '#667eea',
    borderRadius: 20,
    justifyContent: 'center',
    alignItems: 'center'
  },
  text: {
    color: 'white',
    fontSize: 18,
    fontWeight: 'bold'
  }
});
โš ๏ธ ์ฃผ์˜์‚ฌํ•ญ Animated.ValueXY๋Š” ๋„ค์ดํ‹ฐ๋ธŒ ๋“œ๋ผ์ด๋ฒ„๋ฅผ ์ง€์›ํ•˜์ง€ ์•Š์•„!
๊ทธ๋ž˜์„œ useNativeDriver: false๋กœ ์„ค์ •ํ•ด์•ผ ํ•ด.
๋Œ€์‹  ์„ฑ๋Šฅ์ด ์กฐ๊ธˆ ๋–จ์–ด์งˆ ์ˆ˜ ์žˆ์œผ๋‹ˆ, ๋ณต์žกํ•œ ์• ๋‹ˆ๋ฉ”์ด์…˜์—๋Š” ์ฃผ์˜๊ฐ€ ํ•„์š”ํ•ด. ๐Ÿค”

โšก ์„ฑ๋Šฅ ์ตœ์ ํ™” ๊ฟ€ํŒ

์• ๋‹ˆ๋ฉ”์ด์…˜์€ ๋ฉ‹์ง€์ง€๋งŒ, ์ž˜๋ชป ์‚ฌ์šฉํ•˜๋ฉด ์•ฑ์ด ๋ฒ„๋ฒ…๊ฑฐ๋ฆด ์ˆ˜ ์žˆ์–ด. ๐Ÿ˜ฐ
์„ฑ๋Šฅ์„ ์ตœ๋Œ€ํ•œ ๋Œ์–ด์˜ฌ๋ฆฌ๋Š” ๋ฐฉ๋ฒ•๋“ค์„ ์•Œ๋ ค์ค„๊ฒŒ!

์„ฑ๋Šฅ ์ตœ์ ํ™” ์ฒดํฌ๋ฆฌ์ŠคํŠธ โœ… ํ•ด์•ผ ํ•  ๊ฒƒ๋“ค ๋„ค์ดํ‹ฐ๋ธŒ ๋“œ๋ผ์ด๋ฒ„ ์‚ฌ์šฉ โŒ ํ”ผํ•ด์•ผ ํ•  ๊ฒƒ๋“ค ๋ถˆํ•„์š”ํ•œ ๋ฆฌ๋ Œ๋”๋ง โ€ข transform, opacity๋งŒ ์‚ฌ์šฉ โ€ข layout ์†์„ฑ ์• ๋‹ˆ๋ฉ”์ด์…˜ โ€ข useRef๋กœ ๊ฐ’ ๊ด€๋ฆฌ โ€ข setState๋กœ ์• ๋‹ˆ๋ฉ”์ด์…˜ โ€ข ์• ๋‹ˆ๋ฉ”์ด์…˜ ์™„๋ฃŒ ํ›„ ์ •๋ฆฌ โ€ข ๋ฉ”๋ชจ๋ฆฌ ๋ˆ„์ˆ˜ ๋ฐฉ์น˜

1๏ธโƒฃ ๋„ค์ดํ‹ฐ๋ธŒ ๋“œ๋ผ์ด๋ฒ„ ํ™œ์šฉ

โœ… ์ข‹์€ ์˜ˆ์‹œ

// transform๊ณผ opacity๋Š” ๋„ค์ดํ‹ฐ๋ธŒ ๋“œ๋ผ์ด๋ฒ„ ์‚ฌ์šฉ ๊ฐ€๋Šฅ!
Animated.timing(animValue, {
  toValue: 1,
  duration: 300,
  useNativeDriver: true  // ๐Ÿ‘
}).start();

โŒ ๋‚˜์œ ์˜ˆ์‹œ

// width, height, margin ๋“ฑ์€ ๋„ค์ดํ‹ฐ๋ธŒ ๋“œ๋ผ์ด๋ฒ„ ๋ฏธ์ง€์›
Animated.timing(animValue, {
  toValue: 100,
  duration: 300,
  useNativeDriver: true  // ์—๋Ÿฌ ๋ฐœ์ƒ! ๐Ÿ’ฅ
}).start();

๋„ค์ดํ‹ฐ๋ธŒ ๋“œ๋ผ์ด๋ฒ„๊ฐ€ ์ง€์›ํ•˜๋Š” ์†์„ฑ๋“ค:
โ€ข opacity (ํˆฌ๋ช…๋„)
โ€ข transform (translateX, translateY, scale, rotate ๋“ฑ)

์ง€์›ํ•˜์ง€ ์•Š๋Š” ์†์„ฑ๋“ค:
โ€ข width, height
โ€ข margin, padding
โ€ข backgroundColor
โ€ข left, right, top, bottom

2๏ธโƒฃ ๋ถˆํ•„์š”ํ•œ ๋ฆฌ๋ Œ๋”๋ง ๋ฐฉ์ง€

// โŒ ๋‚˜์œ ์˜ˆ์‹œ: ๋งค๋ฒˆ ์ƒˆ๋กœ์šด ๊ฐ์ฒด ์ƒ์„ฑ
const BadExample = () => {
  const [animValue] = useState(new Animated.Value(0)); // ๋ฆฌ๋ Œ๋”๋ง๋งˆ๋‹ค ์ƒˆ๋กœ ์ƒ์„ฑ!
  
  return <Animated.View style={{ opacity: animValue }} />;
};

// โœ… ์ข‹์€ ์˜ˆ์‹œ: useRef๋กœ ์ธ์Šคํ„ด์Šค ์œ ์ง€
const GoodExample = () => {
  const animValue = useRef(new Animated.Value(0)).current; // ํ•œ ๋ฒˆ๋งŒ ์ƒ์„ฑ!
  
  return <Animated.View style={{ opacity: animValue }} />;
};

3๏ธโƒฃ ๋ฉ”๋ชจ๋ฆฌ ๋ˆ„์ˆ˜ ๋ฐฉ์ง€

์ปดํฌ๋„ŒํŠธ๊ฐ€ ์–ธ๋งˆ์šดํŠธ๋  ๋•Œ ์‹คํ–‰ ์ค‘์ธ ์• ๋‹ˆ๋ฉ”์ด์…˜์„ ์ •๋ฆฌํ•ด์•ผ ํ•ด!
์•ˆ ๊ทธ๋Ÿฌ๋ฉด ๋ฉ”๋ชจ๋ฆฌ ๋ˆ„์ˆ˜๊ฐ€ ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ์–ด. ๐Ÿ’ง

useEffect(() => {
  const animation = Animated.timing(fadeAnim, {
    toValue: 1,
    duration: 2000,
    useNativeDriver: true
  });
  
  animation.start();
  
  // ํด๋ฆฐ์—… ํ•จ์ˆ˜๋กœ ์• ๋‹ˆ๋ฉ”์ด์…˜ ์ •๋ฆฌ
  return () => {
    animation.stop();  // ์ปดํฌ๋„ŒํŠธ ์–ธ๋งˆ์šดํŠธ ์‹œ ์ค‘์ง€
  };
}, []);

4๏ธโƒฃ ๋ณต์žกํ•œ ๊ณ„์‚ฐ์€ useMemo ํ™œ์šฉ

const AnimatedComponent = () => {
  const animValue = useRef(new Animated.Value(0)).current;
  
  // ๋ณต์žกํ•œ interpolate ๊ณ„์‚ฐ์€ useMemo๋กœ ์บ์‹ฑ
  const animatedStyle = useMemo(() => ({
    transform: [
      {
        translateY: animValue.interpolate({
          inputRange: [0, 1],
          outputRange: [0, -100]
        })
      },
      {
        scale: animValue.interpolate({
          inputRange: [0, 1],
          outputRange: [1, 1.5]
        })
      }
    ]
  }), [animValue]);
  
  return <Animated.View style={animatedStyle} />;
};

๐ŸŽจ ์‹ค์ „ ํ”„๋กœ์ ํŠธ: ์ธ์Šคํƒ€๊ทธ๋žจ ์Šคํƒ€์ผ ์ข‹์•„์š” ์• ๋‹ˆ๋ฉ”์ด์…˜

์ด์ œ ๋ฐฐ์šด ๊ฑธ ๋‹ค ํ™œ์šฉํ•ด์„œ ์ง„์งœ ์•ฑ์—์„œ ์“ธ ๋งŒํ•œ ๊ฑธ ๋งŒ๋“ค์–ด๋ณด์ž!
์ธ์Šคํƒ€๊ทธ๋žจ์ฒ˜๋Ÿผ ๋”๋ธ” ํƒญํ•˜๋ฉด ํ•˜ํŠธ๊ฐ€ ๋ฟ… ๋‚˜์˜ค๋Š” ํšจ๊ณผ๋ฅผ ๊ตฌํ˜„ํ•ด๋ณผ๊ฒŒ. ๐Ÿ’–

import React, { useRef, useState } from 'react';
import {
  Animated,
  TouchableWithoutFeedback,
  View,
  Image,
  StyleSheet
} from 'react-native';

const InstagramLike = ({ imageUrl }) => {
  const [liked, setLiked] = useState(false);
  const [lastTap, setLastTap] = useState(0);
  
  // ํ•˜ํŠธ ์• ๋‹ˆ๋ฉ”์ด์…˜ ๊ฐ’๋“ค
  const scaleAnim = useRef(new Animated.Value(0)).current;
  const opacityAnim = useRef(new Animated.Value(1)).current;
  
  // ์ข‹์•„์š” ๋ฒ„ํŠผ ์• ๋‹ˆ๋ฉ”์ด์…˜
  const likeButtonScale = useRef(new Animated.Value(1)).current;

  const handleDoubleTap = () => {
    const now = Date.now();
    const DOUBLE_TAP_DELAY = 300;
    
    if (now - lastTap < DOUBLE_TAP_DELAY) {
      // ๋”๋ธ” ํƒญ ๊ฐ์ง€!
      if (!liked) {
        setLiked(true);
        animateHeart();
        animateLikeButton();
      }
    }
    
    setLastTap(now);
  };

  const animateHeart = () => {
    // ์ดˆ๊ธฐํ™”
    scaleAnim.setValue(0);
    opacityAnim.setValue(1);
    
    // ํ•˜ํŠธ ์• ๋‹ˆ๋ฉ”์ด์…˜ ์‹œํ€€์Šค
    Animated.sequence([
      // 1. ํฌ๊ฒŒ ์ปค์ง€๋ฉด์„œ ๋‚˜ํƒ€๋‚จ
      Animated.parallel([
        Animated.spring(scaleAnim, {
          toValue: 1,
          friction: 3,
          useNativeDriver: true
        }),
        Animated.timing(opacityAnim, {
          toValue: 1,
          duration: 200,
          useNativeDriver: true
        })
      ]),
      // 2. ์ž ์‹œ ๋Œ€๊ธฐ
      Animated.delay(400),
      // 3. ์‚ฌ๋ผ์ง
      Animated.parallel([
        Animated.timing(scaleAnim, {
          toValue: 1.2,
          duration: 300,
          useNativeDriver: true
        }),
        Animated.timing(opacityAnim, {
          toValue: 0,
          duration: 300,
          useNativeDriver: true
        })
      ])
    ]).start();
  };

  const animateLikeButton = () => {
    // ์ข‹์•„์š” ๋ฒ„ํŠผ ํ†ตํ†ต ํŠ€๋Š” ํšจ๊ณผ
    Animated.sequence([
      Animated.timing(likeButtonScale, {
        toValue: 0.8,
        duration: 100,
        useNativeDriver: true
      }),
      Animated.spring(likeButtonScale, {
        toValue: 1,
        friction: 3,
        tension: 40,
        useNativeDriver: true
      })
    ]).start();
  };

  const toggleLike = () => {
    setLiked(!liked);
    animateLikeButton();
  };

  return (
    <View style={styles.container}>
      {/* ์ด๋ฏธ์ง€ ์˜์—ญ */}
      <TouchableWithoutFeedback onPress={handleDoubleTap}>
        <View style={styles.imageContainer}>
          <Image 
            source={{ uri: imageUrl }} 
            style={styles.image}
            resizeMode="cover"
          />
          
          {/* ์ค‘์•™ ํ•˜ํŠธ ์• ๋‹ˆ๋ฉ”์ด์…˜ */}
          <Animated.View
            style={[
              styles.centerHeart,
              {
                opacity: opacityAnim,
                transform: [{ scale: scaleAnim }]
              }
            ]}
          >
            <Text style={styles.heartIcon}>โค๏ธ</Text>
          </Animated.View>
        </View>
      </TouchableWithoutFeedback>
      
      {/* ํ•˜๋‹จ ์ข‹์•„์š” ๋ฒ„ํŠผ */}
      <View style={styles.actionBar}>
        <TouchableWithoutFeedback onPress={toggleLike}>
          <Animated.View
            style={{
              transform: [{ scale: likeButtonScale }]
            }}
          >
            <Text style={styles.likeButton}>
              {liked ? 'โค๏ธ' : '๐Ÿค'}
            </Text>
          </Animated.View>
        </TouchableWithoutFeedback>
      </View>
    </View>
  );
};

const styles = StyleSheet.create({
  container: {
    backgroundColor: 'white',
    borderRadius: 12,
    overflow: 'hidden',
    marginVertical: 10
  },
  imageContainer: {
    width: '100%',
    height: 400,
    position: 'relative',
    backgroundColor: '#f0f0f0'
  },
  image: {
    width: '100%',
    height: '100%'
  },
  centerHeart: {
    position: 'absolute',
    top: '50%',
    left: '50%',
    marginLeft: -50,
    marginTop: -50,
    width: 100,
    height: 100,
    justifyContent: 'center',
    alignItems: 'center'
  },
  heartIcon: {
    fontSize: 100
  },
  actionBar: {
    flexDirection: 'row',
    padding: 12,
    alignItems: 'center'
  },
  likeButton: {
    fontSize: 28,
    marginRight: 12
  }
});

export default InstagramLike;
๐ŸŽฏ ํ•ต์‹ฌ ํฌ์ธํŠธ ์ •๋ฆฌ 1. ๋”๋ธ” ํƒญ ๊ฐ์ง€
๋งˆ์ง€๋ง‰ ํƒญ ์‹œ๊ฐ„์„ ์ €์žฅํ•ด์„œ 300ms ์ด๋‚ด์— ๋‹ค์‹œ ํƒญํ•˜๋ฉด ๋”๋ธ” ํƒญ์œผ๋กœ ์ธ์‹!

2. Animated.sequence
์—ฌ๋Ÿฌ ์• ๋‹ˆ๋ฉ”์ด์…˜์„ ์ˆœ์ฐจ์ ์œผ๋กœ ์‹คํ–‰ํ•ด์„œ ์ž์—ฐ์Šค๋Ÿฌ์šด ํ๋ฆ„ ๋งŒ๋“ค๊ธฐ

3. Animated.parallel
ํฌ๊ธฐ์™€ ํˆฌ๋ช…๋„๋ฅผ ๋™์‹œ์— ๋ณ€๊ฒฝํ•ด์„œ ๋” ์—ญ๋™์ ์ธ ํšจ๊ณผ

4. Spring ์• ๋‹ˆ๋ฉ”์ด์…˜
ํ†ตํ†ต ํŠ€๋Š” ๋А๋‚Œ์œผ๋กœ ์ƒ๋™๊ฐ ์žˆ๋Š” UI ๊ตฌํ˜„! ๐ŸŽช

๐Ÿš€ Animated API vs ๋‹ค๋ฅธ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ

๋ฆฌ์•กํŠธ ๋„ค์ดํ‹ฐ๋ธŒ์—์„œ ์• ๋‹ˆ๋ฉ”์ด์…˜์„ ๋งŒ๋“œ๋Š” ๋ฐฉ๋ฒ•์€ ์—ฌ๋Ÿฌ ๊ฐ€์ง€์•ผ.
๊ฐ๊ฐ์˜ ์žฅ๋‹จ์ ์„ ๋น„๊ตํ•ด๋ณผ๊ฒŒ! ๐Ÿค”

๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์žฅ์  ๋‹จ์  ์ถ”์ฒœ ์ƒํ™ฉ
Animated API โ€ข ๊ธฐ๋ณธ ๋‚ด์žฅ
โ€ข ๋„ค์ดํ‹ฐ๋ธŒ ๋“œ๋ผ์ด๋ฒ„ ์ง€์›
โ€ข ์•ˆ์ •์ 
โ€ข ๋ณต์žกํ•œ ์• ๋‹ˆ๋ฉ”์ด์…˜ ๊ตฌํ˜„ ์–ด๋ ค์›€
โ€ข ์ฝ”๋“œ๊ฐ€ ๊ธธ์–ด์งˆ ์ˆ˜ ์žˆ์Œ
๊ธฐ๋ณธ์ ์ธ ์• ๋‹ˆ๋ฉ”์ด์…˜
๊ฐ„๋‹จํ•œ ์ธํ„ฐ๋ž™์…˜
Reanimated 2 โ€ข ๋งค์šฐ ๊ฐ•๋ ฅํ•จ
โ€ข ๋ณต์žกํ•œ ์ œ์Šค์ฒ˜ ์ฒ˜๋ฆฌ
โ€ข ์„ฑ๋Šฅ ์ตœ๊ณ 
โ€ข ํ•™์Šต ๊ณก์„  ๋†’์Œ
โ€ข ์ถ”๊ฐ€ ์„ค์น˜ ํ•„์š”
๋ณต์žกํ•œ ์• ๋‹ˆ๋ฉ”์ด์…˜
๊ณ ์„ฑ๋Šฅ ํ•„์š”์‹œ
Lottie โ€ข ๋””์ž์ด๋„ˆ ํ˜‘์—… ์‰ฌ์›€
โ€ข ๋ณต์žกํ•œ ์• ๋‹ˆ๋ฉ”์ด์…˜ ๊ฐ„๋‹จํžˆ
โ€ข After Effects ํ™œ์šฉ
โ€ข ํŒŒ์ผ ํฌ๊ธฐ
โ€ข ๋™์  ๋ณ€๊ฒฝ ์–ด๋ ค์›€
๊ณ ์ •๋œ ์• ๋‹ˆ๋ฉ”์ด์…˜
์ผ๋Ÿฌ์ŠคํŠธ ์• ๋‹ˆ๋ฉ”์ด์…˜
LayoutAnimation โ€ข ๋งค์šฐ ๊ฐ„๋‹จ
โ€ข ๋ ˆ์ด์•„์›ƒ ๋ณ€๊ฒฝ ์ž๋™
โ€ข ์ œ์–ด๋ ฅ ๋‚ฎ์Œ
โ€ข Android ์ œํ•œ์ 
๊ฐ„๋‹จํ•œ ๋ ˆ์ด์•„์›ƒ ์ „ํ™˜

๐ŸŽฏ ์–ธ์ œ Animated API๋ฅผ ์จ์•ผ ํ• ๊นŒ?

โœ… Animated API๊ฐ€ ์ข‹์€ ๊ฒฝ์šฐ โ€ข ํ”„๋กœ์ ํŠธ ์ดˆ๊ธฐ ๋‹จ๊ณ„ (์ถ”๊ฐ€ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์„ค์น˜ ๋ถ€๋‹ด ์—†์Œ)
โ€ข ํŽ˜์ด๋“œ, ์Šฌ๋ผ์ด๋“œ, ์Šค์ผ€์ผ ๊ฐ™์€ ๊ธฐ๋ณธ ์• ๋‹ˆ๋ฉ”์ด์…˜
โ€ข ๊ฐ„๋‹จํ•œ ์ธํ„ฐ๋ž™ํ‹ฐ๋ธŒ ์š”์†Œ
โ€ข ์•ˆ์ •์„ฑ์ด ์ค‘์š”ํ•œ ํ”„๋กœ๋•์…˜ ์•ฑ
โ€ข ๋ฒˆ๋“ค ํฌ๊ธฐ๋ฅผ ์ตœ์†Œํ™”ํ•˜๊ณ  ์‹ถ์„ ๋•Œ

๐Ÿ”„ ๋‹ค๋ฅธ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ๊ณ ๋ คํ•ด์•ผ ํ•˜๋Š” ๊ฒฝ์šฐ

โ€ข ๋ณต์žกํ•œ ์ œ์Šค์ฒ˜ ๊ธฐ๋ฐ˜ ์• ๋‹ˆ๋ฉ”์ด์…˜ (Reanimated 2)
โ€ข 60fps ์ด์ƒ์˜ ๊ณ ์„ฑ๋Šฅ์ด ํ•„์ˆ˜์ ์ผ ๋•Œ (Reanimated 2)
โ€ข ๋””์ž์ด๋„ˆ๊ฐ€ ๋งŒ๋“  ๋ณต์žกํ•œ ์• ๋‹ˆ๋ฉ”์ด์…˜ (Lottie)
โ€ข ๋ฌผ๋ฆฌ ์—”์ง„์ด ํ•„์š”ํ•œ ๊ฒฝ์šฐ (Matter.js + Reanimated)

๊ฐœ์ธ์ ์œผ๋กœ๋Š” ์ฒ˜์Œ ์‹œ์ž‘ํ•  ๋•Œ๋Š” Animated API๋กœ ์ถฉ๋ถ„ํ•ด!
๋‚˜์ค‘์— ํ•„์š”ํ•˜๋ฉด Reanimated 2๋กœ ๋งˆ์ด๊ทธ๋ ˆ์ด์…˜ํ•˜๋Š” ๊ฒƒ๋„ ์–ด๋ ต์ง€ ์•Š์•„. ๐Ÿ˜Š

์ฐธ๊ณ ๋กœ ์žฌ๋Šฅ๋„ท์—์„œ๋Š” ๋ฆฌ์•กํŠธ ๋„ค์ดํ‹ฐ๋ธŒ ๊ฐœ๋ฐœ ๊ด€๋ จ ๋‹ค์–‘ํ•œ ์žฌ๋Šฅ์„ ๊ฑฐ๋ž˜ํ•  ์ˆ˜ ์žˆ์–ด.
์• ๋‹ˆ๋ฉ”์ด์…˜ ๊ตฌํ˜„์ด ์–ด๋ ต๋‹ค๋ฉด ์ „๋ฌธ๊ฐ€์˜ ๋„์›€์„ ๋ฐ›๋Š” ๊ฒƒ๋„ ์ข‹์€ ๋ฐฉ๋ฒ•์ด์ง€! ๐ŸŽจ

๐Ÿ› ์ž์ฃผ ๋งŒ๋‚˜๋Š” ์—๋Ÿฌ์™€ ํ•ด๊ฒฐ๋ฒ•

์• ๋‹ˆ๋ฉ”์ด์…˜ ๊ตฌํ˜„ํ•˜๋‹ค ๋ณด๋ฉด ์ด๋Ÿฐ์ €๋Ÿฐ ์—๋Ÿฌ๋ฅผ ๋งŒ๋‚˜๊ฒŒ ๋ผ.
์ž์ฃผ ๋ฐœ์ƒํ•˜๋Š” ๋ฌธ์ œ๋“ค๊ณผ ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•์„ ์ •๋ฆฌํ•ด๋ดค์–ด! ๐Ÿ”ง

โŒ Error: Attempting to run JS driven animation on animated node...

์›์ธ
๋„ค์ดํ‹ฐ๋ธŒ ๋“œ๋ผ์ด๋ฒ„๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์—†๋Š” ์†์„ฑ์— useNativeDriver: true๋ฅผ ์„ค์ •ํ–ˆ์„ ๋•Œ

ํ•ด๊ฒฐ๋ฒ•
// โŒ ์—๋Ÿฌ ๋ฐœ์ƒ
Animated.timing(widthAnim, {
  toValue: 200,
  useNativeDriver: true  // width๋Š” ๋„ค์ดํ‹ฐ๋ธŒ ๋“œ๋ผ์ด๋ฒ„ ๋ฏธ์ง€์›!
}).start();

// โœ… ํ•ด๊ฒฐ
Animated.timing(widthAnim, {
  toValue: 200,
  useNativeDriver: false  // false๋กœ ๋ณ€๊ฒฝ
}).start();

// ๋˜๋Š” transform์œผ๋กœ ๋Œ€์ฒด
Animated.timing(scaleAnim, {
  toValue: 2,
  useNativeDriver: true  // transform์€ ์ง€์›!
}).start();

โŒ Warning: Can't perform a React state update on an unmounted component

์›์ธ
์ปดํฌ๋„ŒํŠธ๊ฐ€ ์–ธ๋งˆ์šดํŠธ๋œ ํ›„์—๋„ ์• ๋‹ˆ๋ฉ”์ด์…˜์ด ๊ณ„์† ์‹คํ–‰๋˜๊ณ  ์žˆ์„ ๋•Œ

ํ•ด๊ฒฐ๋ฒ•
useEffect(() => {
  const animation = Animated.timing(fadeAnim, {
    toValue: 1,
    duration: 2000,
    useNativeDriver: true
  });
  
  animation.start();
  
  // ํด๋ฆฐ์—… ํ•จ์ˆ˜ ์ถ”๊ฐ€!
  return () => {
    animation.stop();
  };
}, []);

โŒ ์• ๋‹ˆ๋ฉ”์ด์…˜์ด ๋ถ€๋“œ๋Ÿฝ์ง€ ์•Š๊ณ  ๋Š๊ฒจ์š”

์›์ธ
1. ๋„ค์ดํ‹ฐ๋ธŒ ๋“œ๋ผ์ด๋ฒ„๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š์Œ
2. ๋ฆฌ๋ Œ๋”๋ง์ด ๋„ˆ๋ฌด ์ž์ฃผ ๋ฐœ์ƒ
3. ๋ณต์žกํ•œ ๊ณ„์‚ฐ์ด ๋ฉ”์ธ ์Šค๋ ˆ๋“œ๋ฅผ ๋ธ”๋กœํ‚น

ํ•ด๊ฒฐ๋ฒ•
// 1. ๋„ค์ดํ‹ฐ๋ธŒ ๋“œ๋ผ์ด๋ฒ„ ํ™œ์„ฑํ™”
useNativeDriver: true

// 2. useRef๋กœ ๊ฐ’ ๊ด€๋ฆฌ
const animValue = useRef(new Animated.Value(0)).current;

// 3. ๋ณต์žกํ•œ ๊ณ„์‚ฐ์€ useMemo
const animatedStyle = useMemo(() => ({
  transform: [{ translateY: animValue }]
}), [animValue]);

// 4. shouldComponentUpdate ์ตœ์ ํ™”
const MemoizedComponent = React.memo(AnimatedComponent);

โŒ interpolate ๊ฐ’์ด ์ด์ƒํ•ด์š”

์›์ธ
inputRange์™€ outputRange์˜ ๊ธธ์ด๊ฐ€ ๋‹ค๋ฅด๊ฑฐ๋‚˜, ๋ฒ”์œ„ ์„ค์ •์ด ์ž˜๋ชป๋จ

ํ•ด๊ฒฐ๋ฒ•
// โŒ ์ž˜๋ชป๋œ ์˜ˆ์‹œ
const rotate = animValue.interpolate({
  inputRange: [0, 1],
  outputRange: ['0deg', '90deg', '180deg']  // ๊ธธ์ด ๋ถˆ์ผ์น˜!
});

// โœ… ์˜ฌ๋ฐ”๋ฅธ ์˜ˆ์‹œ
const rotate = animValue.interpolate({
  inputRange: [0, 0.5, 1],
  outputRange: ['0deg', '90deg', '180deg']  // ๊ธธ์ด ์ผ์น˜!
});

// extrapolate ์˜ต์…˜ ํ™œ์šฉ
const scale = animValue.interpolate({
  inputRange: [0, 1],
  outputRange: [1, 2],
  extrapolate: 'clamp'  // ๋ฒ”์œ„ ๋ฐ– ๊ฐ’์€ ๊ณ ์ •
});

๐Ÿ’ก ์‹ค๋ฌด ํŒ๊ณผ ๋ฒ ์ŠคํŠธ ํ”„๋ž™ํ‹ฐ์Šค

์‹ค์ œ ํ”„๋กœ์ ํŠธ์—์„œ ์• ๋‹ˆ๋ฉ”์ด์…˜์„ ๊ตฌํ˜„ํ•  ๋•Œ ์•Œ์•„๋‘๋ฉด ์ข‹์€ ํŒ๋“ค์ด์•ผ! ๐ŸŽฏ

1๏ธโƒฃ ์• ๋‹ˆ๋ฉ”์ด์…˜ ๊ฐ’ ์žฌ์‚ฌ์šฉํ•˜๊ธฐ

๊ฐ™์€ ์• ๋‹ˆ๋ฉ”์ด์…˜์„ ์—ฌ๋Ÿฌ ๋ฒˆ ์‹คํ–‰ํ•ด์•ผ ํ•œ๋‹ค๋ฉด, ๊ฐ’์„ ์žฌ์‚ฌ์šฉํ•˜๋Š” ๊ฒŒ ํšจ์œจ์ ์ด์•ผ!

const useAnimatedValue = (initialValue = 0) => {
  const animValue = useRef(new Animated.Value(initialValue)).current;
  
  const animate = useCallback((toValue, duration = 300) => {
    return Animated.timing(animValue, {
      toValue,
      duration,
      useNativeDriver: true
    });
  }, [animValue]);
  
  const reset = useCallback(() => {
    animValue.setValue(initialValue);
  }, [animValue, initialValue]);
  
  return { animValue, animate, reset };
};

// ์‚ฌ์šฉ ์˜ˆ์‹œ
const MyComponent = () => {
  const { animValue, animate, reset } = useAnimatedValue(0);
  
  const fadeIn = () => animate(1).start();
  const fadeOut = () => animate(0).start();
  
  return (
    <Animated.View style={{ opacity: animValue }}>
      {/* ์ปจํ…์ธ  */}
    </Animated.View>
  );
};

2๏ธโƒฃ ์• ๋‹ˆ๋ฉ”์ด์…˜ ํ”„๋ฆฌ์…‹ ๋งŒ๋“ค๊ธฐ

์ž์ฃผ ์“ฐ๋Š” ์• ๋‹ˆ๋ฉ”์ด์…˜ ์„ค์ •์„ ํ”„๋ฆฌ์…‹์œผ๋กœ ๋งŒ๋“ค์–ด๋‘๋ฉด ํŽธํ•ด! ๐ŸŽจ

// animations.js
export const AnimationPresets = {
  fadeIn: (animValue, duration = 300) => 
    Animated.timing(animValue, {
      toValue: 1,
      duration,
      useNativeDriver: true
    }),
  
  fadeOut: (animValue, duration = 300) =>
    Animated.timing(animValue, {
      toValue: 0,
      duration,
      useNativeDriver: true
    }),
  
  bounceIn: (animValue) =>
    Animated.spring(animValue, {
      toValue: 1,
      friction: 3,
      tension: 40,
      useNativeDriver: true
    }),
  
  slideUp: (animValue, distance = 100) =>
    Animated.timing(animValue, {
      toValue: -distance,
      duration: 300,
      useNativeDriver: true
    })
};

// ์‚ฌ์šฉ
import { AnimationPresets } from './animations';

AnimationPresets.fadeIn(fadeAnim).start();

3๏ธโƒฃ ์• ๋‹ˆ๋ฉ”์ด์…˜ ์ƒํƒœ ๊ด€๋ฆฌ

๋ณต์žกํ•œ ์• ๋‹ˆ๋ฉ”์ด์…˜ ์‹œํ€€์Šค๋Š” ์ƒํƒœ ๋จธ์‹ ์œผ๋กœ ๊ด€๋ฆฌํ•˜๋ฉด ์ข‹์•„!

const useAnimationState = () => {
  const [state, setState] = useState('idle');
  const animValue = useRef(new Animated.Value(0)).current;
  
  const transitions = {
    idle: () => {
      setState('animating');
      Animated.timing(animValue, {
        toValue: 1,
        duration: 300,
        useNativeDriver: true
      }).start(() => setState('completed'));
    },
    
    completed: () => {
      setState('resetting');
      Animated.timing(animValue, {
        toValue: 0,
        duration: 300,
        useNativeDriver: true
      }).start(() => setState('idle'));
    }
  };
  
  const trigger = () => {
    if (transitions[state]) {
      transitions[state]();
    }
  };
  
  return { state, animValue, trigger };
};

4๏ธโƒฃ ์„ฑ๋Šฅ ๋ชจ๋‹ˆํ„ฐ๋ง

๐Ÿ” ์„ฑ๋Šฅ ์ฒดํฌ ๋ฐฉ๋ฒ•

1. React Native Debugger
Performance Monitor๋ฅผ ์ผœ์„œ FPS ํ™•์ธ

2. Flipper
Layout Inspector๋กœ ๋ฆฌ๋ Œ๋”๋ง ์ถ”์ 

3. console.time
์• ๋‹ˆ๋ฉ”์ด์…˜ ์‹คํ–‰ ์‹œ๊ฐ„ ์ธก์ •

console.time('animation');
Animated.timing(animValue, {
  toValue: 1,
  duration: 300,
  useNativeDriver: true
}).start(() => {
  console.timeEnd('animation');
});

5๏ธโƒฃ ์ ‘๊ทผ์„ฑ ๊ณ ๋ คํ•˜๊ธฐ

์• ๋‹ˆ๋ฉ”์ด์…˜์ด ๋ฉ‹์ง€๊ธด ํ•˜์ง€๋งŒ, ๋ชจ๋“  ์‚ฌ์šฉ์ž์—๊ฒŒ ์ข‹์€ ๊ฑด ์•„๋‹ˆ์•ผ.
์ผ๋ถ€ ์‚ฌ๋žŒ๋“ค์€ ์• ๋‹ˆ๋ฉ”์ด์…˜ ๋•Œ๋ฌธ์— ์–ด์ง€๋Ÿฌ์›€์„ ๋А๋‚„ ์ˆ˜ ์žˆ๊ฑฐ๋“ . ๐Ÿ˜ต

import { AccessibilityInfo } from 'react-native';

const useReducedMotion = () => {
  const [reduceMotion, setReduceMotion] = useState(false);
  
  useEffect(() => {
    AccessibilityInfo.isReduceMotionEnabled().then(enabled => {
      setReduceMotion(enabled);
    });
    
    const subscription = AccessibilityInfo.addEventListener(
      'reduceMotionChanged',
      setReduceMotion
    );
    
    return () => subscription.remove();
  }, []);
  
  return reduceMotion;
};

// ์‚ฌ์šฉ
const MyComponent = () => {
  const reduceMotion = useReducedMotion();
  const duration = reduceMotion ? 0 : 300;  // ๋ชจ์…˜ ๊ฐ์†Œ ์„ค์ • ์‹œ ์ฆ‰์‹œ ์ „ํ™˜
  
  Animated.timing(animValue, {
    toValue: 1,
    duration,
    useNativeDriver: true
  }).start();
};

๐ŸŽ“ ๊ณ ๊ธ‰ ํ…Œํฌ๋‹‰: ์ปค์Šคํ…€ ์ด์ง• ํ•จ์ˆ˜

๊ธฐ๋ณธ ์ œ๊ณต๋˜๋Š” ์ด์ง• ํ•จ์ˆ˜ ๋ง๊ณ , ์ง์ ‘ ๋งŒ๋“ค ์ˆ˜๋„ ์žˆ์–ด!
๋” ์„ธ๋ฐ€ํ•œ ์ปจํŠธ๋กค์ด ๊ฐ€๋Šฅํ•˜์ง€. ๐ŸŽ›๏ธ

import { Easing } from 'react-native';

// ๊ธฐ๋ณธ ์ œ๊ณต ์ด์ง• ํ•จ์ˆ˜๋“ค
const easingTypes = {
  linear: Easing.linear,
  ease: Easing.ease,
  quad: Easing.quad,
  cubic: Easing.cubic,
  elastic: Easing.elastic(1),
  bounce: Easing.bounce,
  back: Easing.back(1.5),
  bezier: Easing.bezier(0.25, 0.1, 0.25, 1)
};

// ์ปค์Šคํ…€ ์ด์ง• ํ•จ์ˆ˜
const customEasing = Easing.bezier(0.68, -0.55, 0.265, 1.55);

Animated.timing(animValue, {
  toValue: 1,
  duration: 500,
  easing: customEasing,
  useNativeDriver: true
}).start();
๋‹ค์–‘ํ•œ ์ด์ง• ํ•จ์ˆ˜ ๋น„๊ต Linear Ease In Out Bounce Elastic ์ผ์ •ํ•œ ์†๋„ ๋ถ€๋“œ๋Ÿฌ์šด ๊ฐ€๊ฐ์† ํ†ตํ†ต ํŠ€๋Š” ํšจ๊ณผ ๊ณ ๋ฌด์ค„ ํšจ๊ณผ ์ด์ง• ํ•จ์ˆ˜ ์„ ํƒ ๊ฐ€์ด๋“œ โ€ข Linear: ๋กœ๋”ฉ ์ธ๋””์ผ€์ดํ„ฐ, ์ง„ํ–‰ ๋ฐ” โ€ข Ease In Out: ํ™”๋ฉด ์ „ํ™˜, ๋ชจ๋‹ฌ ๋“ฑ์žฅ โ€ข Bounce: ๋ฒ„ํŠผ ํด๋ฆญ, ์•Œ๋ฆผ ๋ฐฐ์ง€ โ€ข Elastic: ๋‹น๊ฒจ์„œ ์ƒˆ๋กœ๊ณ ์นจ, ๋“œ๋ž˜๊ทธ ์ œ์Šค์ฒ˜ โ€ข Back: ๋ฉ”๋‰ด ์Šฌ๋ผ์ด๋“œ, ์„œ๋ž ์—ด๊ธฐ โ€ข Cubic: ๋ถ€๋“œ๋Ÿฌ์šด ํŽ˜์ด๋“œ, ์ž์—ฐ์Šค๋Ÿฌ์šด ์›€์ง์ž„

๐ŸŽจ ์‹ค์ „ ์˜ˆ์ œ: ์ปค์Šคํ…€ ์ด์ง•์œผ๋กœ ๋ฉ‹์ง„ ํšจ๊ณผ ๋งŒ๋“ค๊ธฐ

const FancyButton = ({ onPress, title }) => {
  const scaleAnim = useRef(new Animated.Value(1)).current;
  const rotateAnim = useRef(new Animated.Value(0)).current;
  
  const handlePressIn = () => {
    Animated.parallel([
      Animated.timing(scaleAnim, {
        toValue: 0.95,
        duration: 100,
        easing: Easing.bezier(0.25, 0.1, 0.25, 1),
        useNativeDriver: true
      }),
      Animated.timing(rotateAnim, {
        toValue: 1,
        duration: 100,
        easing: Easing.elastic(1),
        useNativeDriver: true
      })
    ]).start();
  };
  
  const handlePressOut = () => {
    Animated.parallel([
      Animated.spring(scaleAnim, {
        toValue: 1,
        friction: 3,
        tension: 40,
        useNativeDriver: true
      }),
      Animated.spring(rotateAnim, {
        toValue: 0,
        friction: 3,
        tension: 40,
        useNativeDriver: true
      })
    ]).start();
  };
  
  const rotate = rotateAnim.interpolate({
    inputRange: [0, 1],
    outputRange: ['0deg', '5deg']
  });
  
  return (
    <TouchableWithoutFeedback
      onPressIn={handlePressIn}
      onPressOut={handlePressOut}
      onPress={onPress}
    >
      <Animated.View
        style={{
          transform: [
            { scale: scaleAnim },
            { rotate }
          ],
          backgroundColor: '#667eea',
          padding: 16,
          borderRadius: 12
        }}
      >
        <Text style={{ color: 'white', fontSize: 16, fontWeight: 'bold' }}>
          {title}
        </Text>
      </Animated.View>
    </TouchableWithoutFeedback>
  );
};

๐ŸŒŸ ์‹ค๋ฌด ํ”„๋กœ์ ํŠธ ์˜ˆ์ œ ๋ชจ์Œ

์ด์ œ ์ง„์งœ ์•ฑ์—์„œ ์“ธ ์ˆ˜ ์žˆ๋Š” ์‹ค์šฉ์ ์ธ ์˜ˆ์ œ๋“ค์„ ๋ชจ์•„๋ดค์–ด!
๋ณต์‚ฌํ•ด์„œ ๋ฐ”๋กœ ์“ธ ์ˆ˜ ์žˆ๋„๋ก ์™„์„ฑ๋„ ์žˆ๊ฒŒ ๋งŒ๋“ค์—ˆ์œผ๋‹ˆ ์ฐธ๊ณ ํ•ด๋ด. ๐Ÿ“ฑ

1๏ธโƒฃ ์Šค์ผˆ๋ ˆํ†ค ๋กœ๋”ฉ ์• ๋‹ˆ๋ฉ”์ด์…˜

const SkeletonLoader = ({ width = '100%', height = 20 }) => {
  const shimmerAnim = useRef(new Animated.Value(0)).current;
  
  useEffect(() => {
    Animated.loop(
      Animated.timing(shimmerAnim, {
        toValue: 1,
        duration: 1500,
        easing: Easing.linear,
        useNativeDriver: true
      })
    ).start();
  }, []);
  
  const translateX = shimmerAnim.interpolate({
    inputRange: [0, 1],
    outputRange: [-350, 350]
  });
  
  return (
    <View style={{ width, height, backgroundColor: '#e0e0e0', borderRadius: 4, overflow: 'hidden' }}>
      <Animated.View
        style={{
          width: '100%',
          height: '100%',
          backgroundColor: 'rgba(255, 255, 255, 0.5)',
          transform: [{ translateX }]
        }}
      />
    </View>
  );
};

// ์‚ฌ์šฉ ์˜ˆ์‹œ
const LoadingCard = () => (
  <View style={{ padding: 16 }}>
    <SkeletonLoader width={100} height={100} />
    <View style={{ marginTop: 12 }}>
      <SkeletonLoader width="80%" height={20} />
      <View style={{ marginTop: 8 }}>
        <SkeletonLoader width="60%" height={16} />
      </View>
    </View>
  </View>
);

2๏ธโƒฃ ํ† ์ŠคํŠธ ๋ฉ”์‹œ์ง€ ์• ๋‹ˆ๋ฉ”์ด์…˜

const Toast = ({ message, visible, onHide }) => {
  const translateY = useRef(new Animated.Value(-100)).current;
  const opacity = useRef(new Animated.Value(0)).current;
  
  useEffect(() => {
    if (visible) {
      // ๋‚˜ํƒ€๋‚˜๊ธฐ
      Animated.parallel([
        Animated.spring(translateY, {
          toValue: 0,
          friction: 8,
          tension: 40,
          useNativeDriver: true
        }),
        Animated.timing(opacity, {
          toValue: 1,
          duration: 200,
          useNativeDriver: true
        })
      ]).start();
      
      // 3์ดˆ ํ›„ ์ž๋™์œผ๋กœ ์‚ฌ๋ผ์ง€๊ธฐ
      const timer = setTimeout(() => {
        hideToast();
      }, 3000);
      
      return () => clearTimeout(timer);
    }
  }, [visible]);
  
  const hideToast = () => {
    Animated.parallel([
      Animated.timing(translateY, {
        toValue: -100,
        duration: 200,
        useNativeDriver: true
      }),
      Animated.timing(opacity, {
        toValue: 0,
        duration: 200,
        useNativeDriver: true
      })
    ]).start(() => {
      if (onHide) onHide();
    });
  };
  
  if (!visible) return null;
  
  return (
    <Animated.View
      style={{
        position: 'absolute',
        top: 50,
        left: 20,
        right: 20,
        backgroundColor: '#333',
        padding: 16,
        borderRadius: 8,
        opacity,
        transform: [{ translateY }],
        zIndex: 1000
      }}
    >
      <Text style={{ color: 'white', fontSize: 14 }}>{message}</Text>
    </Animated.View>
  );
};

3๏ธโƒฃ ํ”„๋กœ๊ทธ๋ ˆ์Šค ๋ฐ” ์• ๋‹ˆ๋ฉ”์ด์…˜

const AnimatedProgressBar = ({ progress = 0, color = '#667eea' }) => {
  const widthAnim = useRef(new Animated.Value(0)).current;
  
  useEffect(() => {
    Animated.timing(widthAnim, {
      toValue: progress,
      duration: 500,
      easing: Easing.bezier(0.25, 0.1, 0.25, 1),
      useNativeDriver: false  // width๋Š” ๋„ค์ดํ‹ฐ๋ธŒ ๋“œ๋ผ์ด๋ฒ„ ๋ฏธ์ง€์›
    }).start();
  }, [progress]);
  
  const width = widthAnim.interpolate({
    inputRange: [0, 100],
    outputRange: ['0%', '100%']
  });
  
  return (
    <View style={styles.progressContainer}>
      <Animated.View
        style={[
          styles.progressBar,
          { width, backgroundColor: color }
        ]}
      />
    </View>
  );
};

const styles = StyleSheet.create({
  progressContainer: {
    width: '100%',
    height: 8,
    backgroundColor: '#e0e0e0',
    borderRadius: 4,
    overflow: 'hidden'
  },
  progressBar: {
    height: '100%',
    borderRadius: 4
  }
});

4๏ธโƒฃ ์Šค์™€์ดํ”„ ์‚ญ์ œ ์• ๋‹ˆ๋ฉ”์ด์…˜

const SwipeToDelete = ({ children, onDelete }) => {
  const translateX = useRef(new Animated.Value(0)).current;
  const deleteOpacity = useRef(new Animated.Value(0)).current;
  
  const panResponder = useRef(
    PanResponder.create({
      onStartShouldSetPanResponder: () => true,
      onMoveShouldSetPanResponder: (_, gestureState) => {
        return Math.abs(gestureState.dx) > 5;
      },
      
      onPanResponderMove: (_, gestureState) => {
        if (gestureState.dx < 0) {  // ์™ผ์ชฝ์œผ๋กœ๋งŒ ์Šค์™€์ดํ”„
          translateX.setValue(gestureState.dx);
          
          const opacity = Math.min(Math.abs(gestureState.dx) / 100, 1);
          deleteOpacity.setValue(opacity);
        }
      },
      
      onPanResponderRelease: (_, gestureState) => {
        if (gestureState.dx < -100) {
          // ์‚ญ์ œ ์‹คํ–‰
          Animated.timing(translateX, {
            toValue: -500,
            duration: 200,
            useNativeDriver: false
          }).start(() => {
            if (onDelete) onDelete();
          });
        } else {
          // ์›์œ„์น˜
          Animated.parallel([
            Animated.spring(translateX, {
              toValue: 0,
              useNativeDriver: false
            }),
            Animated.timing(deleteOpacity, {
              toValue: 0,
              duration: 200,
              useNativeDriver: false
            })
          ]).start();
        }
      }
    })
  ).current;
  
  return (
    <View style={{ position: 'relative' }}>
      {/* ์‚ญ์ œ ๋ฒ„ํŠผ ๋ฐฐ๊ฒฝ */}
      <Animated.View
        style={{
          position: 'absolute',
          right: 0,
          top: 0,
          bottom: 0,
          width: 100,
          backgroundColor: '#ef4444',
          justifyContent: 'center',
          alignItems: 'center',
          opacity: deleteOpacity
        }}
      >
        <Text style={{ color: 'white', fontWeight: 'bold' }}>์‚ญ์ œ</Text>
      </Animated.View>
      
      {/* ์Šค์™€์ดํ”„ ๊ฐ€๋Šฅํ•œ ์ปจํ…์ธ  */}
      <Animated.View
        style={{
          transform: [{ translateX }],
          backgroundColor: 'white'
        }}
        {...panResponder.panHandlers}
      >
        {children}
      </Animated.View>
    </View>
  );
};
๐Ÿ’ก ์‹ค๋ฌด ํŒ ์ด๋Ÿฐ ์ปดํฌ๋„ŒํŠธ๋“ค์„ ๋งŒ๋“ค ๋•Œ๋Š” ์žฌ์‚ฌ์šฉ์„ฑ์„ ๊ณ ๋ คํ•ด์„œ ์„ค๊ณ„ํ•˜๋Š” ๊ฒŒ ์ค‘์š”ํ•ด!
props๋กœ ์ƒ‰์ƒ, ํฌ๊ธฐ, ๋™์ž‘ ๋“ฑ์„ ์ปค์Šคํ„ฐ๋งˆ์ด์ง•ํ•  ์ˆ˜ ์žˆ๊ฒŒ ๋งŒ๋“ค๋ฉด
ํ”„๋กœ์ ํŠธ ์ „์ฒด์—์„œ ์ผ๊ด€๋œ UX๋ฅผ ์œ ์ง€ํ•  ์ˆ˜ ์žˆ์–ด. ๐ŸŽจ

์žฌ๋Šฅ๋„ท์—์„œ๋Š” ์ด๋Ÿฐ ์ปดํฌ๋„ŒํŠธ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ๊ฐœ๋ฐœ์ด๋‚˜
UI/UX ๊ฐœ์„  ์ž‘์—…์„ ์˜๋ขฐํ•  ์ˆ˜๋„ ์žˆ์œผ๋‹ˆ ์ฐธ๊ณ ํ•ด๋ด!

๐ŸŽฏ ๋งˆ๋ฌด๋ฆฌํ•˜๋ฉฐ

์™€, ์—ฌ๊ธฐ๊นŒ์ง€ ์ฝ์—ˆ๋‹ค๋ฉด ์ •๋ง ๋Œ€๋‹จํ•ด! ๐Ÿ‘
๋ฆฌ์•กํŠธ ๋„ค์ดํ‹ฐ๋ธŒ์˜ Animated API์— ๋Œ€ํ•ด ๊ฝค ๋งŽ์€ ๊ฑธ ๋ฐฐ์› ์„ ๊ฑฐ์•ผ.

์ฒ˜์Œ์—” ๋ณต์žกํ•ด ๋ณด์ผ ์ˆ˜ ์žˆ์ง€๋งŒ, ์ง์ ‘ ์ฝ”๋“œ๋ฅผ ์งœ๋ณด๋ฉด์„œ ์ตํžˆ๋‹ค ๋ณด๋ฉด
์–ด๋А์ƒˆ ์ž์—ฐ์Šค๋Ÿฝ๊ฒŒ ์• ๋‹ˆ๋ฉ”์ด์…˜์„ ๊ตฌํ˜„ํ•˜๊ณ  ์žˆ๋Š” ์ž์‹ ์„ ๋ฐœ๊ฒฌํ•˜๊ฒŒ ๋  ๊ฑฐ์•ผ! ๐Ÿ˜Š

๐ŸŽ“ ํ•ต์‹ฌ ์š”์•ฝ 1. Animated API์˜ 3์š”์†Œ
โ€ข Animated.Value / ValueXY (๊ฐ’)
โ€ข Animated.View / Text / Image (์ปดํฌ๋„ŒํŠธ)
โ€ข timing / spring / decay (์• ๋‹ˆ๋ฉ”์ด์…˜ ํƒ€์ž…)

2. ์„ฑ๋Šฅ ์ตœ์ ํ™”
โ€ข useNativeDriver: true ํ•„์ˆ˜!
โ€ข transform๊ณผ opacity๋งŒ ๋„ค์ดํ‹ฐ๋ธŒ ๋“œ๋ผ์ด๋ฒ„ ์ง€์›
โ€ข useRef๋กœ ๊ฐ’ ๊ด€๋ฆฌ, ๋ถˆํ•„์š”ํ•œ ๋ฆฌ๋ Œ๋”๋ง ๋ฐฉ์ง€

3. ๊ณ ๊ธ‰ ํ…Œํฌ๋‹‰
โ€ข interpolate๋กœ ๊ฐ’ ๋ณ€ํ™˜
โ€ข parallel, sequence, stagger๋กœ ์กฐํ•ฉ
โ€ข ์ปค์Šคํ…€ ์ด์ง• ํ•จ์ˆ˜๋กœ ์„ธ๋ฐ€ํ•œ ์ œ์–ด

4. ์‹ค๋ฌด ์ ์šฉ
โ€ข ์žฌ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ ์ปดํฌ๋„ŒํŠธ ์„ค๊ณ„
โ€ข ์ ‘๊ทผ์„ฑ ๊ณ ๋ ค (reduceMotion)
โ€ข ์„ฑ๋Šฅ ๋ชจ๋‹ˆํ„ฐ๋ง๊ณผ ์ตœ์ ํ™”

์• ๋‹ˆ๋ฉ”์ด์…˜์€ ๋‹จ์ˆœํžˆ '์˜ˆ์˜๊ฒŒ ๋ณด์ด๋ ค๊ณ ' ํ•˜๋Š” ๊ฒŒ ์•„๋‹ˆ์•ผ.
์‚ฌ์šฉ์ž์—๊ฒŒ ํ”ผ๋“œ๋ฐฑ์„ ์ฃผ๊ณ , ์•ฑ์˜ ์ƒํƒœ๋ฅผ ์ง๊ด€์ ์œผ๋กœ ์ „๋‹ฌํ•˜๋ฉฐ,
์ „์ฒด์ ์ธ ์‚ฌ์šฉ์ž ๊ฒฝํ—˜์„ ํ–ฅ์ƒ์‹œํ‚ค๋Š” ์ค‘์š”ํ•œ ์š”์†Œ์ง€! ๐ŸŒŸ

์ฒ˜์Œ์—” ๊ฐ„๋‹จํ•œ ํŽ˜์ด๋“œ ์ธ/์•„์›ƒ๋ถ€ํ„ฐ ์‹œ์ž‘ํ•ด์„œ,
์ ์  ๋ณต์žกํ•œ ์ธํ„ฐ๋ž™์…˜์„ ๋งŒ๋“ค์–ด๊ฐ€๋‹ค ๋ณด๋ฉด
์–ด๋А์ƒˆ ํ”„๋กœ ์ˆ˜์ค€์˜ ์•ฑ์„ ๋งŒ๋“ค ์ˆ˜ ์žˆ์„ ๊ฑฐ์•ผ! ๐Ÿ’ช

ํ˜น์‹œ ์• ๋‹ˆ๋ฉ”์ด์…˜ ๊ตฌํ˜„ ์ค‘์— ๋ง‰ํžˆ๋Š” ๋ถ€๋ถ„์ด ์žˆ๋‹ค๋ฉด,
๊ณต์‹ ๋ฌธ์„œ๋ฅผ ์ฐธ๊ณ ํ•˜๊ฑฐ๋‚˜, ์ปค๋ฎค๋‹ˆํ‹ฐ์— ์งˆ๋ฌธํ•˜๋Š” ๊ฒƒ๋„ ์ข‹์€ ๋ฐฉ๋ฒ•์ด์•ผ.
๋˜๋Š” ์žฌ๋Šฅ๋„ท์—์„œ ์ „๋ฌธ๊ฐ€์˜ ๋„์›€์„ ๋ฐ›๋Š” ๊ฒƒ๋„ ๊ณ ๋ คํ•ด๋ด! ๐Ÿค

์ž, ์ด์ œ ๋‹น์‹ ์˜ ์•ฑ์— ์ƒ๋ช…์„ ๋ถˆ์–ด๋„ฃ์–ด๋ด!
๋ฉ‹์ง„ ์• ๋‹ˆ๋ฉ”์ด์…˜์œผ๋กœ ์‚ฌ์šฉ์ž๋“ค์„ ๊ฐ๋™์‹œ์ผœ๋ณด์ž! ๐Ÿš€โœจ

๐ŸŽ‰ Happy Animating! ๐ŸŽ‰

๋‹น์‹ ์˜ ์•ฑ์ด ๋”์šฑ ์ƒ๋™๊ฐ ๋„˜์น˜๊ธธ ๋ฐ”๋ผ! ๐Ÿ’ซ

๋Œ“๊ธ€ ์ž‘์„ฑ

์ด ๊ธ€์— ๋Œ€ํ•œ ์—ฌ๋Ÿฌ๋ถ„์˜ ์ƒ๊ฐ์„ ๋“ค๋ ค์ฃผ์„ธ์š”

๋Œ“๊ธ€ 0
๋Œ“๊ธ€์„ ๋ถˆ๋Ÿฌ์˜ค๋Š” ์ค‘์ž…๋‹ˆ๋‹ค.

์•„์ง ๋Œ“๊ธ€์ด ์—†์Šต๋‹ˆ๋‹ค.