fix: 修复歌词手动滚动边界未正确限制可见范围 - #343
Open
K-Blaaaack wants to merge 1 commit into
Open
K-Blaaaack wants to merge 1 commit into
K-Blaaaack wants to merge 1 commit into
Conversation
This branch has not been deployed
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.
改动类型
是否包含破坏性变更
改动说明
修复 #333:手动滚动歌词时首尾边界未按实际可见范围限制。
两个引擎的缺陷都在各自包内部(
lyric-dom0.2.0 /@applemusic-like-lyrics/core0.6.0,均为当前最新版),因此在本仓库接入层修复:applyUserScroll累加userScrollOffset时没有任何上限,滚轮可持续把歌词推出首尾范围,出现大面积空白。1e-4,仍占布局高度,因此仍可滚入这片不可见区域。新增
useLyricScrollBound,在两个歌词容器的捕获阶段拦截滚轮 / 触摸手势,按屏内实际可见的行推导当前姿态下允许的滚动区间,越界的增量直接吞掉。捕获阶段先于引擎的目标阶段监听器执行,因此能有效拦截且与监听器注册顺序无关。为避免与引擎渲染循环争抢,测量过程不调用
getBoundingClientRect/getComputedStyle(两者都会强制同步布局),改为解析引擎逐帧写入的内联translateY,行元素与行高在一次手势内缓存复用,单次滚动事件零布局开销。关联 Issue
Closes #333
测试情况
自动化检查(全部通过):
tsc -p tsconfig.node.json+vue-tsc -p tsconfig.web.json:通过eslint .:0 error(2 个既有 warning 来自未改动的src/settings/categories/player.spec.ts)prettier --check .:通过vitest run:30 文件 / 212 用例通过tsx --test(node 侧):35 用例通过新增用例覆盖两个引擎:首行贴顶时向上滚动被拦截、底部有余量时向下滚动被放行、内容不高于容器时锁死、AMLL 开启「隐藏已播放行」后不越界。另有一条回归防护断言持续滚动时
getBoundingClientRect/getComputedStyle调用为 0,并已反向验证该断言在逐行测量的旧实现下会失败。手动验证:在 Linux 开发模式下运行应用、播放带歌词歌曲实际滚动确认(该过程中发现并修复了本改动引入的一处滚动掉帧问题)。原 issue 环境为 Windows,未在 Windows / macOS 复测;边界逻辑与平台无关,仍建议在 Windows 上确认一次。
自查清单
native/*/index.d.ts(本改动不涉及原生模块)dev分支提交