diff --git a/CHANGELOG.md b/CHANGELOG.md index cb574ab2d..5cdec6de0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,8 @@ * `Tween.init` and `Tween.play` have been rewritten so they are not run multiple times when a Tween is paused before playback, or is part of a Timeline. This didn't cause any problems previously, but it was a redundant duplication of calls. * `Tween.onLoop` will now be invoked _after_ the `loopDelay` has expired, if any was set. * `Tween.onRepeat` will now be invoked _after_ the `repeatDelay` has expired, if any was set. +* `easeParams` would be ignored for tweens that _didn't_ use a string for the ease function name. Fix #3826 (thanks @SBCGames) +* You can now specify `easeParams` for any custom easing function you wish to use. Fix #3826 (thanks @SBCGames) ### New Features diff --git a/src/tweens/builders/GetEaseFunction.js b/src/tweens/builders/GetEaseFunction.js index 7c6447bfa..74a644ad2 100644 --- a/src/tweens/builders/GetEaseFunction.js +++ b/src/tweens/builders/GetEaseFunction.js @@ -19,38 +19,43 @@ var EaseMap = require('../../math/easing/EaseMap'); */ var GetEaseFunction = function (ease, easeParams) { + // Default ease function + var easeFunction = EaseMap.Power0; + + // Prepare ease function if (typeof ease === 'string' && EaseMap.hasOwnProperty(ease)) { - 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]; - } + // String based look-up + easeFunction = EaseMap[ease]; } else if (typeof ease === 'function') { // Custom function - return ease; + easeFunction = ease; } else if (Array.isArray(ease) && ease.length === 4) { // Bezier function (TODO) } - return EaseMap.Power0; + // No custom ease parameters? + if (!easeParams) + { + // Return ease function + return easeFunction; + } + + var cloneParams = easeParams.slice(0); + + cloneParams.unshift(0); + + // Return ease function with custom ease parameters + return function (v) + { + cloneParams[0] = v; + + return easeFunction.apply(this, cloneParams); + }; }; module.exports = GetEaseFunction;