Skip to content

Commit

Permalink
Merge pull request #82 from bolan9999/KeyboardShouldPersistTaps
Browse files Browse the repository at this point in the history
Add props "keyboardShouldPersistTaps"
  • Loading branch information
石破天惊 authored Feb 5, 2018
2 parents 75fdab3 + 165c59f commit f7922a7
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 5 deletions.
8 changes: 8 additions & 0 deletions README-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,11 @@ onScroll | ({nativeEvent:{contentOffset:{x:number,y:number}}})=> any | | 滑动
* default: ()=>null
* LargeList在渲染完成或reloadData 完成后的回调,请注意,在您的视图中componentDidUpdate是不准确的,因为LargeList需要先测量头部、尾部、空视图宽高,再更新,每次更新LargeList都需要render两次

### keyboardShouldPersistTaps
* type: enum('always', 'never', 'handled', false, true)
* default: 'never'
* 与ScrollView的keyboardShouldPersistTaps相同

## 方法
### scrollTo(offset:Offset, animated:boolean=true)
滑动到目标偏移Offset:{x:number,y:number},目前x值只支持0
Expand Down Expand Up @@ -344,6 +349,9 @@ onScroll | ({nativeEvent:{contentOffset:{x:number,y:number}}})=> any | | 滑动

## 更新日志

### 版本 1.2.6
* 添加属性keyboardShouldPersistTaps

### 版本 1.2.5
* 修复reloadData有时Section样式不正确的问题

Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,11 @@ Notice: It is not recommended to use widthForLeftWhenSwipeOut and renderLeftWhen
* default: ()=>null
* Callback when LargeList render completed and reloadData completed.

### keyboardShouldPersistTaps
* type: enum('always', 'never', 'handled', false, true)
* default: 'never'
* Same as keyboardShouldPersistTaps on ScrollView

## Method
### scrollTo(offset:Offset, animated:boolean=true)
Scroll to offset.
Expand Down Expand Up @@ -336,6 +341,9 @@ Get LargeList's footer height

## Update Log

### Version 1.2.6
* Add prop "keyboardShouldPersistTaps"

### Version 1.2.5
* Fix section error when reloadData

Expand Down
20 changes: 16 additions & 4 deletions react-native-largelist/largelist/LargeList.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,14 @@ class LargeList extends React.Component {
initialOffsetY: PropTypes.number,
renderItemSeparator: PropTypes.func,

onLargeListDidUpdate: PropTypes.func
onLargeListDidUpdate: PropTypes.func,
keyboardShouldPersistTaps: PropTypes.oneOf([
"always",
"never",
"handled",
false,
true
])

// onIndexPathDidAppear: PropTypes.func,
// onIndexPathDidDisappear: PropTypes.func,
Expand Down Expand Up @@ -143,7 +150,8 @@ class LargeList extends React.Component {
initialOffsetY: 0,
renderItemSeparator: () =>
<View style={{ height: 1, backgroundColor: "#EEE", marginLeft: 16 }} />,
onLargeListDidUpdate: () => null
onLargeListDidUpdate: () => null,
keyboardShouldPersistTaps: "never"
};

sections: Element[] = [];
Expand Down Expand Up @@ -348,6 +356,7 @@ class LargeList extends React.Component {
bounces={this.props.bounces}
refreshControl={refreshControl}
contentContainerStyle={contentStyle}
keyboardShouldPersistTaps={this.props.keyboardShouldPersistTaps}
onLayout={this._onLayout.bind(this)}
style={{ flex: 1 }}
scrollEventThrottle={this.props.scrollEventThrottle}
Expand Down Expand Up @@ -399,12 +408,15 @@ class LargeList extends React.Component {
}

_createSection(section: number, top: number, refs: LargeListSection[]) {
let height = section>=0 && section< this.numberOfSections() ? this.props.heightForSection(section):0;
let height =
section >= 0 && section < this.numberOfSections()
? this.props.heightForSection(section)
: 0;
return (
<LargeListSection
ref={reference => reference && refs.push(reference)}
key={this.keyForCreating++}
style={[styles.absoluteStretch, { top: top, height:height }]}
style={[styles.absoluteStretch, { top: top, height: height }]}
numberOfSections={this.numberOfSections}
section={section}
renderSection={this.props.renderSection}
Expand Down
2 changes: 1 addition & 1 deletion react-native-largelist/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-largelist",
"version": "1.2.5",
"version": "1.2.6",
"private": false,
"description": "The best performance large list component which is much better than SectionList for React Native.",
"author": "bolan9999 <[email protected]>",
Expand Down

0 comments on commit f7922a7

Please sign in to comment.