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

feat(tooltip): 通过 pointer-events 属性来达到 tooltip 躲避鼠标的交互效果 #2209

Merged
merged 4 commits into from
Mar 23, 2020

Conversation

simaQ
Copy link
Contributor

@simaQ simaQ commented Mar 22, 2020

No description provided.

@simaQ simaQ requested review from dxq613 and hustcc March 22, 2020 15:05
@simaQ simaQ added this to the v4.0.3 milestone Mar 22, 2020
const theme = view.getTheme();
const defaultCfg = get(theme, ['components', 'tooltip'], {});
return deepMix({}, defaultCfg, option);
const isTooltipLocked = view.isTooltipLocked();
const pointerEvents = (get(option, 'enterable') || isTooltipLocked) ? 'auto' : (defaultCfg.enterable ? 'auto' : 'none');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

语意上等同于 下面吗?

// 主要是这里,用户配置就用用户的,没有就去默认值。
const enterable = get(option, 'enterable') || defaultCfg.enterable

const pointerEvents = enterable || isTooltipLocked  'auto' : 'none';

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

语意上等同于 下面吗?

// 主要是这里,用户配置就用用户的,没有就去默认值。
const enterable = get(option, 'enterable') || defaultCfg.enterable

const pointerEvents = enterable || isTooltipLocked  'auto' : 'none';

不等于,因为 enterable 是以用户设置的为准。

}

// 获取 tooltip 配置,因为用户可能会通过 view.tooltip() 重新配置 tooltip,所以就不做缓存,每次直接读取
private getTooltipCfg() {
const view = this.view;
const option = this.option;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lockTooltip 时,不一定会调用 showTooltip,这时候 pointEvent 不会变成 'auto',每次 tooltip show 时都更新 domStyle 成本有些高。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tooltip 组件不会进行比对吗?domStyles 未发生改变不进行更新?

@lgtm-com
Copy link

lgtm-com bot commented Mar 23, 2020

This pull request introduces 1 alert when merging 8d3b0d5 into d835f18 - view on LGTM.com

new alerts:

  • 1 for Unused variable, import, function or class

@dxq613 dxq613 merged commit 4a48885 into master Mar 23, 2020
@dxq613 dxq613 deleted the tooltip-pointer-events branch March 23, 2020 07:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants