Skip to content

Commit 4dff559

Browse files
sam-n-johnstongitim
authored andcommitted
Added refreshControl to ScrollView (#43)
1 parent 081560a commit 4dff559

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ Called when the active row was released.
4444
- **onPressRow** (function)<br />
4545
`(key) => void`<br />
4646
Called when a row was pressed.
47+
- **refreshControl** (Object)<br />
48+
A RefreshControl that works the same way as a ScrollView's refreshControl.
4749

4850
#### Methods
4951
- **scrollBy(dy?, animated?)** scrolls by a given y offset, either immediately or with a smooth animation

src/SortableList.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, {Component, PropTypes} from 'react';
2-
import {Animated, ScrollView, View, StyleSheet, Platform} from 'react-native';
2+
import {Animated, ScrollView, View, StyleSheet, Platform, RefreshControl} from 'react-native';
33
import {shallowEqual, swapArrayElements} from './utils';
44
import Row from './Row';
55

@@ -21,6 +21,7 @@ export default class SortableList extends Component {
2121
sortingEnabled: PropTypes.bool,
2222
scrollEnabled: PropTypes.bool,
2323
horizontal: PropTypes.bool,
24+
refreshControl: PropTypes.object,
2425

2526
renderRow: PropTypes.func.isRequired,
2627

@@ -148,16 +149,27 @@ export default class SortableList extends Component {
148149
const {contentContainerStyle, horizontal, style: containerStyle} = this.props;
149150
const {contentHeight, contentWidth, scrollEnabled} = this.state;
150151
const innerContainerStyle = [styles.container];
152+
let refreshControl = this.props.refreshControl;
151153

152154
if (horizontal) {
153155
innerContainerStyle.push({width: contentWidth});
154156
} else {
155157
innerContainerStyle.push({height: contentHeight});
156158
}
157159

160+
if(refreshControl) {
161+
refreshControl=(
162+
<RefreshControl
163+
{...this.props.refreshControl.props}
164+
enabled={scrollEnabled}
165+
/>
166+
)
167+
}
168+
158169
return (
159170
<Animated.View style={containerStyle} ref={this._onRefContainer}>
160171
<ScrollView
172+
refreshControl={refreshControl}
161173
ref={this._onRefScrollView}
162174
horizontal={horizontal}
163175
contentContainerStyle={contentContainerStyle}

0 commit comments

Comments
 (0)