Quantcast
Channel: Active questions tagged react-native+android - Stack Overflow
Viewing all articles
Browse latest Browse all 29459

React native android animation

$
0
0

I'm trying to animate the height of a View in react native. The animation is working as expected in iOS but is not working in Android. The animated View seems to always be full height regardless of the animation value. Relevant code is below:

var Facets = React.createClass({
  getInitialState: function() {
    return {
      h: new Animated.Value(0),
    };
  },

  _animate: function(newHeight) {
    Animated.timing(this.state.h, {
      duration: 300,
      toValue: newHeight
    }).start();
  },

  render: function() {
    var facetComponents = [];

    if (this.props.shown) {
      this._animate(MAX_HEIGHT);
    }
    else {
      this._animate(0);
    }

    facets.map( (facet, idx) => {
      facetComponents.push(
        <Facet
          key={idx}
          facet={facet}
          filterBy={this.props.filterBy} />);
    });

    return (
      <Animated.View style={{ maxHeight: this.state.h }}>
        {facetComponents}
      </Animated.View>
    );
  }
});

Viewing all articles
Browse latest Browse all 29459

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>