u
This commit is contained in:
@@ -121,6 +121,9 @@ class FillSpace extends Component {
|
|||||||
prevProps.items !== this.props.items ||
|
prevProps.items !== this.props.items ||
|
||||||
prevProps.header !== this.props.header
|
prevProps.header !== this.props.header
|
||||||
) {
|
) {
|
||||||
|
if (this.state.unitHeight <= 0) {
|
||||||
|
this._probeMeasure();
|
||||||
|
}
|
||||||
this._observe();
|
this._observe();
|
||||||
this._viewportMeasure();
|
this._viewportMeasure();
|
||||||
}
|
}
|
||||||
@@ -361,7 +364,14 @@ class FillSpace extends Component {
|
|||||||
}
|
}
|
||||||
const minSize = Math.max(1, Number(minPageSize) || 10);
|
const minSize = Math.max(1, Number(minPageSize) || 10);
|
||||||
const maxSize = Number(this.props.maxPageSize) > 0 ? Number(this.props.maxPageSize) : Infinity;
|
const maxSize = Number(this.props.maxPageSize) > 0 ? Number(this.props.maxPageSize) : Infinity;
|
||||||
const { unitHeight } = this.state;
|
let { unitHeight } = this.state;
|
||||||
|
if (unitHeight <= 0) {
|
||||||
|
const firstRow = this.ref?.querySelector('[data-fill-row]');
|
||||||
|
const h = this.probeRef?.offsetHeight || firstRow?.offsetHeight;
|
||||||
|
if (h > 0) {
|
||||||
|
unitHeight = h;
|
||||||
|
}
|
||||||
|
}
|
||||||
const calculated =
|
const calculated =
|
||||||
unitHeight > 0 ? Math.max(minSize, Math.floor(available / unitHeight)) : minSize;
|
unitHeight > 0 ? Math.max(minSize, Math.floor(available / unitHeight)) : minSize;
|
||||||
const nextPageSize = Math.min(maxSize, calculated);
|
const nextPageSize = Math.min(maxSize, calculated);
|
||||||
@@ -369,11 +379,18 @@ class FillSpace extends Component {
|
|||||||
Number.isFinite(maxSize) && unitHeight > 0
|
Number.isFinite(maxSize) && unitHeight > 0
|
||||||
? Math.min(available, nextPageSize * unitHeight)
|
? Math.min(available, nextPageSize * unitHeight)
|
||||||
: available;
|
: available;
|
||||||
if (
|
const updates = {};
|
||||||
nextViewportHeight !== this.state.viewportHeight ||
|
if (nextViewportHeight !== this.state.viewportHeight) {
|
||||||
nextPageSize !== this.state.pageSize
|
updates.viewportHeight = nextViewportHeight;
|
||||||
) {
|
}
|
||||||
this.setState({ viewportHeight: nextViewportHeight, pageSize: nextPageSize });
|
if (nextPageSize !== this.state.pageSize) {
|
||||||
|
updates.pageSize = nextPageSize;
|
||||||
|
}
|
||||||
|
if (unitHeight > 0 && unitHeight !== this.state.unitHeight) {
|
||||||
|
updates.unitHeight = unitHeight;
|
||||||
|
}
|
||||||
|
if (Object.keys(updates).length > 0) {
|
||||||
|
this.setState(updates);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user