Skip to content

Commit 1b2f076

Browse files
committed
Increase Bezier timing function accuracy
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
1 parent fb701cb commit 1b2f076

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/timing-utilities.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@
168168
var mid = (start + end) / 2;
169169
function f(a, b, m) { return 3 * a * (1 - m) * (1 - m) * m + 3 * b * (1 - m) * m * m + m * m * m};
170170
var xEst = f(a, c, mid);
171-
if (Math.abs(x - xEst) < 0.001) {
171+
if (Math.abs(x - xEst) < 0.0001) {
172172
return f(b, d, mid);
173173
}
174174
if (xEst < x) {

0 commit comments

Comments
 (0)