MingaEditor.Window.ScrollVelocity (Minga v0.1.0)

Copy Markdown View Source

Lightweight scroll-rate estimator for gesture detection.

Tracks a sliding window of scroll event timestamps and computes a velocity tier (:idle, :medium, :fast) based on event rate. The tier is read by MingaEditor.Window.scroll_follow_cursor?/3 to tell whether a wheel/trackpad scroll gesture is in progress, so the render pipeline holds the free-scrolled viewport instead of re-anchoring to the cursor mid-gesture.

The velocity-aware overscan sizing and directional prefetch that this module also fed were deleted with full residence on by default and huge files refused (#2680, epic #2652), which is why only the rate tier remains.

Summary

Types

t()

@type t() :: %MingaEditor.Window.ScrollVelocity{
  count: non_neg_integer(),
  last_event: integer(),
  prev_count: non_neg_integer(),
  window_start: integer()
}

tier()

@type tier() :: :idle | :medium | :fast

Functions

new()

@spec new() :: t()

record(sv, now_ms)

@spec record(t(), integer()) :: t()

tier(sv, now_ms)

@spec tier(t(), integer()) :: tier()