Expand description
Scroll physics timer callback — the core of the timer-based scroll architecture.
This module implements the scroll physics as a regular timer callback, using
the same transactional push_change(CallbackChange::ScrollTo) pattern as all
other state modifications. There is nothing special about the scroll timer —
it is a normal user-space timer that happens to be started by the framework.
§Architecture
Platform Event Handler
→ ScrollManager.record_scroll_input(ScrollInput)
→ starts SCROLL_MOMENTUM_TIMER if not running
Timer fires (every timer_interval_ms from ScrollPhysics):
1. queue.take_recent(100) — consume up to 100 most recent inputs
2. For each input:
- TrackpadContinuous → set offset directly (OS handles momentum)
- WheelDiscrete → add impulse to velocity
- Programmatic → set target position
3. Integrate physics: velocity decay, clamping
4. push_change(CallbackChange::ScrollTo) for each updated node
5. Return continue_and_update() or terminate_unchanged()§Key Design Decisions
- No mutable access to LayoutWindow needed: Uses
CallbackChange::ScrollTo(the same transactional pattern as all other callbacks). - Shared queue via Arc
: The ScrollInputQueueis cloned into the timer’sRefAnydata. Event handlers push, timer pops. - Platform-independent: Works on macOS, Windows, Linux — anywhere timers work.
- Self-terminating: When all velocities are below threshold and no inputs
pending, the timer returns
TerminateTimer::Terminate.
Structs§
- Node
Scroll Physics - Per-node scroll physics state
- Scroll
Physics State - State stored in the timer’s RefAny data.
Functions§
- scroll_
physics_ timer_ callback - The scroll physics timer callback.