微信小程序的relativeToViewport疑问?

场景:
需要在小程序中实现 滚动右侧左侧导航跟着选中当前的状态
框架:taro 3.3

image.png

Taro.createIntersectionObserver(this.$scope,{ observeAll: true })
  .relativeToViewport({bottom: -300, top: 0})
  // .relativeToViewport()
  .observe('._new_nav_rt_card', (res) => {
  
    if(res.intersectionRatio > 0) {
      console.log(res)
      that.setState({
        activeId:+res.id
      })
    }
  });

疑问:
1、relativeToViewport参数的top\left\right\bottom 到底是指的那个?网上查了很多 但是没有资料?
2、如上图我这么写之后 往下滚动的时候 可以捕获 但是往上滚动就没反应了 打印的res 的top\left\right\bottom 都是0

阅读 1.9k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题