Skip to content

Conversation

@deanlee
Copy link
Contributor

@deanlee deanlee commented Nov 26, 2025

Refactors the Scroller's snapping logic to eliminate physics conflicts, fix edge-case bugs, and reduce unnecessary CPU work.

Problems in Previous Snap Logic

  • Fighting Physics: It applies the snap offset on top of the scroll panel's momentum every frame. This causes jitter because the physics engine tries to decay velocity while the snapper forces movement.
  • Frame Rate Dependency: Dividing by 10 (/ 10) creates inconsistent snapping speeds depending on the FPS.
  • Edge Case Bugs: Clamping logic was error-prone, causing issues with small items at the edges.
  • Unnecessary CPU Work: All items were scanned every frame, even when already snapped.

Improvements

  • Snap logic is now state-aware and only runs once the scroll panel settles (no more fighting physics).
  • Snapping is velocity-gated, preventing interference during drag or high-speed flings.
  • Snap offset is computed as an absolute target position, not a per-frame delta.
  • Clamping uses true scroll bounds, fully fixing edge snap issues.
  • When stable, the scroller skips item scanning, saving cycles.

@github-actions github-actions bot added the ui label Nov 26, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Nov 26, 2025

raylib UI Preview

All Screenshots

@deanlee deanlee force-pushed the ui-enhance-scroll-snapping branch from f74b231 to 0403bea Compare November 26, 2025 15:10
@sshane
Copy link
Contributor

sshane commented Nov 27, 2025

This changes how it looks, we want snapping to work with the auto scroll decay so it's a smooth handoff. I agree it's way too complex, all the logic should be in one place

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants