* Determines whether a note and a block overlapped at their pre-layout * positions. Used by targeted layout to distinguish overlaps introduced by the * current pass from arrangements that already existed.
( previousBlocks: Record<string, BlockState>, noteId: string, blockId: string )
| 356 | * current pass from arrangements that already existed. |
| 357 | */ |
| 358 | function noteOverlappedBlockBefore( |
| 359 | previousBlocks: Record<string, BlockState>, |
| 360 | noteId: string, |
| 361 | blockId: string |
| 362 | ): boolean { |
| 363 | const previousNote = previousBlocks[noteId] |
| 364 | const previousBlock = previousBlocks[blockId] |
| 365 | if (!previousNote || !previousBlock) return false |
| 366 | |
| 367 | // A block without a finite prior position was not yet placed on the canvas, |
| 368 | // so it could not have overlapped anything before this pass. |
| 369 | if (!hasFinitePosition(previousNote) || !hasFinitePosition(previousBlock)) return false |
| 370 | |
| 371 | // Derive dimensions from the prior blocks so a resize between passes does not |
| 372 | // pair new dimensions with the old position. |
| 373 | const noteBox = createBoundingBox(previousNote.position, getNoteDimensions(previousNote)) |
| 374 | const blockBox = createBoundingBox(previousBlock.position, getBlockMetrics(previousBlock)) |
| 375 | return boxesOverlap(blockBox, noteBox) |
| 376 | } |
| 377 | |
| 378 | export interface ResolveNoteOverlapsOptions { |
| 379 | /** |
no test coverage detected