w3c / IntersectionObserver

Intersection Observer
https://www.w3.org/TR/intersection-observer/
Other
3.62k stars 522 forks source link

rootMargin can easily fail in the real-world use cases #154

Open ziyunfei opened 8 years ago

ziyunfei commented 8 years ago

Recently I'm trying to use the IntersectionObserver API to lazy load images/contents instead of the old LazyLoad plugin in our website (taobao.com), and I failed, twice, all because the rootMarin option didn't work in some cases. I made two demos to illustrate the problem:

  1. http://a1.alicdn.com/oss/uploads/2016/09/10/98e653c0-771c-11e6-8e09-4d01d5ca328a.html screencast: http://ossgw.alicdn.com/creatives-assets/oss/uploads/2016/09/10/94150ab0-771e-11e6-8856-b9afe8cc46f0.mp4
  2. http://a1.alicdn.com/oss/uploads/2016/09/10/a11fbb20-7727-11e6-9b63-cf4449eeaa69.html

So I think the spec should change, but I don't know how.

ojanvafai commented 8 years ago

This is a good test case. I think this might be a v2 feature. The current behavior optimizes for not lazy loading things that are clipped. Also, the current behavior is what you'd want if building an infinite scroller.

So, for v2, we could add something like "clipMargin" that expands all clip regions.