javascript - MS Edge: IntersectionObserver. Does it work for you? - Stack Overflow

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

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 ponent but don't see why that should make a difference.

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 ponent but don't see why that should make a difference.

Share Improve this question asked Jul 13, 2017 at 21:05 Peter DPeter D 632 silver badges4 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 7

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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745369780a4624746.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信