react-component / scroll-anim

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

Link和Element分开在不同组件内导致Link报错 #4

Closed Naixor closed 8 years ago

jljsj33 commented 8 years ago

代码贴下?

Naixor commented 8 years ago

我的情况是Link,Element写在一个Component内可以使用,但是我是分开在两个子Component内的,这样导致报了个错,location" is null

Naixor commented 8 years ago

看了下实现,了解为啥了...对应location注册的先后顺序问题,源码里那个setTimeout... 不知道能否增加类似Container的概念,Element们可以在Container里来监听事件,发现有link这个元素,就触发事件,发现没有就不做什么类似的~

jljsj33 commented 8 years ago

我这没问题啊。我一直都这么用的啊,,都是分开的啊。。。看 antd 的 home

jljsj33 commented 8 years ago

如果报location is null, 是没注册啊, 上面还有报错吗, 在你用 Element 时有没有 import 进来

jljsj33 commented 8 years ago

https://github.com/ant-design/ant-design/tree/develop-1.0.0/site/component/Home

Naixor commented 8 years ago

确实还有,估计是我这边异步请求数据,然后分子组件分的太多,等等导致的....后来自己简单搞了个,功能没这个强大,先凑合用了,不过假如在调用时,没注册上是不是事件不触发就好,后面注册上了再触发,我那个是按照这个思路搞得,不过还是挺喜欢这个的,由于我用ts,用的时候还先写了个.d.ts文件,不知道对你们有没有用...scroll.anim.d.ts