mirror of
https://github.com/chartjs/Chart.js.git
synced 2024-10-06 12:19:08 +02:00
Hover: only update styles of changed elements (#8185)
This commit is contained in:
parent
b55b361f97
commit
b10d994017
@ -994,15 +994,16 @@ class Chart {
|
||||
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);
|
||||
|
||||
// Remove styling for last active (even if it may still be active)
|
||||
if (lastActive.length) {
|
||||
me.updateHoverStyle(lastActive, hoverOptions.mode, false);
|
||||
if (deactivated.length) {
|
||||
me.updateHoverStyle(deactivated, hoverOptions.mode, false);
|
||||
}
|
||||
|
||||
// Built-in hover styling
|
||||
if (active.length && hoverOptions.mode) {
|
||||
me.updateHoverStyle(active, hoverOptions.mode, true);
|
||||
if (activated.length && hoverOptions.mode) {
|
||||
me.updateHoverStyle(activated, hoverOptions.mode, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user