Upgrade to Pro — share decks privately, control downloads, hide ads and more …

introduction to React Native Animated

introduction to React Native Animated

nolick1219

May 19, 2017
Tweet

More Decks by nolick1219

Other Decks in Programming

Transcript

  1. 1. ΞχϝʹΑΓมԽ͢Δ஋(ม਺)Λఆٛ͢Δ Animated.Value() Animated.ValueXY() ※Ґஔ৘ใʹͻ΋͚͍ͮͨ৔߹ export default class RNMeetup5Demo extends

    Component { constructor(props){ super(props); this.state = { animatedValue: new Animated.Value(0), //0ͰॳظԽ } }
  2. ม਺ͱ͸ผͷϨϯδͰCSSϓϩύςΟʹͻ΋͚͍ͮͨ render(){ const marginLeft = this.state.animatedValue.interpolate({ inputRange: [0, 1], outputRange:

    [0, 300] }) const opacity = this.state.animatedValue.interpolate({ inputRange: [0, 0.5, 1], outputRange: [0, 1, 0] }) const movingMargin = this.state.animatedValue.interpolate({ inputRange: [0, 0.5, 1], outputRange: [0, 300, 0] }) return ( <View style={styles.container}> <Animated.Image style={{ marginLeft, }} /> <Animated.Image style={{ opacity, }} /> <Animated.Image style={{ marginLeft: movingMargin, }} /> /> </View> ) } } interpolate()Λ͔ͭ͏