]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Fix couple of animation bugs (#8439)
authorJukka Kurkela <jukka.kurkela@gmail.com>
Tue, 16 Feb 2021 21:42:07 +0000 (23:42 +0200)
committerGitHub <noreply@github.com>
Tue, 16 Feb 2021 21:42:07 +0000 (16:42 -0500)
src/core/core.animations.js
src/core/core.config.js
src/core/core.datasetController.js

index 1fc7a0e0d209f194e303692c11a5023a0456c3cc..09c577245158c0589ace2d096ac131c3f4e4120b 100644 (file)
@@ -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
index 309cf75fcba515458e810e0b32d311115b3c788c..d30ed3296b3b1905ec4714c73096a0f77bdcf580 100644 (file)
@@ -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);
   }
index 6f5a6c7faeaa0bcd2e52f13a12af9d39a497d986..615c55ddc970ec3e1b4d42c9b0ea491358268ece 100644 (file)
@@ -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) {