refactor: extract magic constants — wave 5 (single-site thresholds)
Long-tail cleanup: threshold and default-value literals in shared helpers get named module-level constants. - CharacterComparisonEngine: CHAR_PROXIMITY_RANGE_PCT (5), DEFAULT_RENDER_SIZE_PX (16) — kept local instead of importing DEFAULT_FONT_SIZE from \$entities/Font because \$shared/lib cannot legally upward-import from \$entities per FSD (also avoids an init cycle through the mocks barrel). - typographySettingsStore: BASE_SIZE_EPSILON (0.01) — rounding-jitter guard for baseSize reconciliation. - createDebouncedState: DEFAULT_DEBOUNCE_MS (300) — exported so callers can mirror the default. - createVirtualizer: MEASUREMENT_EPSILON_PX (0.5) — minimum height delta before committing a re-measured row. - createPerspectiveManager: PERSPECTIVE_TOGGLE_THRESHOLD (0.5) — the halfway point on the 0-1 spring that flips isBack/isFront. Skipped #19 (PerspectivePlan defaults) per review — marginal gain.
This commit is contained in:
@@ -4,6 +4,12 @@
|
||||
* Used to render visible items with absolute positioning based on computed offsets.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Minimum height delta (in px) required to commit a re-measured row height.
|
||||
* Sub-pixel diffs are treated as measurement noise to avoid spurious re-flows.
|
||||
*/
|
||||
const MEASUREMENT_EPSILON_PX = 0.5;
|
||||
|
||||
export interface VirtualItem {
|
||||
/**
|
||||
* Index of the item in the data array
|
||||
@@ -381,8 +387,8 @@ export function createVirtualizer<T>(
|
||||
if (!isNaN(index)) {
|
||||
const oldHeight = measuredSizes[index];
|
||||
|
||||
// Only update if the height difference is significant (> 0.5px)
|
||||
if (oldHeight === undefined || Math.abs(oldHeight - height) > 0.5) {
|
||||
// Only update if the height difference is significant
|
||||
if (oldHeight === undefined || Math.abs(oldHeight - height) > MEASUREMENT_EPSILON_PX) {
|
||||
measurementBuffer[index] = height;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user