/scroll-spy:tune-scroll-spy-stabilityfrom ScrollSpy Assistant
Tunes scroll_spy stability parameters to fix flickering, sluggish switching, null primaries, and update timing issues during scrolling or autoplay.
Ships in ScrollSpy Assistant. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
The pipeline is: region decides who is focused, policy ranks them, stability decides when the winner may change, update policy decides when any of it recomputes. Match the symptom to the stage; change one knob at a time and re-test, because several symptoms have look-alike causes in different stages.
| Symptom | Stage | Change |
|---|---|---|
| Primary alternates rapidly between two adjacent items while scrolling slowly | stability | Raise hysteresisPx (start 24, range 10-50): a challenger must be closer to the anchor than the incumbent by this many px |
| Fast fling fires a barrage of primary changes | stability | Set minPrimaryDuration (start 150ms, range 100-250): incumbent holds at least this long while it stays focused |
| Primary switches feel sluggish/sticky after tuning | stability | Lower the two values above; or set preferCurrentPrimary: false to always take the best candidate each pass (subject only to min duration) |
| Autoplay pauses between cards; primary goes null when the region falls in a gap | stability | Keep allowPrimaryWhenNoItemFocused: true (default): keeps a best-available primary for gapless playback |
| TOC/reading UI highlights a section when nothing is truly under the line | stability | Set allowPrimaryWhenNoItemFocused: false: primary becomes null the moment nothing intersects the region (strict semantics) |
| Focus drops out between items even while one is clearly nearby | region | Zone too thin: raise extentPx (item-extent-sized zones behave well); or switch a line to a zone |
| Two items both "look focused" and the winner feels arbitrary | policy | Pick the policy that matches intent: closestToAnchor (feeds), largestVisibleFraction (galleries), largestFocusOverlap, largestFocusProgress; ties break deterministically by focusProgress, then visibleFraction, then distance, then registration order |
| Primary lags the finger during drag, corrects on settle | update policy | That is onScrollEnd/hybrid semantics; use perFrame (default) for live tracking |
| Updates during scroll are wanted only at rest (impressions, autoplay-on-settle) | update policy | onScrollEnd(debounce: 80ms); state is intentionally stale mid-scroll |
| Rebuild pressure from metric listeners during flings | update policy | hybrid(ballisticInterval: 50ms): per-frame while dragging, throttled ballistic, guaranteed settle pass |
| First/last items can never win with a centered anchor | geometry | Symmetric list padding of (viewportExtent - itemExtent) / 2 (the official demo technique), or bias the anchor (fraction(0.4), or offsetPx) |
| Tuning "randomly resets" while scrolling | config churn | onScrollEnd(...)/hybrid(...) have no const constructors and no ==; constructing them inline in build makes every rebuild a config change. Build once, store in a field |
hysteresisPx compares absolute distance-to-anchor: the challenger wins
only when challenger.absDistance + hysteresisPx < incumbent.absDistance
style dominance holds, after minPrimaryDuration is satisfied, and only
while preferCurrentPrimary is true.minPrimaryDuration is monotonic-clock based (1.x); wall-clock changes
cannot shorten or break the hold. The hold applies only while the current
primary remains focused; when it leaves the region, replacement is
immediate (or falls back per allowPrimaryWhenNoItemFocused).hysteresisPx: 0, minPrimaryDuration: zero: stability is
OFF until you set values. Feeds should set both.ScrollSpyStability.disabled() disables stickiness but still keeps
allowPrimaryWhenNoItemFocused: true.a should win. Non-deterministic comparators cause churn no
stability setting can hide.| Use case | Region | Policy | Stability |
|---|---|---|---|
| Autoplay feed | zone(fraction(0.5), extentPx ~ 200 or itemExtent) | closestToAnchor | 24px, 150ms, both flags true |
| Reading position / TOC | line(fraction(0.2..0.3), thickness 0-2) | closestToAnchor | 0-8px, 0-100ms, allowPrimaryWhenNoItemFocused per strictness |
| Carousel/pager | zone at center, extent ~ page | closestToAnchor or largestFocusProgress | small hysteresis; pager snapping already stabilizes |
| Gallery grid | zone or whole-viewport zone | largestVisibleFraction | 100-150ms duration; hysteresis less relevant |
Reproduce the original gesture (slow boundary scroll for flicker, fling for
barrage). Confirm with debug: true overlay (green outline = primary) or by
counting transitions in a ScrollSpyPrimaryListener log. In widget tests,
drive real gestures and pump per the policy's timing (see the
diagnose-scroll-spy skill for the two-frame commit pipeline). State which
knob changed, why that stage, and what you observed before/after.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub omar-hanafy/scroll_spy --plugin scroll-spy7 skills in this plugin
/convert-visibility-detector-to-scroll-spyUse when replacing the visibility_detector package with scroll_spy in a Flutter app, when migrating VisibilityDetector, VisibilityInfo, or VisibilityDetectorController code, or when a VisibilityDetector-based feed additionally needs a single stable primary item, per-item focus metrics, or scroll-performance improvements./diagnose-scroll-spyUse when scroll_spy misbehaves in a Flutter app and the cause is unknown: primaryId stays null, focusedIds stays empty, listeners or builders never fire, focus ignores jumpTo or programmatic scrolls, the highlighted item is offset under a pinned header or app bar, state resets on setState, nested scrollables interfere, or a widget test reads null focus state./integrate-scroll-spyUse when adding the scroll_spy Flutter package to a screen or feature: autoplay video feeds, current-item tracking, reading-position or TOC highlighting, impression analytics, carousels or PageViews, photo grids, prefetching around the focused item, or wiring ScrollSpyScope, ScrollSpyItem, and ScrollSpyController for the first time, including widget tests for that integration. Not for scrolling work unrelated to focus or visibility tracking (saving/restoring scroll offsets, scroll physics, scroll-to-index)./migrate-scroll-spy-v0-to-v1Use when upgrading a Flutter project from scroll_spy 0.1.x or 0.2.x to 1.x, when a build breaks after a scroll_spy upgrade with unresolved names such as ScrollSpyRegistry, ScrollSpyGeometry, ScrollSpySelection, ScrollSpyDiff, or commitFrame, or when estimating how much work the 0.x to 1.x upgrade needs./migrate-scroll-spy-v1-to-v2Upgrade an existing scroll_spy 1.x integration to 2.x, including SDK constraints and optional ScrollCacheExtent migration. Use for 1.x-to-2.x upgrades or SDK resolution failures after that upgrade./optimize-scroll-spy-performanceUse when a Flutter screen whose code uses scroll_spy (ScrollSpyScope, ScrollSpyItem, ScrollSpyController) shows jank, dropped frames, high CPU, or rebuild storms, or when choosing between ScrollSpyItem, ScrollSpyItemLite, focus builders, listeners, and snapshot listening in large scroll_spy feeds. Not for general Flutter list or image scrolling performance where scroll_spy is not involved.Other plugins' skills for the same job