Skip to content

Reset smooth scroll timer only if waking up the animation loop - #88

Merged
nihiL7331 merged 1 commit into
mainfrom
fix-smooth-scroll
Sep 21, 2026
Merged

nihiL7331 merged 1 commit into
mainfrom
fix-smooth-scroll

Conversation

@nihiL7331

Copy link
Copy Markdown
Owner

This PR fixes smooth scroll issues at high scrolling speeds. The issue in logic was that ctx->term.last_scroll_ms was updated unconditionally on every frame where it was scrolled, instead of on every frame where it was scrolled AND its the first frame of scrolling (on ctx->term.is_scrolling = 0 => ctx->term.is_scrolling = 1 switch).
This later caused the line:

float dt = (float)(now - ctx->term.last_scroll_ms);

to become 0, after which

float decay = dt * SFTE_TERM_SCROLL_DELAY;

became 0, causing the scroll y offset to not get updated in this line:

ctx->term.scroll_y_offset -= ctx->term.scroll_y_offset * decay

It's fixed by adding a simple if (!ctx->term.is_scrolling) check on the last_scroll_ms update.

@nihiL7331 nihiL7331 self-assigned this Sep 21, 2026
@nihiL7331
nihiL7331 merged commit 48cbb72 into main Sep 21, 2026
1 check passed
@nihiL7331
nihiL7331 deleted the fix-smooth-scroll branch September 21, 2026 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant