Feature/improve danmaku title list display style#247
Closed
Troray wants to merge 4 commits intomtvpls:mainfrom
Closed
Feature/improve danmaku title list display style#247Troray wants to merge 4 commits intomtvpls:mainfrom
Troray wants to merge 4 commits intomtvpls:mainfrom
Conversation
同时增强了分组标签区域的操作方式,支持滚轮横向浏览和鼠标拖动浏览,便于在大量分组下快速切换。 为`episode`按钮新增了`tooltip`提示,用于展示完整剧集标题,方便在网格模式下快速查看被缩略的内容。
There was a problem hiding this comment.
Code Review
This pull request implements horizontal scrolling via mouse drag and wheel events for episode categories and adds tooltips in DanmakuPanel.tsx and EpisodeSelector.tsx. The review feedback suggests adding boundary detection for tooltips to prevent clipping, resolving style conflicts regarding text wrapping, extracting the duplicated scrolling logic into a reusable hook, and ensuring UI consistency for scrollbar visibility.
| const containerRect = container.getBoundingClientRect(); | ||
|
|
||
| // 垂直位置:始终显示在下方 | ||
| const vertical: 'top' | 'bottom' = 'bottom'; |
| horizontal: 'left' | 'center' | 'right'; | ||
| }) => { | ||
| const baseStyle = | ||
| 'absolute px-3 py-1 bg-gray-800 dark:bg-gray-900 text-white text-xs rounded-md shadow-lg whitespace-nowrap pointer-events-none z-[100] max-w-[300px] transition-all duration-200 ease-out delay-100'; |
There was a problem hiding this comment.
这里有两个改进点:
- 样式冲突:whitespace-nowrap 会导致长标题溢出 max-w-[300px] 的限制。建议改为允许换行。
- 动画失效:由于 Tooltip 是通过 {isHovered && ...} 条件渲染的,CSS 的 transition 和 delay 在组件挂载时不会生效。若需淡入效果,建议始终渲染组件并控制其 opacity 和 visibility,或者使用动画库。
Suggested change
| 'absolute px-3 py-1 bg-gray-800 dark:bg-gray-900 text-white text-xs rounded-md shadow-lg whitespace-nowrap pointer-events-none z-[100] max-w-[300px] transition-all duration-200 ease-out delay-100'; | |
| 'absolute px-3 py-1 bg-gray-800 dark:bg-gray-900 text-white text-xs rounded-md shadow-lg whitespace-normal break-words pointer-events-none z-[100] max-w-[300px] transition-all duration-200 ease-out delay-100'; |
Comment on lines
+333
to
+353
| const handleWheel = useCallback( | ||
| (e: WheelEvent) => { | ||
| if ( | ||
| isCategoryHovered && | ||
| categoryContainerRef.current && | ||
| canScrollCategoryContainer(e.deltaY) | ||
| ) { | ||
| e.preventDefault(); // 阻止默认的竖向滚动 | ||
|
|
||
| const container = categoryContainerRef.current; | ||
| const scrollAmount = e.deltaY * 2; // 调整滚动速度 | ||
|
|
||
| // 根据滚轮方向进行横向滚动 | ||
| container.scrollBy({ | ||
| left: scrollAmount, | ||
| behavior: 'smooth', | ||
| }); | ||
| } | ||
| }, | ||
| [isCategoryHovered, canScrollCategoryContainer] | ||
| ); |
Contributor
Author
There was a problem hiding this comment.
目前只有两个地方用到,抽成Hook会增加很多没必要的工作量。后续如果还有其他地方需要相同的交互再抽“性价比”比较高。
Comment on lines
+730
to
+734
| onMouseDown={handleCategoryMouseDown} | ||
| onMouseMove={handleCategoryMouseMove} | ||
| onMouseUp={handleCategoryMouseUp} | ||
| onMouseEnter={() => setIsCategoryHovered(true)} | ||
| onMouseLeave={() => setIsCategoryHovered(false)} | ||
| onMouseLeave={handleCategoryMouseLeave} |
`tooltip`改成了超过`300px`才换行,短标题仍然保持单行。 滚轮速度、拖动倍率、拖动阈值提成了具名常量
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


tooltip提示