Enable Flow for bezier
Reviewed By: sahrens Differential Revision: D8346102 fbshipit-source-id: bb1a2eccb5472bf6f3fe113303ad96cf3f386cab
This commit is contained in:
parent
f50ce0850d
commit
6b1bb01804
|
@ -3,8 +3,8 @@
|
||||||
* https://github.com/gre/bezier-easing
|
* https://github.com/gre/bezier-easing
|
||||||
*
|
*
|
||||||
* @copyright 2014-2015 Gaetan Renaudeau. MIT License.
|
* @copyright 2014-2015 Gaetan Renaudeau. MIT License.
|
||||||
* @noflow
|
|
||||||
* @emails oncall+react_native
|
* @emails oncall+react_native
|
||||||
|
* @flow
|
||||||
* @format
|
* @format
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ function allEquals(be1, be2, samples, assertion) {
|
||||||
function repeat(n) {
|
function repeat(n) {
|
||||||
return function(f) {
|
return function(f) {
|
||||||
for (let i = 0; i < n; ++i) {
|
for (let i = 0; i < n; ++i) {
|
||||||
f(i);
|
f();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
* BezierEasing - use bezier curve for transition easing function
|
* BezierEasing - use bezier curve for transition easing function
|
||||||
* https://github.com/gre/bezier-easing
|
* https://github.com/gre/bezier-easing
|
||||||
*
|
*
|
||||||
|
* @flow
|
||||||
* @format
|
* @format
|
||||||
* @copyright 2014-2015 Gaëtan Renaudeau. MIT License.
|
* @copyright 2014-2015 Gaëtan Renaudeau. MIT License.
|
||||||
* @noflow
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
@ -71,9 +71,13 @@ function newtonRaphsonIterate(aX, aGuessT, mX1, mX2) {
|
||||||
return aGuessT;
|
return aGuessT;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = function bezier(mX1, mY1, mX2, mY2) {
|
module.exports = function bezier(
|
||||||
|
mX1: number,
|
||||||
|
mY1: number,
|
||||||
|
mX2: number,
|
||||||
|
mY2: number,
|
||||||
|
) {
|
||||||
if (!(0 <= mX1 && mX1 <= 1 && 0 <= mX2 && mX2 <= 1)) {
|
if (!(0 <= mX1 && mX1 <= 1 && 0 <= mX2 && mX2 <= 1)) {
|
||||||
// eslint-disable-line yoda
|
|
||||||
throw new Error('bezier x values must be in [0, 1] range');
|
throw new Error('bezier x values must be in [0, 1] range');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,7 +127,7 @@ module.exports = function bezier(mX1, mY1, mX2, mY2) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return function BezierEasing(x) {
|
return function BezierEasing(x: number): number {
|
||||||
if (mX1 === mY1 && mX2 === mY2) {
|
if (mX1 === mY1 && mX2 === mY2) {
|
||||||
return x; // linear
|
return x; // linear
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue