Skip to content

Commit 30cffa4

Browse files
committed
Add getItemLayout prop default for smooth fast scrolling
1 parent 8e4eb80 commit 30cffa4

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lib/QuickScrollList.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,15 @@ class FastScroll extends React.Component {
109109
return prop;
110110
}
111111

112+
itemLayout = () => {
113+
const { itemHeight, getItemLayout } = this.props;
114+
return getItemLayout
115+
? getItemLayout
116+
: (data, index) => {
117+
return { length: itemHeight, offset: itemHeight * index, index };
118+
};
119+
};
120+
112121
render() {
113122
//prettier-ignore
114123
const { thumbHeight, thumbStyle, scrollbarStyle, containerStyle, viewportHeight, touchAreaWidth } = this.props;
@@ -128,6 +137,7 @@ class FastScroll extends React.Component {
128137
onScrollEndDrag={this.onScrollEnd}
129138
showsVerticalScrollIndicator={false}
130139
onScrollToIndexFailed={() => {}}
140+
getItemLayout={this.itemLayout()}
131141
/>
132142
<Animated.View
133143
style={[

0 commit comments

Comments
 (0)