微信小程序的relativeToViewport疑问?

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

微信小程序的relativeToViewport疑问?

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

以上是 微信小程序的relativeToViewport疑问? 的全部内容, 来源链接: utcz.com/p/936586.html

回到顶部