react-component / scroll-anim

Animate Scroll React Component
http://react-component.github.io/scroll-anim/
MIT License
305 stars 43 forks source link

OverPack中向上滑到顶部后再下滑会无法再次显示 #45

Closed fybchristasker closed 5 years ago

fybchristasker commented 5 years ago

将OverPack的always设为false后,会出现无法显示的情况 componentDidMount() { this.onScrollHandler = _.throttle(() => { const { headerColorClassName } = this.state const className = window.scrollY > 0 ? 'menu-sticky' : 'menu-transparent' if (headerColorClassName !== className) { this.setState({ headerColorClassName: className }) } }, 200) window.addEventListener('scroll', this.onScrollHandler) } 请问这个该如何解决?

jljsj33 commented 5 years ago

页面刷新时在底部??然后往上滚动不显示吗???

fybchristasker commented 5 years ago

刷新时在任何位置可以显示,但是当我滚动到window.scrollY为0时再往下翻滚就会出现这个问题

jljsj33 commented 5 years ago

always 为 false 时,动画只会播放一次,,播放完后就不会再出现动画了,,,

http://react-component.github.io/scroll-anim/examples/simple.html, 只进入一次,没有问题啊。。。

fybchristasker commented 5 years ago

一般确实不会有问题,我是在componentDidMount中监听了滚动事件,可能OverPack也是通过同样的方法实现的,滑到顶部再下来页面内容都不见了 const className = window.scrollY > 0 ? 'menu-sticky' : 'menu-transparent' window.addEventListener('scroll', this.onScrollHandler)

jljsj33 commented 5 years ago

来个重现吧,https://codesandbox.io/s/serene-water-c2bps

fybchristasker commented 5 years ago

https://codesandbox.io/s/musing-lake-24dz8 第二个OverPack的问题与我情况相似

jljsj33 commented 5 years ago

好的,,我这边看下。。

jljsj33 commented 5 years ago

v2.5.8