mirror of
https://github.com/Matysh/houseplan-card
synced 2026-10-05 14:19:04 +00:00
fix: match wall thickness hover to masonry
Issue: #303 User-Visible: yes
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import { wallCmToUnits } from './wall-thickness';
|
||||
|
||||
/** Historical plan-cell size whose raw SVG constants define the visual baseline. */
|
||||
export const GRID_VISUAL_REFERENCE_CELL_CM = 5;
|
||||
|
||||
@@ -16,6 +18,20 @@ export function gridVisualUnits(baseUnits: number, cellCm: unknown): number {
|
||||
return baseUnits * gridVisualScale(cellCm);
|
||||
}
|
||||
|
||||
/** Half-width of the Plan-editor wall-thickness hover strip, in plan units. */
|
||||
export function wallThickHoverHalfUnits(
|
||||
cm: number, cellCm: number, gridPitch: number,
|
||||
): number {
|
||||
const thicknessCm = Number.isFinite(cm) && cm > 0 ? cm : 0;
|
||||
const normalizedCellCm = Number.isFinite(cellCm) && cellCm > 0
|
||||
? cellCm
|
||||
: GRID_VISUAL_REFERENCE_CELL_CM;
|
||||
const normalizedPitch = Number.isFinite(gridPitch) && gridPitch > 0 ? gridPitch : 0;
|
||||
return thicknessCm > 0
|
||||
? wallCmToUnits(thicknessCm, normalizedCellCm, normalizedPitch) / 2
|
||||
: gridVisualUnits(normalizedPitch * 1.5, normalizedCellCm);
|
||||
}
|
||||
|
||||
/** Default only for newly-created spaces. Read compatibility keeps its own 5 cm fallback. */
|
||||
export function newSpaceCellCm(imperial: boolean): number {
|
||||
return imperial ? GRID_IMPERIAL_CELL_CM : 1;
|
||||
|
||||
Reference in New Issue
Block a user