site/_js/web-components/toc-active.js
/**
 * This is a simplified version of `scrollIntoView`, as that causes odd
 * interactions with nested scroll containers in Chrome.
 *
 * @param {Element} target
 * @param {Element} container
 */
This is a simplified version of `scrollIntoView`, as that causes odd
interactions with nested scroll containers in Chrome.

@param {Element} target
@param {Element} container
This is a simplified version of ` scrollIntoView ` as that causes odd interactions with nested scroll containers in Chrome . @param { Element } target @param { Element } container
function localScrollIntoView(target, container) {
  const bounds = target.getBoundingClientRect();
  const containerBounds = container.getBoundingClientRect();
  const offTop = containerBounds.top - bounds.top;
  if (offTop > 0) {
    container.scrollTop -= offTop;
  } else {
    const offEnd = bounds.bottom - containerBounds.bottom;
    if (offEnd > 0) {
      container.scrollTop += offEnd;
    }
  }
}
function localScrollIntoView ( target , container ) { const bounds = target . getBoundingClientRect ( ) ; const containerBounds = container . getBoundingClientRect ( ) ; const offTop = containerBounds . top - bounds . top ; if ( offTop > 0 ) { container . scrollTop -= offTop ; } else { const offEnd = bounds . bottom - containerBounds . bottom ; if ( offEnd > 0 ) { container . scrollTop += offEnd ; } } }
This is a simplified version of `scrollIntoView`, as that causes odd
 interactions with nested scroll containers in Chrome.
This is a simplified version of ` scrollIntoView ` as that causes odd interactions with nested scroll containers in Chrome .
// Target is above the element. // Target is below the element.