'use strict';
var React = require('react-native');
var {
AppRegistry,
StyleSheet,
Image,
Text,
View,
LayoutAnimation,
TouchableOpacity
} = React;
var CroppingView = React.createClass({
propTypes: {
cropTop: React.PropTypes.number,
cropLeft: React.PropTypes.number,
width: React.PropTypes.number.isRequired,
height: React.PropTypes.number.isRequired
},
getDefaultProps() {
return {
cropTop: 0,
cropLeft: 0
}
},
render() {
return (
{this.props.children}
);
}
});
var CroppedImage = React.createClass({
render() {
return (
{this.props.children}
);
}
});
var animcrop = React.createClass({
getDefaultProps() {
return {
width: 350,
height: 526
};
},
getInitialState() {
return {
width: this.props.width,
height: this.props.height,
left: 0,
top: 0,
radius: 0,
cropped: false
};
},
componentDidMount() {
LayoutAnimation.Presets.spring.duration = 1200;
LayoutAnimation.spring();
},
_zoomIn() {
this.setState({cropped: false});
LayoutAnimation.spring();
this.setState({
left: 75,
top: 110,
width: 190,
height: 250,
radius: 50
});
},
_zoomOut() {
this.setState({cropped: false});
LayoutAnimation.spring();
this.setState({
width: this.props.width,
height: this.props.height,
left: 0,
top: 0,
radius: 0
});
},
_showCropped() {
this.setState({
cropped: true
});
},
_croppedImage() {
return (
);
},
_croppedView() {
return (
);
},
render: function() {
var contents = this.state.cropped ? this._croppedImage() : this._croppedView();
return (
Zoom In!
Zoom Out!
Crop
{contents}
);
}
});
var styles = StyleSheet.create({
container: {
marginTop: 50,
marginLeft: 10
},
button: {
marginRight: 10,
padding: 10,
fontSize: 10,
textAlign: 'center',
backgroundColor: 'green',
width: 100
}
});
AppRegistry.registerComponent('animcrop', () => animcrop);