Skip to content

Commit

Permalink
fix: fix error of tooltip about showDelay, fix #3663
Browse files Browse the repository at this point in the history
  • Loading branch information
xile611 committed Jan 14, 2025
1 parent 97233bc commit 72499df
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions packages/vchart/src/component/tooltip/tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ export class Tooltip extends BaseComponent<any> implements ITooltip {
this._cacheEnterableRect = null;
this._outTimer = setTimeout(
this.hideTooltip,
this._spec.showDelay ?? DEFAULT_SHOW_DELAY
this._spec?.showDelay ?? DEFAULT_SHOW_DELAY
) as unknown as number;
}
}
Expand Down Expand Up @@ -341,14 +341,14 @@ export class Tooltip extends BaseComponent<any> implements ITooltip {
if (this._enterable) {
this._outTimer = setTimeout(() => {
this._handleChartMouseOut(params);
}, this._spec.showDelay ?? DEFAULT_SHOW_DELAY) as unknown as number;
}, this._spec?.showDelay ?? DEFAULT_SHOW_DELAY) as unknown as number;
} else {
this._handleChartMouseOut(params);
}
};

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

Expand Down Expand Up @@ -405,13 +405,16 @@ export class Tooltip extends BaseComponent<any> implements ITooltip {

this._showTimer = setTimeout(() => {
this._handleChartMouseMove(params, isClick);
}, this._spec.showDelay ?? DEFAULT_SHOW_DELAY) as unknown as number;
}, this._spec?.showDelay ?? DEFAULT_SHOW_DELAY) as unknown as number;
} else {
this._handleChartMouseMove(params, isClick);
}
};

protected _handleChartMouseMove = (params: BaseEventParams, isClick: boolean) => {
if (this._isReleased) {
return;
}
/* 获取 tooltip 原始数据 */
const mouseEventData = this._getMouseEventData(params);
const {
Expand Down Expand Up @@ -600,6 +603,9 @@ export class Tooltip extends BaseComponent<any> implements ITooltip {

/** 手动隐藏 tooltip,返回是否成功 */
hideTooltip = (): boolean => {
if (this._isReleased) {
return false;
}
const params: TooltipHandlerParams = {
changePositionOnly: false,
tooltip: this,
Expand Down

0 comments on commit 72499df

Please sign in to comment.