Desktop: Fixes #2122: Fix Goto Anything scrolling issue (#2199)

* Fix Goto scrolling (#2122)

* Better fix to Goto scrolling (#2122)

* Fix #2122: fix bottomItemIndex and top values
pull/2238/head
Rafael Cavalcanti 2019-12-28 18:53:21 -03:00 committed by Laurent Cozic
parent 90de63e650
commit c8a0138b3b
1 changed files with 2 additions and 2 deletions

View File

@ -23,7 +23,7 @@ class ItemList extends React.Component {
const topItemIndex = Math.floor(this.scrollTop_ / props.itemHeight); const topItemIndex = Math.floor(this.scrollTop_ / props.itemHeight);
const visibleItemCount = this.visibleItemCount(props); const visibleItemCount = this.visibleItemCount(props);
let bottomItemIndex = topItemIndex + visibleItemCount; let bottomItemIndex = topItemIndex + (visibleItemCount - 1);
if (bottomItemIndex >= props.items.length) bottomItemIndex = props.items.length - 1; if (bottomItemIndex >= props.items.length) bottomItemIndex = props.items.length - 1;
this.setState({ this.setState({
@ -50,7 +50,7 @@ class ItemList extends React.Component {
} }
makeItemIndexVisible(itemIndex) { makeItemIndexVisible(itemIndex) {
const top = Math.min(this.props.items.length - 1, this.state.topItemIndex + 1); const top = Math.min(this.props.items.length - 1, this.state.topItemIndex);
const bottom = Math.max(0, this.state.bottomItemIndex); const bottom = Math.max(0, this.state.bottomItemIndex);
if (itemIndex >= top && itemIndex <= bottom) return; if (itemIndex >= top && itemIndex <= bottom) return;