-
Notifications
You must be signed in to change notification settings - Fork 167
fix: scrollbar is shaking when dropdown scroll to bottom #226
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
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
大致逻辑看了一下,可以优化一下成状态机:
|
9d5f07f
to
4b6428d
Compare
4b6428d
to
8803d5e
Compare
8803d5e
to
a35d31c
Compare
CI 挂了 |
a35d31c
to
058b31f
Compare
058b31f
to
be2d674
Compare
Codecov Report
@@ Coverage Diff @@
## master #226 +/- ##
==========================================
+ Coverage 99.51% 99.53% +0.02%
==========================================
Files 17 19 +2
Lines 613 645 +32
Branches 128 137 +9
==========================================
+ Hits 610 642 +32
Misses 3 3
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
// make `collectHeight` work | ||
offsetParent: { | ||
get: () => true, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
诶?这里只是修了 test case。但是没有给新的代码加 test case~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok 我加一下
src/hooks/useScrollTo.tsx
Outdated
}; | ||
// check cacheHeiht before calculating | ||
if (!checkIndexIsCache()) { | ||
setScrollToCacheState(MEASURE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里应该算出需要知道的范围后直接短路
src/hooks/useScrollTo.tsx
Outdated
syncScrollTop(targetTop); | ||
unstable_batchedUpdates(() => { | ||
if (startIndex !== undefined ? checkIndexIsCache(startIndex) : checkIndexIsCache()) { | ||
setScrollToCacheState(STABLE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同理,STABLE 不应该是计算时使用。应该是 useLayoutEffect 里更新状态
8033161
to
4476162
Compare
4476162
to
996f6e8
Compare
if (times < 0 || !containerRef.current) return; | ||
|
||
// ================== switch cacheState =================== | ||
if (times === 3) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
等等,这里还有 times?那是不是直接 times 保持 sync 就好了?我试试去
Move to #232 |
因为是cacheHeight影响了scrollHeight,导致useScrollTo这个hooks触发的三次scroll的offesetTop不同,所以我的思路是,当要加载远距离的节点并且该节点未访问时,先在当前的节点下预加载远距离节点,但不滚动,等远距离节点的缓存高度拿到后,再真正加载远距离节点和滚动


close: ant-design/ant-design#44100