ui/inview.js
function(selector, opt_offset, opt_delay) {
  this.selector = selector;
  this.offset = opt_offset || null;
  this.delay = opt_delay || 0;

  // Ensure all videos are loaded.
  var els = document.querySelectorAll(this.selector);
  [].forEach.call(els, function(el) {
    el.load();
  });
}
function(selector, opt_offset, opt_delay) {
  this.selector = selector;
  this.offset = opt_offset || null;
  this.delay = opt_delay || 0;

  // Ensure all videos are loaded.
  var els = document.querySelectorAll(this.selector);
  [].forEach.call(els, function(el) {
    el.load();
  });
}
function ( selector , opt_offset , opt_delay ) { this . selector = selector ; this . offset = opt_offset || null ; this . delay = opt_delay || 0 ; // Ensure all videos are loaded. var els = document . querySelectorAll ( this . selector ) ; [ ] . forEach . call ( els , function ( el ) { el . load ( ) ; } ) ; }
Plays videos when they enter the viewport.
@param {string} selector Query selector to find elements to act upon.
@param {number=} opt_offset Offset (by percentage of the element) to
apply when checking if the element is in view.
@param {Array.<number>=} opt_delay An array of [min delay, max delay].
Plays videos when they enter the viewport .