Show 'show more' when there are less tiles than the default

For example, if you only have 3/10 rooms required for the default then resize smaller, we should have a 'show more' button.

This works by changing the rendering to be slightly more efficient and only looping over what is seen (renderVisibleTiles(), using this.numTiles in place of tiles.length) and using a new setVisibleTilesWithin() function on the layout. Previously resizing the 3/10 case would be setting visibleTiles to ~8 instead of ~1 like it should (because the getter returns a default).
This commit is contained in:
Travis Ralston 2020-06-30 19:14:36 -06:00
parent 8cfe12b817
commit 7674030c6e
2 changed files with 31 additions and 16 deletions

View file

@ -89,6 +89,14 @@ export class ListLayout {
return 10 + RESIZER_BOX_FACTOR;
}
public setVisibleTilesWithin(diff: number, maxPossible: number) {
if (this.visibleTiles > maxPossible) {
this.visibleTiles = maxPossible + diff;
} else {
this.visibleTiles += diff;
}
}
public calculateTilesToPixelsMin(maxTiles: number, n: number, possiblePadding: number): number {
// Only apply the padding if we're about to use maxTiles as we need to
// plan for the padding. If we're using n, the padding is already accounted