-
Notifications
You must be signed in to change notification settings - Fork 455
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
createIntersectionObserver().relativeToViewport().observe() 问题 #468
Comments
看你代码,这里走的就是浏览器的 IntersectionObserver,你这里已经监测到与视窗相交的节点刚好都在视窗内吧。你可以让列表超出视窗,然后滚动一下试试看。 |
这个页面有7张图片 一屏展示的话 最多显示2张图片 因为每一张图片高度498px,而且img_item高度设置的就是498,按道理一屏绝对显示不了这么多图片,但是已进入页面 就会打印7次 每一次都是大于0 |
https://developers.weixin.qq.com/miniprogram/dev/api/wxml/wx.createIntersectionObserver.html 同时监听多个图片的话,带上这个参数试试,而且只需要创建一次 intersectionObserver 就行。如果你要一张一张图片来监听,那么用不同的 class 来区分不同图片,这里不带 observeAll 参数的话会走 querySelector 接口,那只会找符合 selector 的第一个节点。 |
好的 ,感谢!
不带的代码如下: |
在你打 debugger 的地方 console 一下,是没有回调,还是回调不正确? |
没有进行回调 执行observer.relativeToViewport().observe()完后 没有进入回调函数 即没有进入if判断 |
那感觉不太合理,能否精简一个 demo 给我调试一下? |
已经发给你了 那个微信号了 有时间您看下 |
改为
即可。 |
为什么返回的都是intersectionRatio的值1呢
The text was updated successfully, but these errors were encountered: