w3c/IntersectionObserver

When I reference it, I determine that this ('intersectionRatio' in window.IntersectionObserverEntry.prototype) is still false

Closed this issue · 1 comments

SCWR commented

I have a plugin to determine whether to reference the plugin is to copy this decision

if ('IntersectionObserver' in window &&
      'IntersectionObserverEntry' in window &&
      'intersectionRatio' in window.IntersectionObserverEntry.prototype) {

    // Minimal polyfill for Edge 15's lack of `isIntersecting`
    // See: https://github.com/w3c/IntersectionObserver/issues/211
    if (!('isIntersecting' in window.IntersectionObserverEntry.prototype)) {
      Object.defineProperty(window.IntersectionObserverEntry.prototype,
        'isIntersecting', {
        get: function () {
          return this.intersectionRatio > 0;
        }
      });
    }
    return;
  }

So is it added after this

...
// Exposes the constructors globally.
  window.IntersectionObserver = IntersectionObserver
  window.IntersectionObserverEntry = IntersectionObserverEntry
 //add
  Object.defineProperty(window.IntersectionObserverEntry.prototype,
    'intersectionRatio', {
    get: function () {
      return this._$_intersectionRatio;
    },
    set: function(value) {
      this._$_intersectionRatio = value;
    }
  })

  Object.defineProperty(window.IntersectionObserverEntry.prototype,
    'isIntersecting', {
    get: function () {
      return this._$_isIntersecting;
    },
    set: function(value) {
      this._$_isIntersecting = value;
    }
  })
...

Sorry, I'm going to close this issue as it's not clear what problem this suggestion is solving nor how you're proposing this change be implemented.