Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable options on annotations to apply automatically when hovered #840

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
improves update elements invocation logic
  • Loading branch information
stockiNail committed Feb 1, 2023
commit eec18cb2987a475302111650b6f304d2b96f81e1
12 changes: 9 additions & 3 deletions src/hover.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,19 @@ function handleMoveEvents(chart, state, event, options) {
const unhovered = state.activeElements.filter((el) => !elements.includes(el));
setActive(unhovered, false);
state.activeElements = elements;
setActive(elements, true);
updateActiveElements(chart, state, options, unhovered.concat(elements));
const newHovered = elements.filter((el) => !el.active);
if (!unhovered.length && !newHovered.length) {
return false;
}
setActive(newHovered, true);
updateActiveElements(chart, state, options, unhovered.concat(newHovered));
return true;
}

function setActive(elements, active) {
elements.forEach(function(el) {
const result = active ? elements.filter((el) => !el.active) : elements;
result.forEach(function(el) {
el.active = active;
});
return result;
}