Skip to content
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

监听事件bindready,获取高度有时不准确 #195

Closed
Barrycca opened this issue Sep 4, 2020 · 1 comment
Closed

监听事件bindready,获取高度有时不准确 #195

Barrycca opened this issue Sep 4, 2020 · 1 comment
Labels
good first issue Good for newcomers

Comments

@Barrycca
Copy link

Barrycca commented Sep 4, 2020

平台:微信小程序
版本:// 小程序富文本插件 https://github.com/jin-yufeng/Parser 20200828
使用代码 <parser html="{{htmlShow}}" bindready="htmlRender" />
描述:用于图文详情富文本显示,可能是图片太多了,高度有时获取的准确有时获取不准确,原本是4000的高度,有时获取3000,有时获取200,触发频率大概十次有两次获取不准,看了5这个https://github.com/jin-yufeng/Parser/issues/85issue 说解决了,难道是我版本的问题?

@jin-yufeng
Copy link
Owner

判断 ready 的标准是每 350ms 检查一次高度,两次高度不变化就认为加载完毕,然后返回大小,处理的地方在 这里
这个处理方式确实可能在某些情况下不准确,如果 350ms 总高度不变化就会触发,但这个很难权衡,因为要确保一定准确的话可能这个时间间隔要更长或者多次不变化后再触发,这样的话触发的就会很慢,某些情况下会带来问题(比如进入页面后等待图片加载完要跳转到某个锚点,等待时间过长就会影响体验),所以这里如果要求很高的话可能需要自行调整一下
ps:对于这个问题最准确的获取时机应该是所有图片都触发 load 事件的时候,但由于开启懒加载后,一些图片不会立即加载,所以无法判断是否全部加载完毕,以及另外一些原因这个方法不适用,所以只能通过高度变化判断

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants