-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Conversation
src/chart/controller/tooltip.ts
Outdated
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'); |
There was a problem hiding this comment.
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';
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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 成本有些高。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tooltip 组件不会进行比对吗?domStyles 未发生改变不进行更新?
c85fb65
to
1e4e0ba
Compare
This pull request introduces 1 alert when merging 8d3b0d5 into d835f18 - view on LGTM.com new alerts:
|
No description provided.