通过相交 wx.createIntersectionObserver() 来判断
通过相交来判断是否在可视区域内,页面滚动,苹果系统小程序不能时时监听变化,安卓的可以时时监听res返回的值,苹果的需要再滚动完停止了,才会返回res值
wx.createIntersectionObserver().relativeToViewport({ bottom: 100 }).observe(‘.select-area’, (res) => {
if (res.intersectionRect.bottom==0) {
this.setData({
isfloat:true
})
}
else {
this.setData({
isfloat: false
})
}
console.log(res)
})
