2017-08-31 14:11:04 +00:00
|
|
|
var EaseMap = require('../../math/easing/EaseMap');
|
2017-05-10 01:25:46 +00:00
|
|
|
|
2018-02-10 17:11:36 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @function Phaser.Tweens.Builders.GetEaseFunction
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {string|function} ease - [description]
|
|
|
|
* @param {array} easeParams - [description]
|
|
|
|
*
|
|
|
|
* @return {function} [description]
|
|
|
|
*/
|
2017-05-24 03:38:17 +00:00
|
|
|
var GetEaseFunction = function (ease, easeParams)
|
2017-05-10 01:25:46 +00:00
|
|
|
{
|
|
|
|
if (typeof ease === 'string' && EaseMap.hasOwnProperty(ease))
|
|
|
|
{
|
2017-05-24 03:38:17 +00:00
|
|
|
if (easeParams)
|
|
|
|
{
|
|
|
|
var cloneParams = easeParams.slice(0);
|
|
|
|
|
|
|
|
cloneParams.unshift(0);
|
|
|
|
|
|
|
|
return function (v)
|
|
|
|
{
|
|
|
|
cloneParams[0] = v;
|
|
|
|
|
|
|
|
return EaseMap[ease].apply(this, cloneParams);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// String based look-up
|
|
|
|
return EaseMap[ease];
|
|
|
|
}
|
2017-05-10 01:25:46 +00:00
|
|
|
}
|
|
|
|
else if (typeof ease === 'function')
|
|
|
|
{
|
|
|
|
// Custom function
|
|
|
|
return ease;
|
|
|
|
}
|
|
|
|
else if (Array.isArray(ease) && ease.length === 4)
|
|
|
|
{
|
|
|
|
// Bezier function (TODO)
|
|
|
|
}
|
|
|
|
|
|
|
|
return EaseMap.Power0;
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = GetEaseFunction;
|