Skip to content
Closed
Show file tree
Hide file tree
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
23 changes: 23 additions & 0 deletions source/MultiGrid/MultiGrid.jest.js
Original file line number Diff line number Diff line change
Expand Up @@ -712,4 +712,27 @@ describe('MultiGrid', () => {
expect(onScrollbarPresenceChange).not.toHaveBeenCalled();
});
});

describe('isScrolling', () => {
it('should be true for all cells being rendered while scrolling', () => {
const cellRenderer = jest.fn();

const component = render(
getMarkup({
cellRenderer,
}),
);
cellRenderer.mockReset();

component._bottomRightGrid.handleScrollEvent({
scrollTop: 100,
});
expect(cellRenderer).toHaveBeenCalled();

cellRenderer.mock.calls.forEach(call => {
const args = call[0];
expect(args.isScrolling).toBeTruthy();
});
});
});
});
9 changes: 8 additions & 1 deletion source/MultiGrid/MultiGrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ class MultiGrid extends React.PureComponent {

// scrollTop and scrollLeft props are explicitly filtered out and ignored

const {scrollLeft, scrollTop} = this.state;
const {scrollLeft, scrollTop, isScrolling} = this.state;

return (
<div style={this._containerOuterStyle}>
Expand All @@ -238,13 +238,15 @@ class MultiGrid extends React.PureComponent {
...rest,
onScroll,
scrollLeft,
isScrolling: isScrolling || undefined,
Comment thread
mauricedb marked this conversation as resolved.
})}
</div>
<div style={this._containerBottomStyle}>
{this._renderBottomLeftGrid({
...rest,
onScroll,
scrollTop,
isScrolling: isScrolling || undefined,
})}
{this._renderBottomRightGrid({
...rest,
Expand Down Expand Up @@ -559,9 +561,14 @@ class MultiGrid extends React.PureComponent {

_onScroll = scrollInfo => {
const {scrollLeft, scrollTop} = scrollInfo;
const isScrolling =
this.state.scrollTop !== scrollTop ||
this.state.scrollLeft !== scrollLeft;

this.setState({
scrollLeft,
scrollTop,
isScrolling,
});
const onScroll = this.props.onScroll;
if (onScroll) {
Expand Down