fixes
This commit is contained in:
parent
d3fba7fd5f
commit
486674c442
1 changed files with 10 additions and 4 deletions
|
|
@ -80,16 +80,18 @@ export const NewVideoGrid: FC<Props> = ({ items, children }) => {
|
||||||
|
|
||||||
const slotCells = useMemo(() => cells.filter(cell => cell.slot), [cells])
|
const slotCells = useMemo(() => cells.filter(cell => cell.slot), [cells])
|
||||||
|
|
||||||
const tiles: Tile[] = useMemo(() => slotRects.map((slot, i) => {
|
const tiles: Tile[] = useMemo(() => slotRects.flatMap((slot, i) => {
|
||||||
const cell = slotCells[i]
|
const cell = slotCells[i]
|
||||||
return {
|
if (cell === undefined) return []
|
||||||
|
|
||||||
|
return [{
|
||||||
item: cell.item,
|
item: cell.item,
|
||||||
x: slot.x,
|
x: slot.x,
|
||||||
y: slot.y,
|
y: slot.y,
|
||||||
width: slot.width,
|
width: slot.width,
|
||||||
height: slot.height,
|
height: slot.height,
|
||||||
dragging: false,
|
dragging: false,
|
||||||
}
|
}]
|
||||||
}), [slotRects, cells])
|
}), [slotRects, cells])
|
||||||
|
|
||||||
const [tileTransitions] = useTransition(tiles, () => ({
|
const [tileTransitions] = useTransition(tiles, () => ({
|
||||||
|
|
@ -109,7 +111,11 @@ export const NewVideoGrid: FC<Props> = ({ items, children }) => {
|
||||||
|
|
||||||
// Render nothing if the bounds are not yet known
|
// Render nothing if the bounds are not yet known
|
||||||
if (gridBounds.width === 0) {
|
if (gridBounds.width === 0) {
|
||||||
return <div ref={gridRef} className={styles.grid} />
|
return <div ref={gridRef} className={styles.grid}>
|
||||||
|
{/* It's important that we always attach slotGridRef to something,
|
||||||
|
or else we may not receive the initial slot rects. */}
|
||||||
|
<div ref={slotGridRef} className={styles.slotGrid} />
|
||||||
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue