Skip to main content

Smooth Scroll

MonoTerm implements pixel-level scroll accumulation for fluid scrolling experience, especially on trackpads.

The Problem: Row-Based Scrolling

Traditional terminals scroll by whole rows. This creates jerky movement on trackpads that send sub-row pixel deltas.

The Solution: Pixel Accumulation

MonoTerm accumulates sub-row pixel deltas until a full row is reached.

State Tracking

The scroll state tracks accumulated pixel delta (pendingY), current row height, and animation status. When accumulated pixels exceed one row height, scrolling triggers and the remainder carries over.

Trackpad vs Mouse Detection

MonoTerm detects input device type and applies different scroll behavior.

Bezier Animation

For smooth deceleration, MonoTerm applies easing functions to scroll animation.

Configuration

Users can customize scroll behavior via settings:

Alt Buffer Bypass

When in alternate screen mode (vim, tmux, less), smooth scroll is bypassed for native app handling.

Implementation

The wheel event handler follows the flow diagram above: check alt buffer, detect precision input, accumulate or direct scroll. The complete flow is described in the “Scroll Behavior Flow” diagram.

Sync Rendering

Immediate render for flicker-free display

xterm.js Renderer

How xterm.js is used as display component