-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Taro.pageScrollTo 滚动位置不准确 #16609
Comments
This was referenced Sep 28, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
相关平台
H5
复现仓库
https://github.com/shi-thething/taroTest.git
浏览器版本: Chrome 128
使用框架: React
复现步骤
必现问题
源码地址:
69行 - https://github.com/NervJS/taro/blob/main/packages/taro-h5/src/api/ui/scroll/index.ts
问题代码块:
const scroll = (frame = 0) => {
const dest = from delta * easeFunc(frame)
scrollFunc(dest) <---------------------此处是问题代码
if (frame < frameCnt) {
timer && clearTimeout(timer)
timer = setTimeout(() => {
scroll(frame 1)
}, FRAME_DURATION)
} else {
return handle.success({}, { resolve, reject })
}
}
问题:
设置top时,变量 frame 的正确取值范围是 0 - (frameCnt -1)
在最后一次循环调用时rame === frameCnt,easeFunc(frame)的值会大于1,导致dest的值比期望值多了一帧的量
解决方案: scrollFunc(dest)的执行,应该移动到 if (frame < frameCnt) 条件内部
期望结果
滚动准确
实际结果
滚动偏差,多滚动了一帧
环境信息
The text was updated successfully, but these errors were encountered: