Skip to content

Commit

Permalink
Fixed scrollTo first section (#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
souhe authored and adamTrz committed Jan 30, 2018
1 parent ecffccd commit 1ac3f6b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/components/GroupedList/GroupedList.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,10 @@ class GroupedList extends React.PureComponent<Props, State> {

if (this.sectionList) {
this.sectionList.scrollToLocation({
viewOffset: this.props.stickySectionHeadersEnabled
? this.sectionHeadersHeights[sections[index]]
: 0,
viewOffset:
this.props.stickySectionHeadersEnabled !== false
? this.sectionHeadersHeights[sections[index]]
: 0,
sectionIndex: index,
itemIndex: 0,
animated: false,
Expand Down
4 changes: 2 additions & 2 deletions src/components/GroupedList/Sections.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ class Sections extends PureComponent<Props, State> {
return;
}

const sectionIdx = Math.floor(
const sectionIdx = Math.round(
(pageY - this.sectionsY) * this.props.items.length / this.sectionsHeight
);
if (
sectionIdx > 0 &&
sectionIdx >= 0 &&
sectionIdx < this.props.items.length &&
this.currentSectionIdx !== sectionIdx
) {
Expand Down

0 comments on commit 1ac3f6b

Please sign in to comment.