wilderness-core
Version:
The SVG animation engine behind Wilderness
44 lines (35 loc) • 1.33 kB
JavaScript
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
/* globals __DEV__ */
import tweenFunctions from 'tween-functions';
/**
* An easing function.
*
* @param {(function|string)} easing - An easing function or the name of an easing function from https://github.com/chenglou/tween-functions.
*
* @returns {function}
*
* @example
* easingFunc('easeInOutQuad')
*/
var easingFunction = function easingFunction(easing) {
switch (typeof easing === 'undefined' ? 'undefined' : _typeof(easing)) {
case 'string':
if (tweenFunctions[easing]) {
return tweenFunctions[easing];
}
if (process.env.NODE_ENV !== 'production') {
throw new TypeError('Easing must match one of the options defined by https://github.com/chenglou/tween-functions');
}
/* istanbul ignore next */
break;
case 'function':
return easing;
default:
if (process.env.NODE_ENV !== 'production') {
throw new TypeError('Easing must be of type function or string');
}
/* istanbul ignore next */
break;
}
};
export default easingFunction;