@remobile/react-native-action-sheet
Version:
A pure js ActionSheet like ios ActionSheet, support ios and android
35 lines (30 loc) • 888 B
JavaScript
/*
* (The MIT License)
* Copyright (c) 2015-2016 YunJiang.Fang <42550564@qq.com>
*/
;
var React = require('react');
var ReactNative = require('react-native');
var { Animated, StyleSheet, View, Dimensions} = ReactNative;
const DEFAULT_BOTTOM = -300;
const DEFAULT_ANIMATE_TIME = 300;
module.exports = React.createClass({
getInitialState: function() {
return {
bottom: new Animated.Value(DEFAULT_BOTTOM)
};
},
componentWillReceiveProps: function(newProps) {
return Animated.timing(this.state.bottom, {
toValue: newProps.visible ? 0 : DEFAULT_BOTTOM,
duration: DEFAULT_ANIMATE_TIME
}).start();
},
render: function() {
return (
<Animated.View style={{bottom: this.state.bottom}}>
{this.props.children}
</Animated.View>
);
}
});