Commit 7bde4d50 authored by Luke Leber's avatar Luke Leber
Browse files

Issue #3268187 by Luke.Leber, darren.fisher: View of media items using OEmbed...

Issue #3268187 by Luke.Leber, darren.fisher: View of media items using OEmbed Lazyload widget with AJAX pager exhibits strange behavior
parent cd4c3c22
Loading
Loading
Loading
Loading
+53 −56
Original line number Diff line number Diff line
@@ -2,16 +2,12 @@

(function (Drupal, drupalSettings) {

  let io_initialized = false;
  let observe = false;

  Drupal.behaviors.oembedLazyloadIntersectionObserver = {
    attach: function attach(context) {

      if (io_initialized) {
        return;
      }
      io_initialized = true;

      if (observe === false) {
        // Check for IntersectionObserver support.
        // @see https://github.com/w3c/IntersectionObserver/blob/7382ce7e834c57ea166081484bd8f8a6de84de04/polyfill/intersection-observer.js#L16
        const modern_support =
@@ -19,7 +15,7 @@
          'IntersectionObserverEntry' in window &&
          'intersectionRatio' in window.IntersectionObserverEntry.prototype;

      const observe = (function () {
        observe = (function () {
          if (modern_support) {
            // Create an intersection observer that swaps out the src attribute.

@@ -69,6 +65,7 @@
            };
          }
        })();
      }

      // Set the observer to watch each eligible iframe.
      const videos = context.querySelectorAll('.oembed-lazyload[data-strategy="intersection-observer"]');