MS Edge: IntersectionObserver. Does it work for you?

蹲街弑〆低调 提交于 2019-12-02 00:38:53

问题


Before anyone goes to too much effort here, I already have a nasty workaround. I just want to know if anyone has it working.

Version 15 of Edge is now released and has support for intersection observer (for lazy loading).

I've implemented it and it works fine in all browsers which support it (Chrome and Opera. Firefox and Safari haven't implemented yet) but not at all in Edge.

There are no errors thrown, but the callback is never called.

handleIntersectionElement(elm) {
  if (elm && this.state.enabled && !this.observer) {
    this.observer = new global.IntersectionObserver(this.intersectionCallback, this.options);
    this.observer.observe(elm);
  }
}

Options as follows, nothing special:

options = { root: null, rootMargin: '100px', threshold: [0] };

This is part of a React component but don't see why that should make a difference.


回答1:


IntersectionObserver can't observe empty elements which width and height are both 0 in Edge, so the only thing you need do is setting 1px border or min-width: 1px; min-height: 1px; on the element that you want to observe.



来源:https://stackoverflow.com/questions/45090875/ms-edge-intersectionobserver-does-it-work-for-you

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!