Commit b1c27287 authored by zooble's avatar zooble

Merge pull request #25 from jimthedev/patch-1

fix animation and small padding when in landscape
parents 8a1239d2 67edcfe0
'use strict'; 'use strict';
import React, { import React, {
StyleSheet, StyleSheet,
PropTypes, PropTypes,
View, View,
Text, Text,
Animated, Animated,
Platform, Platform,
...@@ -18,6 +18,9 @@ let PickerItem = Picker.Item; ...@@ -18,6 +18,9 @@ let PickerItem = Picker.Item;
let width = Dimensions.get('window').width; let width = Dimensions.get('window').width;
let height = Dimensions.get('window').height; let height = Dimensions.get('window').height;
const longSide = width > height ? width : height;
const shortSide = width > height ? height : width;
export default class PickerAny extends React.Component { export default class PickerAny extends React.Component {
static propTypes = { static propTypes = {
...@@ -102,7 +105,7 @@ export default class PickerAny extends React.Component { ...@@ -102,7 +105,7 @@ export default class PickerAny extends React.Component {
let thirdPickedDataIndex; let thirdPickedDataIndex;
let cascadeData = {}; let cascadeData = {};
let slideAnim = (this.state && this.state.slideAnim ? this.state.slideAnim : new Animated.Value(-props.pickerHeight)); let slideAnim = (this.state && this.state.slideAnim ? this.state.slideAnim : new Animated.Value(-props.pickerHeight));
if(pickerStyle === 'parallel'){ if(pickerStyle === 'parallel'){
//compatible single wheel sence //compatible single wheel sence
if(selectedValue.constructor !== Array){ if(selectedValue.constructor !== Array){
...@@ -364,7 +367,7 @@ export default class PickerAny extends React.Component { ...@@ -364,7 +367,7 @@ export default class PickerAny extends React.Component {
else{ else{
this.pickedValue.splice(0, 2, value, cascadeData.secondWheelData[0]); this.pickedValue.splice(0, 2, value, cascadeData.secondWheelData[0]);
} }
this.setState({ this.setState({
selectedValue: 'wheel1'+value, selectedValue: 'wheel1'+value,
firstPickedData: value, firstPickedData: value,
...@@ -393,12 +396,12 @@ export default class PickerAny extends React.Component { ...@@ -393,12 +396,12 @@ export default class PickerAny extends React.Component {
onValueChange={(index) => { onValueChange={(index) => {
let thirdWheelData = pickerData[this.state.firstPickedData][this.state.secondWheelData[index]]; let thirdWheelData = pickerData[this.state.firstPickedData][this.state.secondWheelData[index]];
if(thirdWheelData){ if(thirdWheelData){
this.pickedValue.splice(1, 2, this.state.secondWheelData[index], thirdWheelData[0]); this.pickedValue.splice(1, 2, this.state.secondWheelData[index], thirdWheelData[0]);
} }
else{ else{
this.pickedValue.splice(1, 1, this.state.secondWheelData[index]); this.pickedValue.splice(1, 1, this.state.secondWheelData[index]);
} }
this.setState({ this.setState({
secondPickedDataIndex: index, secondPickedDataIndex: index,
thirdWheelData, thirdWheelData,
...@@ -464,11 +467,11 @@ export default class PickerAny extends React.Component { ...@@ -464,11 +467,11 @@ export default class PickerAny extends React.Component {
} }
return wheel; return wheel;
} }
render(){ render(){
return ( return (
<Animated.View style={[styles.picker, { <Animated.View style={[styles.picker, {
width: this.state.pickerWidth, width: longSide,
height: this.state.pickerHeight, height: this.state.pickerHeight,
bottom: this.state.slideAnim bottom: this.state.slideAnim
}, this.state.style]}> }, this.state.style]}>
...@@ -485,7 +488,7 @@ export default class PickerAny extends React.Component { ...@@ -485,7 +488,7 @@ export default class PickerAny extends React.Component {
onPress={this._pickerFinish.bind(this)}>{this.state.pickerBtnText}</Text> onPress={this._pickerFinish.bind(this)}>{this.state.pickerBtnText}</Text>
</View> </View>
</View> </View>
<View style={styles.pickerWrap}> <View style={[styles.pickerWrap, { width: this.state.pickerWidth }]}>
{this._renderWheel(this.state.pickerData)} {this._renderWheel(this.state.pickerData)}
</View> </View>
</Animated.View> </Animated.View>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment