diff --git a/README.md b/README.md
index f8998e56674df7805f1cfa784ed326a44fe91dad..7076161c134526741f622ba416fa01b10a37f1f9 100644
--- a/README.md
+++ b/README.md
@@ -27,6 +27,7 @@ Needs react-native >= 0.14.2
- pickerCancelBtnText string, tool bar's cancel ben text
- pickerBtnStyle textStylePropType, tool bar's btn style
- pickerToolBarStyle viewStylePropType, tool bar's style
+- pickerWidth number, width of picker
- pickerHeight number, height of picker
- showDuration number, animation of picker
- pickerTitle string, title of picker
diff --git a/index.js b/index.js
index 4c614db353b9c82c449bbb183e1c2ca148880004..27f922fc2a103139efb9d53b92937bacd74db28d 100644
--- a/index.js
+++ b/index.js
@@ -28,6 +28,7 @@ export default class PickerAny extends React.Component {
pickerTitleStyle: PropTypes.any,
pickerToolBarStyle: PropTypes.any,
pickerItemStyle: PropTypes.any,
+ pickerWidth: PropTypes.number,
pickerHeight: PropTypes.number,
showDuration: PropTypes.number,
pickerData: PropTypes.any.isRequired,
@@ -44,7 +45,8 @@ export default class PickerAny extends React.Component {
showDuration: 300,
onPickerDone: ()=>{},
onPickerCancel: ()=>{},
- onValueChange: ()=>{}
+ onValueChange: ()=>{},
+ pickerWidth: width > height ? height:width
};
constructor(props, context){
@@ -61,6 +63,9 @@ export default class PickerAny extends React.Component {
}
shouldComponentUpdate(nextProps, nextState, context){
+ if(nextState.pickerWidth !== this.state.pickerWidth) {
+ return true;
+ }
if(JSON.stringify(nextState.selectedValue) === JSON.stringify(this.state.selectedValue)){
return false;
}
@@ -78,6 +83,7 @@ export default class PickerAny extends React.Component {
let pickerTitleStyle = props.pickerTitleStyle;
let pickerToolBarStyle = props.pickerToolBarStyle;
let pickerItemStyle = props.pickerItemStyle;
+ let pickerWidth = props.pickerWidth;
let pickerHeight = props.pickerHeight;
let showDuration = props.showDuration;
let pickerData = props.pickerData;
@@ -125,6 +131,7 @@ export default class PickerAny extends React.Component {
pickerTitleStyle,
pickerToolBarStyle,
pickerItemStyle,
+ pickerWidth,
pickerHeight,
showDuration,
pickerData,
@@ -341,7 +348,7 @@ export default class PickerAny extends React.Component {
);
return (
-
+
-
+
{this.state.pickerCancelBtnText}
@@ -487,7 +495,6 @@ export default class PickerAny extends React.Component {
let styles = StyleSheet.create({
picker: {
- width: width,
position: 'absolute',
bottom: 0,
left: 0,
@@ -495,7 +502,6 @@ let styles = StyleSheet.create({
overflow: 'hidden'
},
pickerWrap: {
- width: width,
flexDirection: 'row'
},
pickerWheel: {
@@ -503,7 +509,6 @@ let styles = StyleSheet.create({
},
pickerToolbar: {
height: 30,
- width: width,
backgroundColor: '#e6e6e6',
flexDirection: 'row',
borderTopWidth: 1,