mirror of
https://github.com/chartjs/Chart.js.git
synced 2025-12-08 20:36:08 +00:00
Fix small bugs when animations are disabled (#8253)
* Fix small bugs when animations are disabled * Update test
This commit is contained in:
parent
c2091fc77d
commit
2e43f787de
@ -1002,13 +1002,13 @@ class Chart {
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
_updateHoverStyles(active, lastActive) {
|
||||
_updateHoverStyles(active, lastActive, replay) {
|
||||
const me = this;
|
||||
const options = me.options || {};
|
||||
const hoverOptions = options.hover;
|
||||
const diff = (a, b) => a.filter(x => !b.some(y => x.datasetIndex === y.datasetIndex && x.index === y.index));
|
||||
const deactivated = diff(lastActive, active);
|
||||
const activated = diff(active, lastActive);
|
||||
const activated = replay ? active : diff(active, lastActive);
|
||||
|
||||
if (deactivated.length) {
|
||||
me.updateHoverStyle(deactivated, hoverOptions.mode, false);
|
||||
@ -1093,7 +1093,7 @@ class Chart {
|
||||
changed = !_elementsEqual(active, lastActive);
|
||||
if (changed || replay) {
|
||||
me._active = active;
|
||||
me._updateHoverStyles(active, lastActive);
|
||||
me._updateHoverStyles(active, lastActive, replay);
|
||||
}
|
||||
|
||||
return changed;
|
||||
|
||||
@ -37,7 +37,7 @@ export default class Element {
|
||||
}
|
||||
const ret = {};
|
||||
props.forEach(prop => {
|
||||
ret[prop] = anims[prop] && anims[prop].active ? anims[prop]._to : me[prop];
|
||||
ret[prop] = anims[prop] && anims[prop].active() ? anims[prop]._to : me[prop];
|
||||
});
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -65,5 +65,5 @@ export const _alignStartEnd = (align, start, end) => align === 'start' ? start :
|
||||
*/
|
||||
export function _coordsAnimated(element) {
|
||||
const anims = element && element.$animations;
|
||||
return anims && ((anims.x && anims.x.active) || (anims.y && anims.y.active));
|
||||
return anims && ((anims.x && anims.x.active()) || (anims.y && anims.y.active()));
|
||||
}
|
||||
|
||||
@ -8,7 +8,7 @@ describe('Chart.element', function() {
|
||||
expect(elem.getProps(['x', 'y'])).toEqual(jasmine.objectContaining({x: 10, y: 1.5}));
|
||||
expect(elem.getProps(['x', 'y'], true)).toEqual(jasmine.objectContaining({x: 10, y: 1.5}));
|
||||
|
||||
elem.$animations = {x: {active: true, _to: 20}};
|
||||
elem.$animations = {x: {active: () => true, _to: 20}};
|
||||
expect(elem.getProps(['x', 'y'])).toEqual(jasmine.objectContaining({x: 10, y: 1.5}));
|
||||
expect(elem.getProps(['x', 'y'], true)).toEqual(jasmine.objectContaining({x: 20, y: 1.5}));
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user