Skip to content

Commit

Permalink
Merge pull request #3725 from VisActor/fix/tooltip-enterable-effect
Browse files Browse the repository at this point in the history
Fix/tooltip enterable effect
  • Loading branch information
xile611 authored Feb 13, 2025
2 parents 05db465 + 2c055cd commit 357d8c8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "fix: tooltip should not handle mousemove or mouseout when enter tooltip, fix #3708\n\n",
"type": "none",
"packageName": "@visactor/vchart"
}
],
"packageName": "@visactor/vchart",
"email": "[email protected]"
}
10 changes: 8 additions & 2 deletions packages/vchart/src/component/tooltip/tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ export class Tooltip extends BaseComponent<any> implements ITooltip {
private _needInitEventOfTooltip?: boolean;
private _enterable: boolean;
private _isReleased: boolean = false;
/**
* 是否正在浏览tooltip内容
*/
private _isEnterTooltip: boolean;
protected declare _spec: ITooltipSpec;

tooltipHandler?: ITooltipHandler;
Expand Down Expand Up @@ -178,6 +182,7 @@ export class Tooltip extends BaseComponent<any> implements ITooltip {
if (!this._enterable) {
return;
}
this._isEnterTooltip = true;

const rect = element.getBoundingClientRect?.();
if (rect) {
Expand All @@ -198,6 +203,7 @@ export class Tooltip extends BaseComponent<any> implements ITooltip {
if (!this._enterable) {
return;
}
this._isEnterTooltip = false;

if (this._cacheEnterableRect) {
const newRect = element.getBoundingClientRect?.();
Expand Down Expand Up @@ -348,7 +354,7 @@ export class Tooltip extends BaseComponent<any> implements ITooltip {
};

protected _handleChartMouseOut = (params?: BaseEventParams) => {
if (this._alwaysShow || this._isReleased) {
if (this._alwaysShow || this._isReleased || this._isEnterTooltip) {
return;
}

Expand All @@ -370,7 +376,7 @@ export class Tooltip extends BaseComponent<any> implements ITooltip {
};

protected _getMouseMoveHandler = (isClick: boolean) => (params: BaseEventParams) => {
if (this._isReleased) {
if (this._isReleased || this._isEnterTooltip) {
return;
}
if (this._outTimer) {
Expand Down

0 comments on commit 357d8c8

Please sign in to comment.