Skip to content

Commit

Permalink
perf(core): 优化 tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
enncy committed Feb 28, 2024
1 parent aab04af commit 9655442
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/core/src/utils/creator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@ export const $creator = {
}

const onMouseMove = (e: MouseEvent) => {
$elements.tooltip.style.top = e.y + 'px';
$elements.tooltip.style.left = e.x + 'px';
if ($elements.tooltip.style.display !== 'none') {
$elements.tooltip.style.top = e.y + 'px';
$elements.tooltip.style.left = e.x + 'px';
}
};
const showTitle = (e: MouseEvent) => {
const dataTitle = target.getAttribute('data-title');
Expand All @@ -84,6 +86,7 @@ export const $creator = {
target.addEventListener('mouseenter', showTitle as any);
target.addEventListener('click', showTitle as any);
target.addEventListener('mouseout', hideTitle);
target.addEventListener('mouseleave', hideTitle);
target.addEventListener('blur', hideTitle);

return target;
Expand Down

0 comments on commit 9655442

Please sign in to comment.