function scrollIntoView( elem, opts ) {
  var defaults = { offset: 15 };
  opts = assign( defaults, opts );
  if ( !elementInView( elem, true ) ) {
    var elementTop = elem.getBoundingClientRect().top;
    var to = Math.max( window.pageYOffset + elementTop - opts.offset, 0 );
    scrollTo( to, opts );
  }
}
/**
 * Checks whether element in viewport and if not,
 * scrolls it into view.
 * @param {HTMLNode} elem The DOM element to check for
 * @param {Object} opts Optional parameters, including:
 * 	  offset: Distance from top of screen of element
        when scroll is complete
 *    callback: function called when scroll is complete
 *
 */
Checks whether element in viewport and if not,
scrolls it into view.
@param {HTMLNode} elem The DOM element to check for
@param {Object} opts Optional parameters, including:
offset: Distance from top of screen of element
when scroll is complete
callback: function called when scroll is complete
Checks whether element in viewport and if not scrolls it into view . @param { HTMLNode } elem The DOM element to check for @param { Object } opts Optional parameters including : offset : Distance from top of screen of element when scroll is complete callback : function called when scroll is complete
function scrollIntoView( elem, opts ) {
  var defaults = { offset: 15 };
  opts = assign( defaults, opts );
  if ( !elementInView( elem, true ) ) {
    var elementTop = elem.getBoundingClientRect().top;
    var to = Math.max( window.pageYOffset + elementTop - opts.offset, 0 );
    scrollTo( to, opts );
  }
}
function scrollIntoView ( elem , opts ) { var defaults = { offset : 15 } ; opts = assign ( defaults , opts ) ; if ( ! elementInView ( elem , true ) ) { var elementTop = elem . getBoundingClientRect ( ) . top ; var to = Math . max ( window . pageYOffset + elementTop - opts . offset , 0 ) ; scrollTo ( to , opts ) ; } }
Checks whether element in viewport and if not,
 scrolls it into view.
Checks whether element in viewport and if not scrolls it into view .