Skip to content

Commit

Permalink
Increase Bezier timing function accuracy
Browse files Browse the repository at this point in the history
The polyfill evaluation of cubic Bezier timing functions
gives slightly different results than the native Blink
implementation.

In my testing, this change reduced the absolute error by 63%
while only increasing the number of cubic function evaluations
by 31%

This closes #139
  • Loading branch information
ericwilligers committed Apr 18, 2016
1 parent fb701cb commit 1b2f076
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/timing-utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@
var mid = (start + end) / 2;
function f(a, b, m) { return 3 * a * (1 - m) * (1 - m) * m + 3 * b * (1 - m) * m * m + m * m * m};
var xEst = f(a, c, mid);
if (Math.abs(x - xEst) < 0.001) {
if (Math.abs(x - xEst) < 0.0001) {
return f(b, d, mid);
}
if (xEst < x) {
Expand Down

0 comments on commit 1b2f076

Please sign in to comment.