* Validate a easing option.
(value, duration, noError)
| 640 | * Validate a <code>easing</code> option. |
| 641 | */ |
| 642 | function validateEasing(value, duration, noError) { |
| 643 | if (isString(value)) { |
| 644 | // Named easing |
| 645 | return Easings[value]; |
| 646 | } |
| 647 | if (isFunction(value)) { |
| 648 | return value; |
| 649 | } |
| 650 | // TODO: We should only do these if the correct function exists - don't force loading. |
| 651 | if (Array.isArray(value)) { |
| 652 | if (value.length === 1) { |
| 653 | // Steps |
| 654 | return generateStep(value[0]); |
| 655 | } |
| 656 | if (value.length === 2) { |
| 657 | // springRK4 must be passed the animation's duration. |
| 658 | // Note: If the springRK4 array contains non-numbers, |
| 659 | // generateSpringRK4() returns an easing function generated with |
| 660 | // default tension and friction values. |
| 661 | return generateSpringRK4(value[0], value[1], duration); |
| 662 | } |
| 663 | if (value.length === 4) { |
| 664 | // Note: If the bezier array contains non-numbers, generateBezier() |
| 665 | // returns undefined. |
| 666 | return generateBezier.apply(null, value) || false; |
| 667 | } |
| 668 | } |
| 669 | if (value != null && !noError) { |
| 670 | console.error("VelocityJS: Trying to set 'easing' to an invalid value:", value); |
| 671 | } |
| 672 | } |
| 673 | /** |
| 674 | * Validate a <code>fpsLimit</code> option. |
| 675 | */ |
no test coverage detected
searching dependent graphs…