refactor: extract magic constants — wave 4 (UX timings + physics)
Name throttle/debounce intervals, spring presets, and layout paddings
that were inline numeric literals:
- VirtualList: VISIBLE_CHANGE_THROTTLE_MS (150), NEAR_BOTTOM_THROTTLE_MS
(200), JUMP_THROTTLE_MS (200)
- SampleList: CHECK_POSITION_THROTTLE_MS (100)
- SliderArea: SLIDER_SPRING_CONFIG ({stiffness: 0.2, damping: 0.7}),
SLIDER_PERSIST_DEBOUNCE_MS (100), SLIDER_PADDING_MOBILE_PX (48),
SLIDER_PADDING_DESKTOP_PX (96)
- FontVirtualList: TOUCH_DEBOUNCE_MS (150)
- createPerspectiveManager: PERSPECTIVE_SPRING_CONFIG ({stiffness: 0.2,
damping: 0.8})
No behavior changes — values preserved exactly.
This commit is contained in:
@@ -36,6 +36,12 @@ const SAMPLER_CONTENT_PADDING_X = 32;
|
||||
// Matches the previous hardcoded itemHeight={220} value to avoid regressions.
|
||||
const SAMPLER_FALLBACK_HEIGHT = 220;
|
||||
|
||||
/**
|
||||
* Throttle for the `checkPosition` scroll observer. Trades responsiveness
|
||||
* of the perspective tilt against scroll-handler cost.
|
||||
*/
|
||||
const CHECK_POSITION_THROTTLE_MS = 100;
|
||||
|
||||
let text = $state('The quick brown fox jumps over the lazy dog...');
|
||||
let wrapper = $state<HTMLDivElement | null>(null);
|
||||
// Binds to the actual window height
|
||||
@@ -54,7 +60,7 @@ const checkPosition = throttle(() => {
|
||||
const viewportMiddle = innerHeight / 2;
|
||||
|
||||
isAboveMiddle = rect.top < viewportMiddle;
|
||||
}, 100);
|
||||
}, CHECK_POSITION_THROTTLE_MS);
|
||||
|
||||
// Resolver recreated when typography values change. The returned closure reads
|
||||
// fontLifecycleManager.statuses (a SvelteMap) on every call, so any font status
|
||||
|
||||
Reference in New Issue
Block a user