Summary: Improves the types for Easing and bezier to make them script.

Differential Revision: D10346234

fbshipit-source-id: e941110c62f7dcd17b0d022497cf29e0935db5a3
This commit is contained in:
Naman Goel 2018-11-01 16:20:13 -07:00 коммит произвёл Facebook Github Bot
Родитель 2b603fd8eb
Коммит 17fd1bceb5
2 изменённых файлов: 15 добавлений и 15 удалений

Просмотреть файл

@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*
* @format
* @flow
* @flow strict
*/
'use strict';
@ -175,10 +175,7 @@ class Easing {
*
* - http://tiny.cc/back_default (s = 1.70158, default)
*/
static back(s: number): (t: number) => number {
if (s === undefined) {
s = 1.70158;
}
static back(s: number = 1.70158): (t: number) => number {
return t => t * t * ((s + 1) * t - s);
}
@ -193,17 +190,17 @@ class Easing {
}
if (t < 2 / 2.75) {
t -= 1.5 / 2.75;
return 7.5625 * t * t + 0.75;
const t2 = t - 1.5 / 2.75;
return 7.5625 * t2 * t2 + 0.75;
}
if (t < 2.5 / 2.75) {
t -= 2.25 / 2.75;
return 7.5625 * t * t + 0.9375;
const t2 = t - 2.25 / 2.75;
return 7.5625 * t2 * t2 + 0.9375;
}
t -= 2.625 / 2.75;
return 7.5625 * t * t + 0.984375;
const t2 = t - 2.625 / 2.75;
return 7.5625 * t2 * t2 + 0.984375;
}
/**

Просмотреть файл

@ -7,7 +7,7 @@
* BezierEasing - use bezier curve for transition easing function
* https://github.com/gre/bezier-easing
*
* @flow
* @flow strict
* @format
* @copyright 2014-2015 Gaëtan Renaudeau. MIT License.
*/
@ -45,10 +45,12 @@ function getSlope(aT, aA1, aA2) {
return 3.0 * A(aA1, aA2) * aT * aT + 2.0 * B(aA1, aA2) * aT + C(aA1);
}
function binarySubdivide(aX, aA, aB, mX1, mX2) {
function binarySubdivide(aX, _aA, _aB, mX1, mX2) {
let currentX,
currentT,
i = 0;
i = 0,
aA = _aA,
aB = _aB;
do {
currentT = aA + (aB - aA) / 2.0;
currentX = calcBezier(currentT, mX1, mX2) - aX;
@ -64,7 +66,8 @@ function binarySubdivide(aX, aA, aB, mX1, mX2) {
return currentT;
}
function newtonRaphsonIterate(aX, aGuessT, mX1, mX2) {
function newtonRaphsonIterate(aX, _aGuessT, mX1, mX2) {
let aGuessT = _aGuessT;
for (let i = 0; i < NEWTON_ITERATIONS; ++i) {
const currentSlope = getSlope(aGuessT, mX1, mX2);
if (currentSlope === 0.0) {