Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions SuperGridSectionList.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class SuperGridSectionList extends Component {
}
}


onLayout(e) {
const { staticDimension, onLayout } = this.props;
if (!staticDimension) {
Expand All @@ -42,6 +42,17 @@ class SuperGridSectionList extends Component {
}
}

scrollToTop = () => {
if (this.refs.list) {
this.refs.list.scrollToLocation({
sectionIndex: 0,
itemIndex: 0,
viewPosition: 0,
animated: true,
});
}
}

getDimensions(lvDimension, itemDim) {
const { itemWidth, spacing, fixed, staticDimension } = this.props;
let itemDimension = itemDim || this.props.itemDimension;
Expand Down Expand Up @@ -111,12 +122,12 @@ class SuperGridSectionList extends Component {
const { itemsPerRow } = this.state;

//Deep copy, so that re-renders and chunkArray functions don't affect the actual items object
let sectionsCopy = cloneDeep(sections);
let sectionsCopy = cloneDeep(sections);

for (sectionsPair of sectionsCopy){

//Going through all the sections in sectionsCopy, and dividing their 'data' fields into smaller 'chunked' arrays to represent rows
const chunked = chunkArray(sectionsPair.data, itemsPerRow);
const chunked = chunkArray(sectionsPair.data, itemsPerRow);

//Now adding metadata to these rows
const rows = chunked.map((r, i) => {
Expand All @@ -131,6 +142,7 @@ class SuperGridSectionList extends Component {

return (
<SectionList
ref="list"
sections={sectionsCopy}
renderSectionHeader = {renderSectionHeader}
renderItem={this.renderHorizontalRow}
Expand Down