create account

[React Native] 인터렉티브한 애니메이션(Animations) 만들기 by anpigon

View this thread on: hive.blogpeakd.comecency.com
· @anpigon · (edited)
$2.25
[React Native] 인터렉티브한 애니메이션(Animations) 만들기
![](https://cdn.steemitimages.com/DQmXtBYt3kXFAhrVjuGUGa5TQrgUZ2nL8npNsg67WYqZQ57/11A557AA-ADD4-484C-AD9E-FCD37D09C38B.jpeg)
<div class='pull-right'><i>Design by imrahelk</i></div> 

<hr>

> 이쁜 대문 이미지를 만들어주신 **레이첼(imrahelk)**님 감사합니다. 아직 대문 이미지가 없으신 분은 ["☆축환갑☆ 환갑기념 대문장이 리턴즈"](https://steemit.com/kr-event/@imrahelk/4kchpq)에 이벤트 응모해보세요.


<br><br>
<center>* * *</center>
<br><br>

# Lottie

 [Lottie](https://airbnb.design/lottie/)는 Airbnb에서 출시한 애니메이션 라이브러리입니다. 아래 화면과 같은 아름다운 애니메이션 효과를 만들 수 있습니다.

![](https://github.com/react-native-community/lottie-react-native/raw/master/docs/gifs/Example2.gif)


<br>하지만 애니메이션을 만들기 위해서는 [Adobe After Effect](https://www.adobe.com/kr/products/aftereffects.html)로 애니메이션을 만들고, [Bodymovin](https://github.com/airbnb/lottie-web)로 다시 JSON 파일을 만들어야 합니다.

<br>맥OS 사용자라면,  lottie Bodymovin 플러그인을 brew로 설치할 수 있습니다.

```
brew tap danielbayley/adobe
brew cask install lottie
```
> 하지만 저는 설치하다가 오류가 발생하네요. ㅠㅠ 
그리고 Adobe After Effect 로 애니메이션 만드는 방법도 잘 모르겠습니다.

<br>

## Lottie Files
[https://lottiefiles.com](https://lottiefiles.com/recent)
그러나 Adobe After Effect를 할 줄 몰라도 괜찮습니다. LottieFiles 사이트에는 많은 디자이너들이 만든 애니메이션이 업로드되어 있습니다. 원하는 애니메이션을 검색하고 다운로드하세요. 그리고 모바일앱에 적용하면 됩니다.
![](https://files.steempeak.com/file/steempeak/anpigon/CcPQMlgw-E18489E185B3E1848FE185B3E18485E185B5E186ABE18489E185A3E186BA202019-04-1820E1848BE185A9E18492E185AE204.30.56.png)
> 저는 첫번째의 지갑에 동전 넣은 애니메이션이 마음에 드네요. ㅋ

<br>Lottie로 애니메이션을 구현하고 싶었습니다. 하지만 Adobe After Effect 다루는게 익숙하지가 않네요.

<br><br>
<center>* * *</center>
<br><br>

# React Native Animated API
React Native에서 제공하는 Animated API으로 애니메이션을 구현해보겠습니다. Animated API 사용 방법은 매우 간단합니다. React-Native API 문서를 참고하였습니다.
* 참고: https://facebook.github.io/react-native/docs/animations

<br>
아래와 같이 이미지가 뱅글뱅글 돌아가는 애니메이션을 만들어 봅니다. 이미지는 뉴비존님(newbijohn)께서 디자인해주셨습니다.

|||
|-|-|
| ![](https://files.steempeak.com/file/steempeak/anpigon/GCgECeAt-whan_loader.gif) | ![](https://cdn.steemitimages.com/500x0/http://www.pngmart.com/files/5/Snow-PNG-Transparent-Image.png) |

<br>


코드를 작성합니다.

```
import React, { Component } from 'react';
import { Animated, Easing, StyleSheet, View } from 'react-native';

export default class AuthLoadingScreen extends Component {
  constructor(props) {
    super(props);

    this.state = {
      spinValue: new Animated.Value(0),
    }
  }
  
  componentDidMount() {
    // 애니메이션을 설정한다.
    Animated.timing(
      this.state.spinValue,
      {
        toValue: 1,
        duration: 3000,
        easing: Easing.linear,
        useNativeDriver: true,
      }
    ).start()
  }

  render() {
    // 회전 애니매이션을 수행한다.
    const spin = this.state.spinValue.interpolate({
      inputRange: [0, 360],
      outputRange: ['0deg', '360deg'],
    });

    return (
      <View style={styles.container}>
        <Animated.Image
          style={{transform: [{rotate: spin}] }}
          source={require('../../assets/images/icon.png')} />
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
    backgroundColor: '#fff',
  }
});
```
> 회전값 Value 는 `state`의 `spinValue`에 맵핑됩니다. 그리고 `Animated.timing` 의 `easing` 함수를 사용하여 시간에 따른 애니메이션 효과를 보여줍니다.

<br>

위 코드를 적용하면 아래와 같이 보여집니다.

![](https://files.steempeak.com/file/steempeak/anpigon/OcCUa1U8-1.gif)

<br>여기까지 읽어주셔서 감사합니다.

***

<center>
### WHAN DEV TEAM
[\[출범식\] WDT(WHAN DEV TEAM) 공식 활동 개시](https://steemit.com/steemengine/@newbijohn/wdt-whan-dev-team)
[![](https://steemitimages.com/320x0/https://cdn.steemitimages.com/DQmbo4bis7WgjdVYdXR9VbzWdzh2aCXw2JFVKfruYNCNV4G/wdt.png)](https://steemit.com/steemengine/@newbijohn/wdt-whan-dev-team)


![](https://steemitimages.com/400x0/https://cdn.steemitimages.com/DQmQmWhMN6zNrLmKJRKhvSScEgWZmpb8zCeE2Gray1krbv6/BC054B6E-6F73-46D0-88E4-C88EB8167037.jpeg)
</center>

---

#####  <sub> **Sponsored ( Powered by [dclick](https://www.dclick.io) )** </sub>
[![dclick-imagead](https://s3.ap-northeast-2.amazonaws.com/dclick/image/dclick/1552477485946.png)](https://api.dclick.io/v1/c?x=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjIjoiYW5waWdvbiIsInMiOiJyZWFjdC1uYXJpdmUtYW5pbWF0aW9ucyIsImEiOlsiaS0xOTUiXSwidXJsIjoiaHR0cHM6Ly93d3cuZGNsaWNrLmlvL21vbmV0aXplIiwiaWF0IjoxNTU1NTk2MDU4LCJleHAiOjE4NzA5NTYwNTh9.g6-IsuyGOTzbmmkQU_iwAjrcHTumMkV2yOQIlPO1oG8)
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 87 others
properties (23)
authoranpigon
permlinkreact-narive-animations
categorykr
json_metadata{"app":"steempeak/1.9.8","format":"markdown","tags":["kr","kr-dev","busy"],"links":["/kr-event/@imrahelk/4kchpq","https://airbnb.design/lottie/","https://www.adobe.com/kr/products/aftereffects.html","https://github.com/airbnb/lottie-web","https://lottiefiles.com/recent","https://facebook.github.io/react-native/docs/animations","/steemengine/@newbijohn/wdt-whan-dev-team","/steemengine/@newbijohn/wdt-whan-dev-team","https://www.dclick.io","https://api.dclick.io/v1/c?x=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjIjoiYW5waWdvbiIsInMiOiJyZWFjdC1uYXJpdmUtYW5pbWF0aW9ucyIsImEiOlsiaS0xOTUiXSwidXJsIjoiaHR0cHM6Ly93d3cuZGNsaWNrLmlvL21vbmV0aXplIiwiaWF0IjoxNTU1NTk2MDU4LCJleHAiOjE4NzA5NTYwNTh9.g6-IsuyGOTzbmmkQU_iwAjrcHTumMkV2yOQIlPO1oG8"],"image":["https://cdn.steemitimages.com/DQmXtBYt3kXFAhrVjuGUGa5TQrgUZ2nL8npNsg67WYqZQ57/11A557AA-ADD4-484C-AD9E-FCD37D09C38B.jpeg","https://github.com/react-native-community/lottie-react-native/raw/master/docs/gifs/Example2.gif","https://files.steempeak.com/file/steempeak/anpigon/CcPQMlgw-E18489E185B3E1848FE185B3E18485E185B5E186ABE18489E185A3E186BA202019-04-1820E1848BE185A9E18492E185AE204.30.56.png","https://files.steempeak.com/file/steempeak/anpigon/GCgECeAt-whan_loader.gif","https://cdn.steemitimages.com/500x0/http://www.pngmart.com/files/5/Snow-PNG-Transparent-Image.png","https://files.steempeak.com/file/steempeak/anpigon/OcCUa1U8-1.gif","https://steemitimages.com/320x0/https://cdn.steemitimages.com/DQmbo4bis7WgjdVYdXR9VbzWdzh2aCXw2JFVKfruYNCNV4G/wdt.png","https://steemitimages.com/400x0/https://cdn.steemitimages.com/DQmQmWhMN6zNrLmKJRKhvSScEgWZmpb8zCeE2Gray1krbv6/BC054B6E-6F73-46D0-88E4-C88EB8167037.jpeg","https://s3.ap-northeast-2.amazonaws.com/dclick/image/dclick/1552477485946.png"],"community":"busy","users":["imrahelk","newbijohn"]}
created2019-04-18 13:39:36
last_update2019-04-25 14:18:42
depth0
children9
last_payout2019-04-25 13:39:36
cashout_time1969-12-31 23:59:59
total_payout_value1.731 HBD
curator_payout_value0.515 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length4,286
author_reputation17,258,940,000,931
root_title"[React Native] 인터렉티브한 애니메이션(Animations) 만들기"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id83,324,176
net_rshares3,896,820,318,939
author_curate_reward""
vote details (151)
@codingman ·
Adobe After Effect 무료면 좋은데 참 아쉬움!
그래도 좋은거 업로드 하면 되니 자기 개성에 맞는거 찾아서 쓰시면 괜찮겠네요.
properties (22)
authorcodingman
permlinkre-anpigon-react-narive-animations-20190419t055016973z
categorykr
json_metadata{"tags":["kr"],"app":"steemit/0.1"}
created2019-04-19 05:50:21
last_update2019-04-19 05:50:21
depth1
children1
last_payout2019-04-26 05:50:21
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length77
author_reputation23,188,231,710,844
root_title"[React Native] 인터렉티브한 애니메이션(Animations) 만들기"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id83,367,929
net_rshares0
@anpigon ·
네 저도 그 부분이 매우 아쉽습니다. 그냥 감상만 할뿐입니다. ㅋ
properties (22)
authoranpigon
permlinkre-codingman-re-anpigon-react-narive-animations-20190419t094814482z
categorykr
json_metadata{"tags":["kr"],"app":"steemit/0.1"}
created2019-04-19 09:48:15
last_update2019-04-19 09:48:15
depth2
children0
last_payout2019-04-26 09:48:15
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length36
author_reputation17,258,940,000,931
root_title"[React Native] 인터렉티브한 애니메이션(Animations) 만들기"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id83,376,917
net_rshares0
@gomdory ·
![](https://ipfs.busy.org/ipfs/QmSpSf3UTPCZUwCEfi1sWKKcUXWKH3SnpEaYaqRuWu7omz)
@anpigon님 곰돌이가 1.0배로 보팅해드리고 가요~! 영차~
properties (22)
authorgomdory
permlinkre-react-narive-animations-20190420t105113
categorykr
json_metadata""
created2019-04-20 10:51:15
last_update2019-04-20 10:51:15
depth1
children0
last_payout2019-04-27 10:51:15
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length115
author_reputation38,104,394,235,725
root_title"[React Native] 인터렉티브한 애니메이션(Animations) 만들기"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id83,432,911
net_rshares0
@newbijohn ·
$0.02
여윽싀 능력자 안피곤님 !!
👍  ,
properties (23)
authornewbijohn
permlinkre-anpigon-react-narive-animations-20190418t233214379z
categorykr
json_metadata{"tags":["kr"],"app":"steemit/0.1"}
created2019-04-18 23:32:24
last_update2019-04-18 23:32:24
depth1
children2
last_payout2019-04-25 23:32:24
cashout_time1969-12-31 23:59:59
total_payout_value0.016 HBD
curator_payout_value0.004 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length15
author_reputation72,450,120,773,132
root_title"[React Native] 인터렉티브한 애니메이션(Animations) 만들기"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id83,354,154
net_rshares38,630,533,470
author_curate_reward""
vote details (2)
@anpigon ·
우리 모두가 능력자죠 ㅋㅋ
properties (22)
authoranpigon
permlinkre-newbijohn-re-anpigon-react-narive-animations-20190419t005021279z
categorykr
json_metadata{"community":"busy","app":"busy/2.5.6","format":"markdown","tags":["kr"],"users":[],"links":[],"image":[]}
created2019-04-19 00:50:21
last_update2019-04-19 00:50:21
depth2
children0
last_payout2019-04-26 00:50:21
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length14
author_reputation17,258,940,000,931
root_title"[React Native] 인터렉티브한 애니메이션(Animations) 만들기"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id83,357,214
net_rshares0
@gomdory ·
곰돌이가 @newbijohn님의 소중한 댓글에 $0.017을 보팅해서 $0.006을 살려드리고 가요. 곰돌이가 지금까지 총 4188번 $48.456을 보팅해서 $52.551을 구했습니다.  @gomdory 곰도뤼~
properties (22)
authorgomdory
permlinkre-re-anpigon-react-narive-animations-20190418t233214379z-20190425t090830
categorykr
json_metadata""
created2019-04-25 09:08:33
last_update2019-04-25 09:08:33
depth2
children0
last_payout2019-05-02 09:08:33
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length119
author_reputation38,104,394,235,725
root_title"[React Native] 인터렉티브한 애니메이션(Animations) 만들기"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id83,728,017
net_rshares0
@steem-ua ·
#### Hi @anpigon!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your **UA** account score is currently 2.865 which ranks you at **#11875** across all Steem accounts.
Your rank has improved 574 places in the last three days (old rank 12449).

In our last Algorithmic Curation Round, consisting of 161 contributions, your post is ranked at **#120**.
##### Evaluation of your UA score:

* Only a few people are following you, try to convince more people with good work.
* The readers like your work!
* Try to work on user engagement: the more people that interact with you via the comments, the higher your UA score!


**Feel free to join our [@steem-ua Discord server](https://discord.gg/KpBNYGz)**
properties (22)
authorsteem-ua
permlinkre-react-narive-animations-20190421t115355z
categorykr
json_metadata"{"app": "beem/0.20.19"}"
created2019-04-21 11:53:57
last_update2019-04-21 11:53:57
depth1
children0
last_payout2019-04-28 11:53:57
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length754
author_reputation23,214,230,978,060
root_title"[React Native] 인터렉티브한 애니메이션(Animations) 만들기"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id83,496,537
net_rshares0
@steem.apps ·
![](https://steemitimages.com/32x32/https://steemitimages.com/u/happyberrysboy/avatar) [happyberrysboy](/@happyberrysboy)님이 anpigon님을 멘션하셨습니당. 아래 링크를 누르시면 연결되용~ ^^ <br />[happyberrysboy](/@happyberrysboy)님의 [새로운 대문 하나 더 득~~!!](/kr/@happyberrysboy/2fpmck) <br /> 

 <blockquote>
안녕하세요, 해피베리보이입니다.
오늘 anpigon님이 새로운 대문을 선물해 주셨어요~ ㅋㅋㅋ
우연히 wonsama 님이 저한테 단톡방에서 넷플릭스에 이런게 있다고 보여주셨는데~ 안피곤님이 제 대문으로 변신 시켜주셨더라고요!!...</blockquote>
properties (22)
authorsteem.apps
permlinkre---------react-narive-animations-20190418t134525069z
categorykr
json_metadata{"app":"steem.apps/0.1","format":"markdown"}
created2019-04-18 13:45:27
last_update2019-04-18 13:45:27
depth1
children0
last_payout2019-04-25 13:45:27
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length421
author_reputation7,218,006,883,278
root_title"[React Native] 인터렉티브한 애니메이션(Animations) 만들기"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id83,324,533
net_rshares0
@steem.apps ·
![](https://steemitimages.com/32x32/https://steemitimages.com/u/naha/avatar) [naha](/@naha)님이 anpigon님을 멘션하셨습니당. 아래 링크를 누르시면 연결되용~ ^^ <br />[naha](/@naha)님의 [BNW 백일장 2회 | 사과](/bnw100/@naha/bnw-2-or) <br /> 

 <blockquote>...ndong
sklara
sunnyy
tailcock
ukk
보팅참여 (1회당 1BNW)
abcteacher
anpigonanpigon
asinayo
ayogom
bbooaae
bji1203
bree1042
cheolwoo-kim
...</blockquote>
properties (22)
authorsteem.apps
permlinkre---------react-narive-animations-20190419t085312905z
categorykr
json_metadata{"app":"steem.apps/0.1","format":"markdown"}
created2019-04-19 08:53:15
last_update2019-04-19 08:53:15
depth1
children0
last_payout2019-04-26 08:53:15
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length369
author_reputation7,218,006,883,278
root_title"[React Native] 인터렉티브한 애니메이션(Animations) 만들기"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id83,375,016
net_rshares0