cubicEasing.js 787 B

1234567891011121314151617181920212223
  1. import { cubicAt, cubicRootAt } from '../core/curve.js';
  2. import { trim } from '../core/util.js';
  3. var regexp = /cubic-bezier\(([0-9,\.e ]+)\)/;
  4. export function createCubicEasingFunc(cubicEasingStr) {
  5. var cubic = cubicEasingStr && regexp.exec(cubicEasingStr);
  6. if (cubic) {
  7. var points = cubic[1].split(',');
  8. var a_1 = +trim(points[0]);
  9. var b_1 = +trim(points[1]);
  10. var c_1 = +trim(points[2]);
  11. var d_1 = +trim(points[3]);
  12. if (isNaN(a_1 + b_1 + c_1 + d_1)) {
  13. return;
  14. }
  15. var roots_1 = [];
  16. return function (p) {
  17. return p <= 0
  18. ? 0 : p >= 1
  19. ? 1
  20. : cubicRootAt(0, a_1, c_1, 1, p, roots_1) && cubicAt(0, b_1, d_1, 1, roots_1[0]);
  21. };
  22. }
  23. }