+
+Here's a [Code Sandbox demo](https://codesandbox.io/s/3vnx878jk5).
+
+### Why is my list blank when I scroll?
+
+If your list looks something like this...
+
+
+
+...then you probably forgot to use the `style` parameter! Libraries like react-window work by absolutely positioning the list items (via an inline style), so don't forget to attach it to the DOM element you render!
+
+
+
+### Can I lazy load data for my list?
+
+Yes. I recommend using the [`react-window-infinite-loader` package](https://npmjs.com/package/react-window-infinite-loader):
+
+
+
+Here's a [Code Sandbox demo](https://codesandbox.io/s/5wqo7z2np4).
+
+### Can I attach custom properties or event handlers?
+
+Yes, using the `outerElementType` prop.
+
+
+
+Here's a [Code Sandbox demo](https://codesandbox.io/s/4zqx79nww0).
+
+### Can I add gutter or padding between items?
+
+Yes, although it requires a bit of inline styling.
+
+
+
+Here's a [Code Sandbox demo](https://codesandbox.io/s/2w8wmlm89p).
+
+### Does this library support "sticky" items?
+
+Yes, although it requires a small amount of user code. Here are Code Sandbox demos for list and grids:
+* [List demo](https://codesandbox.io/s/0mk3qwpl4l)
+* [Grid demo](https://codesandbox.io/s/vqk32863wy)
+
## License
MIT © [bvaughn](https://github.com/bvaughn)
diff --git a/package.json b/package.json
index f56c7095..427d5ccb 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "react-window",
- "version": "1.6.0-alpha.1",
+ "version": "1.8.0-alpha.1",
"description":
"React components for efficiently rendering large, scrollable lists and tabular data",
"author":
@@ -61,7 +61,7 @@
},
"dependencies": {
"@babel/runtime": "^7.0.0",
- "memoize-one": "^3.1.1"
+ "memoize-one": ">=3.1.1 <6"
},
"peerDependencies": {
"react": "^15.0.0 || ^16.0.0",
@@ -95,13 +95,14 @@
"gh-pages": "^1.1.0",
"lint-staged": "^7.0.5",
"prettier": "^1.12.1",
- "react": "^16.7.0",
- "react-dom": "^16.7.0",
+ "react": "^16.8.4",
+ "react-dom": "^16.8.4",
+ "react-is": "^16.8.4",
"react-scripts": "^1.1.1",
"react-test-renderer": "^16.7.0",
- "rollup": "^0.65.0",
- "rollup-plugin-babel": "^4.0.2",
- "rollup-plugin-commonjs": "^8.2.1",
- "rollup-plugin-node-resolve": "^3.0.2"
+ "rollup": "^1.4.1",
+ "rollup-plugin-babel": "^4.3.2",
+ "rollup-plugin-commonjs": "^9.2.1",
+ "rollup-plugin-node-resolve": "^4.0.1"
}
}
diff --git a/rollup.config.js b/rollup.config.js
index 5d167d14..c05d722a 100644
--- a/rollup.config.js
+++ b/rollup.config.js
@@ -1,6 +1,7 @@
import babel from 'rollup-plugin-babel';
import commonjs from 'rollup-plugin-commonjs';
import nodeResolve from 'rollup-plugin-node-resolve';
+
import pkg from './package.json';
const input = './src/index.js';
diff --git a/src/DynamicSizeList.js b/src/DynamicSizeList.js
index 6ec34f0f..26149e65 100644
--- a/src/DynamicSizeList.js
+++ b/src/DynamicSizeList.js
@@ -152,7 +152,7 @@ const DynamicSizeList = createListComponent({
scrollOffset: number,
instanceProps: InstanceProps
): number => {
- const { direction, height, width } = props;
+ const { direction, layout, height, width } = props;
if (process.env.NODE_ENV !== 'production') {
const { lastMeasuredIndex } = instanceProps;
@@ -164,7 +164,9 @@ const DynamicSizeList = createListComponent({
}
}
- const size = (((direction === 'horizontal' ? width : height): any): number);
+ const size = (((direction === 'horizontal' || layout === 'horizontal'
+ ? width
+ : height): any): number);
const itemMetadata = getItemMetadata(props, index, instanceProps);
// Get estimated total size after ItemMetadata is computed,
@@ -225,9 +227,11 @@ const DynamicSizeList = createListComponent({
scrollOffset: number,
instanceProps: InstanceProps
): number => {
- const { direction, height, itemCount, width } = props;
+ const { direction, layout, height, itemCount, width } = props;
- const size = (((direction === 'horizontal' ? width : height): any): number);
+ const size = (((direction === 'horizontal' || layout === 'horizontal'
+ ? width
+ : height): any): number);
const itemMetadata = getItemMetadata(props, startIndex, instanceProps);
const maxOffset = scrollOffset + size;
@@ -325,7 +329,7 @@ const DynamicSizeList = createListComponent({
instance.forceUpdate();
} else {
const { scrollOffset } = instance.state;
- const { direction } = instance.props;
+ const { direction, layout } = instance.props;
// Adjusting scroll offset directly interrupts smooth scrolling for some browsers (e.g. Firefox).
// The relative scrollBy() method doesn't interrupt (or at least it won't as of Firefox v65).
@@ -335,10 +339,17 @@ const DynamicSizeList = createListComponent({
// $FlowFixMe Property scrollBy is missing in HTMLDivElement
if (typeof element.scrollBy === 'function') {
element.scrollBy(
- direction === 'horizontal' ? sizeDeltaForStateUpdate : 0,
- direction === 'horizontal' ? 0 : sizeDeltaForStateUpdate
+ direction === 'horizontal' || layout === 'horizontal'
+ ? sizeDeltaForStateUpdate
+ : 0,
+ direction === 'horizontal' || layout === 'horizontal'
+ ? 0
+ : sizeDeltaForStateUpdate
);
- } else if (direction === 'horizontal') {
+ } else if (
+ direction === 'horizontal' ||
+ layout === 'horizontal'
+ ) {
element.scrollLeft = scrollOffset;
} else {
element.scrollTop = scrollOffset;
@@ -418,6 +429,7 @@ const DynamicSizeList = createListComponent({
const {
children,
direction,
+ layout,
itemCount,
itemData,
itemKey = defaultItemKey,
@@ -451,6 +463,7 @@ const DynamicSizeList = createListComponent({
items.push(
createElement(ItemMeasurer, {
direction,
+ layout,
handleNewMeasurements,
index,
item,
diff --git a/src/FixedSizeGrid.js b/src/FixedSizeGrid.js
index f446acb8..6224f71d 100644
--- a/src/FixedSizeGrid.js
+++ b/src/FixedSizeGrid.js
@@ -27,7 +27,9 @@ const FixedSizeGrid = createGridComponent({
{ columnCount, columnWidth, width }: PropsDetermines the direction of text and horizontal scrolling.
+
+ This property also automatically sets the{' '}
+
+ CSS direction style
+ {' '}
+ for the grid component.
+
@@ -181,7 +206,7 @@ const PROPS = [
Called when the range of items rendered by the grid changes.
- This callback will only be called when item indices change. It will
+ This callback will only be called when item indices change. It will
not be called if items are re-rendered for other reasons (e.g. a
change in
By default, the Grid will scroll as little as possible to ensure the
item is visible. You can control the alignment of the item though by
- specifying a second alignment parameter. Acceptable values are:
+ specifying an
+ If either
See here for an example of this API.
@@ -405,6 +442,6 @@ const METHODS = [
Primary scroll direction of the list. Acceptable values are: Determines the direction of text and horizontal scrolling.
- Note that lists may scroll in both directions (depending on CSS) but
- content will only be windowed in the primary direction.
+ This property also automatically sets the{' '}
+
+ CSS Layout/orientation of the list. Acceptable values are:
+ Note that lists may scroll in both directions (depending on CSS) but
+ content will only be windowed in the layout direction specified.
+ isScrolling or data params).
align property. Acceptable values are:
+ auto (default) - Scroll as little as possible to ensure
+ the item is visible. (If the item is already visible, it won't
+ scroll at all.)
+ center - Center align the item within the grid.
end - Align the item to the bottom, right hand side of
+ the grid.
+ start - Align the item to the top, left hand of the
+ grid.
columnIndex or rowIndex are
+ omitted, scrollLeft or scrollTop will be
+ unchanged (respectively).
+
-
direction style
+ {' '}
+ for the list component.
+
+
RTL List
+ RTL Grid
+