Skip to content

fix(web/style): 真正消除 post-list hover 抖动 — 始终挂载滚动条+透明 thumb#111

Merged
github-actions[bot] merged 1 commit into
mainfrom
judy/fix-scrollbar-transparent
Jun 29, 2026
Merged

fix(web/style): 真正消除 post-list hover 抖动 — 始终挂载滚动条+透明 thumb#111
github-actions[bot] merged 1 commit into
mainfrom
judy/fix-scrollbar-transparent

Conversation

@SymbolStar

Copy link
Copy Markdown
Owner

问题

PR #109 用了 scrollbar-gutter: stable 想给隐藏的滚动条保留 gutter,让 hover 切到 auto 时不抢宽度。但是 CSS 规范规定 scrollbar-gutterscrollbar-width: none 时是 no-op——scrollbar 被 suppress 掉就没 gutter 可保留——所以那行修改实际上根本没生效,hover 时仍然真占走 ~10px。Scott 多次反馈刷新后还在抖就是这个原因。

修复

让滚动条始终挂载、宽度固定,但 thumb 和 track 默认完全透明,hover 时给 thumb 上色:

#post-list {
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
  transition: scrollbar-color 0.15s ease;
}
#post-list::-webkit-scrollbar { width: 10px; }
#post-list::-webkit-scrollbar-thumb { background: transparent; ... }

#post-list:hover,
#post-list:focus-within {
  scrollbar-color: rgba(0,0,0,0.25) transparent;
}
#post-list:hover::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.25); ... }

视觉上跟之前的 Slack-style hover-reveal 完全一致:默认看不到、hover 出现、hover 在 thumb 上颜色加深;区别只在布局宽度恒定,鼠标进出零 reflow。

跨浏览器:WebKit / Chromium / Safari 走 ::-webkit-scrollbar*,Firefox 走 scrollbar-width: thin + scrollbar-color 两件套。0.15s transition 让出现/消失更柔和。

部署

SW 在 PR #110 已经改成 network-first,硬刷新一次就直接生效,不需要再 unregister。

PR #109 用 scrollbar-gutter: stable 想保留 gutter,但 CSS 规范规定
gutter 在 scrollbar-width: none 时是 no-op,所以那行修改实际上根本
没生效,hover 切到 auto 仍然会真占走 ~10px。Scott 反馈刷新后还在抖
就是这个原因。

正确做法:让 scrollbar 始终挂载且宽度固定,默认 thumb / track 全透明,
hover 时把 thumb 上色。视觉上跟之前的 Slack-style hover-reveal 完全一样
(默认看不到、hover 出现),但布局宽度恒定,鼠标进出零 reflow。

- WebKit/Chromium/Safari:::-webkit-scrollbar 固定 width: 10px,
  ::-webkit-scrollbar-thumb 默认 transparent,hover 时上色。
- Firefox:scrollbar-width: thin + scrollbar-color: transparent
  transparent 默认,hover 时把 thumb 颜色切到 rgba(0,0,0,0.25)。
- 加 0.15s transition 让出现/消失更柔和。

SW 已经在 v2 = network-first,下次硬刷新一次直接生效。
@github-actions

Copy link
Copy Markdown

🤖 bot-review (comment-only · phase 1)

Diff: 2 files changed, 34 insertions(+), 23 deletions(-) @ f9c9558

Red-line checks:

  • ✅ A-7.5: no new 'forbidden' code in xiaof

Phase 2: auto-approve + auto-merge fire only when red-lines are clean, author is internal, and no needs-human path is touched. Block with no-auto-merge label or [no-auto-merge] in title.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Auto-approved by bot-review: red-line checks clean, internal author, no needs-human paths.

@github-actions github-actions Bot enabled auto-merge (squash) June 29, 2026 03:23
@github-actions github-actions Bot merged commit 991d9ac into main Jun 29, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant