From: Jukka Kurkela Date: Tue, 16 Feb 2021 21:42:07 +0000 (+0200) Subject: Fix couple of animation bugs (#8439) X-Git-Tag: v3.0.0-beta.11~18 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a73a8c4a5ec83b1fd55fdfbbffcaf0e3b4787025;p=thirdparty%2FChart.js.git Fix couple of animation bugs (#8439) --- diff --git a/src/core/core.animations.js b/src/core/core.animations.js index 1fc7a0e0d..09c577245 100644 --- a/src/core/core.animations.js +++ b/src/core/core.animations.js @@ -5,7 +5,7 @@ import {isObject} from '../helpers/helpers.core'; const numbers = ['x', 'y', 'borderWidth', 'radius', 'tension']; const colors = ['borderColor', 'backgroundColor']; -const animationOptions = ['duration', 'easing', 'from', 'to', 'type', 'easing', 'loop', 'fn']; +const animationOptions = ['delay', 'duration', 'easing', 'fn', 'from', 'loop', 'to', 'type']; defaults.set('animation', { // Plain properties can be overridden in each object diff --git a/src/core/core.config.js b/src/core/core.config.js index 309cf75fc..d30ed3296 100644 --- a/src/core/core.config.js +++ b/src/core/core.config.js @@ -1,5 +1,5 @@ import defaults from './core.defaults'; -import {mergeIf, resolveObjectKey, isArray, isFunction, valueOrDefault} from '../helpers/helpers.core'; +import {mergeIf, resolveObjectKey, isArray, isFunction, valueOrDefault, isObject} from '../helpers/helpers.core'; import {_attachContext, _createResolver, _descriptors} from '../helpers/helpers.config'; export function getIndexAxis(type, options) { @@ -301,13 +301,14 @@ export default class Config { /** * @param {object[]} scopes - * @param {function|object} context + * @param {object} [context] + * @param {string[]} [prefixes] */ createResolver(scopes, context, prefixes = ['']) { - const cached = getResolver(this._resolverCache, scopes, prefixes); - return context && cached.needContext - ? _attachContext(cached.resolver, isFunction(context) ? context() : context) - : cached.resolver; + const {resolver} = getResolver(this._resolverCache, scopes, prefixes); + return isObject(context) + ? _attachContext(resolver, isFunction(context) ? context() : context) + : resolver; } } @@ -323,8 +324,7 @@ function getResolver(resolverCache, scopes, prefixes) { const resolver = _createResolver(scopes, prefixes); cached = { resolver, - subPrefixes: prefixes.filter(p => !p.toLowerCase().includes('hover')), - needContext: needContext(resolver, Object.getOwnPropertyNames(resolver)) + subPrefixes: prefixes.filter(p => !p.toLowerCase().includes('hover')) }; cache.set(cacheKey, cached); } diff --git a/src/core/core.datasetController.js b/src/core/core.datasetController.js index 6f5a6c7fa..615c55ddc 100644 --- a/src/core/core.datasetController.js +++ b/src/core/core.datasetController.js @@ -777,8 +777,7 @@ export default class DatasetController { const config = me.chart.config; const scopeKeys = config.datasetAnimationScopeKeys(me._type); const scopes = config.getOptionScopes(me.getDataset().animation, scopeKeys); - const context = () => me.getContext(index, active, mode); - options = config.createResolver(scopes, context); + options = config.createResolver(scopes, me.getContext(index, active, mode)); } const animations = new Animations(chart, options && options[mode] || options); if (options && options._cacheable) {