Skip to content

Commit 25272b1

Browse files
joshuapintergitim
authored andcommitted
Expose autoscrollAreaHeight as a prop instead of a constant.
Defaults to 60, but can be changed. Especially useful when row height or list is small.
1 parent 64fe9bc commit 25272b1

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/SortableList.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import {Animated, ScrollView, View, StyleSheet, Platform} from 'react-native';
33
import {shallowEqual, swapArrayElements} from './utils';
44
import Row from './Row';
55

6-
const AUTOSCROLL_AREA_HEIGTH = 60;
76
const AUTOSCROLL_INTERVAL = 100;
87
const ZINDEX = Platform.OS === 'ios' ? 'zIndex' : 'elevation';
98

@@ -27,11 +26,13 @@ export default class SortableList extends Component {
2726
onChangeOrder: PropTypes.func,
2827
onActivateRow: PropTypes.func,
2928
onReleaseRow: PropTypes.func,
29+
autoscrollAreaHeight: PropTypes.number,
3030
};
3131

3232
static defaultProps = {
3333
sortingEnabled: true,
3434
scrollEnabled: true,
35+
autoscrollAreaHeight: 60,
3536
}
3637

3738
/**
@@ -345,8 +346,8 @@ export default class SortableList extends Component {
345346
_scrollOnMove(e) {
346347
const {pageY} = e.nativeEvent;
347348
const {containerLayout} = this.state;
348-
const inAutoScrollUpArea = pageY < containerLayout.pageY + AUTOSCROLL_AREA_HEIGTH;
349-
const inAutoScrollDownArea = pageY > containerLayout.pageY + containerLayout.height - AUTOSCROLL_AREA_HEIGTH;
349+
const inAutoScrollUpArea = pageY < containerLayout.pageY + this.props.autoscrollAreaHeight;
350+
const inAutoScrollDownArea = pageY > containerLayout.pageY + containerLayout.height - this.props.autoscrollAreaHeight;
350351

351352
if (!inAutoScrollUpArea &&
352353
!inAutoScrollDownArea &&

0 commit comments

Comments
 (0)