function scrollIntoView(element, spot) {
  // Assuming offsetParent is available (it's not available when viewer is in
  // hidden iframe or object). We have to scroll: if the offsetParent is not set
  // producing the error. See also animationStartedClosure.
  var parent = element.offsetParent;
  var offsetY = element.offsetTop + element.clientTop;
  var offsetX = element.offsetLeft + element.clientLeft;
  if (!parent) {
    console.error('offsetParent is not set -- cannot scroll');
    return;
  }
  while (parent.clientHeight === parent.scrollHeight) {
    if (parent.dataset._scaleY) {
      offsetY /= parent.dataset._scaleY;
      offsetX /= parent.dataset._scaleX;
    }
    offsetY += parent.offsetTop;
    offsetX += parent.offsetLeft;
    parent = parent.offsetParent;
    if (!parent) {
      return; // no need to scroll
    }
  }
  if (spot) {
    if (spot.top !== undefined) {
      offsetY += spot.top;
    }
    if (spot.left !== undefined) {
      offsetX += spot.left;
      parent.scrollLeft = offsetX;
    }
  }
  parent.scrollTop = offsetY;
}
/**
 * Scrolls specified element into view of its parent.
 * element {Object} The element to be visible.
 * spot {Object} An object with optional top and left properties,
 *               specifying the offset from the top left edge.
 */
Scrolls specified element into view of its parent.
element {Object} The element to be visible.
spot {Object} An object with optional top and left properties,
specifying the offset from the top left edge.
Scrolls specified element into view of its parent . element { Object } The element to be visible . spot { Object } An object with optional top and left properties specifying the offset from the top left edge .
function scrollIntoView(element, spot) {
  var parent = element.offsetParent;
  var offsetY = element.offsetTop + element.clientTop;
  var offsetX = element.offsetLeft + element.clientLeft;
  if (!parent) {
    console.error('offsetParent is not set -- cannot scroll');
    return;
  }
  while (parent.clientHeight === parent.scrollHeight) {
    if (parent.dataset._scaleY) {
      offsetY /= parent.dataset._scaleY;
      offsetX /= parent.dataset._scaleX;
    }
    offsetY += parent.offsetTop;
    offsetX += parent.offsetLeft;
    parent = parent.offsetParent;
    if (!parent) {
      return; 
    }
  }
  if (spot) {
    if (spot.top !== undefined) {
      offsetY += spot.top;
    }
    if (spot.left !== undefined) {
      offsetX += spot.left;
      parent.scrollLeft = offsetX;
    }
  }
  parent.scrollTop = offsetY;
}
function scrollIntoView ( element , spot ) { var parent = element . offsetParent ; var offsetY = element . offsetTop + element . clientTop ; var offsetX = element . offsetLeft + element . clientLeft ; if ( ! parent ) { console . error ( 'offsetParent is not set -- cannot scroll' ) ; return ; } while ( parent . clientHeight === parent . scrollHeight ) { if ( parent . dataset . _scaleY ) { offsetY /= parent . dataset . _scaleY ; offsetX /= parent . dataset . _scaleX ; } offsetY += parent . offsetTop ; offsetX += parent . offsetLeft ; parent = parent . offsetParent ; if ( ! parent ) { return ; } } if ( spot ) { if ( spot . top !== undefined ) { offsetY += spot . top ; } if ( spot . left !== undefined ) { offsetX += spot . left ; parent . scrollLeft = offsetX ; } } parent . scrollTop = offsetY ; }
Scrolls specified element into view of its parent.
Scrolls specified element into view of its parent .
// Assuming offsetParent is available (it's not available when viewer is in // hidden iframe or object). We have to scroll: if the offsetParent is not set // producing the error. See also animationStartedClosure. // no need to scroll