Skip to content
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

fix(Sticky): 修复offsetTop通过 props传入时动态更新后,onScroll方法取offset仍为初始值的问题 #639

Merged
merged 1 commit into from
May 8, 2023

Conversation

Trojan0523
Copy link
Contributor

@Trojan0523 Trojan0523 commented May 6, 2023

  • Sticky 组件在调用时,需要动态更新offset的值,此时传入的props.offsetTop/props.offsetBottom 已经更新,但是由于 useEventListener 没有设置 depends 更新注册的回调,导致某些不为window且传入offsetTop的container fixed定位判断不准。
  • 修改后,通过传入依赖触发 useEffect , 更新 add 方法, add方法内重新注册新的 listener 回调,拿到新的 offset值,问题修复。

@3lang3 3lang3 merged commit 4692adc into 3lang3:main May 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants