mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-04-10 13:02:59 +00:00
fix: reduce scroll catch-up steps to limit jitter (#219)
Reduce max_steps from 0.1s to 0.04s of catch-up time (from 5 to 2 steps at 50 FPS). When the system lags, the previous catch-up logic allowed jumping up to 5 pixels at once, causing visible jitter. Limiting to 2 steps provides smoother scrolling while still allowing for minor timing corrections. Co-authored-by: Chuck <chuck@example.com> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -240,7 +240,7 @@ class ScrollHelper:
|
|||||||
# Move pixels (can move multiple steps if lag occurred, but cap to prevent huge jumps)
|
# Move pixels (can move multiple steps if lag occurred, but cap to prevent huge jumps)
|
||||||
steps = int(time_since_last_step / self.scroll_delay)
|
steps = int(time_since_last_step / self.scroll_delay)
|
||||||
# Cap at reasonable number to prevent huge jumps from lag
|
# Cap at reasonable number to prevent huge jumps from lag
|
||||||
max_steps = max(1, int(0.1 / self.scroll_delay)) # Allow up to 0.1s of catch-up
|
max_steps = max(1, int(0.04 / self.scroll_delay)) # Limit to 0.04s (2 steps at 50 FPS) for smoother scrolling
|
||||||
steps = min(steps, max_steps)
|
steps = min(steps, max_steps)
|
||||||
pixels_to_move = self.scroll_speed * steps
|
pixels_to_move = self.scroll_speed * steps
|
||||||
# Update last_step_time, preserving fractional delay for smooth timing
|
# Update last_step_time, preserving fractional delay for smooth timing
|
||||||
|
|||||||
Reference in New Issue
Block a user