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

Improve tooltip #13326

Merged
merged 5 commits into from
Dec 4, 2024
Merged

Improve tooltip #13326

merged 5 commits into from
Dec 4, 2024

Conversation

TCOTC
Copy link
Contributor

@TCOTC TCOTC commented Dec 1, 2024

  1. 减少不必要的元素更新

  2. 改进悬浮提示元素位置计算 fix 改进悬浮提示宽度 #12680

    messageElement.innerHTML = message; 会更新元素的内容,元素此时的 top 和 left 属性会对元素的高度和宽度产生影响,导致更新后的元素(比如元素内的文本意外换行了)与直接新建的元素(元素内的文本不会换行)宽度不一致。messageElement.clientWidth 会获取到不符合预期的宽度,进而导致 top 和 left 计算错误。

  3. 特殊情况下悬浮提示会换行一个字 fix 改进悬浮提示宽度 #12680

  4. 隐藏悬浮提示增加少许延迟,避免在相邻的元素间移动时悬浮提示频繁闪烁

    元素没有完全紧挨着就会出现这样的闪烁:

    video.webm

TCOTC added 4 commits December 1, 2024 16:44
messageElement.innerHTML = message; 会更新元素的内容,元素此时的 left 属性会对元素的宽度产生影响,导致更新后的元素(比如元素内的文本意外换行了)与直接新建的元素(元素内的文本不会换行)宽度不一致。messageElement.clientWidth 会获取到不符合预期的宽度,进而导致 left 计算错误。
@88250 88250 requested a review from Vanessa219 December 2, 2024 00:10
@Vanessa219
Copy link
Member

这个主题是?我想重现一下看看

另外还有一个问题,不同情况下悬浮提示的宽度是不同的,就会出现宽度不够导致换行:

default.webm

@TCOTC
Copy link
Contributor Author

TCOTC commented Dec 2, 2024

Savor 主题(我用的是 Sugar 配色)。

其实把这个按钮的位置改到最右边就能复现了。

@Vanessa219 Vanessa219 merged commit eac2902 into siyuan-note:dev Dec 4, 2024
@Vanessa219
Copy link
Member

-1 的原因是?

messageElement.style.left = (window.innerWidth - 1 - messageElement.clientWidth) + "px";

Vanessa219 added a commit that referenced this pull request Dec 4, 2024
@Vanessa219 Vanessa219 added this to the 3.1.15 milestone Dec 4, 2024
@TCOTC TCOTC deleted the dev-tooltip-1 branch December 4, 2024 02:34
@TCOTC
Copy link
Contributor Author

TCOTC commented Dec 4, 2024

-1 的原因是?

messageElement.style.left = (window.innerWidth - 1 - messageElement.clientWidth) + "px";

左移 1px 避免发生换行

@Misuzu2027
Copy link
Contributor

左右Dock栏,从上往下移动的时候,取消闪烁后会有点影响使用。感觉还需要优化一下。

v3.1.14 演示视频

v3.1.14.mp4

v3.1.15-dev1 演示视频

v3.1.15-dev1.mp4

@TCOTC
Copy link
Contributor Author

TCOTC commented Dec 5, 2024

所以我觉得 50ms 就挺合适的,不过这个逻辑已经去掉了

@TCOTC
Copy link
Contributor Author

TCOTC commented Dec 5, 2024

@Vanessa219 话说 50ms 有什么问题吗?现在这个情况还是应该优化的:

video.webm

50ms 的效果:

video.webm

@Vanessa219
Copy link
Member

delay 删除了,否则鼠标在移动的过程中,tip 无法消失。

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