Skip to content

Commit

Permalink
not set overflow style if height is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
zombieJ committed Aug 1, 2019
1 parent 5696901 commit 887297f
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ import {
} from './utils/itemUtil';
import { getIndexByStartLoc, findListDiffIndex } from './utils/algorithmUtil';

const ScrollStyle = {
overflowY: 'auto',
overflowAnchor: 'none',
};

type RenderFunc<T> = (
item: T,
index: number,
Expand Down Expand Up @@ -437,22 +442,22 @@ class List<T> extends React.Component<ListProps<T>, ListState<T>> {
...restProps
} = this.props;

const mergedStyle = {
...style,
height,
overflowY: 'auto',
overflowAnchor: 'none',
};

// Render pure list if not set height or height is enough for all items
if (height === undefined || data.length * itemHeight <= height) {
return (
<Component style={mergedStyle} {...restProps}>
<Component style={height ? { ...style, ...ScrollStyle } : style} {...restProps}>
<Filler height={height}>{this.renderChildren(data, 0, children)}</Filler>
</Component>
);
}

// Use virtual list
const mergedStyle = {
...style,
height,
...ScrollStyle,
};

const { status, startIndex, endIndex, startItemTop } = this.state;
const contentHeight = data.length * itemHeight * ITEM_SCALE_RATE;

Expand Down

0 comments on commit 887297f

Please sign in to comment.