MS Edge:IntersectionObserver.对你起作用吗? [英] MS Edge: IntersectionObserver. Does it work for you?

查看:106
本文介绍了MS Edge:IntersectionObserver.对你起作用吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在任何人在这里付出过多努力之前,我已经有了一个讨厌的解决方法.我只想知道是否有人在使用它.

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

Edge的第15版现已发布,并且支持相交观察器(用于延迟加载).

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

我已经实现了它,并且它在所有支持它的浏览器(Chrome和Opera.尚未实现Firefox和Safari)中都可以正常工作,但是在Edge中根本没有实现.

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] };

这是React组件的一部分,但看不到为什么会有所作为.

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

推荐答案

IntersectionObserver无法在Edge中观察到宽度和高度均为0的空元素,因此您唯一需要做的就是在其上设置1px边框或min-width: 1px; min-height: 1px;您要观察的元素.

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.

这篇关于MS Edge:IntersectionObserver.对你起作用吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆