Skip to content

Commit b1c2728

Browse files
committed
Merge pull request #25 from jimthedev/patch-1
fix animation and small padding when in landscape
2 parents 8a1239d + 67edcfe commit b1c2728

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

index.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
'use strict';
22

33
import React, {
4-
StyleSheet,
5-
PropTypes,
6-
View,
4+
StyleSheet,
5+
PropTypes,
6+
View,
77
Text,
88
Animated,
99
Platform,
@@ -18,6 +18,9 @@ let PickerItem = Picker.Item;
1818
let width = Dimensions.get('window').width;
1919
let height = Dimensions.get('window').height;
2020

21+
const longSide = width > height ? width : height;
22+
const shortSide = width > height ? height : width;
23+
2124
export default class PickerAny extends React.Component {
2225

2326
static propTypes = {
@@ -102,7 +105,7 @@ export default class PickerAny extends React.Component {
102105
let thirdPickedDataIndex;
103106
let cascadeData = {};
104107
let slideAnim = (this.state && this.state.slideAnim ? this.state.slideAnim : new Animated.Value(-props.pickerHeight));
105-
108+
106109
if(pickerStyle === 'parallel'){
107110
//compatible single wheel sence
108111
if(selectedValue.constructor !== Array){
@@ -364,7 +367,7 @@ export default class PickerAny extends React.Component {
364367
else{
365368
this.pickedValue.splice(0, 2, value, cascadeData.secondWheelData[0]);
366369
}
367-
370+
368371
this.setState({
369372
selectedValue: 'wheel1'+value,
370373
firstPickedData: value,
@@ -393,12 +396,12 @@ export default class PickerAny extends React.Component {
393396
onValueChange={(index) => {
394397
let thirdWheelData = pickerData[this.state.firstPickedData][this.state.secondWheelData[index]];
395398
if(thirdWheelData){
396-
this.pickedValue.splice(1, 2, this.state.secondWheelData[index], thirdWheelData[0]);
399+
this.pickedValue.splice(1, 2, this.state.secondWheelData[index], thirdWheelData[0]);
397400
}
398401
else{
399402
this.pickedValue.splice(1, 1, this.state.secondWheelData[index]);
400403
}
401-
404+
402405
this.setState({
403406
secondPickedDataIndex: index,
404407
thirdWheelData,
@@ -464,11 +467,11 @@ export default class PickerAny extends React.Component {
464467
}
465468
return wheel;
466469
}
467-
470+
468471
render(){
469472
return (
470473
<Animated.View style={[styles.picker, {
471-
width: this.state.pickerWidth,
474+
width: longSide,
472475
height: this.state.pickerHeight,
473476
bottom: this.state.slideAnim
474477
}, this.state.style]}>
@@ -485,7 +488,7 @@ export default class PickerAny extends React.Component {
485488
onPress={this._pickerFinish.bind(this)}>{this.state.pickerBtnText}</Text>
486489
</View>
487490
</View>
488-
<View style={styles.pickerWrap}>
491+
<View style={[styles.pickerWrap, { width: this.state.pickerWidth }]}>
489492
{this._renderWheel(this.state.pickerData)}
490493
</View>
491494
</Animated.View>

0 commit comments

Comments
 (0)