Skip to content

Commit

Permalink
fix: picker on android close #117
Browse files Browse the repository at this point in the history
  • Loading branch information
BANG88 committed Dec 13, 2018
1 parent 4699831 commit 5099a7d
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions components/picker/NativePicker.android.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ export interface IPickerProp {
class Picker extends React.Component<IPickerProp & IPickerProps, any> {
itemHeight: number;
itemWidth: number;
scrollBuffer: any;
scrollerRef: any;
contentRef: any;
indicatorRef: any;
scrollBuffer: number;
scrollerRef: ScrollView | null;
contentRef: View | null;
indicatorRef: View | null;

onItemLayout = (e: any) => {
const { height, width } = e.nativeEvent.layout;
Expand All @@ -65,7 +65,7 @@ class Picker extends React.Component<IPickerProp & IPickerProps, any> {
if (this.itemHeight !== height) {
this.itemHeight = height;
if (this.scrollerRef) {
this.scrollerRef.setNativeProps({
(this.scrollerRef as any).setNativeProps({
style: {
height: height * 7,
},
Expand Down Expand Up @@ -129,7 +129,7 @@ class Picker extends React.Component<IPickerProp & IPickerProps, any> {
this.scrollBuffer = setTimeout(() => {
this.clearScrollBuffer();
this.props.doScrollingComplete(y, this.itemHeight, this.fireValueChange);
}, 100);
}, 50);
};

render() {
Expand All @@ -146,7 +146,10 @@ class Picker extends React.Component<IPickerProp & IPickerProps, any> {
onLayout={index === 0 ? this.onItemLayout : undefined}
key={item.key}
>
<Text style={totalStyle} numberOfLines={1}>
<Text
style={[{ includeFontPadding: false }, totalStyle]}
numberOfLines={1}
>
{item.props.label}
</Text>
</View>
Expand All @@ -161,6 +164,12 @@ class Picker extends React.Component<IPickerProp & IPickerProps, any> {
onScroll={this.onScroll}
showsVerticalScrollIndicator={false}
overScrollMode="never"
renderToHardwareTextureAndroid
scrollEventThrottle={10}
needsOffscreenAlphaCompositing
collapsable
horizontal={false}
removeClippedSubviews
>
<View ref={el => (this.contentRef = el)}>{items}</View>
</ScrollView>
Expand Down

0 comments on commit 5099a7d

Please sign in to comment.