Fixed scrolling via jump list on series index
This commit is contained in:
parent
56a33e3b4c
commit
5d316ad7dc
|
@ -7,8 +7,6 @@ import { WindowScroller, Grid } from 'react-virtualized';
|
||||||
import hasDifferentItemsOrOrder from 'Utilities/Object/hasDifferentItemsOrOrder';
|
import hasDifferentItemsOrOrder from 'Utilities/Object/hasDifferentItemsOrOrder';
|
||||||
import styles from './VirtualTable.css';
|
import styles from './VirtualTable.css';
|
||||||
|
|
||||||
const ROW_HEIGHT = 38;
|
|
||||||
|
|
||||||
function overscanIndicesGetter(options) {
|
function overscanIndicesGetter(options) {
|
||||||
const {
|
const {
|
||||||
cellCount,
|
cellCount,
|
||||||
|
@ -47,8 +45,7 @@ class VirtualTable extends Component {
|
||||||
|
|
||||||
componentDidUpdate(prevProps, prevState) {
|
componentDidUpdate(prevProps, prevState) {
|
||||||
const {
|
const {
|
||||||
items,
|
items
|
||||||
scrollIndex
|
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
@ -59,13 +56,6 @@ class VirtualTable extends Component {
|
||||||
// recomputeGridSize also forces Grid to discard its cache of rendered cells
|
// recomputeGridSize also forces Grid to discard its cache of rendered cells
|
||||||
this._grid.recomputeGridSize();
|
this._grid.recomputeGridSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scrollIndex != null && scrollIndex !== prevProps.scrollIndex) {
|
|
||||||
this._grid.scrollToCell({
|
|
||||||
rowIndex: scrollIndex,
|
|
||||||
columnIndex: 0
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -96,6 +86,8 @@ class VirtualTable extends Component {
|
||||||
header,
|
header,
|
||||||
headerHeight,
|
headerHeight,
|
||||||
rowRenderer,
|
rowRenderer,
|
||||||
|
rowHeight,
|
||||||
|
scrollIndex,
|
||||||
...otherProps
|
...otherProps
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
|
@ -125,6 +117,11 @@ class VirtualTable extends Component {
|
||||||
if (!height) {
|
if (!height) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const finalScrollTop = scrollIndex == null ?
|
||||||
|
scrollTop :
|
||||||
|
scrollIndex * rowHeight;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Measure
|
<Measure
|
||||||
whitelist={['width']}
|
whitelist={['width']}
|
||||||
|
@ -144,11 +141,11 @@ class VirtualTable extends Component {
|
||||||
width={width}
|
width={width}
|
||||||
height={height}
|
height={height}
|
||||||
headerHeight={height - headerHeight}
|
headerHeight={height - headerHeight}
|
||||||
rowHeight={ROW_HEIGHT}
|
rowHeight={rowHeight}
|
||||||
rowCount={items.length}
|
rowCount={items.length}
|
||||||
columnCount={1}
|
columnCount={1}
|
||||||
columnWidth={width}
|
columnWidth={width}
|
||||||
scrollTop={scrollTop}
|
scrollTop={finalScrollTop}
|
||||||
onScroll={onChildScroll}
|
onScroll={onChildScroll}
|
||||||
overscanRowCount={2}
|
overscanRowCount={2}
|
||||||
cellRenderer={rowRenderer}
|
cellRenderer={rowRenderer}
|
||||||
|
|
|
@ -270,6 +270,7 @@ SeriesIndexOverview.propTypes = {
|
||||||
};
|
};
|
||||||
|
|
||||||
SeriesIndexOverview.defaultProps = {
|
SeriesIndexOverview.defaultProps = {
|
||||||
|
overview: '',
|
||||||
statistics: {
|
statistics: {
|
||||||
seasonCount: 0,
|
seasonCount: 0,
|
||||||
episodeCount: 0,
|
episodeCount: 0,
|
||||||
|
|
|
@ -71,7 +71,6 @@ class SeriesIndexOverviews extends Component {
|
||||||
items,
|
items,
|
||||||
sortKey,
|
sortKey,
|
||||||
overviewOptions,
|
overviewOptions,
|
||||||
jumpToCharacter,
|
|
||||||
isSmallScreen
|
isSmallScreen
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
|
@ -96,18 +95,6 @@ class SeriesIndexOverviews extends Component {
|
||||||
// recomputeGridSize also forces Grid to discard its cache of rendered cells
|
// recomputeGridSize also forces Grid to discard its cache of rendered cells
|
||||||
this._grid.recomputeGridSize();
|
this._grid.recomputeGridSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (jumpToCharacter != null && jumpToCharacter !== prevProps.jumpToCharacter) {
|
|
||||||
const index = getIndexOfFirstCharacter(items, jumpToCharacter);
|
|
||||||
|
|
||||||
if (this._grid && index != null) {
|
|
||||||
|
|
||||||
this._grid.scrollToCell({
|
|
||||||
rowIndex: index,
|
|
||||||
columnIndex: 0
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -201,6 +188,7 @@ class SeriesIndexOverviews extends Component {
|
||||||
const {
|
const {
|
||||||
scroller,
|
scroller,
|
||||||
items,
|
items,
|
||||||
|
jumpToCharacter,
|
||||||
isSmallScreen
|
isSmallScreen
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
|
@ -222,6 +210,24 @@ class SeriesIndexOverviews extends Component {
|
||||||
return <div />;
|
return <div />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let finalScrollTop = scrollTop;
|
||||||
|
|
||||||
|
if (jumpToCharacter != null) {
|
||||||
|
const index = getIndexOfFirstCharacter(items, jumpToCharacter);
|
||||||
|
|
||||||
|
if (index != null) {
|
||||||
|
if (index > 0) {
|
||||||
|
// Adjust 5px upwards so there is a gap between the bottom
|
||||||
|
// of the toolbar and top of the poster.
|
||||||
|
|
||||||
|
finalScrollTop = rowHeight * index - 5;
|
||||||
|
} else {
|
||||||
|
finalScrollTop = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div ref={registerChild}>
|
<div ref={registerChild}>
|
||||||
<Grid
|
<Grid
|
||||||
|
@ -235,7 +241,7 @@ class SeriesIndexOverviews extends Component {
|
||||||
rowHeight={rowHeight}
|
rowHeight={rowHeight}
|
||||||
width={width}
|
width={width}
|
||||||
onScroll={onChildScroll}
|
onScroll={onChildScroll}
|
||||||
scrollTop={scrollTop}
|
scrollTop={finalScrollTop}
|
||||||
overscanRowCount={2}
|
overscanRowCount={2}
|
||||||
cellRenderer={this.cellRenderer}
|
cellRenderer={this.cellRenderer}
|
||||||
scrollToAlignment={'start'}
|
scrollToAlignment={'start'}
|
||||||
|
|
|
@ -114,7 +114,6 @@ class SeriesIndexPosters extends Component {
|
||||||
items,
|
items,
|
||||||
sortKey,
|
sortKey,
|
||||||
posterOptions,
|
posterOptions,
|
||||||
jumpToCharacter,
|
|
||||||
isSmallScreen
|
isSmallScreen
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
|
@ -139,19 +138,6 @@ class SeriesIndexPosters extends Component {
|
||||||
// recomputeGridSize also forces Grid to discard its cache of rendered cells
|
// recomputeGridSize also forces Grid to discard its cache of rendered cells
|
||||||
this._grid.recomputeGridSize();
|
this._grid.recomputeGridSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (jumpToCharacter != null && jumpToCharacter !== prevProps.jumpToCharacter) {
|
|
||||||
const index = getIndexOfFirstCharacter(items, jumpToCharacter);
|
|
||||||
|
|
||||||
if (this._grid && index != null) {
|
|
||||||
const row = Math.floor(index / columnCount);
|
|
||||||
|
|
||||||
this._grid.scrollToCell({
|
|
||||||
rowIndex: row,
|
|
||||||
columnIndex: 0
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -256,6 +242,7 @@ class SeriesIndexPosters extends Component {
|
||||||
const {
|
const {
|
||||||
scroller,
|
scroller,
|
||||||
items,
|
items,
|
||||||
|
jumpToCharacter,
|
||||||
isSmallScreen
|
isSmallScreen
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
|
@ -281,6 +268,18 @@ class SeriesIndexPosters extends Component {
|
||||||
return <div />;
|
return <div />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let finalScrollTop = scrollTop;
|
||||||
|
|
||||||
|
if (jumpToCharacter != null) {
|
||||||
|
const index = getIndexOfFirstCharacter(items, jumpToCharacter);
|
||||||
|
|
||||||
|
if (index != null) {
|
||||||
|
const row = Math.floor(index / columnCount);
|
||||||
|
|
||||||
|
finalScrollTop = rowHeight * row;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div ref={registerChild}>
|
<div ref={registerChild}>
|
||||||
<Grid
|
<Grid
|
||||||
|
@ -294,7 +293,7 @@ class SeriesIndexPosters extends Component {
|
||||||
rowHeight={rowHeight}
|
rowHeight={rowHeight}
|
||||||
width={width}
|
width={width}
|
||||||
onScroll={onChildScroll}
|
onScroll={onChildScroll}
|
||||||
scrollTop={scrollTop}
|
scrollTop={finalScrollTop}
|
||||||
overscanRowCount={2}
|
overscanRowCount={2}
|
||||||
cellRenderer={this.cellRenderer}
|
cellRenderer={this.cellRenderer}
|
||||||
scrollToAlignment={'start'}
|
scrollToAlignment={'start'}
|
||||||
|
|
Loading…
Reference in New Issue