feat(tabs): add support for scrolling via mouse wheel or touchpad #3105
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.
Types of changes
Background and context
Tabs
组件支持滚轮或者触摸板进行滚动、以及增加滚动定位scrollPosition
与 React 版本一致。Resolves #2909
Resolves #2804
Resolves #2100
Resolves #1867
Closes #2209
Closes #1936
Solution
setActiveTabOffset 来统一计算各种情况下的偏移量。移除了原来逻辑tabEndOffsets 相关的 isInView、getTabEndOffsets 等函数,优化几处冗余的代码。
此外本次新功能也解决了几处历史问题如在 #1936 所讨论的问题
How is the change tested?
测试脚本外还打包到项目中测试无异常。
Changelog
Checklist:
npm run test
)feature
branch and othersshould be submitted to
main
branch)Other information
iShot_2024-04-28.mp4