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:
+9
-1
@@ -28,6 +28,14 @@ import {
|
||||
} from '$shared/lib';
|
||||
import { SvelteMap } from 'svelte/reactivity';
|
||||
|
||||
/**
|
||||
* Epsilon for detecting "significant" base-size changes when reconciling
|
||||
* the multiplier-derived display value back to the underlying baseSize.
|
||||
* Differences below this threshold are treated as rounding jitter and
|
||||
* skipped to avoid spurious storage writes.
|
||||
*/
|
||||
const BASE_SIZE_EPSILON = 0.01;
|
||||
|
||||
type ControlOnlyFields<T extends string = string> = Omit<ControlModel<T>, keyof ControlDataModel>;
|
||||
|
||||
/**
|
||||
@@ -139,7 +147,7 @@ export class TypographySettingsStore {
|
||||
const calculatedBase = currentDisplayValue / this.#multiplier;
|
||||
|
||||
// Only update if the difference is significant (prevents rounding jitter)
|
||||
if (Math.abs(this.#baseSize - calculatedBase) > 0.01) {
|
||||
if (Math.abs(this.#baseSize - calculatedBase) > BASE_SIZE_EPSILON) {
|
||||
this.#baseSize = calculatedBase;
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user