This repository has been archived by the owner on Mar 31, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27
/
index.js
75 lines (71 loc) · 1.67 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
'use strict';
var React = require('react-native');
var {
Text,
View,
Image
} = 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 (
<View style={[{
position: 'absolute',
overflow: 'hidden',
top: this.props.cropTop,
left: this.props.cropLeft,
height: this.props.height,
width: this.props.width,
backgroundColor: 'transparent'
}, this.props.style]}>
<View style={{
position: 'absolute',
top: this.props.cropTop * -1,
left: this.props.cropLeft * -1,
backgroundColor: 'transparent'
}}>
{this.props.children}
</View>
</View>
);
}
});
var CroppedImage = React.createClass({
render() {
return (
<View style={[{
overflow: 'hidden',
height: this.props.cropHeight,
width: this.props.cropWidth,
backgroundColor: 'transparent'
}, this.props.style]}>
<Image style={{
position: 'absolute',
top: this.props.cropTop * -1,
left: this.props.cropLeft * -1,
width: this.props.width,
height: this.props.height
}}
source={this.props.source}
resizeMode={this.props.resizeMode}>
{this.props.children}
</Image>
</View>
);
}
});
module.exports = {
CroppedImage: CroppedImage,
CroppingView: CroppingView
};