Skip to content

refactor(driver): share pointer drag throttling between slider and area - #213

Merged
pbroom merged 2 commits into
mainfrom
refactor/driver-drag-controller
Oct 10, 2026
Merged

pbroom merged 2 commits into
mainfrom
refactor/driver-drag-controller

Conversation

@pbroom

@pbroom pbroom commented Oct 6, 2026 •

Copy link
Copy Markdown
Owner
  • Add a framework-agnostic createPointerDragController to @color-kit/driver:
    rAF coalescing, dragEpsilon filtering (both axes), and a maxUpdateHz cap
    that defers (rather than drops) over-budget frames; end() force-commits
    the pending point. Scheduling and clock are injected (defaults resolve
    requestAnimationFrame/performance.now at call time; no DOM globals at
    module scope).
  • Add normalizeColorAreaPointer; ColorArea drops its inline clamp01 math.
  • ColorSlider and ColorArea both drive drags through the controller.
    Slider now flushes the last pending point on pointerup/cancel like the
    area, and ignores non-finite pointer input.
  • Hard cut-over: ColorSlider maxPointerRate -> maxUpdateHz (same name as
    ColorArea). Docs updated.
  • Unit tests for the controller and area normalization; slider epsilon test
    now uses real pointer coordinates.

Part of a stacked set of PRs (#204 → #221) from the color-kit assessment. Validated per branch with pnpm build and pnpm test; lint, format, typecheck, size, artifact, preprod and agents checks pass at the top of the stack.

🤖 Generated with Claude Code

pbroom commented Oct 6, 2026 •

Copy link
Copy Markdown
Owner Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@greptile-apps

greptile-apps Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 3/5

[Medium risk] Refactors pointer drag handling into a shared controller.

The PR should not merge until controlled slider drags handle external value updates and the handler-composition test reflects the intended release commit.

Fix All in CursorFindings

  1. P1 Controlled updates lose pointer moves ▶
  2. P1 Release commit breaks call assertion ▶
  3. P2 Coalesced sample count is understated ▶

Summary

The PR moves slider and area pointer-drag scheduling into a shared driver controller and adds an area pointer-normalization helper.

  • Both React controls now use the controller for coalescing, epsilon filtering, rate limiting, and drag completion.
  • The slider prop becomes maxUpdateHz, with corresponding documentation and test changes.
  • The slider’s epsilon baseline does not follow external controlled-value updates, and a handler-composition test still assumes the former pointerup behavior.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Pointer down] --> B[Controller start and commit]
  C[Pointer moves] --> D[Keep latest pending input]
  D --> E{Animation frame}
  E -->|Within epsilon| F[Discard pending input]
  E -->|Rate budget unavailable| E
  E -->|Eligible| G[Commit normalized point]
  D --> H[Pointer up or cancel]
  H --> I[Force-commit pending input]
Loading

Reviews (1) · Last reviewed commit: "refactor(driver): share pointer drag thr..."

Comment thread packages/react/src/color-slider.tsx
Comment thread packages/react/__tests__/stable-refs.test.tsx
Comment thread packages/driver/src/drag-controller.ts Outdated
@vercel

vercel Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
color-kit Ready Ready Preview Oct 10, 2026 7:16pm UTC

@pbroom
pbroom force-pushed the feat/react-slider-a11y branch from 1e56d26 to ca25e1a Compare October 8, 2026 02:44
@pbroom
pbroom force-pushed the refactor/driver-drag-controller branch from f92ddf0 to 99c5bbb Compare October 8, 2026 02:44

pbroom commented Oct 10, 2026 •

Copy link
Copy Markdown
Owner Author

Merge activity

  • Oct 10, 6:47 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Oct 10, 7:16 PM UTC: Graphite rebased this pull request as part of a merge.
  • Oct 10, 7:16 PM UTC: @pbroom merged this pull request with Graphite.

@pbroom
pbroom changed the base branch from feat/react-slider-a11y to graphite-base/213 October 10, 2026 19:12
@pbroom
pbroom changed the base branch from graphite-base/213 to main October 10, 2026 19:14
pbroom and others added 2 commits October 10, 2026 19:15
- Add a framework-agnostic createPointerDragController to @color-kit/driver:
  rAF coalescing, dragEpsilon filtering (both axes), and a maxUpdateHz cap
  that defers (rather than drops) over-budget frames; end() force-commits
  the pending point. Scheduling and clock are injected (defaults resolve
  requestAnimationFrame/performance.now at call time; no DOM globals at
  module scope).
- Add normalizeColorAreaPointer; ColorArea drops its inline clamp01 math.
- ColorSlider and ColorArea both drive drags through the controller.
  Slider now flushes the last pending point on pointerup/cancel like the
  area, and ignores non-finite pointer input.
- Hard cut-over: ColorSlider maxPointerRate -> maxUpdateHz (same name as
  ColorArea). Docs updated.
- Unit tests for the controller and area normalization; slider epsilon test
  now uses real pointer coordinates.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- createPointerDragController takes an optional getCurrentPoint and
  measures dragEpsilon against it; ColorSlider passes its displayed value
  so a controlled parent changing it mid-drag no longer swallows moves.
- coalescedCount sums the samples of every move folded into a commit.
- The slider handler-composition test now uses real coordinates and
  asserts the release commit made by end().

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@pbroom
pbroom force-pushed the refactor/driver-drag-controller branch from 99c5bbb to 32bbeae Compare October 10, 2026 19:15
@pbroom
pbroom merged commit cd40ee3 into main Oct 10, 2026
7 checks passed
@pbroom
pbroom deleted the refactor/driver-drag-controller branch October 10, 2026 19:16

This branch was successfully deployed

1 active deployment
Preview — 32bbeae3 Deployed Oct 10, 2026 by vercel[bot]
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