Skip to content

Use bezier-easing 3.2 closed-form solver in Animated bezier - #2888

Merged
zoontek merged 1 commit into
necolas:masterfrom
gre:bezier-easing-3
Nov 10, 2026
Merged

zoontek merged 1 commit into
necolas:masterfrom
gre:bezier-easing-3

Conversation

@gre

@gre gre commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Hi, this is @gre, I'm the author of bezier-easing, which is also embedded in this project (packages/react-native-web/src/vendor/react-native/Animated/bezier.js). The library was recently improved with better performance and more reliability, and I wanted to backport the benefits here.

This brings its 3.2 solver (closed-form, no sample table), same change as in React Native:

  • Fixes steep curves. Easing.bezier(1, 0, 0, 1)(0.4996) returned 0.348 instead of 0.431, and the value went backwards around the middle.
  • Exact. Error goes from up to ~1e-3 (~8e-5 on Easing.ease) to ~1e-14 on regular curves.
  • Faster. Creating an easing is 2-3x faster. A call is about the same speed with a JIT, and 5-7x faster without one (e.g. Safari Lockdown Mode).
  • Smaller. 682 → 424 bytes min+gz.
  • x outside [0, 1] now saturates to 0 / 1. The old search returned arbitrary values there ((0.25, 0.1, 0.25, 1) at -0.5 gave 0.39), which is visible with interpolate + extrapolate: 'extend'. Linear curves are unchanged.

Tests: the Animated tests pass and prettier is clean. Compared against bezier-easing 3.2 on ~7.6M values: bit-identical.

download

@codesandbox-ci

codesandbox-ci Bot commented Oct 8, 2026

Copy link
Copy Markdown

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 757fbea:

Sandbox Source
react-native-web-examples Configuration

@zoontek

zoontek commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator

Hi @gre, thanks a lot for this! The improvements look great, and it's nice to see you backporting the work here.

The Animated code in this repo is vendored from React Native, and we try to keep it in sync with core. This change is not in the latest React Native release yet, so merging it now would make the two implementations diverge.

Could you open a PR on facebook/react-native first (or link it here if you already did)? Once it lands in core, we'll merge it here too.

@gre

gre commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

@zoontek thanks for your answer, makes sense. The React Native PR is here: react/react-native#58941

@gre

gre commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

Hi @zoontek , the fix has been merged in react-native side react/react-native@2ae713e

i'm rebasing the PR

Replace the sample table + Newton-Raphson + bisection search with the
closed-form solver of bezier-easing 3.2: exact (~1e-14 instead of up to
~1e-3), no backward jump on steep curves such as (1, 0, 0, 1), faster.

Inputs outside [0, 1] now saturate to 0 / 1 instead of going through
the old search, which returned arbitrary values there.
@gre
gre force-pushed the bezier-easing-3 branch from 757fbea to 07931c4 Compare October 28, 2026 12:35
@zoontek
zoontek merged commit 59e2250 into necolas:master Nov 10, 2026
5 checks passed
@zoontek

zoontek commented Nov 10, 2026

Copy link
Copy Markdown
Collaborator

@gre Thanks!

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.

2 participants