fix(Sticky): 修复offsetTop通过 props传入时动态更新后,onScroll方法取offset仍为初始值的问题 #639
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.
Sticky
组件在调用时,需要动态更新offset
的值,此时传入的props.offsetTop
/props.offsetBottom
已经更新,但是由于useEventListener
没有设置depends
更新注册的回调,导致某些不为window且传入offsetTop的container fixed定位判断不准。useEffect
, 更新add
方法, add方法内重新注册新的listener
回调,拿到新的 offset值,问题修复。