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

Fix/tooltip enterable effect #3725

Merged
merged 2 commits into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
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
Loading