diff --git a/frontend/src/Author/Index/Banners/AuthorIndexBanners.js b/frontend/src/Author/Index/Banners/AuthorIndexBanners.js index e7dd49135..2b063454d 100644 --- a/frontend/src/Author/Index/Banners/AuthorIndexBanners.js +++ b/frontend/src/Author/Index/Banners/AuthorIndexBanners.js @@ -100,7 +100,8 @@ class AuthorIndexBanners extends Component { columnCount: 1, bannerWidth: 476, bannerHeight: 88, - rowHeight: calculateRowHeight(88, null, props.isSmallScreen, {}) + rowHeight: calculateRowHeight(88, null, props.isSmallScreen, {}), + scrollRestored: false }; this._isInitialized = false; @@ -120,7 +121,8 @@ class AuthorIndexBanners extends Component { width, columnWidth, columnCount, - rowHeight + rowHeight, + scrollRestored } = this.state; if (prevProps.sortKey !== sortKey || @@ -138,6 +140,11 @@ class AuthorIndexBanners extends Component { this._grid.recomputeGridSize(); } + if (this._grid && scrollTop !== 0 && !scrollRestored) { + this.setState({ scrollRestored: true }); + this._grid.scrollToPosition({ scrollTop }); + } + if (jumpToCharacter != null && jumpToCharacter !== prevProps.jumpToCharacter) { const index = getIndexOfFirstCharacter(items, jumpToCharacter); @@ -151,9 +158,6 @@ class AuthorIndexBanners extends Component { } } - if (this._grid && scrollTop !== 0) { - this._grid.scrollToPosition({ scrollTop }); - } } // diff --git a/frontend/src/Author/Index/Overview/AuthorIndexOverviews.js b/frontend/src/Author/Index/Overview/AuthorIndexOverviews.js index 4ce8caf8e..9cfac6096 100644 --- a/frontend/src/Author/Index/Overview/AuthorIndexOverviews.js +++ b/frontend/src/Author/Index/Overview/AuthorIndexOverviews.js @@ -60,7 +60,8 @@ class AuthorIndexOverviews extends Component { columnCount: 1, posterWidth: 238, posterHeight: 238, - rowHeight: calculateRowHeight(238, null, props.isSmallScreen, {}) + rowHeight: calculateRowHeight(238, null, props.isSmallScreen, {}), + scrollRestored: false }; this._grid = null; @@ -77,7 +78,8 @@ class AuthorIndexOverviews extends Component { const { width, - rowHeight + rowHeight, + scrollRestored } = this.state; if (prevProps.sortKey !== sortKey || @@ -93,6 +95,11 @@ class AuthorIndexOverviews extends Component { this._grid.recomputeGridSize(); } + if (this._grid && scrollTop !== 0 && !scrollRestored) { + this.setState({ scrollRestored: true }); + this._grid.scrollToPosition({ scrollTop }); + } + if (jumpToCharacter != null && jumpToCharacter !== prevProps.jumpToCharacter) { const index = getIndexOfFirstCharacter(items, jumpToCharacter); @@ -104,10 +111,6 @@ class AuthorIndexOverviews extends Component { }); } } - - if (this._grid && scrollTop !== 0) { - this._grid.scrollToPosition({ scrollTop }); - } } // diff --git a/frontend/src/Author/Index/Posters/AuthorIndexPosters.js b/frontend/src/Author/Index/Posters/AuthorIndexPosters.js index 47646840e..7675bdaae 100644 --- a/frontend/src/Author/Index/Posters/AuthorIndexPosters.js +++ b/frontend/src/Author/Index/Posters/AuthorIndexPosters.js @@ -100,7 +100,8 @@ class AuthorIndexPosters extends Component { columnCount: 1, posterWidth: 238, posterHeight: 238, - rowHeight: calculateRowHeight(238, null, props.isSmallScreen, {}) + rowHeight: calculateRowHeight(238, null, props.isSmallScreen, {}), + scrollRestored: false }; this._isInitialized = false; @@ -122,7 +123,8 @@ class AuthorIndexPosters extends Component { width, columnWidth, columnCount, - rowHeight + rowHeight, + scrollRestored } = this.state; if (prevProps.sortKey !== sortKey || @@ -140,6 +142,11 @@ class AuthorIndexPosters extends Component { this._grid.recomputeGridSize(); } + if (this._grid && scrollTop !== 0 && !scrollRestored) { + this.setState({ scrollRestored: true }); + this._grid.scrollToPosition({ scrollTop }); + } + if (jumpToCharacter != null && jumpToCharacter !== prevProps.jumpToCharacter) { const index = getIndexOfFirstCharacter(items, jumpToCharacter); @@ -152,10 +159,6 @@ class AuthorIndexPosters extends Component { }); } } - - if (this._grid && scrollTop !== 0) { - this._grid.scrollToPosition({ scrollTop }); - } } // diff --git a/frontend/src/Components/Table/VirtualTable.js b/frontend/src/Components/Table/VirtualTable.js index 55e701778..6d9e337e2 100644 --- a/frontend/src/Components/Table/VirtualTable.js +++ b/frontend/src/Components/Table/VirtualTable.js @@ -37,7 +37,8 @@ class VirtualTable extends Component { super(props, context); this.state = { - width: 0 + width: 0, + scrollRestored: false }; this._grid = null; @@ -52,7 +53,8 @@ class VirtualTable extends Component { } = this.props; const { - width + width, + scrollRestored } = this.state; if (this._grid && @@ -63,16 +65,17 @@ class VirtualTable extends Component { this._grid.recomputeGridSize(); } + if (this._grid && scrollTop !== undefined && scrollTop !== 0 && !scrollRestored) { + this.setState({ scrollRestored: true }); + this._grid.scrollToPosition({ scrollTop }); + } + if (scrollIndex != null && scrollIndex !== prevProps.scrollIndex) { this._grid.scrollToCell({ rowIndex: scrollIndex, columnIndex: 0 }); } - - if (this._grid && scrollTop !== undefined && scrollTop !== 0) { - this._grid.scrollToPosition({ scrollTop }); - } } //