9
9
*/
10
10
'use strict' ;
11
11
12
- var React = require ( 'react' ) ;
13
- var ReactNative = require ( 'react-native' ) ;
14
- var {
12
+ const React = require ( 'react' ) ;
13
+ const ReactNative = require ( 'react-native' ) ;
14
+ const {
15
15
CameraRoll,
16
16
Image,
17
17
ImageEditor,
23
23
View,
24
24
} = ReactNative ;
25
25
26
- var PAGE_SIZE = 20 ;
26
+ const PAGE_SIZE = 20 ;
27
27
28
28
type ImageOffset = { |
29
29
x : number ,
@@ -68,9 +68,9 @@ class SquareImageCropper extends React.Component<
68
68
if ( ! this . _isMounted ) {
69
69
return ;
70
70
}
71
- var edges = data . edges ;
72
- var edge = edges [ Math . floor ( Math . random ( ) * edges . length ) ] ;
73
- var randomPhoto = edge && edge . node && edge . node . image ;
71
+ const edges = data . edges ;
72
+ const edge = edges [ Math . floor ( Math . random ( ) * edges . length ) ] ;
73
+ const randomPhoto = edge && edge . node && edge . node . image ;
74
74
if ( randomPhoto ) {
75
75
this . setState ( { randomPhoto} ) ;
76
76
}
@@ -89,7 +89,7 @@ class SquareImageCropper extends React.Component<
89
89
< View
90
90
style = { styles . container }
91
91
onLayout = { event => {
92
- var measuredWidth = event . nativeEvent . layout . width ;
92
+ const measuredWidth = event . nativeEvent . layout . width ;
93
93
if ( ! measuredWidth ) {
94
94
return ;
95
95
}
@@ -111,7 +111,7 @@ class SquareImageCropper extends React.Component<
111
111
if ( ! this . state . randomPhoto ) {
112
112
return < View style = { styles . container } /> ;
113
113
}
114
- var error = null ;
114
+ let error = null ;
115
115
if ( this . state . cropError ) {
116
116
error = < Text > { this . state . cropError . message } </ Text > ;
117
117
}
@@ -184,8 +184,8 @@ class ImageCropper extends React.Component<$FlowFixMeProps, $FlowFixMeState> {
184
184
componentWillMount ( ) {
185
185
// Scale an image to the minimum size that is large enough to completely
186
186
// fill the crop box.
187
- var widthRatio = this . props . image . width / this . props . size . width ;
188
- var heightRatio = this . props . image . height / this . props . size . height ;
187
+ const widthRatio = this . props . image . width / this . props . size . width ;
188
+ const heightRatio = this . props . image . height / this . props . size . height ;
189
189
this . _horizontal = widthRatio > heightRatio ;
190
190
if ( this . _horizontal ) {
191
191
this . _scaledImageSize = {
@@ -234,12 +234,12 @@ class ImageCropper extends React.Component<$FlowFixMeProps, $FlowFixMeState> {
234
234
}
235
235
236
236
_updateTransformData ( offset , scaledImageSize , croppedImageSize ) {
237
- var offsetRatioX = offset . x / scaledImageSize . width ;
238
- var offsetRatioY = offset . y / scaledImageSize . height ;
239
- var sizeRatioX = croppedImageSize . width / scaledImageSize . width ;
240
- var sizeRatioY = croppedImageSize . height / scaledImageSize . height ;
237
+ const offsetRatioX = offset . x / scaledImageSize . width ;
238
+ const offsetRatioY = offset . y / scaledImageSize . height ;
239
+ const sizeRatioX = croppedImageSize . width / scaledImageSize . width ;
240
+ const sizeRatioY = croppedImageSize . height / scaledImageSize . height ;
241
241
242
- var cropData : ImageCropData = {
242
+ const cropData : ImageCropData = {
243
243
offset : {
244
244
x : this . props . image . width * offsetRatioX ,
245
245
y : this . props . image . height * offsetRatioY ,
@@ -287,7 +287,7 @@ exports.examples = [
287
287
} ,
288
288
] ;
289
289
290
- var styles = StyleSheet . create ( {
290
+ const styles = StyleSheet . create ( {
291
291
container : {
292
292
flex : 1 ,
293
293
alignSelf : 'stretch' ,
0 commit comments