Skip to content
Source
Sign inSign up
TanStack/charts

fix: start motion timing when updates are scheduled #222

Mergedtannerlinsleymerged 4 commits intomain fromtaren/motion-clock-originmerged by tannerlinsley

tannerlinsleycommented

Fix

Start the motion clock when the update is scheduled, using the owning window's performance.now(). An early first frame no longer advances a tween too far, and a delayed first frame no longer postpones the whole animation.

Remove the two bound frame callbacks so the fix fits the existing bundle budgets. Calls still use the owning window as their receiver. Public options, defaults and motion inheritance are unchanged.

Thanks @toomingos for the detailed reproduction in #192.

Closes #192.

Verification

  • pnpm validate passes all 19 tasks, including 2,224 main-suite tests, typechecking, packed consumers, docs, bundle gates and 188 catalog previews.
  • Regression coverage for early frames, delayed frames, per-track delay and the frame callback receiver.
  • Chromium, Firefox and WebKit reproduce the old timing error and pass with the fix.
  • Maintained example builds pass.
  • All 151 bundle entries satisfy the existing policies. Only the optional motion entry changes: 69.344 to 69.396 kB minified, 23.238 to 23.230 kB gzip, and 20.600 to 20.534 kB Brotli. The 60 comparison bundles are unchanged.
  • Two sets of seven paired Chromium trials at 1, 24 and 300 bars found no repeatable runtime regression. For 50 render-and-animation cycles at 300 bars, medians were 145.7 to 148.2 ms in the first set and 137.4 to 137.2 ms in the repeat. These are targeted local measurements, not a claim about all chart workloads.
  • Includes a patch Changeset. No added dependencies, CI jobs or budget increases.

Summary by CodeRabbit

  • Bug Fixes
    • Animation timing now begins when an update is scheduled, rather than at the first animation frame. This makes delayed animations progress according to their scheduled start time.
    1. 🦋 Changeset detected

      Latest commit: 5dcc33a7d8ce52ea184b3f1953b41ce4cfa1e936

      The changes in this PR will be included in the next version bump.

      This PR includes changesets to release 12 packages
      NameType
      @tanstack/chartsPatch
      @tanstack/alpine-chartsPatch
      @tanstack/angular-chartsPatch
      @tanstack/lit-chartsPatch
      @tanstack/octane-chartsPatch
      @tanstack/preact-chartsPatch
      @tanstack/react-chartsPatch
      @tanstack/react-native-chartsPatch
      @tanstack/solid-chartsPatch
      @tanstack/svelte-chartsPatch
      @tanstack/vue-chartsPatch
      @tanstack/charts-scalesPatch

      Not sure what this means? Click here to learn what changesets are.

      Click here if you're a maintainer who wants to add another changeset to this PR

    2. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Review in Change Stack →

      No actionable comments were generated in the recent review. 🎉

      ℹ️ Recent review info
      ⚙️ Run configuration
      • Configuration used: defaults
      • Review profile: CHILL
      • Plan: Advanced
      • Run ID: 6f950c0d-e9fe-4e73-aae0-6f4eaf2b6904
      📥 Commits

      Reviewing files that changed from the base of the PR and between f29d649308510a0a82bfb75d1d156a2cd31594ca and 5dcc33a7d8ce52ea184b3f1953b41ce4cfa1e936.

      📒 Files selected for processing: 15
      • .changeset/scheduled-motion-clock.md
      • benchmarks/comparison/bundle-baseline.json
      • benchmarks/conformance/cases/114-spring-line-motion/tanstack.test.ts
      • benchmarks/conformance/cases/115-definition-motion/tanstack.test.ts
      • benchmarks/conformance/cases/116-geometry-morph/tanstack.test.ts
      • benchmarks/conformance/cases/126-drillable-sunburst/tanstack.test.ts
      • benchmarks/conformance/previews/manifest.json
      • docs/comparison.md
      • packages/charts-core/docs/comparison.md
      • packages/charts-core/src/motion-clock.test.ts
      • packages/charts-core/src/motion.test.ts
      • packages/charts-core/src/motion.ts
      • packages/charts-core/src/ridgeline.test.ts
      • packages/charts-core/src/view-compose.test.ts
      • packages/charts-core/src/violin.test.ts

      Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

      📝 Walkthrough

      Motion runs now measure elapsed time from when an update is scheduled, rather than from the first animation-frame timestamp. Tests simulate performance time alongside frame callbacks. Benchmark metadata and comparison-page revisions are updated.

      Changes: Motion Timing

      Layer / File(s)Summary
      Scheduled start time and regression coverage
      .changeset/scheduled-motion-clock.md, packages/charts-core/src/motion.ts, packages/charts-core/src/motion-clock.test.ts
      runTracks reads the view’s performance clock before scheduling the first frame. The new parameterized test checks animation values at selected times and verifies the final motion state.
      Simulated clock and frame helpers
      packages/charts-core/src/motion.test.ts, packages/charts-core/src/ridgeline.test.ts, packages/charts-core/src/view-compose.test.ts, packages/charts-core/src/violin.test.ts, benchmarks/conformance/cases/*/tanstack.test.ts
      Test helpers set mocked performance time before frame callbacks and restore the clock mock during cleanup. The managed-frame helper also supports advancing time without invoking a callback.
      Benchmark and comparison metadata
      benchmarks/comparison/bundle-baseline.json, benchmarks/conformance/previews/manifest.json, docs/comparison.md, packages/charts-core/docs/comparison.md
      The baseline timestamp, source revision, and input digest are updated. The preview source hash and comparison-page workspace revision are also updated.

      Priority: ➖ Normal

      Estimated code review effort: 3 (Moderate) | ~20 minutes

      Change: Bug fix

      Merge Risk: ⚪ Minimal · up to 5dcc3

      The scheduled motion-clock change has no established merge-blocking risk; it is ready for normal merge checks.

      Pre-merge checks: Passed 4 · Failed 1
      Failed Failed checks: 1 warning
      Check nameStatusExplanationResolution
      Docstring CoverageWarningDocstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 18 functions across 10 files. (5 skipped: …Write docstrings for the functions missing them to satisfy the coverage threshold.
      Passed Passed checks: 4 passed
      Check nameStatusExplanation
      Description CheckPassedCheck skipped - CodeRabbit’s high-level summary is enabled.
      Title checkPassedThe title clearly and concisely describes the main change: starting motion timing when updates are scheduled.
      Linked Issues checkPassedThe direct linked issue is #192. packages/charts-core/src/motion.ts now reads view.performance.now() before scheduling the first frame and uses that value as the motion origin. It calls `requestAn…
      Out of Scope Changes checkPassedThe changes stay within the motion-clock fix. The added test and test-helper clock controls support deterministic motion timing coverage. The changeset, conformance updates, preview metadata, bundle b…
      Full details: Docstring Coverage

      Explanation

      Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 18 functions across 10 files. (5 skipped: 5 unsupported.)

      • Fix all pre-merge checks with AI
      ✨ Finishing Touches: 💡 1
      📝 Generate docstrings: 💡
      • Commit to this branch
      • Create a new PR
      🧪 Generate unit tests (beta)
      • Commit to this branch
      • Create a new PR
      • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

      Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

      ❤️ Share
      Comment `@coderabbitai help` to get the list of available commands.
    3. nx-cloud[bot](GitHub profile, opens in a new tab)commented

      View your CI Pipeline Execution ↗ for commit 5dcc33a7d8ce52ea184b3f1953b41ce4cfa1e936

      CommandStatusDurationResult
      nx run charts-workspace:ci-distributed✅ Succeeded2m 51sView ↗
      nx run charts-workspace:package-check✅ Succeeded<1sView ↗
      nx run charts-workspace:benchmark-check✅ Succeeded<1sView ↗

      ☁️ Nx Cloud last updated this comment at 2026-10-13 23:45:50 UTC

    4. tannerlinsley merged thisba6b647

    5. tannerlinsley closed this

Sign in to join this conversation.