Repository navigation
Use bezier-easing 3.2 closed-form solver in Animated bezier - #2888
Conversation
|
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:
|
|
Hi @gre, thanks a lot for this! The improvements look great, and it's nice to see you backporting the work here. The 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. |
|
@zoontek thanks for your answer, makes sense. The React Native PR is here: react/react-native#58941 |
|
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 Thanks! |
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:
Easing.bezier(1, 0, 0, 1)(0.4996)returned 0.348 instead of 0.431, and the value went backwards around the middle.Easing.ease) to ~1e-14 on regular curves.(0.25, 0.1, 0.25, 1)at -0.5 gave 0.39), which is visible withinterpolate+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.