Skip to content

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

Open
gre wants to merge 1 commit into
necolas:masterfrom
gre:bezier-easing-3
Open

gre wants to merge 1 commit into
necolas:masterfrom
gre:bezier-easing-3

Conversation

@gre

@gre gre commented Oct 8, 2026

Copy link
Copy Markdown

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

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.
@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
Author

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

This branch has not been deployed

No deployments
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